MercuryDPM  0.11
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MovingWallUnitTest.cpp File Reference
#include <cmath>
#include <iostream>
#include <iomanip>
#include <Logger.h>
#include "DPMBase.h"
#include "Particles/BaseParticle.h"
#include "Species/LinearViscoelasticSlidingFrictionSpecies.h"
#include "Walls/InfiniteWall.h"

Go to the source code of this file.

Classes

class  MovingWall
 This tests if moving the wall works with CWall::move(Vec3D velocity,Vec3D dt). More...
 
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, Vec3D orientationDifference, Vec3D AngularVelocityDifference)
 
int main (int argc UNUSED, char *argv[] UNUSED)
 

Function Documentation

void compareParticles ( BaseParticle Ptest,
BaseParticle Pref,
double  absError,
Vec3D  positionDifference,
Vec3D  velocityDifference,
Vec3D  orientationDifference,
Vec3D  AngularVelocityDifference 
)

Definition at line 225 of file MovingWallUnitTest.cpp.

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

Referenced by main().

226 {
227  if (!mathsFunc::isEqual(Ptest->getPosition(), Pref->getPosition() + positionDifference, absError))
228  {
229  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);
230  }
231  if (!mathsFunc::isEqual(Ptest->getVelocity(), Pref->getVelocity() + velocityDifference, absError))
232  {
233  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);
234  }
235  if (!mathsFunc::isEqual(Ptest->getOrientation(), Pref->getOrientation() + orientationDifference, absError))
236  {
237  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);
238  }
239  if (!mathsFunc::isEqual(Ptest->getAngularVelocity(), Pref->getAngularVelocity() + AngularVelocityDifference, absError))
240  {
241  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);
242  }
243 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
virtual const Vec3D & getAngularVelocity() const
Returns the angular velocity of this interactable.
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
const Vec3D & getOrientation() const
Returns the orientation of this BaseInteractable.
LL< Log::FATAL > FATAL
Fatal log level.
Definition: Logger.cc:25
bool isEqual(Mdouble v1, Mdouble v2, double absError)
Compares the difference of two Mdouble with an absolute error, useful in UnitTests.
virtual const Vec3D & getVelocity() const
Returns the velocity of this interactable.
int main ( int argc  UNUSED,
char *argv[]  UNUSED 
)

Definition at line 245 of file MovingWallUnitTest.cpp.

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

