FindParticlesSelfTest.cpp File Reference

Functions

int main ()
 This tests the hGridFindParticleContacts routine. More...
 

Function Documentation

◆ main()

int main ( )

This tests the hGridFindParticleContacts routine.

Particle are inserted into a square domain using an insertion boundary. Then we find all particles close to the center and give them a velocity.

19  {
20  // create dpm setup, set necessary variables (time step, domain, name, species)
21  Mercury2D dpm;
22  dpm.setTimeStep(1e-4);
23  dpm.setDomain({0,0,0},{10,10,0});
24  dpm.setName("FindParticles");
25 
26  // define and add species to dpm
28  species.setDensity(6.0 / pi);
29  species.setCollisionTimeAndRestitutionCoefficient(1.0, 1.0, 1.0);
30  dpm.speciesHandler.copyAndAddObject(species);
31 
32  // define an insertion boundary and use it to insert particles;
33  // note, the boundary is not added to the dpm, it is only used to insert particles initially
34  SphericalParticle particle;
35  particle.setSpecies(dpm.speciesHandler.getLastObject());
36  particle.setRadius(0.1);
37  int maxFailed = 100;
38  Vec3D posMin = dpm.getMin();
39  Vec3D posMax = dpm.getMax();
40  Vec3D velMin = {0, 0, 0};
41  Vec3D velMax = {0, 0, 0};
42  CubeInsertionBoundary insertionBoundary;
43  insertionBoundary.set(&particle, maxFailed, posMin, posMax, velMin, velMax);
44  //insertionBoundary.setVolumeFlowRate(10);
45  insertionBoundary.checkBoundaryBeforeTimeStep(&dpm);
46  logger(INFO,"number of particles % ",dpm.particleHandler.getNumberOfObjects());
47 
48  // use a search particle to find all particles close to the center of the domain, and give those particles a velocity
49  SphericalParticle searchParticle;
50  searchParticle.setSpecies(dpm.speciesHandler.getLastObject());
51  searchParticle.setRadius(3);
52  searchParticle.setPosition({5,5,0});
53  auto particlesInContact = dpm.hGridFindParticleContacts(&searchParticle);
54  for (auto p : particlesInContact) {
55  p->setVelocity({1,0,0});
56  }
57  logger(INFO,"number of particles in contact with the search particle %",particlesInContact.size());
58 
59  //run the dpm to create the output files; it can be seen in the output that the particles in the center have velocity
60  dpm.solve();
61  logger(INFO,"All particles in contact to the search particle have a different velocity, see findCloseParticles.xballs");
62 
63  return 0;
64 }
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.
float * p
Definition: Tutorial_Map_using.cpp:9
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:360
T * getLastObject()
Gets a pointer to the last Object in this BaseHandler.
Definition: BaseHandler.h:642
virtual void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
Definition: BaseInteractable.h:218
virtual void setRadius(Mdouble radius)
Sets the particle's radius_ (and adjusts the mass_ accordingly, based on the particle's species)
Definition: BaseParticle.cc:548
virtual void setSpecies(const ParticleSpecies *species)
Definition: BaseParticle.cc:798
It's an insertion boundary which has cuboidal shape (yes, 'CuboidalInsertionBoundary' would have been...
Definition: CubeInsertionBoundary.h:21
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:86
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1433
void setDomain(const Vec3D &min, const Vec3D &max)
Sets the minimum coordinates of the problem domain.
Definition: DPMBase.cc:1089
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:400
Vec3D getMax() const
Returns the maximum coordinates of the problem domain.
Definition: DPMBase.h:659
Vec3D getMin() const
Returns the minimum coordinates of the problem domain.
Definition: DPMBase.h:653
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 solve()
The work horse of the code.
Definition: DPMBase.cc:4334
void checkBoundaryBeforeTimeStep(DPMBase *md) override
Fills the boundary with particles.
Definition: InsertionBoundary.cc:163
void setCollisionTimeAndRestitutionCoefficient(Mdouble tc, Mdouble eps, BaseParticle *p)
Sets k, disp such that it matches a given tc and eps for a collision of two copies of particle p.
Definition: LinearViscoelasticNormalSpecies.cc:191
This adds on the hierarchical grid code for 2D problems.
Definition: Mercury2D.h:15
std::vector< BaseParticle * > hGridFindParticleContacts(const BaseParticle *obj) override
Returns all particles that have a contact with a given particle.
Definition: Mercury2D.cc:477
unsigned int getNumberOfObjects() const override
Returns the number of objects in the container. In parallel code this practice is forbidden to avoid ...
Definition: ParticleHandler.cc:1323
void setDensity(Mdouble density)
Definition: ParticleSpecies.cc:88
A spherical particle is the most simple particle used in MercuryDPM.
Definition: SphericalParticle.h:16
Definition: Kernel/Math/Vector.h:30
#define INFO(i)
Definition: mumps_solver.h:54
const Mdouble pi
Definition: ExtendedMath.h:23

References InsertionBoundary::checkBoundaryBeforeTimeStep(), BaseHandler< T >::copyAndAddObject(), e(), BaseHandler< T >::getLastObject(), DPMBase::getMax(), DPMBase::getMin(), ParticleHandler::getNumberOfObjects(), Mercury2D::hGridFindParticleContacts(), INFO, logger, p, DPMBase::particleHandler, constants::pi, CubeInsertionBoundary::set(), LinearViscoelasticNormalSpecies::setCollisionTimeAndRestitutionCoefficient(), ParticleSpecies::setDensity(), DPMBase::setDomain(), DPMBase::setName(), BaseInteractable::setPosition(), BaseParticle::setRadius(), BaseParticle::setSpecies(), DPMBase::setTimeStep(), DPMBase::solve(), and DPMBase::speciesHandler.