NurbsSurfaceUnitTest.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  //output of the unit test: check if evaluation works
23  Vec3D val = nurbsSurface.evaluate(0.5,0.5);
24  helpers::check(val,{.6,.8,1},std::numeric_limits<double>::epsilon(),"Nurbs evaluation failed");
25 
26  //now demonstrate how nurbs wall can be defined:
27 
28  //create a basic dpm class
29  DPMBase dpm;
30  dpm.setName("NurbsSurfaceUnitTest");
31  auto s = dpm.speciesHandler.copyAndAddObject(LinearViscoelasticSpecies());
33  p.setSpecies(s);
34  p.setRadius(1);
35  p.setPosition({1,1,.2});
36  dpm.particleHandler.copyAndAddObject(p);
37 
38  //define nurbs wall and add to dpm class
39  NurbsWall nurbsWall;
40  nurbsWall.setSpecies(s);
41  nurbsWall.set(nurbsSurface);
42  auto w = dpm.wallHandler.copyAndAddObject(nurbsWall);
43 
44  //write vtk file
45  dpm.wallHandler.setWriteVTK(FileType::ONE_FILE);
46  dpm.forceWriteOutputFiles();
47 
48  //test if contact can be found
49  Vec3D normal;
50  double distance;
51  w->getDistanceAndNormal(p,distance,normal);
52  helpers::check(normal,{-sqrt(.5),-sqrt(.5),0},4*std::numeric_limits<double>::epsilon(),"Nurbs contact evaluation");
53 
54  return 0;
55 }
AnnoyingScalar sqrt(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:134
@ 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
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
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:400
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
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
val
Definition: calibrate.py:119
void check(double real, double ideal, double error, std::string errorMessage)
Definition: TestHelpers.cc:16
double epsilon
Definition: osc_ring_sarah_asymptotics.h:43

References helpers::check(), oomph::SarahBL::epsilon, NurbsSurface::evaluate(), WallFunction::normal(), ONE_FILE, p, s, NurbsWall::set(), DPMBase::setName(), BaseWall::setSpecies(), sqrt(), calibrate::val, w, and calibrate::weights.