CG< Coordinates, BaseFunction, Fields > Class Template Reference

Evaluates time-resolved continuum fields and writes the data into a stat file. More...

#include <CG.h>

+ Inheritance diagram for CG< Coordinates, BaseFunction, Fields >:

Public Types

typedef BaseFunction< CoordinatesFunction
 Because of this typedefs, Point can be used instead of CGPoint<Function> and Function can be used instead of BaseFunction<Coordinates> in this class. This was done to avoid the overly use of template notation. More...
 
typedef CGPoint< Coordinates, Fields > Point
 

Public Member Functions

 CG ()=default
 Default constructor; does nothing, i.e. no points are created initially. More...
 
 CG (Mdouble width, unsigned n)
 
 CG (const CG &p)=default
 Default copy Constructor; copies all member variables. More...
 
virtual ~CG ()=default
 Default destructor; does nothing. More...
 
CG< Coordinates, BaseFunction, Fields > * copy () const override
 Copy operator; creates a new'ed CG object. More...
 
void write (std::ostream &os) const override
 Writes class content, except for the points, into an output stream. More...
 
void writeAll (std::ostream &os) const
 Writes class content, including the points_, into an output stream, usually a stat file. More...
 
std::string getName () const override
 returns the name of the class, which is required by write. More...
 
void initialise () override
 Called at the beginning of the DPM simulation to initialise the cg evaluation and to open the statFile. More...
 
virtual void createMesh ()
 Creates spatial mesh of CGPoints, the points where the CG-variables are evaluated. More...
 
void evaluate () override
 Called after a given number of time steps (statFile::saveCount_) to evaluate the CG fields. More...
 
Point evaluateAverage ()
 Computes the spatially-averaged value for each field. More...
 
Point evaluateTotal ()
 Computes the total value (integrated over space) for each field. More...
 
void evaluateParticleAtPoint (Fields &currentInteraction, const BaseParticle &p, Point &r)
 
void evaluateParticle (const BaseParticle &p)
 Contains the basic for loop over all CGPoints, required to do particle statistics. More...
 
void evaluateContact (const BaseInteraction &i)
 Contains the basic for loop over all CGPoints, required to do contact statistics. More...
 
IntegralType getIntegralType (const BaseInteraction &c)
 
void finish () override
 Called at the end of the DPM simulation to finish the cg evaluation and to close the statFile. More...
 
const PointgetPoint (size_t i) const
 
const std::vector< Point > & getPoints () const
 
FunctiongetFunction ()
 
void setStandardDeviation (Mdouble std) override
 
void setRadius (Mdouble radius) override
 
void setWidth (Mdouble width) override
 
Mdouble getWidth () const override
 
- Public Member Functions inherited from BaseCG
 BaseCG ()
 Simple constructor, sets default values. More...
 
 BaseCG (const BaseCG &p)=default
 Default copy constructor, copies all values. More...
 
 ~BaseCG () override=default
 Default destructor, does nothing. More...
 
void read (std::istream &is) override
 Currently, no read functions are implemented for the CGHandler, but the function is required for any derivative of BaseObject. More...
 
void clear ()
 This class seems to have no use (?), but is required for any derivative of BaseObject. More...
 
void setHandler (CGHandler *handler)
 Sets handler_, the pointer to the CGHandler. More...
 
CGHandlergetHandler () const
 Returns handler_, a pointer to the CGHandler. More...
 
void setNZ (std::size_t nZ)
 Sets nZ_, the number of spatial mesh points in the z-direction. More...
 
std::size_t getNZ () const
 Returns nZ_, the number of spatial mesh points in the z-direction. More...
 
void setNY (std::size_t nY)
 Sets nY_, the number of spatial mesh points in the y-direction. More...
 
std::size_t getNY () const
 Returns nY_, the number of spatial mesh points in the y-direction. More...
 
void setNX (std::size_t nX)
 Sets nX_, the number of spatial mesh points in the x-direction. More...
 
std::size_t getNX () const
 Returns nX_, the number of spatial mesh points in the x-direction. More...
 
