MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GradVelocityField.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 "GradVelocityField.h"
27 #include <Particles/BaseParticle.h>
28 
29 namespace CGFields
30 {
31 
33 {
34  setZero();
35 #ifdef DEBUG_CONSTRUCTOR
36  std::cerr << "GradVelocityField::GradVelocityField() finished" << std::endl;
37 #endif
38 }
39 
43 void GradVelocityField::writeNames(std::ostream& os, const unsigned countVariables)
44 {
45  os << countVariables + 1 << ":Density ";
46  os << countVariables + 2 << "-" << countVariables + 4 << ":momentum ";
47  os << countVariables + 5 << "-" << countVariables + 7 << ":ddensity ";
48  os << countVariables + 8 << "-" << countVariables + 16 << ":dmomentum ";
49 }
50 
54 void GradVelocityField::write(std::ostream& os) const
55 {
56  os << density_;
57  os << " " << momentum_;
58  os << " " << ddensity_;
59  os << " " << dmomentum_;
60 }
61 
65 void GradVelocityField::output(std::ostream& os) const
66 {
67  os << "density " << density_;
68  os << " momentum " << momentum_;
69  os << " ddensity " << ddensity_;
70  os << " dmomentum " << dmomentum_;
71 }
72 
74 {
75  density_ = 0.0;
79 }
80 
85 {
91  return P;
92 }
93 
99 = default;
100 
106 {
107  density_ += P.density_;
108  momentum_ += P.momentum_;
109  ddensity_ += P.ddensity_;
110  dmomentum_ += P.dmomentum_;
111  return *this;
112 }
113 
119 {
120  density_ -= P.density_;
121  momentum_ -= P.momentum_;
122  ddensity_ -= P.ddensity_;
123  dmomentum_ -= P.dmomentum_;
124  return *this;
125 }
126 
132 {
134  p.density_ = density_ * a;
135  p.momentum_ = momentum_ * a;
136  p.ddensity_ = ddensity_ * a;
137  p.dmomentum_ = dmomentum_ * a;
138  return p;
139 }
140 
146 {
147  density_ /= a;
148  momentum_ /= a;
149  ddensity_ /= a;
150  dmomentum_ /= a;
151  return *this;
152 }
153 
159 {
160  density_ += currentInteraction.getDensity() * phi;
161  momentum_ += currentInteraction.getMomentum() * phi;
162 }
163 
169 {
170 }
171 
178 {
179 }
180 
182 {
183  ddensity_ += currentInteraction.getDensity() * dphi;
184  dmomentum_ += Matrix3D::dyadic(currentInteraction.getMomentum(), dphi);
185 }
186 
194 {
195  return false;
196 }
197 
199 {
200 }
201 
203 {
204  density_ = p.getMass();
205  momentum_ = p.getVelocity() * p.getMass();
206 }
207 
209 {
210 }
211 
213 {
214  setFields(p);
216 }
217 
218 }
GradVelocityField & operator=(const GradVelocityField &P)
Copies all field values.
void output(std::ostream &os) const
Writes human-readable class content into an output stream, typically a stat file. ...
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
GradVelocityField operator*(Mdouble a) const
Multiplies the field values on the left of the '*' by the scalar value on the right of the '*' and re...
double Mdouble
Definition: GeneralDefine.h:34
void setZero()
Sets all fields to zero.
GradVelocityField getSquared() const
Returns the square of all field values (to calculate standard deviation).
Vec3D getCylindricalTensorField(const Vec3D &position) const
Returns this vector field at point p to cylindrical coordinates.
Definition: Vector.cc:261
void setZero()
Sets all elements to zero.
Definition: Vector.cc:43
void addParticleStatistics(Mdouble phi, const GradVelocityField &currentInteraction)
This function should be called from within a loop over all particles to compute all the fields that a...
static Vec3D square(const Vec3D &a)
Calculates the pointwise square of a Vec3D.
Definition: Vector.cc:114
GradVelocityField()
Default constructor, sets all field values to zero.
void setCylindricalFields(const BaseInteraction &c, IntegralType type)
Stores information about interactions between two interactable objects; often particles but could be ...
static Matrix3D dyadic(const Vec3D &a, const Vec3D &b)
Calculates the dyadic product of a two Vec3D: .
Definition: Matrix.cc:323
IntegralType
Specifies the two points between which a line integral is computed.
Definition: IntegralType.h:33
void addContactPointStatistics(Mdouble phi, const GradVelocityField &currentInteraction)
This function should be called from within a loop over all Interactions to compute all the fields tha...
GradVelocityField & operator+=(const GradVelocityField &P)
Adds the field values on the RHS to the LHS of the equation.
Mdouble getMass() const
Returns the particle's mass.
Definition: BaseParticle.h:322
void setFields(const BaseInteraction &c, IntegralType type)
static void writeNames(std::ostream &os, unsigned countVariables)
static bool doInteractionStatistics()
Returns true if the class contains fields that are defined as a sum over all Interactions (e...
GradVelocityField & operator-=(const GradVelocityField &P)
Subtracts the field values on the RHS from the LHS of the equation.
GradVelocityField & operator/=(Mdouble a)
Divides the field values on the LHS by the RHS of the equation.
void setZero()
Sets all elements to zero.
Definition: Matrix.cc:75
void addParticleDifferentialStatistics(Vec3D &dphi, const GradVelocityField &currentInteraction)
void write(std::ostream &os) const
Writes class content into an output stream, typically a stat file.
virtual const Vec3D & getVelocity() const
Returns the velocity of this interactable.
Definition: Vector.h:49
T square(const T val)
squares a number
Definition: ExtendedMath.h:104
static Matrix3D square(const Matrix3D &A)
Calculates the pointwise square.
Definition: Matrix.cc:298
void addInteractionStatistics(Mdouble psi, const GradVelocityField &currentInteraction)
This function should be called from within a loop over all Interactions to compute all the fields tha...