LiquidMigrationPeriodicBoundaryUnitTest.cpp File Reference

Classes

class  LiquidMigrationPeriodicBoundaryInteraction
 

Functions

int main ()
 

Function Documentation

◆ main()

int main ( )
65 {
66  logger(INFO,"This unit test checks that liquid bridge migration is not affected by the slight inaccuracy created "
67  "by having ghost particles. A pair of particles is created that touches right at the periodic boundary.");
68 
69  logger(INFO,"Testing formation");
70 
72 
73  //set dpm properties
74  {
75  dpm.setName("LiquidMigrationPeriodicBoundaryInteraction");
76  dpm.setTimeStep(1e-4);
77  dpm.setTimeMax(5e-4);
78  dpm.setMin({0,-.5,-.5});
79  dpm.setMax({5,.5,.5});
80  dpm.setSaveCount(1);
81  dpm.setGravity({0,0,0});
82  }
83 
84  //add species
85  {
87  s.setDensity(6. / constants::pi);
88  s.setCollisionTimeAndRestitutionCoefficient(50*dpm.getTimeStep(), .9, 1);
89  s.setLiquidBridgeVolumeMax(1.1);
91  }
92 
93  //add boundary
94  {
96  b.set({1,0,0},-.5,4.5);
98  }
99 
100  //add particles
101  {
103  p.setRadius(.5);
104  p.setSpecies(dpm.speciesHandler.getLastObject());
105  p.setLiquidVolume(.5);
106 
107  p.setPosition({4,0,0});
109 
110  //p.setPosition({0,0,0});
111  p.setPosition({2*pow(2,-52),0,0}); //touches on left boundary, but not on right
113  }
114 
115  //solve should cause a bridge to form
116  Mdouble initialLiquidVolume = dpm.getLiquidVolume();
117  dpm.printTime();
118  dpm.solve();
119 
120  logger.assert_always(isEqual(dpm.getLiquidVolume(), initialLiquidVolume, 1e-14),
121  "Liquid Volume not conserved (%!=%)", dpm.getLiquidVolume(), initialLiquidVolume);
122 
123  logger(INFO,"Testing rupture");
124 
125  //move particles, causing a rupture
126  {
128  p->setPosition({3,0,0});
129  }
130 
131 
132  //solve should cause a bridge to rupture
133  dpm.setRestarted(true);
134  dpm.setTimeMax(2.0*dpm.getTimeMax());
135  dpm.printTime();
136  dpm.solve();
137 
138  logger.assert_always(isEqual(dpm.getLiquidVolume(), initialLiquidVolume, 1e-14),
139  "Liquid Volume not conserved (%!=%)", dpm.getLiquidVolume(), initialLiquidVolume);
140 
141 
142 
143  return 0;
144 }
LL< Log::INFO > INFO
Info log level.
Definition: Logger.cc:55
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
std::enable_if<!std::is_pointer< U >::value, U * >::type copyAndAddObject(const U &object)
Creates a copy of a Object and adds it to the BaseHandler.
Definition: BaseHandler.h:379
T * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:613
T * getLastObject()
Gets a pointer to the last Object in this BaseHandler.
Definition: BaseHandler.h:634
virtual void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
Definition: BaseInteractable.h:239
Definition: BaseParticle.h:54
void setSaveCount(unsigned int saveCount)
Sets File::saveCount_ for all files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:408
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1427
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 getTimeStep() const
Returns the simulation time step.
Definition: DPMBase.cc:1250
void setMin(const Vec3D &min)
Sets the minimum coordinates of the problem domain.
Definition: DPMBase.cc:1118
void setRestarted(bool newRestartedFlag)
Allows to set the flag stating if the simulation is to be restarted or not.
Definition: DPMBase.cc:1501
BoundaryHandler boundaryHandler
An object of the class BoundaryHandler which concerns insertion and deletion of particles into or fro...
Definition: DPMBase.h:1452
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created.
Definition: DPMBase.h:1437
void setTimeStep(Mdouble newDt)
Sets a new value for the simulation time step.
Definition: DPMBase.cc:1234
void setTimeMax(Mdouble newTMax)
Sets a new value for the maximum simulation duration.
Definition: DPMBase.cc:873
void solve()
The work horse of the code.
Definition: DPMBase.cc:4270
void setMax(const Vec3D &max)
Sets the maximum coordinates of the problem domain.
Definition: DPMBase.cc:1082
Mdouble getTimeMax() const
Returns the maximum simulation duration.
Definition: DPMBase.cc:888
void setGravity(Vec3D newGravity)
Sets a new value for the gravitational acceleration.
Definition: DPMBase.cc:1383
Definition: LiquidFilmParticle.h:36
void setLiquidVolume(Mdouble liquidVolume)
Definition: LiquidFilmParticle.h:108
Definition: LiquidMigrationPeriodicBoundaryUnitTest.cpp:31
Mdouble getLiquidVolume() const
Definition: LiquidMigrationPeriodicBoundaryUnitTest.cpp:55
void printTime() const override
Displays the current simulation time and the maximum simulation duration.
Definition: LiquidMigrationPeriodicBoundaryUnitTest.cpp:59
void setDensity(Mdouble density)
Definition: ParticleSpecies.cc:108
Defines a pair of periodic walls. Inherits from BaseBoundary.
Definition: PeriodicBoundary.h:41
void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight)
Defines a PeriodicBoundary by its normal and positions.
Definition: PeriodicBoundary.cc:84
Contains material and contact force properties.
Definition: Species.h:35
const Mdouble pi
Definition: ExtendedMath.h:45
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 DPMBase::boundaryHandler, BaseHandler< T >::copyAndAddObject(), BaseHandler< T >::getLastObject(), LiquidMigrationPeriodicBoundaryInteraction::getLiquidVolume(), BaseHandler< T >::getObject(), DPMBase::getTimeMax(), DPMBase::getTimeStep(), INFO, mathsFunc::isEqual(), logger, DPMBase::particleHandler, constants::pi, LiquidMigrationPeriodicBoundaryInteraction::printTime(), PeriodicBoundary::set(), ParticleSpecies::setDensity(), DPMBase::setGravity(), LiquidFilm< Particle >::setLiquidVolume(), DPMBase::setMax(), DPMBase::setMin(), DPMBase::setName(), BaseInteractable::setPosition(), DPMBase::setRestarted(), DPMBase::setSaveCount(), DPMBase::setTimeMax(), DPMBase::setTimeStep(), DPMBase::solve(), and DPMBase::speciesHandler.