MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
OrientationField.cc
Go to the documentation of this file.
1 //Copyright (c) 2013-2020, The MercuryDPM Developers Team. All rights reserved.
2 //For the list of developers, see <http://www.MercuryDPM.org/Team>.
3 //
4 //Redistribution and use in source and binary forms, with or without
5 //modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name MercuryDPM nor the
12 // names of its contributors may be used to endorse or promote products
13 // derived from this software without specific prior written permission.
14 //
15 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 //DISCLAIMED. IN NO EVENT SHALL THE MERCURYDPM DEVELOPERS TEAM BE LIABLE FOR ANY
19 //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 #include "OrientationField.h"
27 #include "Particles/BaseParticle.h"
28 #include <cmath>
29 
30 namespace CGFields
31 {
33  {
34  setZero();
35  logger(DEBUG, "OrientationField::OrientationField() finished");
36  }
37 
38  void OrientationField::writeNames(std::ostream& os, unsigned countVariables)
39  {
40  os << countVariables + 1 << ":Orientation "; //orientation
41  }
42 
43  void OrientationField::write(std::ostream& os) const
44  {
45  os << orientation_;
46  }
47 
48  void OrientationField::output(std::ostream& os) const
49  {
50  os << "Orientation " << orientation_;
51  }
52 
54  {
56  }
57 
59  {
60  OrientationField orientationField;
62  return orientationField;
63  }
64 
66 
68  {
70  return *this;
71  }
72 
74  {
76  return *this;
77  }
78 
80  {
81  orientation_ /= a;
82  return *this;
83  }
84 
86  {
88  p.orientation_ = orientation_ * a;
89  return p;
90  }
91 
93  {
94  orientation_ += currentInteraction.getOrientation() * phi;
95  }
96 
98  {
99  Vec3D orientation = p.getOrientation().getAxis();
100  orientation_.XX = orientation.X * orientation.X;
101  orientation_.XY = orientation.X * orientation.Y;
102  orientation_.YY = orientation.Y * orientation.Y;
103  orientation_.XZ = orientation.X * orientation.Z;
104  orientation_.YZ = orientation.Y * orientation.Z;
105  orientation_.ZZ = orientation.Z * orientation.Z;
106  logger(DEBUG, "orientation: %", orientation_);
107  }
108 
109 
111  {
112  setFields(p);
113  }
114 
115 }
static MatrixSymmetric3D square(const MatrixSymmetric3D &A)
Calculates the pointwise square.
Mdouble X
the vector components
Definition: Vector.h:65
LL< Log::DEBUG > DEBUG
Debug information.
Definition: Logger.cc:58
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
double Mdouble
Definition: GeneralDefine.h:34
OrientationField operator*(Mdouble a) const
Multiplies the field values on the left of the '*' by the scalar value on the right of the '*' and re...
void addParticleStatistics(Mdouble phi, const OrientationField &currentInteraction)
This function should be called from within a loop over all particles to compute all the fields that a...
Vec3D getAxis() const
Converts the quaternions into a normal vector by rotating the vector x=(1,0,0); see See Wiki for deta...
Definition: Quaternion.cc:501
void output(std::ostream &os) const
Writes human-readable class content into an output stream, typically a stat file. ...
OrientationField & operator+=(const OrientationField &P)
Adds the field values on the RHS to the LHS of the equation.
OrientationField & operator-=(const OrientationField &P)
Subtracts the field values on the RHS from the LHS of the equation.
OrientationField getSquared() const
Returns the square of all field values (to calculate standard deviation).
OrientationField & operator=(const OrientationField &P)
Copies all field values.
void setZero()
Sets all elements to zero.
void setZero()
Sets all fields to zero.
MatrixSymmetric3D orientation_
Mdouble Y
Definition: Vector.h:65
OrientationField & operator/=(Mdouble a)
Divides the field values on the LHS by the RHS of the equation.
MatrixSymmetric3D getOrientation() const
Contains the computed field values, like density, momentum and stress.
Definition: Vector.h:49
const Quaternion & getOrientation() const
Returns the orientation of this BaseInteractable.
Mdouble Z
Definition: Vector.h:65
void setFields(const BaseParticle &p)
void write(std::ostream &os) const
Writes class content into an output stream, typically a stat file.
Mdouble XX
The six distinctive matrix elements.
static void writeNames(std::ostream &os, unsigned countVariables)
void setCylindricalFields(const BaseParticle &p)