void setN (std::size_t n)
 Sets nX_, nY_, nZ_, the number of spatial mesh points in each cartesian direction. More...
 
void setN (std::array< std::size_t, 3 > n)
 Sets nX_, nY_, nZ_, the number of spatial mesh points in each cartesian direction. More...
 
void setH (Mdouble h)
 Sets nX_, nY_, nZ_, the number of spatial mesh points in each cartesian direction. However, instead of explicitly defining n, the mesh size h=(max-min)/n is defined. More...
 
void setHX (Mdouble h)
 Sets nX_ the number of spatial mesh points in the X-direction. Instead of explicitly defining nX, the mesh size hX=(max.X-min.X)/nX is defined. More...
 
void setHY (Mdouble h)
 Sets nX_ the number of spatial mesh points in the X-direction. Instead of explicitly defining nX, the mesh size hX=(max.X-min.X)/nX is defined. More...
 
void setHZ (Mdouble h)
 Sets nX_ the number of spatial mesh points in the X-direction. Instead of explicitly defining nX, the mesh size hX=(max.X-min.X)/nX is defined. More...
 
void setTimeMin (Mdouble timeMin)
 Sets timeMin_, the lower limit of the temporal domain. More...
 
void setTimeMax (Mdouble timeMax)
 Sets timeMax_, the upper limit of the temporal domain. More...
 
Mdouble getTimeMin () const
 Returns timeMin_, the lower limit of the temporal domain. More...
 
Mdouble getTimeMax () const
 Returns timeMax_, the upper limit of the temporal domain. More...
 
void setMin (Vec3D min)
 Sets max_, the lower limit of the spatial domain. More...
 
void setX (Mdouble min, Mdouble max)
 Sets min_.X, max_.X, the limits of the spatial domain in X. More...
 
void setY (Mdouble min, Mdouble max)
 Sets min_.Y, max_.Y, the limits of the spatial domain in Y. More...
 
void setZ (Mdouble min, Mdouble max)
 Sets min_.Z, max_.Z, the limits of the spatial domain in Z. More...
 
void setXGrid (Mdouble min, Mdouble max, Mdouble h)
 
void setYGrid (Mdouble min, Mdouble max, Mdouble h)
 
void setZGrid (Mdouble min, Mdouble max, Mdouble h)
 
void setGrid (Vec3D min, Vec3D max, Mdouble h)
 
void setMax (Vec3D max)
 Sets max_, the upper limit of the spatial domain. More...
 
Vec3D getMin () const
 Returns min_, the lower limit of the spatial domain. More...
 
Vec3D getMax () const
 Returns max_, the upper limit of the spatial domain. More...
 
void selectSpecies (unsigned speciesIndex)
 
void setSelectedParticle (const std::function< const bool(const BaseInteractable *)> &selectedParticle)
 
void setEps (Mdouble eps)
 
Mdouble getEps () const
 
void setAverageBeyondDomain (const bool val)
 
bool getAverageBeyondDomain () const
 
void setVerbose (const bool verbose)
 
bool getVerbose () const
 
- Public Member Functions inherited from BaseObject
 BaseObject ()=default
 Default constructor. More...
 
 BaseObject (const BaseObject &p)=default
 Copy constructor, copies all the objects BaseObject contains. More...
 
virtual ~BaseObject ()=default
 virtual destructor More...
 
virtual void moveInHandler (unsigned int index)
 Except that it is virtual, it does the same thing as setIndex() does. More...
 
void setIndex (unsigned int index)
 Allows one to assign an index to an object in the handler/container. More...
 
void setId (unsigned long id)
 Assigns a unique identifier to each object in the handler (container) which remains constant even after the object is deleted from the container/handler. More...
 
unsigned int getIndex () const
 Returns the index of the object in the handler. More...
 
unsigned int getId () const
 Returns the unique identifier of any particular object. More...
 
void setGroupId (unsigned groupId)
 
unsigned getGroupId () const
 

Protected Member Functions

