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?
15 {
16  helpers::writeToFile("1Particle4WallsRestartUnitTest.ini",
17  "1 0 0 0 0 .96 1 .96\n"
18  "0.48 0 0.48 0 0 0 0.5 0 0 0 0 0 0 0\n"
19  );
20 
21  helpers::writeToFile("1Particle4WallsRestartUnitTest.restart",
22  "restart_version 1.0 name 1Particle4WallsRestart\n"
23  "dataFile name 1Particle4WallsRestart.data fileType ONE_FILE saveCount 5 counter 0 nextSavedTimeStep 0\n"
24  "fStatFile name 1Particle4WallsRestart.fstat fileType ONE_FILE saveCount 5 counter 0 nextSavedTimeStep 0\n"
25  "eneFile name 1Particle4WallsRestart.ene fileType ONE_FILE saveCount 5 counter 0 nextSavedTimeStep 0\n"
26  "restartFile name 1Particle4WallsRestart.restart fileType ONE_FILE saveCount 5 counter 0 nextSavedTimeStep 0\n"
27  "statFile name 1Particle4WallsRestart.stat fileType ONE_FILE saveCount 5 counter 0 nextSavedTimeStep 0\n"
28  "interactionFile name 1Particle4WallsRestart.interaction fileType ONE_FILE saveCount 5 counter 0 nextSavedTimeStep 0\n"
29  "xMin 0 xMax 1 yMin 0 yMax 1 zMin 0 zMax 1\n"
30  "timeStep 1e-04 time 0 ntimeSteps 0 timeMax 0.01\n"
31  "systemDimensions 3 particleDimensions 3 gravity 0 0 0\n"
32  "Species 1\n"
33  "LinearViscoelasticSlidingFrictionSpecies id 0 density 1.9098593 stiffness 200000 dissipation 0 slidingStiffness 57142.857 slidingDissipation 0 frictionCoefficient 0.5 frictionCoefficientStatic 0.5\n"
34  "Walls 4\n"
35  "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"
36  "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"
37  "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"
38  "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"
39  "Boundaries 0\n"
40  "Particles 1\n"
41  "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"
42  "Interactions 4\n"
43  "LinearViscoelasticSlidingFrictionInteraction particleWallIds 0 0 timeStamp 0 force 0 0 0 torque 0 0 0 slidingSpring 0 0 0\n"
44  "LinearViscoelasticSlidingFrictionInteraction particleWallIds 0 1 timeStamp 0 force 0 0 0 torque 0 0 0 slidingSpring 0 0 0\n"
45  "LinearViscoelasticSlidingFrictionInteraction particleWallIds 0 2 timeStamp 0 force 0 0 0 torque 0 0 0 slidingSpring 0 0 0\n"
46  "LinearViscoelasticSlidingFrictionInteraction particleWallIds 0 3 timeStamp 0 force 0 0 0 torque 0 0 0 slidingSpring 0 0 0\n"
47  );
48 
50  problem.setName("1Particle4WallsRestartUnitTest");
51  problem.readRestartFile();
52  //problem.readDataFile("1Particle4WallsRestartUnitTest.ini");
53  problem.setAppend(false);
54  //problem.write(std::cout,true);
55  problem.solve();
56  //problem.write(std::cout,true);
57  problem.writeRestartFile();
58 
59  Mdouble expectedAngularVelocity = 21.2838972413563;
60  BaseParticle* p = problem.particleHandler.getObject(0);
61  if (!p->getAngularVelocity().isEqualTo(Vec3D(0.0, expectedAngularVelocity, 0.0), 1e-7))
62  logger(FATAL, "First particles has the wrong angular velocity it is %, while is should be %.",
63  p->getAngularVelocity(), Vec3D(0.0, expectedAngularVelocity, 0.0));
64  if (!p->getVelocity().isEqualTo(Vec3D(0.0, 0.0, 0.0), 1e-7))
65  logger(FATAL, "First particle has the wrong velocity, it is %, while it should be %", p->getVelocity(), 0.0);
66 
67  //Now check the rotational energy in the system; it should loose some rotational energy in the first loop due to
68  //sliding, then conserve energy as no tangential dissipation is used.
69  //gnuplot:
70  // 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'
72 }
Array< double, 1, 3 > e(1./3., 0.5, 2.)
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:31
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
float * p
Definition: Tutorial_Map_using.cpp:9
Definition: BaseParticle.h:33
The DPMBase header includes quite a few header files, defining all the handlers, which are essential....
Definition: DPMBase.h:56
Definition: Kernel/Math/Vector.h:30
bool writeToFile(const std::string &filename, const std::string &filecontent)
Writes a string to a file.
Definition: FileIOHelpers.cc:29
Constructor for SteadyAxisymAdvectionDiffusion problem
Definition: steady_axisym_advection_diffusion.cc:213

References e(), FATAL, logger, p, problem, and helpers::writeToFile().