NurbsWallUnitTest.cpp File Reference

Functions

int main ()
 

Function Documentation

◆ main()

int main ( )
35 {
36  //define quarter circle as nurbs surface
37  std::vector<double> knotsU = {0,0,0,1,1,1};
38  std::vector<double> knotsV = {0,0,1,1};
39  std::vector<std::vector<Vec3D>> controlPoints = {{{1,0,0},{1,0,2}},{{1,1,0},{1,1,2}},{{0,1,0},{0,1,2}}} ;
40  std::vector<std::vector<Mdouble>> weights = {{1,1},{1,1},{2,2}};
41  NurbsSurface nurbsSurface(knotsU,knotsV,controlPoints,weights);
42 
43  //create a basic dpm class
44  DPMBase dpm;
45  dpm.setName("NurbsSurfaceUnitTest");
47 
48  //define nurbs wall and add to dpm class
49  NurbsWall nurbsWall;
50  nurbsWall.setSpecies(s);
51  nurbsWall.set(nurbsSurface);
52  auto w = dpm.wallHandler.copyAndAddObject(nurbsWall);
53 
54  SphericalParticle particle;
55  particle.setSpecies(s);
56  particle.setRadius(.99);
57  for (double x=-.5; x<=4.5; x+=.125) {
58  for (double z = -.5; z <= 2.5; z += .5) {
59  particle.setPosition({x, 2-x, z});
60  dpm.particleHandler.copyAndAddObject(particle);
61  }
62  }
63 
64  //test if contact can be found
65  Vec3D normal;
66  double distance;
67  std::stringstream ss;
68  for (auto p : dpm.particleHandler) {
69  if (w->getDistanceAndNormal(*p, distance, normal)) {
70  p->setPosition(distance * normal + p->getPosition());
71  ss << p->getPosition() << '\t' << distance << '\t' << distance * normal + p->getPosition() << '\n';
72  } else {
73  p->setPosition({0,0,0});
74  }
75  }
76  helpers::writeToFile("NurbsWallUnitTest.txt",ss.str());
77 
78  //write vtk file
79  dpm.setName("NurbsWallUnitTest");
81  dpm.setParticlesWriteVTK(true);
83 
84  return 0;
85 }
@ ONE_FILE
all data will be written into/ read from a single file called name_
Species< LinearViscoelasticNormalSpecies > LinearViscoelasticSpecies
Definition: LinearViscoelasticSpecies.h:33
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
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
void setSpecies(const ParticleSpecies *species)
Defines the species of the current wall.
Definition: BaseWall.cc:169
The DPMBase header includes quite a few header files, defining all the handlers, which are essential....
Definition: DPMBase.h:77
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1427
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:422
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
void forceWriteOutputFiles()
Writes output files immediately, even if the current time step was not meant to be written....
Definition: DPMBase.cc:4028
Definition: NurbsSurface.h:34
This function defines a wall via a NurbsSurface.
Definition: NurbsWall.h:37
void set(const NurbsSurface &nurbsSurface)
Defines a wall, given a NurbsSurface.
Definition: NurbsWall.cc:69
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
bool writeToFile(std::string filename, std::string filecontent)
Writes a string to a file.
Definition: FileIOHelpers.cc:58

References BaseHandler< T >::copyAndAddObject(), DPMBase::forceWriteOutputFiles(), ONE_FILE, DPMBase::particleHandler, NurbsWall::set(), DPMBase::setName(), DPMBase::setParticlesWriteVTK(), BaseInteractable::setPosition(), BaseParticle::setRadius(), BaseParticle::setSpecies(), BaseWall::setSpecies(), WallHandler::setWriteVTK(), DPMBase::speciesHandler, DPMBase::wallHandler, and helpers::writeToFile().