NurbsWallUnitTest.cpp File Reference

Functions

int main ()
 

Function Documentation

◆ main()

int main ( )
14 {
15  //define quarter circle as nurbs surface
16  std::vector<double> knotsU = {0,0,0,1,1,1};
17  std::vector<double> knotsV = {0,0,1,1};
18  std::vector<std::vector<Vec3D>> controlPoints = {{{1,0,0},{1,0,2}},{{1,1,0},{1,1,2}},{{0,1,0},{0,1,2}}} ;
19  std::vector<std::vector<Mdouble>> weights = {{1,1},{1,1},{2,2}};
20  NurbsSurface nurbsSurface(knotsU,knotsV,controlPoints,weights);
21 
22  //create a basic dpm class
23  DPMBase dpm;
24  dpm.setName("NurbsSurfaceUnitTest");
26 
27  //define nurbs wall and add to dpm class
28  NurbsWall nurbsWall;
29  nurbsWall.setSpecies(s);
30  nurbsWall.set(nurbsSurface);
31  auto w = dpm.wallHandler.copyAndAddObject(nurbsWall);
32 
33  SphericalParticle particle;
34  particle.setSpecies(s);
35  particle.setRadius(.99);
36  for (double x=-.5; x<=4.5; x+=.125) {
37  for (double z = -.5; z <= 2.5; z += .5) {
38  particle.setPosition({x, 2-x, z});
39  dpm.particleHandler.copyAndAddObject(particle);
40  }
41  }
42 
43  //test if contact can be found
44  Vec3D normal;
45  double distance;
46  std::stringstream ss;
47  for (auto p : dpm.particleHandler) {
48  if (w->getDistanceAndNormal(*p, distance, normal)) {
49  p->setPosition(distance * normal + p->getPosition());
50  ss << p->getPosition() << '\t' << distance << '\t' << distance * normal + p->getPosition() << '\n';
51  } else {
52  p->setPosition({0,0,0});
53  }
54  }
55  helpers::writeToFile("NurbsWallUnitTest.txt",ss.str());
56 
57  //write vtk file
58  dpm.setName("NurbsWallUnitTest");
60  dpm.setParticlesWriteVTK(true);
62 
63  return 0;
64 }
@ ONE_FILE
all data will be written into/ read from a single file called name_
Species< LinearViscoelasticNormalSpecies > LinearViscoelasticSpecies
Definition: LinearViscoelasticSpecies.h:11
RowVector3d w
Definition: Matrix_resize_int.cpp:3
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
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
void setSpecies(const ParticleSpecies *species)
Defines the species of the current wall.
Definition: BaseWall.cc:148
The DPMBase header includes quite a few header files, defining all the handlers, which are essential....
Definition: DPMBase.h:56
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1433
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:400
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1453
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created.
Definition: DPMBase.h:1443
void setParticlesWriteVTK(bool writeParticlesVTK)
Sets whether particles are written in a VTK file.
Definition: DPMBase.cc:933
void forceWriteOutputFiles()
Writes output files immediately, even if the current time step was not meant to be written....
Definition: DPMBase.cc:4094
Definition: NurbsSurface.h:13
This function defines a wall via a NurbsSurface.
Definition: NurbsWall.h:16
void set(const NurbsSurface &nurbsSurface)
Defines a wall, given a NurbsSurface.
Definition: NurbsWall.cc:48
A spherical particle is the most simple particle used in MercuryDPM.
Definition: SphericalParticle.h:16
Definition: Kernel/Math/Vector.h:30
void setWriteVTK(FileType)
Sets whether walls are written into a VTK file.
Definition: WallHandler.cc:445
RealScalar s
Definition: level1_cplx_impl.h:130
void normal(const Vector< double > &x, Vector< double > &normal)
Definition: free_surface_rotation.cc:65
list weights
Definition: calibrate.py:94
bool writeToFile(const std::string &filename, const std::string &filecontent)
Writes a string to a file.
Definition: FileIOHelpers.cc:29
list x
Definition: plotDoE.py:28

References BaseHandler< T >::copyAndAddObject(), DPMBase::forceWriteOutputFiles(), WallFunction::normal(), ONE_FILE, p, DPMBase::particleHandler, s, NurbsWall::set(), DPMBase::setName(), DPMBase::setParticlesWriteVTK(), BaseInteractable::setPosition(), BaseParticle::setRadius(), BaseParticle::setSpecies(), BaseWall::setSpecies(), WallHandler::setWriteVTK(), DPMBase::speciesHandler, w, DPMBase::wallHandler, calibrate::weights, helpers::writeToFile(), and plotDoE::x.