MovingIntersectionOfWallsUnitTest.cpp File Reference
#include <cmath>
#include <iostream>
#include <iomanip>
#include "Logger.h"
#include "DPMBase.h"
#include "Walls/IntersectionOfWalls.h"
#include "Species/LinearViscoelasticSpecies.h"

Classes

class  MovingIntersectionOfWallsUnitTest_Basic
 
class  MovingIntersectionOfWallsUnitTest_MovingReferenceFrame
 

Functions

void compareParticles (BaseParticle *Ptest, BaseParticle *Pref, double absError, Vec3D positionDifference, Vec3D velocityDifference, Quaternion orientationDifference, Vec3D AngularVelocityDifference)
 
int main (int argc UNUSED, char *argv[] UNUSED)
 

Function Documentation

◆ compareParticles()

void compareParticles ( BaseParticle Ptest,
BaseParticle Pref,
double  absError,
Vec3D  positionDifference,
Vec3D  velocityDifference,
Quaternion  orientationDifference,
Vec3D  AngularVelocityDifference 
)
105 {
106  if (!mathsFunc::isEqual(Ptest->getPosition(), Pref->getPosition() + positionDifference, absError))
107  {
108  logger(FATAL, "The particle has the wrong position. It is %, however is should be %, the difference is %", Ptest->getPosition(), Pref->getPosition() + positionDifference, Ptest->getPosition() - Pref->getPosition() - positionDifference);
109  }
110  if (!mathsFunc::isEqual(Ptest->getVelocity(), Pref->getVelocity() + velocityDifference, absError))
111  {
112  logger(FATAL, "The particle has the wrong velocity. It is %, however is should be %, the difference is %", Ptest->getVelocity(), Pref->getVelocity() + velocityDifference, Ptest->getVelocity() - Pref->getVelocity() - velocityDifference);
113  }
114  if (!mathsFunc::isEqual(Ptest->getOrientation(), Pref->getOrientation() + orientationDifference, absError))
115  {
116  logger(FATAL, "The particle has the wrong orientation. It is %, however is should be %, the difference is %", Ptest->getOrientation(), Pref->getOrientation() + orientationDifference, Ptest->getOrientation() - Pref->getOrientation() - orientationDifference);
117  }
118  if (!mathsFunc::isEqual(Ptest->getAngularVelocity(), Pref->getAngularVelocity() + AngularVelocityDifference, absError))
119  {
120  logger(FATAL, "The particle has the wrong angular velocity. It is %, however is should be %, the difference is %", Ptest->getAngularVelocity(), Pref->getAngularVelocity() + AngularVelocityDifference, Ptest->getAngularVelocity() - Pref->getAngularVelocity() - AngularVelocityDifference);
121  }
122 }
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 Quaternion & getOrientation() const
Returns the orientation of this BaseInteractable.
Definition: BaseInteractable.h:209
virtual const Vec3D & getAngularVelocity() const
Returns the angular velocity of this interactable.
Definition: BaseInteractable.cc:319
virtual const Vec3D & getVelocity() const
Returns the velocity of this interactable.
Definition: BaseInteractable.cc:307
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Definition: BaseInteractable.h:197
bool isEqual(Mdouble v1, Mdouble v2, Mdouble absError)
Compares the difference of two Mdouble with an absolute error, useful in UnitTests.
Definition: ExtendedMath.cc:230

References FATAL, BaseInteractable::getAngularVelocity(), BaseInteractable::getOrientation(), BaseInteractable::getPosition(), BaseInteractable::getVelocity(), mathsFunc::isEqual(), and logger.

Referenced by main().

◆ main()

int main ( int argc  UNUSED,
char *argv[]  UNUSED 
)
124 {
127  basic.setName("MovingIntersectionOfWallsUnitTest_Basic");
128  movingReferenceFrame.setName("MovingIntersectionOfWallsUnitTest_MovingReferenceFrame");
129  basic.solve();
130  movingReferenceFrame.solve();
131  compareParticles(movingReferenceFrame.p1f,basic.p1f, 1e-10, movingReferenceFrame.velocity*movingReferenceFrame.getTime(), movingReferenceFrame.velocity, {0,0,0,0}, {0,0,0});
132  compareParticles(movingReferenceFrame.p2f,basic.p2f, 1e-10, movingReferenceFrame.velocity*movingReferenceFrame.getTime(), movingReferenceFrame.velocity, {0,0,0,0}, {0,0,0});
133  compareParticles(movingReferenceFrame.p3f,basic.p3f, 1e-10, movingReferenceFrame.velocity*movingReferenceFrame.getTime(), movingReferenceFrame.velocity, {0,0,0,0}, {0,0,0});
134  compareParticles(movingReferenceFrame.p1e,basic.p1e, 1e-10, movingReferenceFrame.velocity*movingReferenceFrame.getTime(), movingReferenceFrame.velocity, {0,0,0,0}, {0,0,0});
135  compareParticles(movingReferenceFrame.p2e,basic.p2e, 1e-10, movingReferenceFrame.velocity*movingReferenceFrame.getTime(), movingReferenceFrame.velocity, {0,0,0,0}, {0,0,0});
136  compareParticles(movingReferenceFrame.p3e,basic.p3e, 1e-10, movingReferenceFrame.velocity*movingReferenceFrame.getTime(), movingReferenceFrame.velocity, {0,0,0,0}, {0,0,0});
137 }
Array< double, 1, 3 > e(1./3., 0.5, 2.)
void compareParticles(BaseParticle *Ptest, BaseParticle *Pref, double absError, Vec3D positionDifference, Vec3D velocityDifference, Quaternion orientationDifference, Vec3D AngularVelocityDifference)
Definition: MovingIntersectionOfWallsUnitTest.cpp:104
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:400
Mdouble getTime() const
Returns the current simulation time.
Definition: DPMBase.cc:799
void solve()
The work horse of the code.
Definition: DPMBase.cc:4334
Definition: MovingIntersectionOfWallsUnitTest.cpp:19
BaseParticle * p3e
Definition: MovingIntersectionOfWallsUnitTest.cpp:81
BaseParticle * p3f
Definition: MovingIntersectionOfWallsUnitTest.cpp:78
BaseParticle * p1f
Definition: MovingIntersectionOfWallsUnitTest.cpp:76
BaseParticle * p1e
Definition: MovingIntersectionOfWallsUnitTest.cpp:79
BaseParticle * p2f
Definition: MovingIntersectionOfWallsUnitTest.cpp:77
BaseParticle * p2e
Definition: MovingIntersectionOfWallsUnitTest.cpp:80
Definition: MovingIntersectionOfWallsUnitTest.cpp:90
Vec3D velocity
Definition: MovingIntersectionOfWallsUnitTest.cpp:102

References compareParticles(), e(), DPMBase::getTime(), MovingIntersectionOfWallsUnitTest_Basic::p1e, MovingIntersectionOfWallsUnitTest_Basic::p1f, MovingIntersectionOfWallsUnitTest_Basic::p2e, MovingIntersectionOfWallsUnitTest_Basic::p2f, MovingIntersectionOfWallsUnitTest_Basic::p3e, MovingIntersectionOfWallsUnitTest_Basic::p3f, DPMBase::setName(), DPMBase::solve(), and MovingIntersectionOfWallsUnitTest_MovingReferenceFrame::velocity.