void resetVariables ()
 set all variables to zero More...
 
void volumeAverageVariables ()
 divide each variable by the domain volume More...
 
void writeVariables ()
 write variables to the stat file More...
 
void evaluateCommon ()
 The part of evaluate that is used for CG, timeAveragedCG and timeSmoothedCG. More...
 
void outputSumOfVariables ()
 plot total to console More...
 

Protected Attributes

std::vector< Pointpoints_
 Contains the CGPoint's, i.e. the positions at which the StandardFields are evaluated. More...
 
Function function_
 
- Protected Attributes inherited from BaseCG
CGHandlerhandler_
 
std::size_t nX_
 
std::size_t nY_
 
std::size_t nZ_
 
Mdouble eps_
 
Mdouble timeMin_
 
Mdouble timeMax_
 
Vec3D min_
 
Vec3D max_
 
std::function< bool(const BaseInteractable *)> selectedParticle_
 
bool averageBeyondDomain_ = true
 Determines whether particles outside the domain are considered when computing the averaged fields. More...
 
bool verbose_ = false
 

Additional Inherited Members

- Public Attributes inherited from BaseCG
File statFile
 File class to handle the output into a .stat file. More...
 

Detailed Description

template<class Coordinates = CGCoordinates::O, template< class > class BaseFunction = CGFunctions::Lucy, class Fields = CGFields::StandardFields>
class CG< Coordinates, BaseFunction, Fields >

Evaluates time-resolved continuum fields and writes the data into a stat file.

Derived from BaseCG, which already contains the basic functionality of a CG object. This class adds points_, a set of CGPoints, which are templated with a certain CGFunction.

The CGHandler stores all CG objects. Its member functions initialise, evaluate, and finish are called by the CGHandler before, during and after the time loop, respectively, and contain the main functionality:

  • open, write to, and close the statFile.
  • for each time step, calls the functions in CGPoint that cause the evaluation of the fields.

For time-averaged or time-smoothed fields, see TimeAverageCG and TimeSmoothedCG.

See also: MercuryCG: Post-processing discrete particle data using the coarse-graining formulation (in development).

Member Typedef Documentation

◆ Function

template<class Coordinates = CGCoordinates::O, template< class > class BaseFunction = CGFunctions::Lucy, class Fields = CGFields::StandardFields>
typedef BaseFunction<Coordinates> CG< Coordinates, BaseFunction, Fields >::Function

Because of this typedefs, Point can be used instead of CGPoint<Function> and Function can be used instead of BaseFunction<Coordinates> in this class. This was done to avoid the overly use of template notation.

◆ Point

template<class Coordinates = CGCoordinates::O, template< class > class BaseFunction = CGFunctions::Lucy, class Fields = CGFields::StandardFields>
typedef CGPoint<Coordinates, Fields> CG< Coordinates, BaseFunction, Fields >::Point

Constructor & Destructor Documentation

◆ CG() [1/3]

template<class Coordinates = CGCoordinates::O, template< class > class BaseFunction = CGFunctions::Lucy, class Fields = CGFields::StandardFields>
CG< Coordinates, BaseFunction, Fields >::CG ( )
default

Default constructor; does nothing, i.e. no points are created initially.

◆ CG() [2/3]

template<class Coordinates = CGCoordinates::O, template< class > class BaseFunction = CGFunctions::Lucy, class Fields = CGFields::StandardFields>
CG< Coordinates, BaseFunction, Fields >::CG ( Mdouble  width,
unsigned  n 
)

◆ CG() [3/3]

template<class Coordinates = CGCoordinates::O, template< class > class BaseFunction = CGFunctions::Lucy, class Fields = CGFields::StandardFields>
CG< Coordinates, BaseFunction, Fields >::CG ( const CG< Coordinates, BaseFunction, Fields > &  p)
default

Default copy Constructor; copies all member variables.

◆ ~CG()

template<class Coordinates = CGCoordinates::O, template< class > class BaseFunction = CGFunctions::Lucy, class Fields = CGFields::StandardFields>
virtual CG< Coordinates, BaseFunction, Fields >::~CG ( )
virtualdefault

