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

Go to the source code of this file.

Classes

class  ExtremeOverlapWithWallsUnitTest
 Compresses 2 particles (vertically) until they have an extreme overlap. More...
 

Functions

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

Function Documentation

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

Start off my solving the default problem

Definition at line 105 of file ExtremeOverlapWithWallsUnitTest.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.

106 {
108  ExtremeOverlapWithWallsUnitTest OverlapProblem;
109  auto species = OverlapProblem.speciesHandler.copyAndAddObject(LinearViscoelasticSpecies());
110  species->setDensity(2000);
111  species->setStiffness(1e5);
112  species->setDissipation(1e-2);
113  OverlapProblem.setName("ExtremeOverlapWithWallsUnitTest");
114  OverlapProblem.setFileType(FileType::NO_FILE);
115  OverlapProblem.dataFile.setFileType(FileType::ONE_FILE);
116  OverlapProblem.setSaveCount(1000);
117  OverlapProblem.setDimension(3);
118  OverlapProblem.setTimeStep(1e-7);
119  OverlapProblem.setTimeMax(0.01);
120  // OverlapProblem.dataFile.getFstream().precision(10);
121  OverlapProblem.solve(argc,argv);
122 
123  Vec3D position = OverlapProblem.particleHandler.getObject(0)->getPosition();
124  Vec3D positionToCompare = Vec3D(0, -0.0004900098000491, 0.004008957617341);
125  if (!position.isEqualTo(positionToCompare, 1e-10))
126  logger(FATAL,"Large particle is in the wrong position. It is at % and should be %",position,positionToCompare);
127  else
128  std::cout << "Test passed" << std::endl;
129  position = OverlapProblem.particleHandler.getObject(1)->getPosition();
130  positionToCompare = Vec3D(0, -0.0004900098000491, 0.009004578797915);
131  //std::cout.precision(13); std::cout << position << std::endl;
132  if (!position.isEqualTo(positionToCompare, 1e-10))
133  logger(FATAL,"Large particle is in the wrong position. It is at % and should be %",position,positionToCompare);
134  else
135  std::cout << "Test passed" << std::endl;
136 
137  return 0;
138 }
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
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
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
Species< LinearViscoelasticNormalSpecies > LinearViscoelasticSpecies
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
Compresses 2 particles (vertically) until they have an extreme overlap.