MercuryDPM  Trunk
CGCoordinates::XYZ Class Reference

Defines the position of the CGPoint, in the non-averaged directions, i.e. all directions on which spatial coarse-graining is applied (all directions for XYZ); all other directions are averaged over homogeneously. More...

#include <XYZ.h>

Inheritance diagram for CGCoordinates::XYZ:

## Public Member Functions

void write (std::ostream &os) const
Writes the coordinates in human-readable form to an ostream. More...

Mdouble getDistanceSquared (const Vec3D &p) const
Returns the square of the distance between the particle p and the current CGPoint, in the non-averaged directions. More...

void setXYZ (Vec3D p)
Returns the position of the current CGPoint, in the non-averaged directions. More...

Mdouble getINormal (const BaseInteraction &c, const Vec3D &normal) const
For the Interaction between particles/walls P and I, this function returns the dot product between the normal vector of the interaction and the branch vector from the current CGPoint towards I. More...

Mdouble getPNormal (const BaseInteraction &c, const Vec3D &normal) const
For the Interaction between particles/walls P and I, this function returns the dot product between the normal vector of the interaction and the branch vector from the current CGPoint towards P. More...

Mdouble getCNormal (const BaseInteraction &c, const Vec3D &normal) const
For the Interaction between particles/walls P and I, this function returns the dot product between the normal vector of the interaction and the branch vector from the current CGPoint towards the contact point. More...

Mdouble getTangentialSquared (const BaseInteraction &c, Mdouble pNormal) const
For the Interaction between particles/walls P and I, this function returns the square of the minimum distance between the the current CGPoint and the branch vector between P and I. More...

Public Member Functions inherited from CGCoordinates::BaseCoordinates
virtual Mdouble getWeight ()

## Static Public Member Functions

static void writeNames (std::ostream &os)
Writes the coordinate names in human-readable form to an ostream. More...

static Mdouble getVolumeOfAveragedDimensions (const Vec3D &min, const Vec3D &max)
returns the factor the CGFunction has to be divided by, due to integrating the variables over the averaged dimensions, 1.0 for XYZ. More...

static Mdouble getLength (const Vec3D &p)
Returns the length of the input vector in the non-averaged directions. More...

static Mdouble getGaussPrefactor (Mdouble width, Mdouble cutoff)
Computes the prefactor of the Gauss CGFunction, which is dependent on the number of non-averaged dimensions. More...

static Mdouble getGaussIntegralPrefactor (Mdouble distance, Mdouble width, Mdouble cutoff)
Computes the prefactor of the Gauss line integral, which is dependent on the number of non-averaged dimensions. More...

static void normalisePolynomialCoefficients (std::vector< Mdouble > &coefficients, Mdouble cutoff)
Normalises the coefficients of Polynomial CGFunction such that the integral over all non-averaged dimensions is unity. More...

static const unsigned countVariables ()

static bool isResolvedIn (unsigned i)

static std::string getName ()

Static Public Member Functions inherited from CGCoordinates::BaseCoordinates
static Mdouble getDomainVolume (const Vec3D &min, const Vec3D &max)

Vec3D p_

## Detailed Description

Defines the position of the CGPoint, in the non-averaged directions, i.e. all directions on which spatial coarse-graining is applied (all directions for XYZ); all other directions are averaged over homogeneously.

In addition to defining the spatial variable, the classes in CGCoordinates contain all functions that only depend on how many coordinate directions are locally resolved (i.e. not averaged over); e.g. getDistanceSquared and getVolumeOfAveragedDimensions.

The CGCoordinates class should be chosen such that the system in homogeneous (symmetric) in the averaged directions. E.g., periodic chutes are homogeneous in x, y and t, but varying in z, so Z should be used.

See member CGCoordinates for more details.

Definition at line 74 of file XYZ.h.

## Member Function Documentation

 const unsigned XYZ::countVariables ( )
static

returns the number of variables (in this case three)

Definition at line 190 of file XYZ.cc.

191 {
192  return 3;
193 }
 Mdouble XYZ::getCNormal ( const BaseInteraction & c, const Vec3D & normal ) const

For the Interaction between particles/walls P and I, this function returns the dot product between the normal vector of the interaction and the branch vector from the current CGPoint towards the contact point.

Parameters
 [in] c the Interaction object from which iNormal is computed
Returns
cNormal, one of the three distances needed to calculate the line integral $$\psi$$ which defines the stress distribution (see image).
Illustration of the line integral

Definition at line 114 of file XYZ.cc.

115 {
116  return Vec3D::dot(c.getContactPoint() - p_, c.getNormal());
117 }
const Vec3D & getContactPoint() const
Gets constant reference to contact point (vector).
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:76
const Vec3D & getNormal() const
Gets the normal vector between the two interacting objects.
 Mdouble XYZ::getDistanceSquared ( const Vec3D & p ) const

Returns the square of the distance between the particle p and the current CGPoint, in the non-averaged directions.

This function is needed to evaluate the CGFunction, as this function has the distance between the CGPoint and the Particle as an argument. To properly account for the averaging, the distance is only computed in the non-averaged directions.

