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[] 
)
66 {
67  TangentialSpringUnitTest tangentialSpringUnitTestProblem;
68  tangentialSpringUnitTestProblem.setName("TangentialSpringUnitTest");
69 
70  //set the species properties, with a very large sliding friction coefficient
71  auto species = tangentialSpringUnitTestProblem.speciesHandler.copyAndAddObject(
73  species->setDensity(6. / constants::pi);
74  species->setCollisionTimeAndRestitutionCoefficient(1e-3, .2, 1. / 8);
75  species->setSlidingStiffness(species->getStiffness() * 2 / 7);
76  species->setSlidingFrictionCoefficient(1e20);
77 
78  //set simulation-parameters: time, time step, gravity, output-file properties
79  tangentialSpringUnitTestProblem.setTimeStep(2e-5);
80  tangentialSpringUnitTestProblem.setFileType(FileType::NO_FILE);
81  tangentialSpringUnitTestProblem.setGravity(Vec3D(0, 0, -1));
82  tangentialSpringUnitTestProblem.setTimeMax(2.5);
83 
84  //solve the system
85  tangentialSpringUnitTestProblem.solve(argc, argv);
86 
87  //Test if particles have the correct position and velocity
88  BaseParticle* p = tangentialSpringUnitTestProblem.particleHandler.getObject(0);
89  logger.assert_always(p->getPosition().isEqualTo(Vec3D(0.5, 0.5, 0.25), 1e-7),
90  "First particles is in the wrong position. It is %", p->getPosition());
91  logger.assert_always(p->getVelocity().isEqualTo(Vec3D(0.0, 0.0, 0.0), 1e-7),
92  "First particle has the wrong velocity. It is %", p->getVelocity());
93 
94  p = tangentialSpringUnitTestProblem.particleHandler.getObject(1);
95  logger.assert_always((p->getPosition().isEqualTo(Vec3D(0.961524052956078, 0.5, 0.450153103106219), 1e-7)),
96  "Second particle has the wrong position. It is % at time %", p->getPosition(),
97  tangentialSpringUnitTestProblem.getTime());
98  logger.assert_always(p->getVelocity().isEqualTo(Vec3D(0.325869890236916, 0, -0.623251003973752), 1e-7),
99  "Second particle has the wrong velocity. It is %", p->getVelocity());
100  logger.assert_always(p->getAngularVelocity().isEqualTo(Vec3D(0.0, 2.11896618998424, 0.0), 1e-7),
101  "Second particles has the wrong angular velocity. It is %", p->getAngularVelocity());
102 }
@ NO_FILE
file will not be created/read
Species< LinearViscoelasticNormalSpecies, SlidingFrictionSpecies > LinearViscoelasticSlidingFrictionSpecies
Definition: LinearViscoelasticSlidingFrictionSpecies.h:34
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
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
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
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Definition: BaseInteractable.h:218
Definition: BaseParticle.h:54
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1427
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:422
Mdouble getTime() const
Returns the current simulation time.
Definition: DPMBase.cc:808
void setFileType(FileType fileType)
Sets File::fileType_ for all files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:459
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
void setGravity(Vec3D newGravity)
Sets a new value for the gravitational acceleration.
Definition: DPMBase.cc:1383
Definition: TangentialSpringUnitTest.cpp:35
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
const Mdouble pi
Definition: ExtendedMath.h:45

References BaseHandler< T >::copyAndAddObject(), BaseInteractable::getAngularVelocity(), BaseHandler< T >::getObject(), BaseInteractable::getPosition(), DPMBase::getTime(), BaseInteractable::getVelocity(), Vec3D::isEqualTo(), logger, NO_FILE, DPMBase::particleHandler, constants::pi, DPMBase::setFileType(), DPMBase::setGravity(), DPMBase::setName(), DPMBase::setTimeMax(), DPMBase::setTimeStep(), DPMBase::solve(), and DPMBase::speciesHandler.