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 
)
126 {
127  if (!mathsFunc::isEqual(Ptest->getPosition(), Pref->getPosition() + positionDifference, absError))
128  {
129  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);
130  }
131  if (!mathsFunc::isEqual(Ptest->getVelocity(), Pref->getVelocity() + velocityDifference, absError))
132  {
133  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);
134  }
135  if (!mathsFunc::isEqual(Ptest->getOrientation(), Pref->getOrientation() + orientationDifference, absError))
136  {
137  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);
138  }
139  if (!mathsFunc::isEqual(Ptest->getAngularVelocity(), Pref->getAngularVelocity() + AngularVelocityDifference, absError))
140  {
141  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);
142  }
143 }
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 Quaternion & getOrientation() const
Returns the orientation of this BaseInteractable.
Definition: BaseInteractable.h:230
virtual const Vec3D & getAngularVelocity() const
Returns the angular velocity of this interactable.
Definition: BaseInteractable.cc:341
virtual const Vec3D & getVelocity() const
Returns the velocity of this interactable.
Definition: BaseInteractable.cc:329
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Definition: BaseInteractable.h:218
bool isEqual(Mdouble v1, Mdouble v2, Mdouble absError)
Compares the difference of two Mdouble with an absolute error, useful in UnitTests.
Definition: ExtendedMath.cc:251

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 
)
145 {
148  basic.setName("MovingIntersectionOfWallsUnitTest_Basic");
149  movingReferenceFrame.setName("MovingIntersectionOfWallsUnitTest_MovingReferenceFrame");
150  basic.solve();
151  movingReferenceFrame.solve();
152  compareParticles(movingReferenceFrame.p1f,basic.p1f, 1e-10, movingReferenceFrame.velocity*movingReferenceFrame.getTime(), movingReferenceFrame.velocity, {0,0,0,0}, {0,0,0});
153  compareParticles(movingReferenceFrame.p2f,basic.p2f, 1e-10, movingReferenceFrame.velocity*movingReferenceFrame.getTime(), movingReferenceFrame.velocity, {0,0,0,0}, {0,0,0});
154  compareParticles(movingReferenceFrame.p3f,basic.p3f, 1e-10, movingReferenceFrame.velocity*movingReferenceFrame.getTime(), movingReferenceFrame.velocity, {0,0,0,0}, {0,0,0});
155  compareParticles(movingReferenceFrame.p1e,basic.p1e, 1e-10, movingReferenceFrame.velocity*movingReferenceFrame.getTime(), movingReferenceFrame.velocity, {0,0,0,0}, {0,0,0});
156  compareParticles(movingReferenceFrame.p2e,basic.p2e, 1e-10, movingReferenceFrame.velocity*movingReferenceFrame.getTime(), movingReferenceFrame.velocity, {0,0,0,0}, {0,0,0});
157  compareParticles(movingReferenceFrame.p3e,basic.p3e, 1e-10, movingReferenceFrame.velocity*movingReferenceFrame.getTime(), movingReferenceFrame.velocity, {0,0,0,0}, {0,0,0});
158 }
void compareParticles(BaseParticle *Ptest, BaseParticle *Pref, double absError, Vec3D positionDifference, Vec3D velocityDifference, Quaternion orientationDifference, Vec3D AngularVelocityDifference)
Definition: MovingIntersectionOfWallsUnitTest.cpp:125
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:422
Mdouble getTime() const
Returns the current simulation time.
Definition: DPMBase.cc:808
void solve()
The work horse of the code.
Definition: DPMBase.cc:4270
Definition: MovingIntersectionOfWallsUnitTest.cpp:40
BaseParticle * p3e
Definition: MovingIntersectionOfWallsUnitTest.cpp:102
BaseParticle * p3f
Definition: MovingIntersectionOfWallsUnitTest.cpp:99
BaseParticle * p1f
Definition: MovingIntersectionOfWallsUnitTest.cpp:97
BaseParticle * p1e
Definition: MovingIntersectionOfWallsUnitTest.cpp:100
BaseParticle * p2f
Definition: MovingIntersectionOfWallsUnitTest.cpp:98
BaseParticle * p2e
Definition: MovingIntersectionOfWallsUnitTest.cpp:101
Definition: MovingIntersectionOfWallsUnitTest.cpp:111
Vec3D velocity
Definition: MovingIntersectionOfWallsUnitTest.cpp:123

References compareParticles(), 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.