CGParticleParticleUnitTest.cpp File Reference

Classes

class  TwoParticles
 

Functions

int main ()
 

Function Documentation

◆ main()

int main ( )
55 {
56  logger(INFO," Simulates a particle-particle collision.\n"
57  " Checks cg \n"
58  " - at one instant in time\n"
59  " - standard fields (density and stress)\n"
60  " - for O, Z, and XYZ coordinates\n"
61  " - for both Gauss and Lucy kernel functions\n");
62 
63  TwoParticles dpm;
64  dpm.setName("CGParticleParticleUnitTest");
65  dpm.setTimeStep(1e-4);
66  dpm.setTimeMax(0);
68 
69  //Define coarse graining objects
70  Mdouble width = 0.15;
71 
72  //Unresolved
74 
75  //Resolved in z at particle centre
76  auto Z = dpm.cgHandler.copyAndAddObject(CG<CGCoordinates::Z>(width,1));
77  Z->setMin({-1,-1,0.95});
78  Z->setMax({1,1,0.95});
79 
80  //Resolved in z at particle centre with Gauss cg function
82  G->setMin({-1,-1,0.95});
83  G->setMax({1,1,0.95});
84 
85  //Resolved in z, at particle-particle contact
86  auto C = dpm.cgHandler.copyAndAddObject(CG<CGCoordinates::Z>(width,1));
87 
88  //Resolved in xyz at particle centre
90  XYZ->setMin({-0.95,-1,0.95});
91  XYZ->setMax({1.05,1,0.95});
92 
93  //Resolved in xz, at particle-particle contact
96  auto cg = dpm.cgHandler.copyAndAddObject(CG<CGCoordinates::XY>(3*width,50));
97 
98  dpm.solve();
99 
100  //A few checks
101  logger(INFO,"Checking a few cg parameters");
102 
103  //Checks density for unresolved cg, rho = M/V = 2/16 = 0.125
104  helpers::check(O->getPoint(0).getDensity(),0.125,1e-15, "Average density");
105 
106  //Checks density at the center of one particle for z-resolved cg, rho = m_2*phi_2(0),
107  //assuming the distance between the particles is bigger than the cutoff
108  Mdouble phiL0 = 1.25 / width; //peak value of Lucy
109  helpers::check(Z->getPoint(0).getDensity(),phiL0/4.0,1e-15, "Z-resolved density at particle centre");
110 
111  //Check the same for a Gauss cg function
112  Mdouble phiG0 = 1.0 / (sqrt_2 * sqrt_pi * erf(3.0/sqrt_2))/width; //peak value of Gaussian cutoff at 3*width
113  helpers::check(G->getPoint(0).getDensity(),phiG0/4.0,1e-15, "Z-resolved density for Gaussian CG");
114 
115  //Check the same for fully-resolved cg
116  Mdouble phi30 = 105.0/16.0/pi / mathsFunc::cubic(width); //peak value of Lucy in 3D
117  helpers::check(XYZ->getPoint(0).getDensity(),phi30,1e-11, "Fully-resolved density at particle centre");
118 
119 
120  //Checks if the unresolved cg returns the right value for stress, sigma_zz = f_12*r_12/V
122  Mdouble overlap = 2.0-distance;
123  helpers::check(O->getPoint(0).getContactStress().trace(),2e5*overlap*distance/16,1e-11, "Average stress");
124 
125  //Checks if z-resolved cg returns the right value for stress at the center of the contact,
126  //sigma_zz = f_12*r_12/r_12z/A, assuming the cutoff is smaller than the branch vector
128  helpers::check(C->getPoint(0).getContactStress().trace(),2e5*overlap*distance/distanceZ/4,1e-11, "Z-resolved stress at contact point");
129 
130  return 0;
131 }
@ NO_FILE
file will not be created/read
LL< Log::INFO > INFO
Info log level.
Definition: Logger.cc:55
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
@ Z
Definition: StatisticsVector.h:42
@ XYZ
Definition: StatisticsVector.h:42
std::enable_if<!std::is_pointer< U >::value, U * >::type copyAndAddObject(const U &object)
Creates a copy of a Object and adds it to the BaseHandler.
Definition: BaseHandler.h:379
T * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:613
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Definition: BaseInteractable.h:218
Evaluates time-resolved continuum fields and writes the data into a stat file.
Definition: CG.h:76
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:422
void setFileType(FileType fileType)
Sets File::fileType_ for all files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:459
CGHandler cgHandler
Object of the class cgHandler.
Definition: DPMBase.h:1473
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created.
Definition: DPMBase.h:1437
void setTimeStep(Mdouble newDt)
Sets a new value for the simulation time step.
Definition: DPMBase.cc:1234
void setTimeMax(Mdouble newTMax)
Sets a new value for the maximum simulation duration.
Definition: DPMBase.cc:873
void solve()
The work horse of the code.
Definition: DPMBase.cc:4270
Definition: CGLiquidsUnitTest.cpp:35
static Mdouble getDistance(const Vec3D &a, const Vec3D &b)
Calculates the distance between two Vec3D: .
Definition: Vector.cc:175
Mdouble Z
Definition: Vector.h:66
const Mdouble pi
Definition: ExtendedMath.h:45
const Mdouble sqrt_pi
Definition: ExtendedMath.h:46
const Mdouble sqrt_2
Definition: ExtendedMath.h:48
void check(double real, double ideal, double error, std::string errorMessage)
Definition: TestHelpers.cc:37
T cubic(const T val)
calculates the cube of a number
Definition: ExtendedMath.h:115

References DPMBase::cgHandler, helpers::check(), BaseHandler< T >::copyAndAddObject(), mathsFunc::cubic(), Vec3D::getDistance(), BaseHandler< T >::getObject(), BaseInteractable::getPosition(), INFO, logger, NO_FILE, DPMBase::particleHandler, constants::pi, DPMBase::setFileType(), DPMBase::setName(), DPMBase::setTimeMax(), DPMBase::setTimeStep(), DPMBase::solve(), constants::sqrt_2, constants::sqrt_pi, XYZ, Vec3D::Z, and Z.