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?
56 {
57  logger(INFO," Simulates a particle-wall collision.\n"
58  " Checks cg \n"
59  " - at one instant in time\n"
60  " - standard fields (density and stress)\n"
61  " - for O, Z, and XYZ coordinates\n"
62  " - for both Gauss and Lucy kernel functions\n");
63 
64  ParticleWall dpm;
65  dpm.setName("CGParticleWallUnitTest");
66  dpm.setTimeStep(1e-4);
67  dpm.setTimeMax(0);
69 
70  //Define coarse graining objects
71  Mdouble width = 0.075;
72 
73  //Unresolved
75 
76  //Resolved in z, at particle center
77  auto Z = dpm.cgHandler.copyAndAddObject(CG<CGCoordinates::Z>(width,1));
78  Z->setMin({-1,-1,0.95});
79  Z->setMax({1,1,0.95});
80 
81  //Resolved in z with Gauss cg function
83  G->setMin({-1,-1,0.95});
84  G->setMax({1,1,0.95});
85 
86  //Resolved in z, on contact line
87  auto C = dpm.cgHandler.copyAndAddObject(CG<CGCoordinates::Z>(width,1));
88  C->setMin({-1,-1,0.25});
89  C->setMax({1,1,0.25});
90 
91  //Resolved in xyz, at particle center
93  XYZ->setMin({-0.95,-1,0.95});
94  XYZ->setMax({1.05,1,0.95});
95 
96  dpm.solve();
97 
98  //A few checks
99  logger(INFO,"Checking a few cg parameters");
100 
101  //Checks if the unresolved cg returns the right value for stress, sigma_zz = f_12*r_12/V
102  Vec3D contactPoint = dpm.interactionHandler.getObject(0)->getContactPoint();
103  Mdouble overlap = dpm.interactionHandler.getObject(0)->getOverlap();
104  Mdouble distance = dpm.interactionHandler.getObject(0)->getDistance();
105  Mdouble distance2 = Vec3D::getDistance(contactPoint,dpm.particleHandler.getObject(0)->getPosition());
106  Mdouble distance3 = distance+0.5*overlap;
107  logger(INFO,"Distance % % % Overlap % Contact % Distance %",distance,distance2,distance3,overlap,contactPoint);
108  helpers::check(O->getPoint(0).getContactStress().trace(),2e5*overlap*distance2/16,1e-11, "Average stress");
110 
111  //Checks if z-resolved cg returns the right value for stress at the center of the contact,
112  //sigma_zz = f_12*r_12/r_12z/A, assuming the cutoff is smaller than the branch vector
113  Mdouble distanceZ = dpm.particleHandler.getObject(0)->getPosition().Z;
114  helpers::check(C->getPoint(0).getContactStress().trace(),2e5*overlap*distance/distanceZ/4,1e-11, "Z-resolved stress at contact point");
115 
116 
117  return 0;
118 }
@ 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
const Vec3D & getContactPoint() const
Gets constant reference to contact point (vector).
Definition: BaseInteraction.h:234
Mdouble getDistance() const
Returns an Mdouble which is the norm (length) of distance vector.
Definition: BaseInteraction.cc:539
Mdouble getOverlap() const
Returns a Mdouble with the current overlap between the two interacting objects.
Definition: BaseInteraction.h:240
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
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1467
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: CGParticleWallUnitTest.cpp:33
Definition: Vector.h:51
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
void check(double real, double ideal, double error, std::string errorMessage)
Definition: TestHelpers.cc:37

References DPMBase::cgHandler, helpers::check(), BaseHandler< T >::copyAndAddObject(), 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, Vec3D::Z, and Z.