BaseCG.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 BaseCG_H
6 #define BaseCG_H
7 
8 #include <cstdlib>
9 #include <functional>
10 #include "GeneralDefine.h"
11 #include "BaseObject.h"
12 #include "File.h"
13 #include "Math/Vector.h"
14 
15 class CGHandler;
16 
17 class BaseInteractable;
18 
35 class BaseCG : public BaseObject
36 {
37 public:
38 
42  BaseCG();
43 
47  BaseCG(const BaseCG& p) = default;
48 
52  ~BaseCG() override = default;
53 
58  void read(std::istream& is) override;
59 
63  void write(std::ostream& os) const override;
64 
69  void clear();
70 
74  virtual BaseCG* copy() const = 0;
75 
80  virtual void initialise() = 0;
81 
86  virtual void evaluate() = 0;
87 
92  virtual void finish() = 0;
93 
97  void setHandler(CGHandler* handler);
98 
102  CGHandler* getHandler() const;
103 
108  virtual void setWidth(Mdouble width)=0;
109 
113  virtual Mdouble getWidth() const =0;
114 
118  void setNZ(std::size_t nZ);
119 
123  std::size_t getNZ() const;
124 
128  void setNY(std::size_t nY);
129 
133  std::size_t getNY() const;
134 
138  void setNX(std::size_t nX);
139 
143  std::size_t getNX() const;
144 
148  void setN(std::size_t n);
149 
153  void setN(std::array<std::size_t, 3> n);
154 
159  void setH(Mdouble h);
160 
165  void setHX(Mdouble h);
166 
171  void setHY(Mdouble h);
172 
177  void setHZ(Mdouble h);
178 
182  void setTimeMin(Mdouble timeMin);
183 
187  void setTimeMax(Mdouble timeMax);
188 
192  Mdouble getTimeMin() const;
193 
197  Mdouble getTimeMax() const;
198 
202  void setMin(Vec3D min);
203 
207  void setX(Mdouble min, Mdouble max);
208 
212  void setY(Mdouble min, Mdouble max);
213 
217  void setZ(Mdouble min, Mdouble max);
218 
220 
222 
224 
225  void setGrid(Vec3D min, Vec3D max, Mdouble h);
226 
230  void setMax(Vec3D max);
231 
235  Vec3D getMin() const;
236 
240  Vec3D getMax() const;
241 
246  void selectSpecies(unsigned speciesIndex);
247 
248  void setSelectedParticle(const std::function<const bool(const BaseInteractable*)>& selectedParticle);
249 
250  void setEps(Mdouble eps);
251 
252  Mdouble getEps() const;
253 
255 
257 
258  void setVerbose(const bool verbose) {verbose_=verbose;}
259 
260  bool getVerbose() const {return verbose_;}
261 
262  virtual void setWidthTime(Mdouble widthTime);
263 
264  virtual Mdouble getWidthTime() const;
265 
266  virtual void setTimeStep(Mdouble timeStep);
267 
268  virtual Mdouble getTimeStep() const;
269 
270  /*
271  * Sets width such that the CG function has a fixed standard deviation
272  * See CGStandardDeviationUnitTest.
273  */
274  virtual void setStandardDeviation(Mdouble std) = 0;
275 
276  /*
277  * Sets width such that the CG function has the same standard deviation as a spherical cg function.
278  * See CGStandardDeviationUnitTest.
279  */
280  virtual void setRadius(Mdouble radius) = 0;
281 
282 protected:
283 
288 
296  std::size_t nX_;
297 
301  std::size_t nY_;
302 
306  std::size_t nZ_;
307 
313 
321 
326 
333 
338 
342  std::function<bool(const BaseInteractable*)> selectedParticle_;
343 
355  bool averageBeyondDomain_ = true;
356 
357  bool verbose_ = false;
358 
359 public:
364 };
365 
366 #endif
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
double Mdouble
Definition: GeneralDefine.h:13
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
virtual Mdouble getWidth() const =0
Returns width_, the coarse-graining width.
void setHX(Mdouble h)
Sets nX_ the number of spatial mesh points in the X-direction. Instead of explicitly defining nX,...
Definition: BaseCG.cc:229
void setNY(std::size_t nY)
Sets nY_, the number of spatial mesh points in the y-direction.
Definition: BaseCG.cc:91
Mdouble getTimeMax() const
Returns timeMax_, the upper limit of the temporal domain.
Definition: BaseCG.cc:160
~BaseCG() override=default
Default destructor, does nothing.
void setMax(Vec3D max)
Sets max_, the upper limit of the spatial domain.
Definition: BaseCG.cc:150
void setVerbose(const bool verbose)
Definition: BaseCG.h:258
bool averageBeyondDomain_
Determines whether particles outside the domain are considered when computing the averaged fields.
Definition: BaseCG.h:355
BaseCG(const BaseCG &p)=default
Default copy constructor, copies all values.
void setSelectedParticle(const std::function< const bool(const BaseInteractable *)> &selectedParticle)
Definition: BaseCG.cc:216
Mdouble timeMin_
Definition: BaseCG.h:320
void setZ(Mdouble min, Mdouble max)
Sets min_.Z, max_.Z, the limits of the spatial domain in Z.
Definition: BaseCG.cc:177
File statFile
File class to handle the output into a .stat file.
Definition: BaseCG.h:363
void setNX(std::size_t nX)
Sets nX_, the number of spatial mesh points in the x-direction.
Definition: BaseCG.cc:101
std::size_t getNY() const
Returns nY_, the number of spatial mesh points in the y-direction.
Definition: BaseCG.cc:96
Mdouble getEps() const
Definition: BaseCG.cc:76
void setHY(Mdouble h)
Sets nX_ the number of spatial mesh points in the X-direction. Instead of explicitly defining nX,...
Definition: BaseCG.cc:238
void setYGrid(Mdouble min, Mdouble max, Mdouble h)
Definition: BaseCG.cc:189
void setHandler(CGHandler *handler)
Sets handler_, the pointer to the CGHandler.
Definition: BaseCG.cc:52
virtual void setWidth(Mdouble width)=0
Sets width_, the coarse-graining width.
virtual Mdouble getTimeStep() const
Definition: BaseCG.cc:272
virtual void evaluate()=0
Called after a given number of time steps (statFile::saveCount_) to evaluate the CG fields.
std::size_t nY_
Definition: BaseCG.h:301
virtual void setWidthTime(Mdouble widthTime)
Definition: BaseCG.cc:256
void clear()
This class seems to have no use (?), but is required for any derivative of BaseObject.
Definition: BaseCG.cc:25
Vec3D min_
Definition: BaseCG.h:332
Mdouble eps_
Definition: BaseCG.h:312
BaseCG()
Simple constructor, sets default values.
Definition: BaseCG.cc:8
void setTimeMin(Mdouble timeMin)
Sets timeMin_, the lower limit of the temporal domain.
Definition: BaseCG.cc:125
void setX(Mdouble min, Mdouble max)
Sets min_.X, max_.X, the limits of the spatial domain in X.
Definition: BaseCG.cc:165
void setH(Mdouble h)
Sets nX_, nY_, nZ_, the number of spatial mesh points in each cartesian direction....
Definition: BaseCG.cc:221
CGHandler * getHandler() const
Returns handler_, a pointer to the CGHandler.
Definition: BaseCG.cc:60
virtual void finish()=0
Called at the end of the DPM simulation to finish the cg evaluation and to close the statFile.
void setAverageBeyondDomain(const bool val)
Definition: BaseCG.h:254
std::function< bool(const BaseInteractable *)> selectedParticle_
Definition: BaseCG.h:342
Vec3D getMin() const
Returns min_, the lower limit of the spatial domain.
Definition: BaseCG.cc:135
void setXGrid(Mdouble min, Mdouble max, Mdouble h)
Definition: BaseCG.cc:183
Mdouble getTimeMin() const
Returns timeMin_, the lower limit of the temporal domain.
Definition: BaseCG.cc:155
void setEps(Mdouble eps)
Definition: BaseCG.cc:71
std::size_t nZ_
Definition: BaseCG.h:306
void write(std::ostream &os) const override
Writes class content into an output stream, usually a stat file.
Definition: BaseCG.cc:38
void setMin(Vec3D min)
Sets max_, the lower limit of the spatial domain.
Definition: BaseCG.cc:145
virtual void initialise()=0
Called at the beginning of the DPM simulation to initialise the cg evaluation and to open the statFil...
void setZGrid(Mdouble min, Mdouble max, Mdouble h)
Definition: BaseCG.cc:195
void selectSpecies(unsigned speciesIndex)
Definition: BaseCG.cc:208
virtual void setRadius(Mdouble radius)=0
bool getVerbose() const
Definition: BaseCG.h:260
void setNZ(std::size_t nZ)
Sets nZ_, the number of spatial mesh points in the z-direction.
Definition: BaseCG.cc:81
virtual BaseCG * copy() const =0
Copy operator. Required for BaseHandler::copyAndAddObject.
std::size_t getNZ() const
Returns nZ_, the number of spatial mesh points in the z-direction.
Definition: BaseCG.cc:86
void setTimeMax(Mdouble timeMax)
Sets timeMax_, the upper limit of the temporal domain.
Definition: BaseCG.cc:130
void setGrid(Vec3D min, Vec3D max, Mdouble h)
Definition: BaseCG.cc:201
void setN(std::size_t n)
Sets nX_, nY_, nZ_, the number of spatial mesh points in each cartesian direction.
Definition: BaseCG.cc:111
std::size_t nX_
Definition: BaseCG.h:296
std::size_t getNX() const
Returns nX_, the number of spatial mesh points in the x-direction.
Definition: BaseCG.cc:106
Mdouble timeMax_
Definition: BaseCG.h:325
CGHandler * handler_
Definition: BaseCG.h:287
void setHZ(Mdouble h)
Sets nX_ the number of spatial mesh points in the X-direction. Instead of explicitly defining nX,...
Definition: BaseCG.cc:247
virtual Mdouble getWidthTime() const
Definition: BaseCG.cc:266
bool verbose_
Definition: BaseCG.h:357
void read(std::istream &is) override
Currently, no read functions are implemented for the CGHandler, but the function is required for any ...
Definition: BaseCG.cc:31
virtual void setStandardDeviation(Mdouble std)=0
bool getAverageBeyondDomain() const
Definition: BaseCG.h:256
Vec3D max_
Definition: BaseCG.h:337
Vec3D getMax() const
Returns max_, the upper limit of the spatial domain.
Definition: BaseCG.cc:140
virtual void setTimeStep(Mdouble timeStep)
Definition: BaseCG.cc:261
void setY(Mdouble min, Mdouble max)
Sets min_.Y, max_.Y, the limits of the spatial domain in Y.
Definition: BaseCG.cc:171
Defines the basic properties that a interactable object can have.
Definition: BaseInteractable.h:34
It is an abstract base class due to the purely virtual functions declared below. Even if the function...
Definition: BaseObject.h:30
Container that stores all CG objects.
Definition: CGHandler.h:45
Definition: File.h:59
Definition: Kernel/Math/Vector.h:30
#define min(a, b)
Definition: datatypes.h:22
#define max(a, b)
Definition: datatypes.h:23
double eps
Definition: crbond_bessel.cc:24
radius
Definition: UniformPSDSelfTest.py:15
val
Definition: calibrate.py:119
bool verbose
Definition: statXZ.cpp:7