Default destructor; does nothing.

Member Function Documentation

◆ copy()

template<class Coordinates = CGCoordinates::O, template< class > class BaseFunction = CGFunctions::Lucy, class Fields = CGFields::StandardFields>
CG<Coordinates, BaseFunction, Fields>* CG< Coordinates, BaseFunction, Fields >::copy ( ) const
overridevirtual

◆ createMesh()

template<class Coordinates = CGCoordinates::O, template< class > class BaseFunction = CGFunctions::Lucy, class Fields = CGFields::StandardFields>
virtual void CG< Coordinates, BaseFunction, Fields >::createMesh ( )
virtual

Creates spatial mesh of CGPoints, the points where the CG-variables are evaluated.

Reimplemented in TimeAveragedLebedevCG< BaseFunction, Fields >.

◆ evaluate()

template<class Coordinates = CGCoordinates::O, template< class > class BaseFunction = CGFunctions::Lucy, class Fields = CGFields::StandardFields>
void CG< Coordinates, BaseFunction, Fields >::evaluate ( )
overridevirtual

Called after a given number of time steps (statFile::saveCount_) to evaluate the CG fields.

Implements BaseCG.

Reimplemented in TimeAveragedCG< CGCoordinates::XYZ, BaseFunction, CGFields::StandardFields >, and TimeAveragedLebedevCG< BaseFunction, Fields >.

◆ evaluateAverage()

template<class Coordinates = CGCoordinates::O, template< class > class BaseFunction = CGFunctions::Lucy, class Fields = CGFields::StandardFields>
Point CG< Coordinates, BaseFunction, Fields >::evaluateAverage ( )

Computes the spatially-averaged value for each field.

◆ evaluateCommon()

template<class Coordinates = CGCoordinates::O, template< class > class BaseFunction = CGFunctions::Lucy, class Fields = CGFields::StandardFields>
void CG< Coordinates, BaseFunction, Fields >::evaluateCommon ( )
protected

The part of evaluate that is used for CG, timeAveragedCG and timeSmoothedCG.

◆ evaluateContact()

template<class Coordinates = CGCoordinates::O, template< class > class BaseFunction = CGFunctions::Lucy, class Fields = CGFields::StandardFields>
void CG< Coordinates, BaseFunction, Fields >::evaluateContact ( const BaseInteraction i)

Contains the basic for loop over all CGPoints, required to do contact statistics.

Todo:
the check for contact statistics should be done here, not per particle.

◆ evaluateParticle()

template<class Coordinates = CGCoordinates::O, template< class > class BaseFunction = CGFunctions::Lucy, class Fields = CGFields::StandardFields>
void CG< Coordinates, BaseFunction, Fields >::evaluateParticle ( const BaseParticle p)

Contains the basic for loop over all CGPoints, required to do particle statistics.

Todo:
evaluateParticle and evaluateContact can be optimized by using the grid properties for smart neighborhood search.

◆ evaluateParticleAtPoint()

template<class Coordinates = CGCoordinates::O, template< class > class BaseFunction = CGFunctions::Lucy, class Fields = CGFields::StandardFields>
void CG< Coordinates, BaseFunction, Fields >::evaluateParticleAtPoint ( Fields &  currentInteraction,
const BaseParticle p,
Point r 
)

◆ evaluateTotal()

template<class Coordinates = CGCoordinates::O, template< class > class BaseFunction = CGFunctions::Lucy, class Fields = CGFields::StandardFields>
Point CG< Coordinates, BaseFunction, Fields >::evaluateTotal ( )

Computes the total value (integrated over space) for each field.

◆ finish()

template<class Coordinates = CGCoordinates::O, template< class > class BaseFunction = CGFunctions::Lucy, class Fields = CGFields::StandardFields>
void CG< Coordinates, BaseFunction, Fields >::finish ( )
overridevirtual

Called at the end of the DPM simulation to finish the cg evaluation and to close the statFile.

