TangentialSpringUnitTest.cpp File Reference
#include <iostream>
#include "Species/LinearViscoelasticSlidingFrictionSpecies.h"
#include "DPMBase.h"
#include "Logger.h"

Classes

class  TangentialSpringUnitTest
 

Functions

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

Function Documentation

◆ main()

int main ( int argc  ,
char argv[] 
)
45 {
46  TangentialSpringUnitTest tangentialSpringUnitTestProblem;
47  tangentialSpringUnitTestProblem.setName("TangentialSpringUnitTest");
48 
49  //set the species properties, with a very large sliding friction coefficient
50  auto species = tangentialSpringUnitTestProblem.speciesHandler.copyAndAddObject(
52  species->setDensity(6. / constants::pi);
53  species->setCollisionTimeAndRestitutionCoefficient(1e-3, .2, 1. / 8);
54  species->setSlidingStiffness(species->getStiffness() * 2 / 7);
55  species->setSlidingFrictionCoefficient(1e20);
56 
57  //set simulation-parameters: time, time step, gravity, output-file properties
58  tangentialSpringUnitTestProblem.setTimeStep(2e-5);
59  tangentialSpringUnitTestProblem.setFileType(FileType::NO_FILE);
60  tangentialSpringUnitTestProblem.setGravity(Vec3D(0, 0, -1));
61  tangentialSpringUnitTestProblem.setTimeMax(2.5);
62 
63  //solve the system
64  tangentialSpringUnitTestProblem.solve(argc, argv);
65 
66  //Test if particles have the correct position and velocity
67  BaseParticle* p = tangentialSpringUnitTestProblem.particleHandler.getObject(0);
68  logger.assert_always(p->getPosition().isEqualTo(Vec3D(0.5, 0.5, 0.25), 1e-7),
69  "First particles is in the wrong position. It is %", p->getPosition());
70  logger.assert_always(p->getVelocity().isEqualTo(Vec3D(0.0, 0.0, 0.0), 1e-7),
71  "First particle has the wrong velocity. It is %", p->getVelocity());
72 
73  p = tangentialSpringUnitTestProblem.particleHandler.getObject(1);
74 
75  Vec3D expectedPosition = Vec3D(0.96152405440385, 0.5, 0.45015310115274);
76  logger.assert_always((p->getPosition().isEqualTo(expectedPosition, 1e-7)),
77  "Second particle has the wrong position. It is %g at time % (should be %g)", p->getPosition(),
78  tangentialSpringUnitTestProblem.getTime(), expectedPosition);
79  Vec3D expectedVelocity = Vec3D(0.32586989790503, 0, -0.62325101431855);
80  logger.assert_always(p->getVelocity().isEqualTo(expectedVelocity, 1e-7),
81  "Second particle has the wrong velocity. It is %g (should be %g)", p->getVelocity(), expectedVelocity);
82  Vec3D expectedAngularVelocity = Vec3D(0.0, 2.118966061231, 0.0);
83  logger.assert_always(p->getAngularVelocity().isEqualTo(expectedAngularVelocity, 1e-7),
84  "Second particles has the wrong angular velocity. It is %g (should be %g)", p->getAngularVelocity(), expectedAngularVelocity);
85 }
Array< double, 1, 3 > e(1./3., 0.5, 2.)
@ NO_FILE
file will not be created/read
Species< LinearViscoelasticNormalSpecies, SlidingFrictionSpecies > LinearViscoelasticSlidingFrictionSpecies
Definition: LinearViscoelasticSlidingFrictionSpecies.h:12
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
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
Definition: BaseParticle.h:33
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1433
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:400
Mdouble getTime() const
Returns the current simulation time.
Definition: DPMBase.cc:799
void setFileType(FileType fileType)
Sets File::fileType_ for all files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:437
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
void setGravity(Vec3D newGravity)
Sets a new value for the gravitational acceleration.
Definition: DPMBase.cc:1374
Definition: TangentialSpringUnitTest.cpp:14
Definition: Kernel/Math/Vector.h:30
const Mdouble pi
Definition: ExtendedMath.h:23

References BaseHandler< T >::copyAndAddObject(), e(), BaseHandler< T >::getObject(), DPMBase::getTime(), logger, NO_FILE, p, DPMBase::particleHandler, constants::pi, DPMBase::setFileType(), DPMBase::setGravity(), DPMBase::setName(), DPMBase::setTimeMax(), DPMBase::setTimeStep(), DPMBase::solve(), and DPMBase::speciesHandler.