246 {
247 
248  {
249  MovingWallReference problem0;
250  problem0.setName("MovingWallUnitTest_Normal_Reference");
251  problem0.solve();
253  problem1.setName("MovingWallUnitTest_Normal_SimpleIntegration");
254  problem1.solve();
256  problem2.setName("MovingWallUnitTest_Normal_PrescribedPosition");
257  problem2.solve();
259  problem3.setName("MovingWallUnitTest_Normal_PrescribedVelocity");
260  problem3.solve();
262  problem4.setName("MovingWallUnitTest_Normal_PrescribedPositionPrescribedVelocity");
263  problem4.solve();
264 
265  Vec3D positionDifference = Vec3D(0.0, 0.0, problem0.getTime());
266  Vec3D velocityDifference = Vec3D(0.0, 0.0, 1.0);
267  Vec3D orientationDifference = Vec3D(0.0, 0.0, 0.0);
268  Vec3D angularVelocityDifference = Vec3D(0.0, 0.0, 0.0);
269  compareParticles(problem1.particleHandler.getLastObject(), problem0.particleHandler.getLastObject(), 1e-10, positionDifference, velocityDifference, orientationDifference, angularVelocityDifference);
270  compareParticles(problem2.particleHandler.getLastObject(), problem0.particleHandler.getLastObject(), 1e-10, positionDifference, velocityDifference, orientationDifference, angularVelocityDifference);
271  compareParticles(problem3.particleHandler.getLastObject(), problem0.particleHandler.getLastObject(), 1e-10, positionDifference, velocityDifference, orientationDifference, angularVelocityDifference);
272  compareParticles(problem4.particleHandler.getLastObject(), problem0.particleHandler.getLastObject(), 1e-10, positionDifference, velocityDifference, orientationDifference, angularVelocityDifference);
273  }
274  {
276  problem5.setName("MovingWallUnitTest_Tangential_Reference");
277  problem5.solve();
279  problem6.setName("MovingWallUnitTest_Tangential_SimpleIntegration");
280  problem6.solve();
282  problem7.setName("MovingWallUnitTest_Tangential_PrescribedPosition");
283  problem7.solve();
285  problem8.setName("MovingWallUnitTest_Tangential_PrescribedVelocity");
286  problem8.solve();
288  problem9.setName("MovingWallUnitTest_Tangential_PrescribedPositionPrescribedVelocity");
289  problem9.solve();
290 
291  Vec3D positionDifference = Vec3D(problem5.getTime(), 0.0, 0.0);
292  Vec3D velocityDifference = Vec3D(1.0, 0.0, 0.0);
293  Vec3D orientationDifference = Vec3D(0.0, 0.0, 0.0);
294  Vec3D angularVelocityDifference = Vec3D(0.0, 0.0, 0.0);
295  compareParticles(problem6.particleHandler.getLastObject(), problem5.particleHandler.getLastObject(), 1e-10, positionDifference, velocityDifference, orientationDifference, angularVelocityDifference);
296  compareParticles(problem7.particleHandler.getLastObject(), problem5.particleHandler.getLastObject(), 1e-10, positionDifference, velocityDifference, orientationDifference, angularVelocityDifference);
297  compareParticles(problem8.particleHandler.getLastObject(), problem5.particleHandler.getLastObject(), 1e-10, positionDifference, velocityDifference, orientationDifference, angularVelocityDifference);
298  compareParticles(problem9.particleHandler.getLastObject(), problem5.particleHandler.getLastObject(), 1e-10, positionDifference, velocityDifference, orientationDifference, angularVelocityDifference);
299  }
300 
301  /*
302  diff ../../../Source/Drivers/UnitTests/SelfTestData/movingWall.data MovingWallUnitTest_Normal_PrescribedPosition.data
303  diff ../../../Source/Drivers/UnitTests/SelfTestData/movingWall.data MovingWallUnitTest_Normal_PrescribedVelocity.data
304  diff ../../../Source/Drivers/UnitTests/SelfTestData/movingWall.data MovingWallUnitTest_Normal_PrescribedPositionPrescribedVelocity.data
305  diff ../../../Source/Drivers/UnitTests/SelfTestData/movingWall.data MovingWallUnitTest_Normal_SimpleIntegration.data
306  diff ../../../Source/Drivers/UnitTests/SelfTestData/noMovingWall.data MovingWallUnitTest_Normal_Reference.data
307 
308  diff ../../../Source/Drivers/UnitTests/SelfTestData/movingWallTangential.data MovingWallUnitTest_Tangential_PrescribedPosition.data
309  diff ../../../Source/Drivers/UnitTests/SelfTestData/movingWallTangential.data MovingWallUnitTest_Tangential_PrescribedVelocity.data
310  diff ../../../Source/Drivers/UnitTests/SelfTestData/movingWallTangential.data MovingWallUnitTest_Tangential_PrescribedPositionPrescribedVelocity.data
311  diff ../../../Source/Drivers/UnitTests/SelfTestData/movingWallTangential.data MovingWallUnitTest_Tangential_SimpleIntegration.data
312  diff ../../../Source/Drivers/UnitTests/SelfTestData/noMovingWallTangential.data MovingWallUnitTest_Tangential_Reference.data
313  */
314 
315 
316  return 0;
317 }
void compareParticles(BaseParticle *Ptest, BaseParticle *Pref, double absError, Vec3D positionDifference, Vec3D velocityDifference, Vec3D orientationDifference, Vec3D AngularVelocityDifference)
void solve()
The work horse of the code.
Definition: DPMBase.cc:1895
In the reference case the particle just moves two times as fast.
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: Files.cc:149
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:878
In the reference case the particle just moves two times as fast.
T * getLastObject()
Gets a pointer to the last Object in this BaseHandler.
Definition: BaseHandler.h:452
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
Mdouble getTime() const
Access function for the time.
Definition: DPMBase.cc:158