Implements BaseCG.

Reimplemented in TimeAveragedCG< CGCoordinates::XYZ, BaseFunction, CGFields::StandardFields >.

◆ getFunction()

template<class Coordinates = CGCoordinates::O, template< class > class BaseFunction = CGFunctions::Lucy, class Fields = CGFields::StandardFields>
Function& CG< Coordinates, BaseFunction, Fields >::getFunction ( )
inline
193  {
194  return function_;
195  }
Function function_
Definition: CG.h:268

References CG< Coordinates, BaseFunction, Fields >::function_.

◆ getIntegralType()

template<class Coordinates = CGCoordinates::O, template< class > class BaseFunction = CGFunctions::Lucy, class Fields = CGFields::StandardFields>
IntegralType CG< Coordinates, BaseFunction, Fields >::getIntegralType ( const BaseInteraction c)

◆ getName()

template<class Coordinates = CGCoordinates::O, template< class > class BaseFunction = CGFunctions::Lucy, class Fields = CGFields::StandardFields>
std::string CG< Coordinates, BaseFunction, Fields >::getName ( ) const
overridevirtual

returns the name of the class, which is required by write.

Implements BaseObject.

Reimplemented in TimeAveragedCG< CGCoordinates::XYZ, BaseFunction, CGFields::StandardFields >.

◆ getPoint()

template<class Coordinates = CGCoordinates::O, template< class > class BaseFunction = CGFunctions::Lucy, class Fields = CGFields::StandardFields>
const Point& CG< Coordinates, BaseFunction, Fields >::getPoint ( size_t  i) const
inline
183  {
184  return points_[i];
185  }
std::vector< Point > points_
Contains the CGPoint's, i.e. the positions at which the StandardFields are evaluated.
Definition: CG.h:266
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51

References constants::i, and CG< Coordinates, BaseFunction, Fields >::points_.

Referenced by testCGHandler().

◆ getPoints()

template<class Coordinates = CGCoordinates::O, template< class > class BaseFunction = CGFunctions::Lucy, class Fields = CGFields::StandardFields>
const std::vector<Point>& CG< Coordinates, BaseFunction, Fields >::getPoints ( ) const
inline
188  {
189  return points_;
190  }

References CG< Coordinates, BaseFunction, Fields >::points_.

Referenced by testCGHandler().

◆ getWidth()

template<class Coordinates = CGCoordinates::O, template< class > class BaseFunction = CGFunctions::Lucy, class Fields = CGFields::StandardFields>
Mdouble CG< Coordinates, BaseFunction, Fields >::getWidth ( ) const
inlineoverridevirtual
Returns
width of the cg function for all CGPoints

Implements BaseCG.

229  {
230  return function_.getWidth();
231  }

References CG< Coordinates, BaseFunction, Fields >::function_.

◆ initialise()

template<class Coordinates = CGCoordinates::O, template< class > class BaseFunction = CGFunctions::Lucy, class Fields = CGFields::StandardFields>
void CG< Coordinates, BaseFunction, Fields >::initialise ( )
overridevirtual

Called at the beginning of the DPM simulation to initialise the cg evaluation and to open the statFile.

Implements BaseCG.

Reimplemented in TimeAveragedCG< CGCoordinates::XYZ, BaseFunction, CGFields::StandardFields >.

◆ outputSumOfVariables()

template<class Coordinates = CGCoordinates::O, template< class > class BaseFunction = CGFunctions::Lucy, class Fields = CGFields::StandardFields>
void CG< Coordinates, BaseFunction, Fields >::outputSumOfVariables ( )
protected

plot total to console

◆ resetVariables()

template<class Coordinates = CGCoordinates::O, template< class > class BaseFunction = CGFunctions::Lucy, class Fields = CGFields::StandardFields>
void CG< Coordinates, BaseFunction, Fields >::resetVariables ( )
protected

set all variables to zero

◆ setRadius()

