InteractionHandlerSpeedTest.cpp File Reference

Classes

class  DPM
 In this file a cubic packing of 5^3 particles in a tri-axial box is created and allowed to settle under small gravity. After that Z statistics are calculated. More...
 

Functions

int main ()
 

Function Documentation

◆ main()

int main ( )
81 {
82  // create a simulation
83  DPM dpm;
84  // restart from initial condition; create them if they dont exist.
85  if (!dpm.readRestartFile("InteractionHandlerSpeedTestInit")) {
86  logger(ERROR,"Creating restart file first");
87  // create a initial simulation
88  unsigned n = 100000;
89  DPM dpm0;
90  dpm0.setName("InteractionHandlerSpeedTestInit");
91  dpm0.setDomain(Vec3D(0, 0, 0), cbrt(n) * 0.95 * Vec3D(1, 1, 1));
92  //dpm0.setGravity(Vec3D(0,0,-1));
93  dpm0.setTimeStep(1e-4);
94  dpm0.setTimeMax(10);
95  dpm0.setSaveCount(50);
96  // create species
98  species->setDensity(6.0/constants::pi);
99  species->setCollisionTimeAndRestitutionCoefficient(10 * dpm0.getTimeStep(), 0.1, 1.0);
100  // create walls
101  InfiniteWall wall(species);
102  wall.set(Vec3D(0,0,1), dpm0.getMax());
103  dpm0.wallHandler.copyAndAddObject(wall);
104  wall.set(Vec3D(0,0,-1), dpm0.getMin());
105  dpm0.wallHandler.copyAndAddObject(wall);
106  wall.set(Vec3D(0,1,0), dpm0.getMax());
107  dpm0.wallHandler.copyAndAddObject(wall);
108  wall.set(Vec3D(0, -1, 0), dpm0.getMin());
109  dpm0.wallHandler.copyAndAddObject(wall);
110  wall.set(Vec3D(1, 0, 0), dpm0.getMax());
111  dpm0.wallHandler.copyAndAddObject(wall);
112  wall.set(Vec3D(-1, 0, 0), dpm0.getMin());
113  dpm0.wallHandler.copyAndAddObject(wall);
114  // create particles
115  SphericalParticle particle(species);
116  CubeInsertionBoundary insertionBoundary;
117  insertionBoundary.set(particle, 1e6, dpm0.getMin(), dpm0.getMax(), {0, 0, 0}, {0, 0, 0});
118  insertionBoundary.setInitialVolume((n - 0.5) * constants::pi / 6.);
119  insertionBoundary.checkBoundaryBeforeTimeStep(&dpm0);
120  logger(INFO, "Number of particles: %", dpm0.particleHandler.getSize());
121  //solve
122  dpm0.solve();
123  if (!dpm.readRestartFile("InteractionHandlerSpeedTestInit"))
124  {
125  logger(ERROR, "Restart file could not be created");
126  }
127  }
128 
129  //rename simulation
130  dpm.setName("InteractionHandlerSpeedTest");
131  dpm.setTime(0);
132  //simulate 0 time steps
133  dpm.setTimeMax(0);
134  dpm.setHGridMaxLevels(1);
136  dpm.solve();
138  dpm.computeAllForces();
139  Time timer;
140  int repetitions = 10;
141  logger(INFO,"% interactions",dpm.interactionHandler.getNumberOfObjects());
142  dpm.hGridInfo(std::cout);
143 
144 
145  //timings
146  timer.tic();
147  for (int i = 0; i < repetitions; ++i) {
149  dpm.computeAllForces();
150  }
151  logger(INFO, "Time to simulate contact detection and force computation for % non-existing contacts: % s",dpm.interactionHandler.getNumberOfObjects(), timer.toctic());
152 
153  for (int i = 0; i < repetitions; ++i) {
154  dpm.computeAllForces();
155  }
156  logger(INFO, "Time to simulate contact detection and force computation for % existing contacts: % s",dpm.interactionHandler.getNumberOfObjects(), timer.toctic());
157 
158  for (int i = 0; i < repetitions; ++i) {
160  }
161  logger(INFO, "Time to simulate force computation for % existing contacts: % s",dpm.interactionHandler.getNumberOfObjects(), timer.toctic());
162 
163  return 0;
164 }
const unsigned n
Definition: CG3DPackingUnitTest.cpp:32
@ NO_FILE
file will not be created/read
Species< LinearViscoelasticNormalSpecies > LinearViscoelasticSpecies
Definition: LinearViscoelasticSpecies.h:33
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
virtual unsigned int getNumberOfObjects() const
Gets the number of real Object in this BaseHandler. (i.e. no mpi or periodic particles)
Definition: BaseHandler.h:648
virtual void clear()
Empties the whole BaseHandler by removing all Objects and setting all other variables to 0.
Definition: BaseHandler.h:528
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
unsigned int getSize() const
Gets the size of the particleHandler (including mpi and periodic particles)
Definition: BaseHandler.h:655
It's an insertion boundary which has cuboidal shape (yes, 'CuboidalInsertionBoundary' would have been...
Definition: CubeInsertionBoundary.h:42
void set(BaseParticle *particleToCopy, unsigned int maxFailed, Vec3D posMin, Vec3D posMax, Vec3D velMin={0, 0, 0}, Vec3D velMax={0, 0, 0})
Sets the properties of the InsertionBoundary for mutliple different particle types.
Definition: CubeInsertionBoundary.cc:107
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 setDomain(const Vec3D &min, const Vec3D &max)
Sets the minimum coordinates of the problem domain.
Definition: DPMBase.cc:1098
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
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1447
Vec3D getMax() const
Definition: DPMBase.h:670
void setFileType(FileType fileType)
Sets File::fileType_ for all files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:459
Vec3D getMin() const
Definition: DPMBase.h:664
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1467
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 setTime(Mdouble time)
Sets a new value for the current simulation time.
Definition: DPMBase.cc:836
bool readRestartFile(ReadOptions opt=ReadOptions::ReadAll)
Reads all the particle data corresponding to a given, existing . restart file (for more details regar...
Definition: DPMBase.cc:3006
In this file a cubic packing of 5^3 particles in a tri-axial box is created and allowed to settle und...
Definition: HGridUpdateUnitTest.cpp:30
void computeAllForcesNoHGrid()
Definition: InteractionHandlerSpeedTest.cpp:46
void computeAllForces() override
Computes all the forces acting on the particles using the BaseInteractable::setForce() and BaseIntera...
Definition: InteractionHandlerSpeedTest.cpp:42
A infinite wall fills the half-space {point: (position_-point)*normal_<=0}.
Definition: InfiniteWall.h:48
void checkBoundaryBeforeTimeStep(DPMBase *md) override
Fills the boundary with particles.
Definition: InsertionBoundary.cc:184
void setInitialVolume(Mdouble initialVolume)
Gets the Volume which should be inserted by the insertion routine.
Definition: InsertionBoundary.cc:643
void hGridInfo(std::ostream &os=std::cout) const
Writes the info of the HGrid to the screen in a nice format.
Definition: MercuryBase.cc:655
void setHGridMaxLevels(unsigned int HGridMaxLevels)
Sets the maximum number of levels of the HGrid in this MercuryBase.
Definition: MercuryBase.cc:476
A spherical particle is the most simple particle used in MercuryDPM.
Definition: SphericalParticle.h:37
Allows for timing the algorithms; accurate up to 0.01 sec.
Definition: MercuryTime.h:46
Mdouble toctic()
Outputs the toc value and resets the start time.
Definition: MercuryTime.h:96
void tic()
This is like a start button of a stopwatch. Assigns the variable start with the current number of clo...
Definition: MercuryTime.h:59
Definition: Vector.h:51
const Mdouble pi
Definition: ExtendedMath.h:45
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51

References InsertionBoundary::checkBoundaryBeforeTimeStep(), BaseHandler< T >::clear(), DPM::computeAllForces(), DPM::computeAllForcesNoHGrid(), BaseHandler< T >::copyAndAddObject(), ERROR, DPMBase::getMax(), DPMBase::getMin(), BaseHandler< T >::getNumberOfObjects(), BaseHandler< T >::getSize(), DPMBase::getTimeStep(), MercuryBase::hGridInfo(), constants::i, INFO, DPMBase::interactionHandler, logger, n, NO_FILE, DPMBase::particleHandler, constants::pi, DPMBase::readRestartFile(), CubeInsertionBoundary::set(), InfiniteWall::set(), DPMBase::setDomain(), DPMBase::setFileType(), MercuryBase::setHGridMaxLevels(), InsertionBoundary::setInitialVolume(), DPMBase::setName(), DPMBase::setSaveCount(), DPMBase::setTime(), DPMBase::setTimeMax(), DPMBase::setTimeStep(), DPMBase::solve(), DPMBase::speciesHandler, Time::tic(), Time::toctic(), and DPMBase::wallHandler.