CG.h
Go to the documentation of this file.
1 // This file is part of the MercuryDPM project (https://www.mercurydpm.org).
2 // Copyright (c), The MercuryDPM Developers Team. All rights reserved.
3 // License: BSD 3-Clause License; see the LICENSE file in the root directory.
4 
5 #ifndef CG_H
6 #define CG_H
7 
8 #include "CG/BaseCG.h"
9 #include <vector>
10 
11 class CGHandler;
12 
13 class Function;
14 
15 class BaseParticle;
16 
17 class BaseInteraction;
18 
19 #include "CG/CGPoint.h"
20 #include "DPMBase.h"
21 #include "CG/CGHandler.h"
23 #include "Logger.h"
24 #include "CG/Functions/Lucy.h"
25 #include "CG/Functions/Heaviside.h"
26 
51 template<class Coordinates = CGCoordinates::O,
52  template<class> class BaseFunction=CGFunctions::Lucy,
53  class Fields=CGFields::StandardFields>
54 class CG : public BaseCG
55 {
56 public:
63  typedef BaseFunction<Coordinates> Function;
65 
70  CG() = default;
71 
75  CG(Mdouble width, unsigned n);
76 
80  CG(const CG& p) = default;
81 
85  virtual ~CG() = default;
86 
91 
95  void write(std::ostream& os) const override;
96 
101  void writeAll(std::ostream& os) const;
102 
106  std::string getName() const override;
107 
112  void initialise() override;
113 
117  virtual void createMesh();
118 
123  void evaluate() override;
124 
129 
134 
135  void evaluateParticleAtPoint(Fields& currentInteraction, const BaseParticle& p, Point& r);
136 
144 
152 
154 
159  void finish() override;
160 
161  const Point& getPoint(size_t i) const
162  {
163  return points_[i];
164  }
165 
166  const std::vector<Point>& getPoints() const
167  {
168  return points_;
169  }
170 
172  {
173  return function_;
174  }
175 
176  void setStandardDeviation(Mdouble std) override
177  {
178  function_.setStandardDeviation(std);
179  }
180 
181  void setRadius(Mdouble radius) override
182  {
184  {
185  function_.setStandardDeviation(radius * sqrt(.2));
186  }
188  {
189  function_.setStandardDeviation(radius * sqrt(.4));
190  }
191  else /*XYZ*/ {
192  function_.setStandardDeviation(radius * sqrt(.6));
193  }
194  }
195 
199  void setWidth(Mdouble width) override
200  {
201  function_.setWidth(width);
202  }
203 
207  Mdouble getWidth() const override
208  {
209  return function_.getWidth();
210  }
211 
212 protected:
213 
218 
223 
228 
233 
238 
239 protected:
240 
245  std::vector<Point> points_;
246 
248 
249 
250 };
251 
252 #include "CG/CG.hcc"
253 
254 #endif
AnnoyingScalar sqrt(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:134
int i
Definition: BiCGSTAB_step_by_step.cpp:9
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
IntegralType
Specifies the two points between which a line integral is computed.
Definition: IntegralType.h:14
@ O
Definition: StatisticsVector.h:21
float * p
Definition: Tutorial_Map_using.cpp:9
Base class of all CG objects, needed to store the various CG objects in the CGHandler.
Definition: BaseCG.h:36
Stores information about interactions between two interactable objects; often particles but could be ...
Definition: BaseInteraction.h:39
Definition: BaseParticle.h:33
Contains the computed field values, like density, momentum and stress.
Definition: StandardFields.h:33
A specialisation of Polynomials for PolynomialType::Lucy. See Polynomial for details.
Definition: Lucy.h:19
Container that stores all CG objects.
Definition: CGHandler.h:45
Combines the position of the CGPoint (e.g. x, y, z), the parameters of the coarse-graining function (...
Definition: CGPoint.h:24
Evaluates time-resolved continuum fields and writes the data into a stat file.
Definition: CG.h:55
void evaluateParticle(const BaseParticle &p)
Contains the basic for loop over all CGPoints, required to do particle statistics.
Function & getFunction()
Definition: CG.h:171
virtual void createMesh()
Creates spatial mesh of CGPoints, the points where the CG-variables are evaluated.
std::string getName() const override
returns the name of the class, which is required by write.
const std::vector< Point > & getPoints() const
Definition: CG.h:166
void evaluateCommon()
The part of evaluate that is used for CG, timeAveragedCG and timeSmoothedCG.
BaseFunction< Coordinates > Function
Because of this typedefs, Point can be used instead of CGPoint<Function> and Function can be used ins...
Definition: CG.h:63
void resetVariables()
set all variables to zero
Point evaluateTotal()
Computes the total value (integrated over space) for each field.
void setStandardDeviation(Mdouble std) override
Definition: CG.h:176
virtual ~CG()=default
Default destructor; does nothing.
void write(std::ostream &os) const override
Writes class content, except for the points, into an output stream.
void evaluateParticleAtPoint(Fields &currentInteraction, const BaseParticle &p, Point &r)
Function function_
Definition: CG.h:247
CGPoint< Coordinates, Fields > Point
Definition: CG.h:64
void evaluateContact(const BaseInteraction &i)
Contains the basic for loop over all CGPoints, required to do contact statistics.
void writeVariables()
write variables to the stat file
CG(const CG &p)=default
Default copy Constructor; copies all member variables.
std::vector< Point > points_
Contains the CGPoint's, i.e. the positions at which the StandardFields are evaluated.
Definition: CG.h:245
void initialise() override
Called at the beginning of the DPM simulation to initialise the cg evaluation and to open the statFil...
void evaluate() override
Called after a given number of time steps (statFile::saveCount_) to evaluate the CG fields.
const Point & getPoint(size_t i) const
Definition: CG.h:161
CG()=default
Default constructor; does nothing, i.e. no points are created initially.
void writeAll(std::ostream &os) const
Writes class content, including the points_, into an output stream, usually a stat file.
IntegralType getIntegralType(const BaseInteraction &c)
Mdouble getWidth() const override
Definition: CG.h:207
void volumeAverageVariables()
divide each variable by the domain volume
void setWidth(Mdouble width) override
Definition: CG.h:199
void setRadius(Mdouble radius) override
Definition: CG.h:181
Point evaluateAverage()
Computes the spatially-averaged value for each field.
void finish() override
Called at the end of the DPM simulation to finish the cg evaluation and to close the statFile.
void outputSumOfVariables()
plot total to console
CG(Mdouble width, unsigned n)
CG< Coordinates, BaseFunction, Fields > * copy() const override
Copy operator; creates a new'ed CG object.
Template argument; use a member class of CGCoordinates to instantiate.
Template argument; use a member class of CGFunctions to instantiate.
squared absolute value
Definition: GlobalFunctions.h:87
r
Definition: UniformPSDSelfTest.py:20
radius
Definition: UniformPSDSelfTest.py:15
int c
Definition: calibrate.py:100
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286