HGridUnitTest.cpp File Reference

Classes

class  MD_demo
 
class  HGrid_demo
 

Functions

int main (int argc UNUSED, char *argv[] UNUSED)
 

Function Documentation

◆ main()

int main ( int argc  UNUSED,
char *argv[]  UNUSED 
)
162 {
163  MD_demo MD_problem;
164  MD_problem.species->setDensity(2000);
165 
166  MD_problem.omega = 40;
167  MD_problem.alpha = -2;
168  MD_problem.nu = 0.7;
169  MD_problem.N = 1000;
170  MD_problem.setSystemDimensions(3);
171  MD_problem.setParticleDimensions(3);
172  MD_problem.setName("HGridUnitTest_MD");
173  MD_problem.setTimeStep(0.1);
174  MD_problem.setTimeMax(0.09);
175  MD_problem.setSaveCount(1);
176  MD_problem.setupInitialConditions();
177 
178  HGrid_demo HGrid_problem1(MD_problem);
179  HGrid_problem1.setHGridMethod(TOPDOWN);
180  HGrid_problem1.setHGridMaxLevels(3);
181  HGrid_problem1.setHGridDistribution(EXPONENTIAL);
182  HGrid_problem1.setName("HGridUnitTest_HGrid1");
183 
184  HGrid_demo HGrid_problem2(MD_problem);
185  HGrid_problem2.setHGridMethod(BOTTOMUP);
186  HGrid_problem2.setHGridMaxLevels(8);
187  HGrid_problem2.setHGridDistribution(LINEAR);
188  HGrid_problem2.setName("HGridUnitTest_HGrid2");
189 
190  logger(INFO, "Solving the MD problem");
191  MD_problem.solve();
192  logger(INFO, "Solving the first HGrid problem");
193  HGrid_problem1.solve();
194  logger(INFO, "Solving the second HGrid problem");
195  HGrid_problem2.solve();
196 
197  // Check the particles are in the same place for all three problem i.e. no HGrid and two different HGrid settings
198  const double tolerance = 1e-10;
199  std::vector<BaseParticle*>::iterator hGrid1It = HGrid_problem1.particleHandler.begin();
200  std::vector<BaseParticle*>::iterator hGrid2It = HGrid_problem2.particleHandler.begin();
201  for(BaseParticle* particle : MD_problem.particleHandler)
202  {
203  if (!(particle->getPosition().isEqualTo((*hGrid1It)->getPosition(), tolerance)))
204  {
205  logger(ERROR, "position of particle in hGrid 1 is not equal to the position without hGrid");
206  }
207  if (!(particle->getPosition().isEqualTo((*hGrid2It)->getPosition(), tolerance)))
208  {
209  logger(ERROR, "position of particle in hGrid 2 is not equal to the position without hGrid");
210  }
211  ++hGrid1It;
212  ++hGrid2It;
213  }
214 }
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.
LL< Log::ERROR > ERROR
Error log level.
Definition: Logger.cc:53
@ EXPONENTIAL
Definition: MercuryBase.h:85
@ LINEAR
Definition: MercuryBase.h:85
@ BOTTOMUP
Definition: MercuryBase.h:45
@ TOPDOWN
Definition: MercuryBase.h:45
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Definition: BaseInteractable.h:218
Definition: BaseParticle.h:54
void setSaveCount(unsigned int saveCount)
Sets File::saveCount_ for all files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:408
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:422
void setParticleDimensions(unsigned int particleDimensions)
Sets the particle dimensionality.
Definition: DPMBase.cc:1448
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 setSystemDimensions(unsigned int newDim)
Sets the system dimensionality.
Definition: DPMBase.cc:1417
void solve()
The work horse of the code.
Definition: DPMBase.cc:4270
Definition: HGridUnitTest.cpp:153
Definition: HGridUnitTest.cpp:31
unsigned int N
Definition: HGridUnitTest.cpp:148
void setupInitialConditions() override
This function allows to set the initial conditions for our problem to be solved, by default particle ...
Definition: HGridUnitTest.cpp:40
double alpha
Definition: HGridUnitTest.cpp:146
LinearViscoelasticSpecies * species
Definition: HGridUnitTest.cpp:149
double omega
Definition: HGridUnitTest.cpp:145
double nu
Definition: HGridUnitTest.cpp:147
void setDensity(Mdouble density)
Definition: ParticleSpecies.cc:108
bool isEqualTo(const Vec3D &other, double tol) const
Checks if the length this Vec3D is equal the length of other with a certain tolerance.
Definition: Vector.cc:294

References MD_demo::alpha, BaseHandler< T >::begin(), BOTTOMUP, ERROR, EXPONENTIAL, BaseInteractable::getPosition(), INFO, Vec3D::isEqualTo(), LINEAR, logger, MD_demo::N, MD_demo::nu, MD_demo::omega, DPMBase::particleHandler, ParticleSpecies::setDensity(), MercuryBase::setHGridDistribution(), MercuryBase::setHGridMaxLevels(), MercuryBase::setHGridMethod(), DPMBase::setName(), DPMBase::setParticleDimensions(), DPMBase::setSaveCount(), DPMBase::setSystemDimensions(), DPMBase::setTimeMax(), DPMBase::setTimeStep(), MD_demo::setupInitialConditions(), DPMBase::solve(), MD_demo::species, and TOPDOWN.