MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
CG.h
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 #ifndef CG_H
27 #define CG_H
28 
29 #include "CG/BaseCG.h"
30 #include <vector>
31 
32 class CGHandler;
33 
34 class Function;
35 
36 class BaseParticle;
37 
38 class BaseInteraction;
39 
40 #include "CG/CGPoint.h"
41 #include "DPMBase.h"
42 #include "CG/CGHandler.h"
44 #include "Logger.h"
45 #include "CG/Functions/Lucy.h"
46 #include "CG/Functions/Heaviside.h"
47 
72 template<class Coordinates = CGCoordinates::O,
73  template<class> class BaseFunction=CGFunctions::Lucy,
74  class Fields=CGFields::StandardFields>
75 class CG : public BaseCG
76 {
77 public:
84  typedef BaseFunction<Coordinates> Function;
86 
91  CG() = default;
92 
96  CG(Mdouble width, unsigned n);
97 
101  CG(const CG& p) = default;
102 
106  virtual ~CG() = default;
107 
112 
117  void write(std::ostream& os) const override;
118 
123  void writeAll(std::ostream& os) const;
124 
128  std::string getName() const override;
129 
134  void initialise() override;
135 
139  virtual void createMesh();
140 
145  void evaluate() override;
146 
151 
156 
157  void evaluateParticleAtPoint(Fields& currentInteraction, const BaseParticle& p, Point& r);
158 
165  void evaluateParticle(const BaseParticle& p);
166 
173  void evaluateContact(const BaseInteraction& i);
174 
176 
181  void finish() override;
182 
183  const Point& getPoint(size_t i) const
184  {
185  return points_[i];
186  }
187 
188  const std::vector<Point>& getPoints() const
189  {
190  return points_;
191  }
192 
194  {
195  return function_;
196  }
197 
198  void setStandardDeviation(Mdouble std) override
199  {
200  function_.setStandardDeviation(std);
201  }
202 
203  void setRadius(Mdouble radius) override
204  {
205  if (std::is_base_of<CGCoordinates::Base_X_Y_Z, Coordinates>::value)
206  {
207  function_.setStandardDeviation(radius * sqrt(.2));
208  }
209  else if (std::is_base_of<CGCoordinates::Base_XY_XZ_YZ, Coordinates>::value)
210  {
211  function_.setStandardDeviation(radius * sqrt(.4));
212  }
213  else /*XYZ*/ {
214  function_.setStandardDeviation(radius * sqrt(.6));
215  }
216  }
217 
221  void setWidth(Mdouble width) override
222  {
223  function_.setWidth(width);
224  }
225 
229  Mdouble getWidth() const override
230  {
231  return function_.getWidth();
232  }
233 
234 protected:
235 
239  void resetVariables();
240 
244  void volumeAverageVariables();
245 
249  void writeVariables();
250 
254  void evaluateCommon();
255 
259  void outputSumOfVariables();
260 
261 protected:
262 
267  std::vector<Point> points_;
268 
270 
271 
272 };
273 
274 #include "CG/CG.hcc"
275 
276 #endif
CGPoint< Coordinates, Fields > Point
Definition: CG.h:85
Container that stores all CG objects.
Definition: CGHandler.h:64
Template argument; use a member class of CGFunctions to instantiate.
void initialise() override
Called at the beginning of the DPM simulation to initialise the cg evaluation and to open the statFil...
void write(std::ostream &os) const override
Writes class content, except for the points, into an output stream.
Combines the position of the CGPoint (e.g. x, y, z), the parameters of the coarse-graining function (...
Definition: CGPoint.h:43
double Mdouble
Definition: GeneralDefine.h:34
void setRadius(Mdouble radius) override
Definition: CG.h:203
std::vector< Point > points_
Contains the CGPoint's, i.e. the positions at which the StandardFields are evaluated.
Definition: CG.h:267
void evaluateParticleAtPoint(Fields &currentInteraction, const BaseParticle &p, Point &r)
A specialisation of Polynomials for PolynomialType::Lucy. See Polynomial for details.
Definition: Lucy.h:38
void writeAll(std::ostream &os) const
Writes class content, including the points_, into an output stream, usually a stat file...
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
CG()=default
Default constructor; does nothing, i.e. no points are created initially.
CG< Coordinates, BaseFunction, Fields > * copy() const override
Copy operator; creates a new'ed CG object.
void setStandardDeviation(Mdouble std) override
Definition: CG.h:198
Function & getFunction()
Definition: CG.h:193
Point evaluateTotal()
Computes the total value (integrated over space) for each field.
void finish() override
Called at the end of the DPM simulation to finish the cg evaluation and to close the statFile...
virtual ~CG()=default
Default destructor; does nothing.
void evaluateParticle(const BaseParticle &p)
Contains the basic for loop over all CGPoints, required to do particle statistics.
Stores information about interactions between two interactable objects; often particles but could be ...
Function function_
Definition: CG.h:269
void writeVariables()
write variables to the stat file
Mdouble getWidth() const override
Definition: CG.h:229
IntegralType
Specifies the two points between which a line integral is computed.
Definition: IntegralType.h:33
virtual void createMesh()
Creates spatial mesh of CGPoints, the points where the CG-variables are evaluated.
Point evaluateAverage()
Computes the spatially-averaged value for each field.
void evaluateCommon()
The part of evaluate that is used for CG, timeAveragedCG and timeSmoothedCG.
const Point & getPoint(size_t i) const
Definition: CG.h:183
const std::vector< Point > & getPoints() const
Definition: CG.h:188
void volumeAverageVariables()
divide each variable by the domain volume
IntegralType getIntegralType(const BaseInteraction &c)
Evaluates time-resolved continuum fields and writes the data into a stat file.
Definition: CG.h:75
void evaluate() override
Called after a given number of time steps (statFile::saveCount_) to evaluate the CG fields...
void setWidth(Mdouble width) override
Definition: CG.h:221
Contains the computed field values, like density, momentum and stress.
void resetVariables()
set all variables to zero
void evaluateContact(const BaseInteraction &i)
Contains the basic for loop over all CGPoints, required to do contact statistics. ...
BaseFunction< Coordinates > Function
Because of this typedefs, Point can be used instead of CGPoint and Function can be used ins...
Definition: CG.h:84
Base class of all CG objects, needed to store the various CG objects in the CGHandler.
Definition: BaseCG.h:56
void outputSumOfVariables()
plot total to console
std::string getName() const override
returns the name of the class, which is required by write.
Template argument; use a member class of CGCoordinates to instantiate.