1Particle4WallsRestartUnitTest.cpp File Reference
#include <Logger.h>
#include "DPMBase.h"
#include "Math/Helpers.h"

Functions

int main (int argc UNUSED, char *argv[] UNUSED)
 

Function Documentation

◆ main()

int main ( int argc  UNUSED,
char *argv[]  UNUSED 
)

In this file, 1 Particle and 4 Walls are loaded from files "1Particle4Walls.ini" and "1Particle4Walls.restart". The particles are aligned such that the single nonfixed particle rotates sinusoidally without moving. This is to test the behaviour of the tangential spring and the file loading routines.

Todo:
should inertia and mass be outputted by restart, since these are computed variables?
36 {
37  helpers::writeToFile("1Particle4WallsRestartUnitTest.ini",
38  "1 0 0 0 0 .96 1 .96\n"
39  "0.48 0 0.48 0 0 0 0.5 0 0 0 0 0 0 0\n"
40  );
41 
42  helpers::writeToFile("1Particle4WallsRestartUnitTest.restart",
43  "restart_version 1.0 name 1Particle4WallsRestart\n"
44  "dataFile name 1Particle4WallsRestart.data fileType ONE_FILE saveCount 5 counter 0 nextSavedTimeStep 0\n"
45  "fStatFile name 1Particle4WallsRestart.fstat fileType ONE_FILE saveCount 5 counter 0 nextSavedTimeStep 0\n"
46  "eneFile name 1Particle4WallsRestart.ene fileType ONE_FILE saveCount 5 counter 0 nextSavedTimeStep 0\n"
47  "restartFile name 1Particle4WallsRestart.restart fileType ONE_FILE saveCount 5 counter 0 nextSavedTimeStep 0\n"
48  "statFile name 1Particle4WallsRestart.stat fileType ONE_FILE saveCount 5 counter 0 nextSavedTimeStep 0\n"
49  "interactionFile name 1Particle4WallsRestart.interaction fileType ONE_FILE saveCount 5 counter 0 nextSavedTimeStep 0\n"
50  "xMin 0 xMax 1 yMin 0 yMax 1 zMin 0 zMax 1\n"
51  "timeStep 1e-04 time 0 ntimeSteps 0 timeMax 0.01\n"
52  "systemDimensions 3 particleDimensions 3 gravity 0 0 0\n"
53  "Species 1\n"
54  "LinearViscoelasticSlidingFrictionSpecies id 0 density 1.9098593 stiffness 200000 dissipation 0 slidingStiffness 57142.857 slidingDissipation 0 frictionCoefficient 0.5 frictionCoefficientStatic 0.5\n"
55  "Walls 4\n"
56  "InfiniteWall id 0 indSpecies 0 position 0 0 0 orientation 1 0 0 0 velocity 0 0 0 angularVelocity 0 0 0 force 0 0 0 torque 0 0 0 normal -1 0 0 factor 1\n"
57  "InfiniteWall id 1 indSpecies 0 position 0.96 0 0 orientation 1 0 0 0 velocity 0 0 0 angularVelocity 0 0 0 force 0 0 0 torque 0 0 0 normal 1 0 0 factor 1\n"
58  "InfiniteWall id 2 indSpecies 0 position 0 0 0 orientation 1 0 0 0 velocity 0 0 0 angularVelocity 0 0 0 force 0 0 0 torque 0 0 0 normal 0 0 -1 factor 1\n"
59  "InfiniteWall id 3 indSpecies 0 position 0 0 0.96 orientation 1 0 0 0 velocity 0 0 0 angularVelocity 0 0 0 force 0 0 0 torque 0 0 0 normal 0 0 1 factor 1\n"
60  "Boundaries 0\n"
61  "Particles 1\n"
62  "BaseParticle id 0 indSpecies 0 position 0.48 0 0.48 orientation 1 0 0 0 velocity 0 0 0 angularVelocity 0 60 0 force 0 0 0 torque 0 0 0 radius 0.5 invMass 1 invInertia 10\n"
63  "Interactions 4\n"
64  "LinearViscoelasticSlidingFrictionInteraction particleWallIds 0 0 timeStamp 0 force 0 0 0 torque 0 0 0 slidingSpring 0 0 0\n"
65  "LinearViscoelasticSlidingFrictionInteraction particleWallIds 0 1 timeStamp 0 force 0 0 0 torque 0 0 0 slidingSpring 0 0 0\n"
66  "LinearViscoelasticSlidingFrictionInteraction particleWallIds 0 2 timeStamp 0 force 0 0 0 torque 0 0 0 slidingSpring 0 0 0\n"
67  "LinearViscoelasticSlidingFrictionInteraction particleWallIds 0 3 timeStamp 0 force 0 0 0 torque 0 0 0 slidingSpring 0 0 0\n"
68  );
69 
70  DPMBase problem;
71  problem.setName("1Particle4WallsRestartUnitTest");
72  problem.readRestartFile();
73  //problem.readDataFile("1Particle4WallsRestartUnitTest.ini");
74  problem.setAppend(false);
75  //problem.write(std::cout,true);
76  problem.solve();
77  //problem.write(std::cout,true);
78  problem.writeRestartFile();
79 
80  BaseParticle* p = problem.particleHandler.getObject(0);
81  if (!p->getAngularVelocity().isEqualTo(Vec3D(0.0, 17.7251802668803, 0.0), 1e-7))
82  logger(FATAL, "First particles has the wrong angular velocity it is %, while is should be %.",
83  p->getAngularVelocity(), Vec3D(0.0, 17.7251802668803, 0.0));
84  if (!p->getVelocity().isEqualTo(Vec3D(0.0, 0.0, 0.0), 1e-7))
85  logger(FATAL, "First particle has the wrong velocity, it is %, while it should be %", p->getVelocity(), 0.0);
86 
87  //Now check the rotational energy in the system; it should loose some rotational energy in the first loop due to
88  //sliding, then conserve energy as no tangential dissipation is used.
89  //gnuplot:
90  // p '1Particle4WallsRestart.ene' u 1:4 w l t 'rotational energy', '1Particle4WallsRestart.ene' u 1:($3+$4+$5-160) w l t 'total energy - normal elastic energy'
92 }
LL< Log::FATAL > FATAL
Definition of the different loglevels by its wrapper class LL. These are used as tags in template met...
Definition: Logger.cc:52
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
T * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:613
virtual const Vec3D & getAngularVelocity() const
Returns the angular velocity of this interactable.
Definition: BaseInteractable.cc:341
virtual const Vec3D & getVelocity() const
Returns the velocity of this interactable.
Definition: BaseInteractable.cc:329
Definition: BaseParticle.h:54
The DPMBase header includes quite a few header files, defining all the handlers, which are essential....
Definition: DPMBase.h:77
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:422
virtual void writeRestartFile()
Stores all the particle data for current save time step to a "restart" file, which is a file simply i...
Definition: DPMBase.cc:2942
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created.
Definition: DPMBase.h:1437
void solve()
The work horse of the code.
Definition: DPMBase.cc:4270
void setAppend(bool newAppendFlag)
Sets whether the "append" option is on or off.
Definition: DPMBase.cc:1522
bool readRestartFile(ReadOptions opt=ReadOptions::ReadAll)
Reads all the particle data corresponding to a given, existing . restart file (for more details regar...
Definition: DPMBase.cc:3006
Definition: Vector.h:51
bool isEqualTo(const Vec3D &other, double tol) const
Checks if the length this Vec3D is equal the length of other with a certain tolerance.
Definition: Vector.cc:294
bool writeToFile(std::string filename, std::string filecontent)
Writes a string to a file.
Definition: FileIOHelpers.cc:58

References FATAL, BaseInteractable::getAngularVelocity(), BaseHandler< T >::getObject(), BaseInteractable::getVelocity(), Vec3D::isEqualTo(), logger, DPMBase::particleHandler, DPMBase::readRestartFile(), DPMBase::setAppend(), DPMBase::setName(), DPMBase::solve(), DPMBase::writeRestartFile(), and helpers::writeToFile().