MercuryDPM  0.11
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
1Particle4WallsRestartUnitTest.cpp File Reference
#include <Logger.h>
#include "DPMBase.h"
#include "Math/Helpers.h"

Go to the source code of this file.

Functions

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". More...
 

Function Documentation

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.

Definition at line 35 of file 1Particle4WallsRestartUnitTest.cpp.

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

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 1Particle4WallsRestartUnitTest_restart\n"
44  "dataFile name 1Particle4WallsRestartUnitTest_restart.data fileType ONE_FILE saveCount 5 counter 0 nextSavedTimeStep 0\n"
45  "fStatFile name 1Particle4WallsRestartUnitTest_restart.fstat fileType ONE_FILE saveCount 5 counter 0 nextSavedTimeStep 0\n"
46  "eneFile name 1Particle4WallsRestartUnitTest_restart.ene fileType ONE_FILE saveCount 5 counter 0 nextSavedTimeStep 0\n"
47  "restartFile name 1Particle4WallsRestartUnitTest_restart.restart fileType ONE_FILE saveCount 5 counter 0 nextSavedTimeStep 0\n"
48  "statFile name 1Particle4WallsRestartUnitTest_restart.stat fileType ONE_FILE saveCount 5 counter 0 nextSavedTimeStep 0\n"
49  "xMin 0 xMax 1 yMin 0 yMax 1 zMin 0 zMax 1\n"
50  "timeStep 1e-04 time 0 ntimeSteps 0 timeMax 0.01\n"
51  "systemDimensions 3 particleDimensions 3 gravity 0 0 0\n"
52  "Species 1\n"
53  "LinearViscoelasticSlidingFrictionSpecies id 0 density 1.9098593 stiffness 200000 dissipation 0 slidingStiffness 57142.857 slidingDissipation 0 frictionCoefficient 0.5 frictionCoefficientStatic 0.5\n"
54  "Walls 4\n"
55  "InfiniteWall id 0 indSpecies 0 position 0 0 0 orientation 0 0 0 1 velocity 0 0 0 angularVelocity 0 0 0 0 force 0 0 0 torque 0 0 0 normal -1 0 0 factor 1\n"
56  "InfiniteWall id 1 indSpecies 0 position 0.96 0 0 orientation 0 0 0 1 velocity 0 0 0 angularVelocity 0 0 0 0 force 0 0 0 torque 0 0 0 normal 1 0 0 factor 1\n"
57  "InfiniteWall id 2 indSpecies 0 position 0 0 0 orientation 0 0 0 1 velocity 0 0 0 angularVelocity 0 0 0 0 force 0 0 0 torque 0 0 0 normal 0 0 -1 factor 1\n"
58  "InfiniteWall id 3 indSpecies 0 position 0 0 0.96 orientation 0 0 0 1 velocity 0 0 0 angularVelocity 0 0 0 0 force 0 0 0 torque 0 0 0 normal 0 0 1 factor 1\n"
59  "Boundaries 0\n"
60  "Particles 1\n"
61  "BaseParticle id 0 indSpecies 0 position 0.48 0 0.48 orientation 0 0 0 1 velocity 0 0 0 angularVelocity 0 60 0 0 force 0 0 0 torque 0 0 0 radius 0.5 invMass 1 invInertia 10\n"
62  "Interactions 4\n"
63  "LinearViscoelasticSlidingFrictionInteraction particleWallIds 0 0 timeStamp 0 force 0 0 0 torque 0 0 0 slidingSpring 0 0 0\n"
64  "LinearViscoelasticSlidingFrictionInteraction particleWallIds 0 1 timeStamp 0 force 0 0 0 torque 0 0 0 slidingSpring 0 0 0\n"
65  "LinearViscoelasticSlidingFrictionInteraction particleWallIds 0 2 timeStamp 0 force 0 0 0 torque 0 0 0 slidingSpring 0 0 0\n"
66  "LinearViscoelasticSlidingFrictionInteraction particleWallIds 0 3 timeStamp 0 force 0 0 0 torque 0 0 0 slidingSpring 0 0 0\n"
67  );
68 
69  DPMBase problem;
70  problem.setName("1Particle4WallsRestartUnitTest");
71  problem.readRestartFile();
72  //problem.readDataFile("1Particle4WallsRestartUnitTest.ini");
73  problem.setAppend(false);
74  //problem.write(std::cout,true);
75  problem.solve();
76  //problem.write(std::cout,true);
77  problem.writeRestartFile();
78 
79  BaseParticle* p = problem.particleHandler.getObject(0);
80  if (!p->getAngularVelocity().isEqualTo(Vec3D(0.0,17.7251802668803,0.0), 1e-7)) logger(FATAL, "First particles has the wrong angular velocity it is %, while is should be %.",p->getAngularVelocity(),Vec3D(0.0,17.7251802668803,0.0));
81  if (!p->getVelocity().isEqualTo(Vec3D(0.0,0.0,0.0) , 1e-7)) logger(FATAL, "First particle has the wrong velocity, it is %, while it should be %",p->getVelocity(),0.0);
82 
83  //Now check the rotational energy in the system; it should loose some rotational energy in the first loop due to
84  //sliding, then conserve energy as no tangential dissipation is used.
85  //gnuplot:
86  // p '1Particle4WallsRestartUnitTest_restart.ene' u 1:4 w l t 'rotational energy', '1Particle4WallsRestartUnitTest_restart.ene' u 1:($3+$4+$5-160) w l t 'total energy - normal elastic energy'
87 
88 }
bool writeToFile(std::string filename, std::string filecontent)
Writes a string to a file.
Definition: Helpers.cc:411
void solve()
The work horse of the code.
Definition: DPMBase.cc:1895
The DPMBase header includes quite a few header files, defining all the handlers, which are essential...
Definition: DPMBase.h:61
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
virtual const Vec3D & getAngularVelocity() const
Returns the angular velocity of this interactable.
void setAppend(bool newAppendFlag)
Allows to set the append option.
Definition: DPMBase.cc:544
bool isEqualTo(const Vec3D &other, const double tol) const
Checks if the length this Vec3D is equal the length of other with a certain tolerance.
Definition: Vector.cc:390
int readRestartFile()
Reads all the particle data corresponding to the current saved time step. Which is what the restart f...
Definition: DPMBase.cc:1375
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: Files.cc:149
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:878
T * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:415
LL< Log::FATAL > FATAL
Fatal log level.
Definition: Logger.cc:25
virtual void writeRestartFile()
Stores all the particle data for current save time step. Calls the write function.
Definition: DPMBase.cc:1365
virtual const Vec3D & getVelocity() const
Returns the velocity of this interactable.
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45