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 
)
64 {
65  PlasticForceUnitTest PlasticForceUnitTestProblem;
66  double k1=100.0;
67  PlasticForceUnitTestProblem.species->setPlasticParameters(k1, 5.0*k1, k1, 0.05);
68  PlasticForceUnitTestProblem.species->setDissipation(0);
69  PlasticForceUnitTestProblem.setParticleDimensions(3);
70  PlasticForceUnitTestProblem.setSystemDimensions(3);
71 
72  logger(INFO,"Testing particle particles collision for elastic plastic forces. \n"
73  "This will be done for serveral values of scaled relative velocity chi");
74 
75  //PlasticForceUnitTestProblem.restartFile.getFstream().precision(20);
76 
77  //Set up constant data that will be used
78  const std::vector<double> chi = {0.34, 0.69, 1.1, 1.37};
79  const std::vector<Vec3D> leftFinalVecloity = {
80  Vec3D(-0.032721738352012,0.0,0.0),
81  Vec3D(-0.0138683231953154,0.0,0.0),
82  Vec3D(-0.0204655358555405,0.0,0.0),
83  Vec3D(-0.163049415300304,0.0,0.0)};
84  const std::vector<Vec3D> leftFinalPosition = {
85  Vec3D(0.995546292935715,1.0,1.0),
86  Vec3D(1.00695193269955,1.0,1.0),
87  Vec3D(1.00840467123501,1.0,1.0),
88  Vec3D(0.969386085767181,1.0,1.0)};
89 
90  //Loop over all test cases
91  for (int i=0; i<4; i++)
92  {
93  logger(INFO, "Running for chi=%",chi[i]);
94  PlasticForceUnitTestProblem.set_chi(chi[i]);
95  std::stringstream ss("");
96  ss << "PlasticForceUnitTest" << PlasticForceUnitTestProblem.get_chi();
97  PlasticForceUnitTestProblem.setName(ss.str().c_str());
98  PlasticForceUnitTestProblem.solve();
99  //PlasticForceUnitTestProblem.writeRestartFile();
100 
101  //Now check the particles are in the right place for each of the 4 cases
102  auto pIt = PlasticForceUnitTestProblem.particleHandler.begin();
103  if (!(*pIt)->getPosition().isEqualTo(leftFinalPosition[i], 1e-10))
104  logger(FATAL, "Left particle is in the wrong position. It is at % and should be %", (*pIt)->getPosition(),
105  leftFinalPosition[i]);
106  if (!(*pIt)->getVelocity().isEqualTo(leftFinalVecloity[i], 1e-10))
107  logger(FATAL, "Left particle has the wrong velocity. It is at % and should be %", (*pIt)->getVelocity(),
108  leftFinalVecloity[i]);
109  }
110 
111  logger(INFO, "Execute 'gnuplot PlasticForceUnitTest.gnu' to view output");
112  helpers::writeToFile("PlasticForceUnitTest.gnu",
113  "set xlabel 'displacement [{/Symbol d}]'\n"
114  "set ylabel 'force [f^n]'\n"
115  "set grid\n"
116  "plot 'PlasticForceUnitTest0.34.fstat' u 7:9 w lp\n"
117  );
118 }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Array< double, 1, 3 > e(1./3., 0.5, 2.)
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:31
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:698
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:400
void setParticleDimensions(unsigned int particleDimensions)
Sets the particle dimensionality.
Definition: DPMBase.cc:1439
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created.
Definition: DPMBase.h:1443
void setSystemDimensions(unsigned int newDim)
Sets the system dimensionality.
Definition: DPMBase.cc:1408
void solve()
The work horse of the code.
Definition: DPMBase.cc:4334
[T11:contactModel]
Definition: PlasticForceUnitTest.cpp:15
void set_chi(double new_)
Definition: PlasticForceUnitTest.cpp:56
double get_chi()
Definition: PlasticForceUnitTest.cpp:57
LinearPlasticViscoelasticSpecies * species
Definition: PlasticForceUnitTest.cpp:60
Definition: Kernel/Math/Vector.h:30
#define INFO(i)
Definition: mumps_solver.h:54
bool writeToFile(const std::string &filename, const std::string &filecontent)
Writes a string to a file.
Definition: FileIOHelpers.cc:29

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