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 
)
141 {
142  MD_demo MD_problem;
143  MD_problem.species->setDensity(2000);
144 
145  MD_problem.omega = 40;
146  MD_problem.alpha = -2;
147  MD_problem.nu = 0.7;
148  MD_problem.N = 1000;
149  MD_problem.setSystemDimensions(3);
150  MD_problem.setParticleDimensions(3);
151  MD_problem.setName("HGridUnitTest_MD");
152  MD_problem.setTimeStep(0.1);
153  MD_problem.setTimeMax(0.09);
154  MD_problem.setSaveCount(1);
155  MD_problem.setupInitialConditions();
156 
157  HGrid_demo HGrid_problem1(MD_problem);
158  HGrid_problem1.setHGridMethod(TOPDOWN);
159  HGrid_problem1.setHGridMaxLevels(3);
160  HGrid_problem1.setHGridDistribution(EXPONENTIAL);
161  HGrid_problem1.setName("HGridUnitTest_HGrid1");
162 
163  HGrid_demo HGrid_problem2(MD_problem);
164  HGrid_problem2.setHGridMethod(BOTTOMUP);
165  HGrid_problem2.setHGridMaxLevels(8);
166  HGrid_problem2.setHGridDistribution(LINEAR);
167  HGrid_problem2.setName("HGridUnitTest_HGrid2");
168 
169  logger(INFO, "Solving the MD problem");
170  MD_problem.solve();
171  logger(INFO, "Solving the first HGrid problem");
172  HGrid_problem1.solve();
173  logger(INFO, "Solving the second HGrid problem");
174  HGrid_problem2.solve();
175 
176  // Check the particles are in the same place for all three problem i.e. no HGrid and two different HGrid settings
177  const double tolerance = 1e-10;
178  std::vector<BaseParticle*>::iterator hGrid1It = HGrid_problem1.particleHandler.begin();
179  std::vector<BaseParticle*>::iterator hGrid2It = HGrid_problem2.particleHandler.begin();
180  for(BaseParticle* particle : MD_problem.particleHandler)
181  {
182  if (!(particle->getPosition().isEqualTo((*hGrid1It)->getPosition(), tolerance)))
183  {
184  logger(ERROR, "position of particle in hGrid 1 is not equal to the position without hGrid");
185  }
186  if (!(particle->getPosition().isEqualTo((*hGrid2It)->getPosition(), tolerance)))
187  {
188  logger(ERROR, "position of particle in hGrid 2 is not equal to the position without hGrid");
189  }
190  ++hGrid1It;
191  ++hGrid2It;
192  }
193 }
Array< double, 1, 3 > e(1./3., 0.5, 2.)
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:32
@ EXPONENTIAL
Definition: MercuryBase.h:64
@ LINEAR
Definition: MercuryBase.h:64
@ BOTTOMUP
Definition: MercuryBase.h:24
@ TOPDOWN
Definition: MercuryBase.h:24
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Definition: BaseInteractable.h:197
Definition: BaseParticle.h:33
void setSaveCount(unsigned int saveCount)
Sets File::saveCount_ for all files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:386
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:400
void setParticleDimensions(unsigned int particleDimensions)
Sets the particle dimensionality.
Definition: DPMBase.cc:1439
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created.
Definition: DPMBase.h:1443
void setTimeStep(Mdouble newDt)
Sets a new value for the simulation time step.
Definition: DPMBase.cc:1225
void setTimeMax(Mdouble newTMax)
Sets a new value for the maximum simulation duration.
Definition: DPMBase.cc:864
void setSystemDimensions(unsigned int newDim)
Sets the system dimensionality.
Definition: DPMBase.cc:1408
void solve()
The work horse of the code.
Definition: DPMBase.cc:4334
Definition: HGridUnitTest.cpp:132
Definition: HGridUnitTest.cpp:10
unsigned int N
Definition: HGridUnitTest.cpp:127
void setupInitialConditions() override
This function allows to set the initial conditions for our problem to be solved, by default particle ...
Definition: HGridUnitTest.cpp:19
double alpha
Definition: HGridUnitTest.cpp:125
LinearViscoelasticSpecies * species
Definition: HGridUnitTest.cpp:128
double omega
Definition: HGridUnitTest.cpp:124
double nu
Definition: HGridUnitTest.cpp:126
void setDensity(Mdouble density)
Definition: ParticleSpecies.cc:88
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:313
#define INFO(i)
Definition: mumps_solver.h:54

References MD_demo::alpha, BaseHandler< T >::begin(), BOTTOMUP, e(), 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.