MovingWallUnitTest.cpp File Reference
#include <cmath>
#include <iostream>
#include <iomanip>
#include <Logger.h>
#include "DPMBase.h"
#include "Species/LinearViscoelasticSlidingFrictionSpecies.h"
#include "Walls/InfiniteWall.h"

Classes

class  MovingWall
 
class  MovingWallReference
 In the reference case the particle just moves two times as fast. More...
 
class  MovingWallSimpleIntegration
 
class  MovingWallPrescribedPosition
 
class  MovingWallPrescribedVelocity
 
class  MovingWallPrescribedPositionPrescribedVelocity
 
class  MovingWallTangential
 
class  MovingWallTangentialReference
 In the reference case the particle just moves two times as fast. More...
 
class  MovingWallTangentialSimpleIntegration
 
class  MovingWallTangentialPrescribedPosition
 
class  MovingWallTangentialPrescribedVelocity
 
class  MovingWallTangentialPrescribedPositionPrescribedVelocity
 

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 
)
196 {
197  if (!mathsFunc::isEqual(Ptest->getPosition(), Pref->getPosition() + positionDifference, absError))
198  {
199  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);
200  }
201  if (!mathsFunc::isEqual(Ptest->getVelocity(), Pref->getVelocity() + velocityDifference, absError))
202  {
203  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);
204  }
205  if (!mathsFunc::isEqual(Ptest->getOrientation(), Pref->getOrientation() + orientationDifference, absError))
206  {
207  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);
208  }
209  if (!mathsFunc::isEqual(Ptest->getAngularVelocity(), Pref->getAngularVelocity() + AngularVelocityDifference, absError))
210  {
211  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);
212  }
213 }
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 
)
216 {
217 
218  {
219  MovingWallReference problem0;
220  problem0.setName("MovingWallUnitTest_Normal_Reference");
221  problem0.solve();
223  problem1.setName("MovingWallUnitTest_Normal_SimpleIntegration");
224  problem1.solve();
226  problem2.setName("MovingWallUnitTest_Normal_PrescribedPosition");
227  problem2.solve();
229  problem3.setName("MovingWallUnitTest_Normal_PrescribedVelocity");
230  problem3.solve();
232  problem4.setName("MovingWallUnitTest_Normal_PrescribedPositionPrescribedVelocity");
233  problem4.solve();
234 
235  Vec3D positionDifference = Vec3D(0.0, 0.0, problem0.getTime());
236  Vec3D velocityDifference = Vec3D(0.0, 0.0, 1.0);
237  Quaternion orientationDifference = {0,0,0,0};
238  Vec3D angularVelocityDifference = Vec3D(0.0, 0.0, 0.0);
239  compareParticles(problem1.particleHandler.getLastObject(), problem0.particleHandler.getLastObject(), 1e-10, positionDifference, velocityDifference, orientationDifference, angularVelocityDifference);
240  compareParticles(problem2.particleHandler.getLastObject(), problem0.particleHandler.getLastObject(), 1e-10, positionDifference, velocityDifference, orientationDifference, angularVelocityDifference);
241  compareParticles(problem3.particleHandler.getLastObject(), problem0.particleHandler.getLastObject(), 1e-10, positionDifference, velocityDifference, orientationDifference, angularVelocityDifference);
242  compareParticles(problem4.particleHandler.getLastObject(), problem0.particleHandler.getLastObject(), 1e-10, positionDifference, velocityDifference, orientationDifference, angularVelocityDifference);
243  }
244  {
246  problem5.setName("MovingWallUnitTest_Tangential_Reference");
247  problem5.solve();
249  problem6.setName("MovingWallUnitTest_Tangential_SimpleIntegration");
250  problem6.solve();
252  problem7.setName("MovingWallUnitTest_Tangential_PrescribedPosition");
253  problem7.solve();
255  problem8.setName("MovingWallUnitTest_Tangential_PrescribedVelocity");
256  problem8.solve();
258  problem9.setName("MovingWallUnitTest_Tangential_PrescribedPositionPrescribedVelocity");
259  problem9.solve();
260 
261  Vec3D positionDifference = Vec3D(problem5.getTime(), 0.0, 0.0);
262  Vec3D velocityDifference = Vec3D(1.0, 0.0, 0.0);
263  Quaternion orientationDifference = {0,0,0,0};
264  Vec3D angularVelocityDifference = Vec3D(0.0, 0.0, 0.0);
265  compareParticles(problem6.particleHandler.getLastObject(), problem5.particleHandler.getLastObject(), 1e-10, positionDifference, velocityDifference, orientationDifference, angularVelocityDifference);
266  compareParticles(problem7.particleHandler.getLastObject(), problem5.particleHandler.getLastObject(), 1e-10, positionDifference, velocityDifference, orientationDifference, angularVelocityDifference);
267  compareParticles(problem8.particleHandler.getLastObject(), problem5.particleHandler.getLastObject(), 1e-10, positionDifference, velocityDifference, orientationDifference, angularVelocityDifference);
268  compareParticles(problem9.particleHandler.getLastObject(), problem5.particleHandler.getLastObject(), 1e-10, positionDifference, velocityDifference, orientationDifference, angularVelocityDifference);
269  }
270 
271  /*
272  diff ../../../Source/Drivers/UnitTests/SelfTestData/movingWall.data MovingWallUnitTest_Normal_PrescribedPosition.data
273  diff ../../../Source/Drivers/UnitTests/SelfTestData/movingWall.data MovingWallUnitTest_Normal_PrescribedVelocity.data
274  diff ../../../Source/Drivers/UnitTests/SelfTestData/movingWall.data MovingWallUnitTest_Normal_PrescribedPositionPrescribedVelocity.data
275  diff ../../../Source/Drivers/UnitTests/SelfTestData/movingWall.data MovingWallUnitTest_Normal_SimpleIntegration.data
276  diff ../../../Source/Drivers/UnitTests/SelfTestData/noMovingWall.data MovingWallUnitTest_Normal_Reference.data
277 
278  diff ../../../Source/Drivers/UnitTests/SelfTestData/movingWallTangential.data MovingWallUnitTest_Tangential_PrescribedPosition.data
279  diff ../../../Source/Drivers/UnitTests/SelfTestData/movingWallTangential.data MovingWallUnitTest_Tangential_PrescribedVelocity.data
280  diff ../../../Source/Drivers/UnitTests/SelfTestData/movingWallTangential.data MovingWallUnitTest_Tangential_PrescribedPositionPrescribedVelocity.data
281  diff ../../../Source/Drivers/UnitTests/SelfTestData/movingWallTangential.data MovingWallUnitTest_Tangential_SimpleIntegration.data
282  diff ../../../Source/Drivers/UnitTests/SelfTestData/noMovingWallTangential.data MovingWallUnitTest_Tangential_Reference.data
283  */
284 
285 
286  return 0;
287 }
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: MovingWallUnitTest.cpp:195
T * getLastObject()
Gets a pointer to the last Object in this BaseHandler.
Definition: BaseHandler.h:642
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
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created.
Definition: DPMBase.h:1443
void solve()
The work horse of the code.
Definition: DPMBase.cc:4334
Definition: MovingWallUnitTest.cpp:107
Definition: MovingWallUnitTest.cpp:83
Definition: MovingWallUnitTest.cpp:94
In the reference case the particle just moves two times as fast.
Definition: MovingWallUnitTest.cpp:64
Definition: MovingWallUnitTest.cpp:74
Definition: MovingWallUnitTest.cpp:181
Definition: MovingWallUnitTest.cpp:157
Definition: MovingWallUnitTest.cpp:168
In the reference case the particle just moves two times as fast.
Definition: MovingWallUnitTest.cpp:138
Definition: MovingWallUnitTest.cpp:148
This class contains the 4 components of a quaternion and the standard operators and functions needed ...
Definition: Kernel/Math/Quaternion.h:42
Definition: Kernel/Math/Vector.h:30

References compareParticles(), e(), BaseHandler< T >::getLastObject(), DPMBase::getTime(), DPMBase::particleHandler, DPMBase::setName(), and DPMBase::solve().