MercuryDPM  0.11
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ExtremeOverlapUnitTest.cpp File Reference
#include "DPMBase.h"
#include "Particles/BaseParticle.h"
#include "Walls/InfiniteWall.h"
#include <iostream>
#include <Species/LinearViscoelasticSlidingFrictionSpecies.h>
#include <Logger.h>

Go to the source code of this file.

Classes

class  ExtremeOverlapUnitTest
 Makes sure that the behavior is still sensible if the overlap of two particles grows extremely large. More...
 

Functions

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

Function Documentation

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

Definition at line 97 of file ExtremeOverlapUnitTest.cpp.

References BaseHandler< T >::copyAndAddObject(), Files::dataFile, FATAL, BaseHandler< T >::getObject(), BaseInteractable::getPosition(), Vec3D::isEqualTo(), logger, NO_FILE, ONE_FILE, DPMBase::particleHandler, DPMBase::setDimension(), File::setFileType(), Files::setFileType(), Files::setName(), Files::setSaveCount(), DPMBase::setTimeMax(), DPMBase::setTimeStep(), DPMBase::solve(), and DPMBase::speciesHandler.

98 {
99  ExtremeOverlapUnitTest OverlapProblem;
100 
101  //set some contact parameters; the contact is elastic (so we can check
102  //energy conservation), and very soft (so the particles repel each other slowly))
103  //To check Energy conservation, use gnuplot:
104  // p 'ExtremeOverlapUnitTest.ene' u 1:($2+$3+$4+$5)
106  species->setDensity(2000);
107  species->setStiffness(1e1);
108  species->setDissipation(0.0);
109  species->setSlidingFrictionCoefficient(1.0);
110  species->setSlidingStiffness(2.0/7.0*species->getStiffness());
111  species->setSlidingDissipation(2.0/7.0*species->getDissipation());
112 
113  OverlapProblem.setName("ExtremeOverlapUnitTest");
114  OverlapProblem.setFileType(FileType::NO_FILE);
115  OverlapProblem.dataFile.setFileType(FileType::ONE_FILE);
116  OverlapProblem.setSaveCount(10000);
117  OverlapProblem.setDimension(2);
118  OverlapProblem.setTimeStep(1e-8);
119  OverlapProblem.setTimeMax(0.01);
120  OverlapProblem.solve(argc,argv);
121 
122  Vec3D position = OverlapProblem.particleHandler.getObject(0)->getPosition();
123  Vec3D positionToCompare = Vec3D(-1.031389999146e-06, 0.009506389407855, 0);
124  if (!position.isEqualTo(positionToCompare, 1e-10))
125  logger(FATAL,"Large particle is in the wrong position. It is at % and should be %",position,positionToCompare);
126  else
127  std::cout << "Test passed" << std::endl;
128  position = OverlapProblem.particleHandler.getObject(1)->getPosition();
129  positionToCompare = Vec3D(0.01010314899993, 0.01487096023445, 0);
130  if (!position.isEqualTo(positionToCompare, 1e-10))
131  logger(FATAL,"Large particle is in the wrong position. It is at % and should be %",position,positionToCompare);
132  else
133  std::cout << "Test passed" << std::endl;
134  //std::cout.precision(13); std::cout << position << std::endl;
135  return 0;
136 }
void solve()
The work horse of the code.
Definition: DPMBase.cc:1895
void setTimeMax(Mdouble newTMax)
Allows the upper time limit to be changed.
Definition: DPMBase.cc:179
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
void setDimension(unsigned int newDim)
Sets the system and particle dimension.
Definition: DPMBase.cc:445
Species< LinearViscoelasticNormalSpecies, SlidingFrictionSpecies > LinearViscoelasticSlidingFrictionSpecies
void setFileType(FileType fileType)
Sets File::fileType_ for all files (ene, data, fstat, restart, stat)
Definition: Files.cc:169
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
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
file will not be created/read
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: Files.cc:149
U * copyAndAddObject(const U &O)
Creates a copy of a Object and adds it to the BaseHandler.
Definition: BaseHandler.h:268
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:878
all data will be written into/ read from a single file called name_
T * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:415
Makes sure that the behavior is still sensible if the overlap of two particles grows extremely large...
LL< Log::FATAL > FATAL
Fatal log level.
Definition: Logger.cc:25
void setSaveCount(unsigned int saveCount)
Sets File::saveCount_ for all files (ene, data, fstat, restart, stat)
Definition: Files.cc:138
File dataFile
An instance of class File to handle in- and output into a .data file.
Definition: Files.h:204
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. elastic, linear visco-elastic... et cetera...
Definition: DPMBase.h:868
void setFileType(FileType fileType)
Sets the type of file needed to write into or read from. File::fileType_.
Definition: File.cc:209
void setTimeStep(Mdouble newDt)
Allows the time step dt to be changed.
Definition: DPMBase.cc:353
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45