Parameters
 [in] p the position of a particle for which the distance is computed.

Definition at line 73 of file XYZ.cc.

References Vec3D::getLengthSquared(), and p_.

74 {
75  return Vec3D::getLengthSquared(p_ - p);
76 }
Mdouble getLengthSquared() const
Calculates the squared length of this Vec3D: .
Definition: Vector.cc:184
 Mdouble XYZ::getGaussIntegralPrefactor ( Mdouble distance, Mdouble width, Mdouble cutoff )
static

Computes the prefactor of the Gauss line integral, which is dependent on the number of non-averaged dimensions.

The prefactor of the Gauss line integral is set such that the integral over the non-averaged dimensions is unity.

Parameters
 [in] distance length of the branch vector along which the line integral is evaluated. [in] width width (equals the standard deviation in 1D) of the Gauss CGFunction. [in] cutoff cutoff of the Gauss CGFunction
Returns
the prefactor of the Gauss CGFunction.

Definition at line 157 of file XYZ.cc.

References mathsFunc::exp(), constants::sqrt_2, constants::sqrt_pi, and mathsFunc::square().

158 {
159  Mdouble widthSqrt2 = width * constants::sqrt_2;
160  Mdouble a = -cutoff;
161  Mdouble b = cutoff + distance;
162  //full 2D prefactor
163  Mdouble prefactor = 1.0 / (constants::sqrt_2 * constants::sqrt_pi * width);
164  prefactor = mathsFunc::square(prefactor) / (1.0 - exp(-0.5 * mathsFunc::square(cutoff / width)));
165  return prefactor * 0.5 / (
166  +erf(b / widthSqrt2) * b
167  + widthSqrt2 / constants::sqrt_pi * exp(-mathsFunc::square(b / widthSqrt2))
168  - erf(a / widthSqrt2) * a
169  - widthSqrt2 / constants::sqrt_pi * exp(-mathsFunc::square(a / widthSqrt2))
170  );
171 }
double Mdouble
Definition: GeneralDefine.h:34
Mdouble exp(Mdouble Exponent)
Definition: ExtendedMath.cc:84
const Mdouble sqrt_pi
Definition: ExtendedMath.h:46
const Mdouble sqrt_2
Definition: ExtendedMath.h:48
T square(const T val)
squares a number
Definition: ExtendedMath.h:104
 Mdouble XYZ::getGaussPrefactor ( Mdouble width, Mdouble cutoff )
static

Computes the prefactor of the Gauss CGFunction, which is dependent on the number of non-averaged dimensions.

The prefactor of the Gauss CGFunction is set such that the integral over the non-averaged dimensions is unity.

Parameters
 [in] width width (equals the standard deviation in 1D) of the Gauss CGFunction. [in] cutoff cutoff of the Gauss CGFunction
Returns
the prefactor of the Gauss CGFunction.

Definition at line 138 of file XYZ.cc.

139 {
140  //Wolfram alpha: erf(c/(sqrt(2) w))-(sqrt(2/pi) c e^(-c^2/(2 w^2)))/w
141  Mdouble prefactor = 1.0 / (constants::sqrt_2 * constants::sqrt_pi * width);
142  Mdouble cw = cutoff / width;
143  return mathsFunc::cubic(prefactor) / (
144  erf(cw / constants::sqrt_2)
146  );
147 }
double Mdouble
Definition: GeneralDefine.h:34
Mdouble exp(Mdouble Exponent)
Definition: ExtendedMath.cc:84
const Mdouble sqrt_pi
Definition: ExtendedMath.h:46
T cubic(const T val)
calculates the cube of a number
Definition: ExtendedMath.h:113
const Mdouble sqrt_2
Definition: ExtendedMath.h:48
T square(const T val)
squares a number
Definition: ExtendedMath.h:104
 Mdouble XYZ::getINormal ( const BaseInteraction & c, const Vec3D & normal ) const

For the Interaction between particles/walls P and I, this function returns the dot product between the normal vector of the interaction and the branch vector from the current CGPoint towards I.

Parameters
 [in] c the Interaction object from which iNormal is computed
Returns
iNormal, one of the three distances needed to calculate the line integral $$\psi$$ which defines the stress distribution (see image).
Illustration of the line integral

Definition at line 94 of file XYZ.cc.

95 {
96  return Vec3D::dot(c.getI()->getPosition() - p_, c.getNormal());
97 }
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
BaseInteractable * getI()
Returns a pointer to the second object involved in the interaction (often a wall or a particle)...
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:76
const Vec3D & getNormal() const
Gets the normal vector between the two interacting objects.
 Mdouble XYZ::getLength ( const Vec3D & p )
static

Returns the length of the input vector in the non-averaged directions.

Parameters
 [in] p vector whose length should be determined
Returns
length of the vector in the non-averaged directions
Todo:

Definition at line 83 of file XYZ.cc.

References Vec3D::X, Vec3D::Y, and Vec3D::Z.

84 {
85  return sqrt(p.X * p.X + p.Y * p.Y + p.Z * p.Z);
86 }
Mdouble X
the vector components
Definition: Vector.h:65
Mdouble Y
Definition: Vector.h:65
Mdouble Z
Definition: Vector.h:65
 std::string XYZ::getName ( )
