ScrewUnitTest.cpp File Reference

Functions

int main ()
 

Function Documentation

◆ main()

int main ( )

Testing if screw geometry is implemented well

33 {
34  Mercury3D dpm;
35 
37  species.setDensity(1);
38  species.setStiffness(1);
39  auto s = dpm.speciesHandler.copyAndAddObject(species);
40 
41  Screw screw({0,0,0}, 1, 1, 1, 0, .1, ScrewType::singleHelix);
42  screw.setSpecies(s);
43  auto w = dpm.wallHandler.copyAndAddObject(screw);
44 
45  dpm.setDomain({-0.2,-1,-1},{1.2,1,1});
46  dpm.setTimeStep(1e-12);
47  dpm.setTimeMax(dpm.getTimeStep());
48  dpm.setName("ScrewUnitTest");
49  dpm.setParticlesWriteVTK(true);
50  dpm.wallHandler.setWriteVTK(true);
51 
52  Mdouble h = 0.05;
53  Mdouble distance;
54  Vec3D normal;
55  SphericalParticle particle(s);
56  particle.setRadius(0.5*h);
57  for (Mdouble x = dpm.getXMin(); x<dpm.getXMax(); x+=h) {
58  for (Mdouble y = dpm.getYMin(); y<dpm.getYMax(); y+=h) {
59  for (Mdouble z = dpm.getZMin(); z<dpm.getZMax(); z+=h)
60  {
61  particle.setPosition({x, y, z});
62  if (w->getDistanceAndNormal(particle,distance,normal))
63  {
64  dpm.particleHandler.copyAndAddObject(particle);
65  //logger(INFO,"p %",particle.getPosition());
66  }
67  }
68  }
69  }
70  logger(INFO,"Inserted % particles",dpm.particleHandler.getSize());
71 
72  //dpm.solve();
73  helpers::check(dpm.particleHandler.getSize(),8213,0,"Screw surface was wrongly detected");
74 
75  return 0;
76 }
double Mdouble
Definition: GeneralDefine.h:34
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
unsigned int getSize() const
Gets the size of the particleHandler (including mpi and periodic particles)
Definition: BaseHandler.h:655
void setSpecies(const ParticleSpecies *species)
Defines the species of the current wall.
Definition: BaseWall.cc:169
Mdouble getXMin() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMin() returns XMin.
Definition: DPMBase.h:619
Mdouble getXMax() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMax() returns XMax.
Definition: DPMBase.h:626
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
Mdouble getYMin() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMin() returns YMin.
Definition: DPMBase.h:632
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
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created.
Definition: DPMBase.h:1437
void setParticlesWriteVTK(bool writeParticlesVTK)
Sets whether particles are written in a VTK file.
Definition: DPMBase.cc:942
Mdouble getYMax() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMax() returns XMax.
Definition: DPMBase.h:638
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
Mdouble getZMax() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMax() returns ZMax.
Definition: DPMBase.h:650
Mdouble getZMin() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMin() returns ZMin.
Definition: DPMBase.h:644
void setStiffness(Mdouble new_k)
Allows the spring constant to be changed.
Definition: LinearViscoelasticNormalSpecies.cc:93
This adds on the hierarchical grid code for 3D problems.
Definition: Mercury3D.h:37
void setDensity(Mdouble density)
Definition: ParticleSpecies.cc:108
This function defines an Archimedes' screw in the z-direction from a (constant) starting point,...
Definition: Screw.h:44
A spherical particle is the most simple particle used in MercuryDPM.
Definition: SphericalParticle.h:37
Definition: Vector.h:51
void setWriteVTK(FileType)
Sets whether walls are written into a VTK file.
Definition: WallHandler.cc:467
void check(double real, double ideal, double error, std::string errorMessage)
Definition: TestHelpers.cc:37

References helpers::check(), BaseHandler< T >::copyAndAddObject(), BaseHandler< T >::getSize(), DPMBase::getTimeStep(), DPMBase::getXMax(), DPMBase::getXMin(), DPMBase::getYMax(), DPMBase::getYMin(), DPMBase::getZMax(), DPMBase::getZMin(), INFO, logger, DPMBase::particleHandler, ParticleSpecies::setDensity(), DPMBase::setDomain(), DPMBase::setName(), DPMBase::setParticlesWriteVTK(), BaseInteractable::setPosition(), BaseParticle::setRadius(), BaseWall::setSpecies(), LinearViscoelasticNormalSpecies::setStiffness(), DPMBase::setTimeMax(), DPMBase::setTimeStep(), WallHandler::setWriteVTK(), singleHelix, DPMBase::speciesHandler, and DPMBase::wallHandler.