template<class Coordinates = CGCoordinates::O, template< class > class BaseFunction = CGFunctions::Lucy, class Fields = CGFields::StandardFields>
void CG< Coordinates, BaseFunction, Fields >::setRadius ( Mdouble  radius)
inlineoverridevirtual

Implements BaseCG.

203  {
204  if (std::is_base_of<CGCoordinates::Base_X_Y_Z, Coordinates>::value)
205  {
206  function_.setStandardDeviation(radius * sqrt(.2));
207  }
208  else if (std::is_base_of<CGCoordinates::Base_XY_XZ_YZ, Coordinates>::value)
209  {
210  function_.setStandardDeviation(radius * sqrt(.4));
211  }
212  else /*XYZ*/ {
213  function_.setStandardDeviation(radius * sqrt(.6));
214  }
215  }

References CG< Coordinates, BaseFunction, Fields >::function_.

◆ setStandardDeviation()

template<class Coordinates = CGCoordinates::O, template< class > class BaseFunction = CGFunctions::Lucy, class Fields = CGFields::StandardFields>
void CG< Coordinates, BaseFunction, Fields >::setStandardDeviation ( Mdouble  std)
inlineoverridevirtual

Implements BaseCG.

198  {
199  function_.setStandardDeviation(std);
200  }

References CG< Coordinates, BaseFunction, Fields >::function_.

◆ setWidth()

template<class Coordinates = CGCoordinates::O, template< class > class BaseFunction = CGFunctions::Lucy, class Fields = CGFields::StandardFields>
void CG< Coordinates, BaseFunction, Fields >::setWidth ( Mdouble  width)
inlineoverridevirtual
Parameters
[in]widthof the cg function for all CGPoints

Implements BaseCG.

221  {
222  function_.setWidth(width);
223  }

References CG< Coordinates, BaseFunction, Fields >::function_.

Referenced by main(), and setCGHandler().

◆ volumeAverageVariables()

template<class Coordinates = CGCoordinates::O, template< class > class BaseFunction = CGFunctions::Lucy, class Fields = CGFields::StandardFields>
void CG< Coordinates, BaseFunction, Fields >::volumeAverageVariables ( )
protected

divide each variable by the domain volume

◆ write()

template<class Coordinates = CGCoordinates::O, template< class > class BaseFunction = CGFunctions::Lucy, class Fields = CGFields::StandardFields>
void CG< Coordinates, BaseFunction, Fields >::write ( std::ostream &  os) const
overridevirtual

Writes class content, except for the points, into an output stream.

Reimplemented from BaseCG.

Reimplemented in TimeAveragedCG< CGCoordinates::XYZ, BaseFunction, CGFields::StandardFields >.

◆ writeAll()

template<class Coordinates = CGCoordinates::O, template< class > class BaseFunction = CGFunctions::Lucy, class Fields = CGFields::StandardFields>
void CG< Coordinates, BaseFunction, Fields >::writeAll ( std::ostream &  os) const

Writes class content, including the points_, into an output stream, usually a stat file.

Referenced by testCGHandler().

◆ writeVariables()

template<class Coordinates = CGCoordinates::O, template< class > class BaseFunction = CGFunctions::Lucy, class Fields = CGFields::StandardFields>
void CG< Coordinates, BaseFunction, Fields >::writeVariables ( )
protected

write variables to the stat file

Member Data Documentation

◆ function_

template<class Coordinates = CGCoordinates::O, template< class > class BaseFunction = CGFunctions::Lucy, class Fields = CGFields::StandardFields>
Function CG< Coordinates, BaseFunction, Fields >::function_
protected

◆ points_

template<class Coordinates = CGCoordinates::O, template< class > class BaseFunction = CGFunctions::Lucy, class Fields = CGFields::StandardFields>
std::vector<Point> CG< Coordinates, BaseFunction, Fields >::points_
protected

Contains the CGPoint's, i.e. the positions at which the StandardFields are evaluated.

Referenced by CG< Coordinates, BaseFunction, Fields >::getPoint(), and CG< Coordinates, BaseFunction, Fields >::getPoints().


The documentation for this class was generated from the following file: