MercuryDPM  0.11
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HGridUnitTest.cpp File Reference

Go to the source code of this file.

Classes

class  MD_demo
 
class  HGrid_demo
 

Functions

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

Function Documentation

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

Definition at line 163 of file HGridUnitTest.cpp.

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

164 {
165  MD_demo MD_problem;
166  MD_problem.species->setDensity(2000);
167 
168  MD_problem.omega = 40;
169  MD_problem.alpha = -2;
170  MD_problem.nu = 0.7;
171  MD_problem.N = 1000;
172  MD_problem.setSystemDimensions(3);
173  MD_problem.setParticleDimensions(3);
174  MD_problem.setName("HGridUnitTest_MD");
175  MD_problem.setTimeStep(0.1);
176  MD_problem.setTimeMax(0.09);
177  MD_problem.setSaveCount(1);
178  MD_problem.setupInitialConditions();
179 
180  HGrid_demo HGrid_problem1(MD_problem);
181  HGrid_problem1.setHGridMethod(TOPDOWN);
182  HGrid_problem1.setHGridMaxLevels(3);
183  HGrid_problem1.setHGridDistribution(EXPONENTIAL);
184  HGrid_problem1.setName("HGridUnitTest_HGrid1");
185 
186  HGrid_demo HGrid_problem2(MD_problem);
187  HGrid_problem2.setHGridMethod(BOTTOMUP);
188  HGrid_problem2.setHGridMaxLevels(8);
189  HGrid_problem2.setHGridDistribution(LINEAR);
190  HGrid_problem2.setName("HGridUnitTest_HGrid2");
191 
192  std::cout << "Solving the MD problem" << std::endl;
193  MD_problem.solve();
194  std::cout << "Solving the first HGrid problem" << std::endl;
195  HGrid_problem1.solve();
196  std::cout << "Solving the second HGrid problem" << std::endl;
197  HGrid_problem2.solve();
198 
199  // Check the particles are in the same place for all three problem i.e. no HGrid and two different HGrid settings
200  std::vector<BaseParticle*>::iterator hGrid1It = HGrid_problem1.particleHandler.begin();
201  std::vector<BaseParticle*>::iterator hGrid2It = HGrid_problem2.particleHandler.begin();
202  for (std::vector<BaseParticle*>::iterator mdIt = MD_problem.particleHandler.begin(); mdIt != MD_problem.particleHandler.end(); ++mdIt)
203  {
204  if (!(*mdIt)->getPosition().isEqualTo((*hGrid1It)->getPosition(),1e-10))
205  {
206  exit(-1);
207  }
208  if (!(*mdIt)->getPosition().isEqualTo((*hGrid2It)->getPosition(), 1e-10))
209  {
210  exit(-1);
211  }
212  ++hGrid1It;
213  ++hGrid2It;
214  }
215 }
void solve()
The work horse of the code.
Definition: DPMBase.cc:1895
void setTimeMax(Mdouble newTMax)
Allows the upper time limit to be changed.
Definition: DPMBase.cc:179
const std::vector< T * >::const_iterator end() const
Gets the end of the const_iterator over all BaseBoundary in this BaseHandler.
Definition: BaseHandler.h:494
void setParticleDimensions(unsigned int particleDimensions)
Allows the dimension of the particle (f.e. for mass) to be changed. e.g. discs or spheres...
Definition: DPMBase.cc:474
void setSystemDimensions(unsigned int newDim)
Allows for the dimension of the simulation to be changed.
Definition: DPMBase.cc:453
const std::vector< T * >::const_iterator begin() const
Gets the begin of the const_iterator over all Object in this BaseHandler.
Definition: BaseHandler.h:482
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
void setupInitialConditions()
This function allows to set the initial conditions for our problem to be solved, by default particle ...
void setDensity(Mdouble density)
Allows the density to be changed.
void setSaveCount(unsigned int saveCount)
Sets File::saveCount_ for all files (ene, data, fstat, restart, stat)
Definition: Files.cc:138
double alpha
unsigned int N
void setTimeStep(Mdouble newDt)
Allows the time step dt to be changed.
Definition: DPMBase.cc:353
double omega
LinearViscoelasticSpecies * species