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 
)
217 {
218  if (!mathsFunc::isEqual(Ptest->getPosition(), Pref->getPosition() + positionDifference, absError))
219  {
220  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);
221  }
222  if (!mathsFunc::isEqual(Ptest->getVelocity(), Pref->getVelocity() + velocityDifference, absError))
223  {
224  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);
225  }
226  if (!mathsFunc::isEqual(Ptest->getOrientation(), Pref->getOrientation() + orientationDifference, absError))
227  {
228  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);
229  }
230  if (!mathsFunc::isEqual(Ptest->getAngularVelocity(), Pref->getAngularVelocity() + AngularVelocityDifference, absError))
231  {
232  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);
233  }
234 }
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 
)
237 {
238 
239  {
240  MovingWallReference problem0;
241  problem0.setName("MovingWallUnitTest_Normal_Reference");
242  problem0.solve();
244  problem1.setName("MovingWallUnitTest_Normal_SimpleIntegration");
245  problem1.solve();
247  problem2.setName("MovingWallUnitTest_Normal_PrescribedPosition");
248  problem2.solve();
250  problem3.setName("MovingWallUnitTest_Normal_PrescribedVelocity");
251  problem3.solve();
253  problem4.setName("MovingWallUnitTest_Normal_PrescribedPositionPrescribedVelocity");
254  problem4.solve();
255 
256  Vec3D positionDifference = Vec3D(0.0, 0.0, problem0.getTime());
257  Vec3D velocityDifference = Vec3D(0.0, 0.0, 1.0);
258  Quaternion orientationDifference = {0,0,0,0};
259  Vec3D angularVelocityDifference = Vec3D(0.0, 0.0, 0.0);
260  compareParticles(problem1.particleHandler.getLastObject(), problem0.particleHandler.getLastObject(), 1e-10, positionDifference, velocityDifference, orientationDifference, angularVelocityDifference);
261  compareParticles(problem2.particleHandler.getLastObject(), problem0.particleHandler.getLastObject(), 1e-10, positionDifference, velocityDifference, orientationDifference, angularVelocityDifference);
262  compareParticles(problem3.particleHandler.getLastObject(), problem0.particleHandler.getLastObject(), 1e-10, positionDifference, velocityDifference, orientationDifference, angularVelocityDifference);
263  compareParticles(problem4.particleHandler.getLastObject(), problem0.particleHandler.getLastObject(), 1e-10, positionDifference, velocityDifference, orientationDifference, angularVelocityDifference);
264  }
265  {
267  problem5.setName("MovingWallUnitTest_Tangential_Reference");
268  problem5.solve();
270  problem6.setName("MovingWallUnitTest_Tangential_SimpleIntegration");
271  problem6.solve();
273  problem7.setName("MovingWallUnitTest_Tangential_PrescribedPosition");
274  problem7.solve();
276  problem8.setName("MovingWallUnitTest_Tangential_PrescribedVelocity");
277  problem8.solve();
279  problem9.setName("MovingWallUnitTest_Tangential_PrescribedPositionPrescribedVelocity");
280  problem9.solve();
281 
282  Vec3D positionDifference = Vec3D(problem5.getTime(), 0.0, 0.0);
283  Vec3D velocityDifference = Vec3D(1.0, 0.0, 0.0);
284  Quaternion orientationDifference = {0,0,0,0};
285  Vec3D angularVelocityDifference = Vec3D(0.0, 0.0, 0.0);
286  compareParticles(problem6.particleHandler.getLastObject(), problem5.particleHandler.getLastObject(), 1e-10, positionDifference, velocityDifference, orientationDifference, angularVelocityDifference);
287  compareParticles(problem7.particleHandler.getLastObject(), problem5.particleHandler.getLastObject(), 1e-10, positionDifference, velocityDifference, orientationDifference, angularVelocityDifference);
288  compareParticles(problem8.particleHandler.getLastObject(), problem5.particleHandler.getLastObject(), 1e-10, positionDifference, velocityDifference, orientationDifference, angularVelocityDifference);
289  compareParticles(problem9.particleHandler.getLastObject(), problem5.particleHandler.getLastObject(), 1e-10, positionDifference, velocityDifference, orientationDifference, angularVelocityDifference);
290  }
291 
292  /*
293  diff ../../../Source/Drivers/UnitTests/SelfTestData/movingWall.data MovingWallUnitTest_Normal_PrescribedPosition.data
294  diff ../../../Source/Drivers/UnitTests/SelfTestData/movingWall.data MovingWallUnitTest_Normal_PrescribedVelocity.data
295  diff ../../../Source/Drivers/UnitTests/SelfTestData/movingWall.data MovingWallUnitTest_Normal_PrescribedPositionPrescribedVelocity.data
296  diff ../../../Source/Drivers/UnitTests/SelfTestData/movingWall.data MovingWallUnitTest_Normal_SimpleIntegration.data
297  diff ../../../Source/Drivers/UnitTests/SelfTestData/noMovingWall.data MovingWallUnitTest_Normal_Reference.data
298 
299  diff ../../../Source/Drivers/UnitTests/SelfTestData/movingWallTangential.data MovingWallUnitTest_Tangential_PrescribedPosition.data
300  diff ../../../Source/Drivers/UnitTests/SelfTestData/movingWallTangential.data MovingWallUnitTest_Tangential_PrescribedVelocity.data
301  diff ../../../Source/Drivers/UnitTests/SelfTestData/movingWallTangential.data MovingWallUnitTest_Tangential_PrescribedPositionPrescribedVelocity.data
302  diff ../../../Source/Drivers/UnitTests/SelfTestData/movingWallTangential.data MovingWallUnitTest_Tangential_SimpleIntegration.data
303  diff ../../../Source/Drivers/UnitTests/SelfTestData/noMovingWallTangential.data MovingWallUnitTest_Tangential_Reference.data
304  */
305 
306 
307  return 0;
308 }
void compareParticles(BaseParticle *Ptest, BaseParticle *Pref, double absError, Vec3D positionDifference, Vec3D velocityDifference, Quaternion orientationDifference, Vec3D AngularVelocityDifference)
Definition: MovingWallUnitTest.cpp:216
T * getLastObject()
Gets a pointer to the last Object in this BaseHandler.
Definition: BaseHandler.h:634
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
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created.
Definition: DPMBase.h:1437
void solve()
The work horse of the code.
Definition: DPMBase.cc:4270
Definition: MovingWallUnitTest.cpp:128
Definition: MovingWallUnitTest.cpp:104
Definition: MovingWallUnitTest.cpp:115
In the reference case the particle just moves two times as fast.
Definition: MovingWallUnitTest.cpp:85
Definition: MovingWallUnitTest.cpp:95
Definition: MovingWallUnitTest.cpp:202
Definition: MovingWallUnitTest.cpp:178
Definition: MovingWallUnitTest.cpp:189
In the reference case the particle just moves two times as fast.
Definition: MovingWallUnitTest.cpp:159
Definition: MovingWallUnitTest.cpp:169
This class contains the 4 components of a quaternion and the standard operators and functions needed ...
Definition: Quaternion.h:63
Definition: Vector.h:51

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