PlasticForceUnitTest.cpp File Reference
#include "DPMBase.h"
#include <iostream>
#include <vector>
#include <Species/LinearPlasticViscoelasticSpecies.h>
#include <Logger.h>

Classes

class  PlasticForceUnitTest
 [T11:contactModel] More...
 

Functions

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

Function Documentation

◆ main()

int main ( int argc  UNUSED,
char *argv[]  UNUSED 
)
85 {
86  PlasticForceUnitTest PlasticForceUnitTestProblem;
87  double k1=100.0;
88  PlasticForceUnitTestProblem.species->setPlasticParameters(k1, 5.0*k1, k1, 0.05);
89  PlasticForceUnitTestProblem.species->setDissipation(0);
90  PlasticForceUnitTestProblem.setParticleDimensions(3);
91  PlasticForceUnitTestProblem.setSystemDimensions(3);
92 
93  logger(INFO,"Testing particle particles collision for elastic plastic forces. \n"
94  "This will be done for serveral values of scaled relative velocity chi");
95 
96  //PlasticForceUnitTestProblem.restartFile.getFstream().precision(20);
97 
98  //Set up constant data that will be used
99  const std::vector<double> chi = {0.34, 0.69, 1.1, 1.37};
100  const std::vector<Vec3D> leftFinalVecloity = {
101  Vec3D(-0.032721738352012,0.0,0.0),
102  Vec3D(-0.0138683231953154,0.0,0.0),
103  Vec3D(-0.0204655358555405,0.0,0.0),
104  Vec3D(-0.163049415300304,0.0,0.0)};
105  const std::vector<Vec3D> leftFinalPosition = {
106  Vec3D(0.995546292935715,1.0,1.0),
107  Vec3D(1.00695193269955,1.0,1.0),
108  Vec3D(1.00840467123501,1.0,1.0),
109  Vec3D(0.969386085767181,1.0,1.0)};
110 
111  //Loop over all test cases
112  for (int i=0; i<4; i++)
113  {
114  logger(INFO, "Running for chi=%",chi[i]);
115  PlasticForceUnitTestProblem.set_chi(chi[i]);
116  std::stringstream ss("");
117  ss << "PlasticForceUnitTest" << PlasticForceUnitTestProblem.get_chi();
118  PlasticForceUnitTestProblem.setName(ss.str().c_str());
119  PlasticForceUnitTestProblem.solve();
120  //PlasticForceUnitTestProblem.writeRestartFile();
121 
122  //Now check the particles are in the right place for each of the 4 cases
123  auto pIt = PlasticForceUnitTestProblem.particleHandler.begin();
124  if (!(*pIt)->getPosition().isEqualTo(leftFinalPosition[i], 1e-10))
125  logger(FATAL, "Left particle is in the wrong position. It is at % and should be %", (*pIt)->getPosition(),
126  leftFinalPosition[i]);
127  if (!(*pIt)->getVelocity().isEqualTo(leftFinalVecloity[i], 1e-10))
128  logger(FATAL, "Left particle has the wrong velocity. It is at % and should be %", (*pIt)->getVelocity(),
129  leftFinalVecloity[i]);
130  }
131 
132  logger(INFO, "Execute 'gnuplot PlasticForceUnitTest.gnu' to view output");
133  helpers::writeToFile("PlasticForceUnitTest.gnu",
134  "set xlabel 'displacement [{/Symbol d}]'\n"
135  "set ylabel 'force [f^n]'\n"
136  "set grid\n"
137  "plot 'PlasticForceUnitTest0.34.fstat' u 7:9 w lp\n"
138  );
139 }
LL< Log::INFO > INFO
Info log level.
Definition: Logger.cc:55
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:52
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
const std::vector< T * >::const_iterator begin() const
Gets the begin of the const_iterator over all Object in this BaseHandler.
Definition: BaseHandler.h:690
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:422
void setParticleDimensions(unsigned int particleDimensions)
Sets the particle dimensionality.
Definition: DPMBase.cc:1448
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created.
Definition: DPMBase.h:1437
void setSystemDimensions(unsigned int newDim)
Sets the system dimensionality.
Definition: DPMBase.cc:1417
void solve()
The work horse of the code.
Definition: DPMBase.cc:4270
[T11:contactModel]
Definition: PlasticForceUnitTest.cpp:36
void set_chi(double new_)
Definition: PlasticForceUnitTest.cpp:77
double get_chi()
Definition: PlasticForceUnitTest.cpp:78
LinearPlasticViscoelasticSpecies * species
Definition: PlasticForceUnitTest.cpp:81
Definition: Vector.h:51
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51
bool writeToFile(std::string filename, std::string filecontent)
Writes a string to a file.
Definition: FileIOHelpers.cc:58

References BaseHandler< T >::begin(), FATAL, PlasticForceUnitTest::get_chi(), constants::i, INFO, logger, DPMBase::particleHandler, PlasticForceUnitTest::set_chi(), DPMBase::setName(), DPMBase::setParticleDimensions(), DPMBase::setSystemDimensions(), DPMBase::solve(), PlasticForceUnitTest::species, and helpers::writeToFile().