static

Definition at line 195 of file XYZ.cc.

196 {
197  return "XYZ";
198 }
 Mdouble XYZ::getPNormal ( const BaseInteraction & c, const Vec3D & normal ) const

For the Interaction between particles/walls P and I, this function returns the dot product between the normal vector of the interaction and the branch vector from the current CGPoint towards P.

Parameters
 [in] c the Interaction object from which iNormal is computed
Returns
pNormal, one of the three distances needed to calculate the line integral $$\psi$$ which defines the stress distribution (see image).
Illustration of the line integral

Definition at line 104 of file XYZ.cc.

105 {
106  return Vec3D::dot(c.getP()->getPosition() - p_, c.getNormal());
107 }
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:76
const Vec3D & getNormal() const
Gets the normal vector between the two interacting objects.
BaseInteractable * getP()
Returns a pointer to first object involved in the interaction (normally a particle).
 Mdouble XYZ::getTangentialSquared ( const BaseInteraction & c, Mdouble pNormal ) const

For the Interaction between particles/walls P and I, this function returns the square of the minimum distance between the the current CGPoint and the branch vector between P and I.

Parameters
 [in] c the Interaction object from which iNormal is computed [in] pNormal the output of getPNormal needed for the computation.
Returns
iNormal, one of the three distances needed to calculate the line integral $$\psi$$ which defines the stress distribution (see image).
Illustration of the line integral

Definition at line 126 of file XYZ.cc.

127 {
128  return Vec3D::getLengthSquared(c.getP()->getPosition() - p_) - mathsFunc::square(pNormal);
129 }
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Mdouble getLengthSquared() const
Calculates the squared length of this Vec3D: .
Definition: Vector.cc:184
BaseInteractable * getP()
Returns a pointer to first object involved in the interaction (normally a particle).
T square(const T val)
squares a number
Definition: ExtendedMath.h:104
 Mdouble XYZ::getVolumeOfAveragedDimensions ( const Vec3D & min, const Vec3D & max )
static

returns the factor the CGFunction has to be divided by, due to integrating the variables over the averaged dimensions, 1.0 for XYZ.

If averaged dimensions are present (i.e. for all Coordinates except XYZ), the CGFunction has to be divided by a factor (here called volume) due to integrating the variables over the averaged dimensions.

Parameters
 [in] min the lower limits of the mesh domain (xMin, yMin, zMin) [in] max the upper limits of the mesh domain (xMax, yMax, zMax)
Returns
the volume factor

Definition at line 53 of file XYZ.cc.

54 {
55  return 1.0;
56 }
 static bool CGCoordinates::XYZ::isResolvedIn ( unsigned i )
inlinestatic

Definition at line 162 of file XYZ.h.

162 {return true;}
 void XYZ::normalisePolynomialCoefficients ( std::vector< Mdouble > & coefficients, Mdouble cutoff )
static

Normalises the coefficients of Polynomial CGFunction such that the integral over all non-averaged dimensions is unity.

The volume is computed as

$volume= \int_0^1\sum_{i=1}^n c_i r/c^i 4 pi r^2 dr = 4 pi \sum_{i=1}^n c_i/(i+3)$

with 4 pi r^2 the surface area of a sphere.

Parameters
 [in,out] coefficients the coefficients of Polynomial CGFunctions. [in] cutoff cutoff of the Gauss CGFunction

Definition at line 180 of file XYZ.cc.

References mathsFunc::cubic(), constants::i, and constants::pi.

181 {
182  Mdouble volume = 0.0;
183  for (std::size_t i = 0; i < coefficients.size(); i++)
184  volume += coefficients[i] / static_cast<Mdouble>(i + 3);
185  volume *= 4.0 * constants::pi * mathsFunc::cubic(cutoff);
186  for (double& coefficient : coefficients)
187  coefficient /= volume;
188 }
double Mdouble
Definition: GeneralDefine.h:34
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
T cubic(const T val)
calculates the cube of a number
Definition: ExtendedMath.h:113
const Mdouble pi
Definition: ExtendedMath.h:45
 void XYZ::setXYZ ( Vec3D p )

Returns the position of the current CGPoint, in the non-averaged directions.

Parameters
 [in] p the position that is to be set.

Definition at line 61 of file XYZ.cc.

References p_.

62 {
63  p_ = p;
64 }
 void XYZ::write ( std::ostream & os ) const

Writes the coordinates in human-readable form to an ostream.

Parameters
 [out] os the ostream file to which the position is written

Definition at line 40 of file XYZ.cc.

References p_.

41 {
42  os << p_ << ' ';
43 }
 void XYZ::writeNames ( std::ostream & os )
static

Writes the coordinate names in human-readable form to an ostream.

Definition at line 32 of file XYZ.cc.

33 {
34  os << "x y z ";
35 }

## Member Data Documentation

 Vec3D CGCoordinates::XYZ::p_
protected

The position of the current CGPoint.

Definition at line 171 of file XYZ.h.

Referenced by getDistanceSquared(), getINormal(), getTangentialSquared(), setXYZ(), and write().

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