NurbsSurfaceUnitTest.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  //output of the unit test: check if evaluation works
44  Vec3D val = nurbsSurface.evaluate(0.5,0.5);
45  helpers::check(val,{.6,.8,1},std::numeric_limits<double>::epsilon(),"Nurbs evaluation failed");
46 
47  //now demonstrate how nurbs wall can be defined:
48 
49  //create a basic dpm class
50  DPMBase dpm;
51  dpm.setName("NurbsSurfaceUnitTest");
52  auto s = dpm.speciesHandler.copyAndAddObject(LinearViscoelasticSpecies());
54  p.setSpecies(s);
55  p.setRadius(1);
56  p.setPosition({1,1,.2});
57  dpm.particleHandler.copyAndAddObject(p);
58 
59  //define nurbs wall and add to dpm class
60  NurbsWall nurbsWall;
61  nurbsWall.setSpecies(s);
62  nurbsWall.set(nurbsSurface);
63  auto w = dpm.wallHandler.copyAndAddObject(nurbsWall);
64 
65  //write vtk file
66  dpm.wallHandler.setWriteVTK(FileType::ONE_FILE);
67  dpm.forceWriteOutputFiles();
68 
69  //test if contact can be found
70  Vec3D normal;
71  double distance;
72  w->getDistanceAndNormal(p,distance,normal);
73  helpers::check(normal,{-sqrt(.5),-sqrt(.5),0},4*std::numeric_limits<double>::epsilon(),"Nurbs contact evaluation");
74 
75  return 0;
76 }
@ ONE_FILE
all data will be written into/ read from a single file called name_
Species< LinearViscoelasticNormalSpecies > LinearViscoelasticSpecies
Definition: LinearViscoelasticSpecies.h:33
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
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:422
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 check(double real, double ideal, double error, std::string errorMessage)
Definition: TestHelpers.cc:37

References helpers::check(), NurbsSurface::evaluate(), ONE_FILE, NurbsWall::set(), DPMBase::setName(), BaseInteractable::setPosition(), BaseParticle::setRadius(), BaseParticle::setSpecies(), and BaseWall::setSpecies().