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.

40  {
41  // create dpm setup, set necessary variables (time step, domain, name, species)
42  Mercury2D dpm;
43  dpm.setTimeStep(1e-4);
44  dpm.setDomain({0,0,0},{10,10,0});
45  dpm.setName("FindParticles");
46 
47  // define and add species to dpm
49  species.setDensity(6.0 / pi);
50  species.setCollisionTimeAndRestitutionCoefficient(1.0, 1.0, 1.0);
51  dpm.speciesHandler.copyAndAddObject(species);
52 
53  // define an insertion boundary and use it to insert particles;
54  // note, the boundary is not added to the dpm, it is only used to insert particles initially
55  SphericalParticle particle;
56  particle.setSpecies(dpm.speciesHandler.getLastObject());
57  particle.setRadius(0.1);
58  int maxFailed = 100;
59  Vec3D posMin = dpm.getMin();
60  Vec3D posMax = dpm.getMax();
61  Vec3D velMin = {0, 0, 0};
62  Vec3D velMax = {0, 0, 0};
63  CubeInsertionBoundary insertionBoundary;
64  insertionBoundary.set(&particle, maxFailed, posMin, posMax, velMin, velMax);
65  //insertionBoundary.setVolumeFlowRate(10);
66  insertionBoundary.checkBoundaryBeforeTimeStep(&dpm);
67  logger(INFO,"number of particles % ",dpm.particleHandler.getNumberOfObjects());
68 
69  // use a search particle to find all particles close to the center of the domain, and give those particles a velocity
70  SphericalParticle searchParticle;
71  searchParticle.setSpecies(dpm.speciesHandler.getLastObject());
72  searchParticle.setRadius(3);
73  searchParticle.setPosition({5,5,0});
74  auto particlesInContact = dpm.hGridFindParticleContacts(&searchParticle);
75  for (auto p : particlesInContact) {
76  p->setVelocity({1,0,0});
77  }
78  logger(INFO,"number of particles in contact with the search particle %",particlesInContact.size());
79 
80  //run the dpm to create the output files; it can be seen in the output that the particles in the center have velocity
81  dpm.solve();
82  logger(INFO,"All particles in contact to the search particle have a different velocity, see findCloseParticles.xballs");
83 
84  return 0;
85 }
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.
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
T * getLastObject()
Gets a pointer to the last Object in this BaseHandler.
Definition: BaseHandler.h:634
virtual void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
Definition: BaseInteractable.h:239
virtual void setRadius(Mdouble radius)
Sets the particle's radius_ (and adjusts the mass_ accordingly, based on the particle's species)
Definition: BaseParticle.cc:553
void setSpecies(const ParticleSpecies *species)
Definition: BaseParticle.cc:818
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
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
Vec3D getMax() const
Definition: DPMBase.h:670
Vec3D getMin() const
Definition: DPMBase.h:664
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 solve()
The work horse of the code.
Definition: DPMBase.cc:4270
void checkBoundaryBeforeTimeStep(DPMBase *md) override
Fills the boundary with particles.
Definition: InsertionBoundary.cc:184
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:212
This adds on the hierarchical grid code for 2D problems.
Definition: Mercury2D.h:36
std::vector< BaseParticle * > hGridFindParticleContacts(const BaseParticle *obj) override
Returns all particles that have a contact with a given particle.
Definition: Mercury2D.cc:498
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:1325
void setDensity(Mdouble density)
Definition: ParticleSpecies.cc:108
A spherical particle is the most simple particle used in MercuryDPM.
Definition: SphericalParticle.h:37
Definition: Vector.h:51
const Mdouble pi
Definition: ExtendedMath.h:45

References InsertionBoundary::checkBoundaryBeforeTimeStep(), BaseHandler< T >::copyAndAddObject(), BaseHandler< T >::getLastObject(), DPMBase::getMax(), DPMBase::getMin(), ParticleHandler::getNumberOfObjects(), Mercury2D::hGridFindParticleContacts(), INFO, logger, 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.