CGParticleWallUnitTest.cpp File Reference

Classes

class  ParticleWall
 

Functions

int main ()
 

Function Documentation

◆ main()

int main ( )
Todo:
TW should there be a discrepancy between distance and distance2?
35 {
36  logger(INFO," Simulates a particle-wall collision.\n"
37  " Checks cg \n"
38  " - at one instant in time\n"
39  " - standard fields (density and stress)\n"
40  " - for O, Z, and XYZ coordinates\n"
41  " - for both Gauss and Lucy kernel functions\n");
42 
43  ParticleWall dpm;
44  dpm.setName("CGParticleWallUnitTest");
45  dpm.setTimeStep(1e-4);
46  dpm.setTimeMax(0);
48 
49  //Define coarse graining objects
50  Mdouble width = 0.075;
51 
52  //Unresolved
54 
55  //Resolved in z, at particle center
56  auto Z = dpm.cgHandler.copyAndAddObject(CG<CGCoordinates::Z>(width,1));
57  Z->setMin({-1,-1,0.95});
58  Z->setMax({1,1,0.95});
59 
60  //Resolved in z with Gauss cg function
62  G->setMin({-1,-1,0.95});
63  G->setMax({1,1,0.95});
64 
65  //Resolved in z, on contact line
66  auto C = dpm.cgHandler.copyAndAddObject(CG<CGCoordinates::Z>(width,1));
67  C->setMin({-1,-1,0.25});
68  C->setMax({1,1,0.25});
69 
70  //Resolved in xyz, at particle center
72  XYZ->setMin({-0.95,-1,0.95});
73  XYZ->setMax({1.05,1,0.95});
74 
75  dpm.solve();
76 
77  //A few checks
78  logger(INFO,"Checking a few cg parameters");
79 
80  //Checks if the unresolved cg returns the right value for stress, sigma_zz = f_12*r_12/V
81  Vec3D contactPoint = dpm.interactionHandler.getObject(0)->getContactPoint();
82  Mdouble overlap = dpm.interactionHandler.getObject(0)->getOverlap();
83  Mdouble distance = dpm.interactionHandler.getObject(0)->getDistance();
84  Mdouble distance2 = Vec3D::getDistance(contactPoint,dpm.particleHandler.getObject(0)->getPosition());
85  Mdouble distance3 = distance+0.5*overlap;
86  logger(INFO,"Distance % % % Overlap % Contact % Distance %",distance,distance2,distance3,overlap,contactPoint);
87  helpers::check(O->getPoint(0).getContactStress().trace(),2e5*overlap*distance2/16,1e-11, "Average stress");
89 
90  //Checks if z-resolved cg returns the right value for stress at the center of the contact,
91  //sigma_zz = f_12*r_12/r_12z/A, assuming the cutoff is smaller than the branch vector
92  Mdouble distanceZ = dpm.particleHandler.getObject(0)->getPosition().Z;
93  helpers::check(C->getPoint(0).getContactStress().trace(),2e5*overlap*distance/distanceZ/4,1e-11, "Z-resolved stress at contact point");
94 
95 
96  return 0;
97 }
Array< double, 1, 3 > e(1./3., 0.5, 2.)
@ NO_FILE
file will not be created/read
JacobiRotation< float > G
Definition: Jacobi_makeGivens.cpp:2
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
@ XYZ
Definition: StatisticsVector.h:21
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:360
T * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:621
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Definition: BaseInteractable.h:197
const Vec3D & getContactPoint() const
Gets constant reference to contact point (vector).
Definition: BaseInteraction.h:213
Mdouble getDistance() const
Returns an Mdouble which is the norm (length) of distance vector.
Definition: BaseInteraction.cc:520
Mdouble getOverlap() const
Returns a Mdouble with the current overlap between the two interacting objects.
Definition: BaseInteraction.h:219
Evaluates time-resolved continuum fields and writes the data into a stat file.
Definition: CG.h:55
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:400
void setFileType(FileType fileType)
Sets File::fileType_ for all files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:437
CGHandler cgHandler
Object of the class cgHandler.
Definition: DPMBase.h:1479
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1473
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created.
Definition: DPMBase.h:1443
void setTimeStep(Mdouble newDt)
Sets a new value for the simulation time step.
Definition: DPMBase.cc:1225
void setTimeMax(Mdouble newTMax)
Sets a new value for the maximum simulation duration.
Definition: DPMBase.cc:864
void solve()
The work horse of the code.
Definition: DPMBase.cc:4334
Definition: CGParticleWallUnitTest.cpp:12
Definition: Kernel/Math/Vector.h:30
static Mdouble getDistance(const Vec3D &a, const Vec3D &b)
Calculates the distance between two Vec3D: .
Definition: Vector.cc:155
Mdouble Z
Definition: Kernel/Math/Vector.h:45
Definition: matrices.h:74
#define Z
Definition: icosphere.cpp:21
#define INFO(i)
Definition: mumps_solver.h:54
void check(double real, double ideal, double error, std::string errorMessage)
Definition: TestHelpers.cc:16

References DPMBase::cgHandler, helpers::check(), BaseHandler< T >::copyAndAddObject(), e(), G, BaseInteraction::getContactPoint(), BaseInteraction::getDistance(), Vec3D::getDistance(), BaseHandler< T >::getObject(), BaseInteraction::getOverlap(), BaseInteractable::getPosition(), INFO, DPMBase::interactionHandler, logger, NO_FILE, DPMBase::particleHandler, DPMBase::setFileType(), DPMBase::setName(), DPMBase::setTimeMax(), DPMBase::setTimeStep(), DPMBase::solve(), XYZ, Z, and Vec3D::Z.