TriangleWallCubeSelfTest.cpp File Reference

Functions

int main ()
 Tests the implementation of TriangulatedWall. More...
 

Function Documentation

◆ main()

int main ( )

Tests the implementation of TriangulatedWall.

38 {
39  //write input files
40  helpers::writeToFile("TriangulatedWallSimple.vtk","# vtk DataFile Version 2.0\n"
41  "Defines a domain outside of a tetrahedron\n"
42  "ASCII\n"
43  "DATASET UNSTRUCTURED_GRID\n"
44  "POINTS 4 double\n"
45  "0 0 0\n"
46  "1 0 0\n"
47  "0 1 0\n"
48  "0 0 1\n"
49  "\n"
50  "CELLS 4 16\n"
51  "3 0 1 2\n"
52  "3 0 2 3\n"
53  "3 0 3 1\n"
54  "3 1 3 2\n"
55  "\n"
56  "CELL_TYPES 4\n"
57  "5\n"
58  "5\n"
59  "5\n"
60  "5");
61 
62  helpers::writeToFile("TriangulatedWallInverted.vtk","# vtk DataFile Version 2.0\n"
63  "Defines a domain inside of a tetrahedron\n"
64  "ASCII\n"
65  "DATASET UNSTRUCTURED_GRID\n"
66  "POINTS 4 double\n"
67  "0 0 0\n"
68  "1 0 0\n"
69  "0 1 0\n"
70  "0 0 1\n"
71  "\n"
72  "CELLS 4 16\n"
73  "3 0 2 1\n"
74  "3 0 3 2\n"
75  "3 0 1 3\n"
76  "3 1 2 3\n"
77  "\n"
78  "CELL_TYPES 4\n"
79  "5\n"
80  "5\n"
81  "5\n"
82  "5");
83 
84  helpers::writeToFile("TriangulatedWall.vtk","# vtk DataFile Version 2.0\n"
85  "Cube Normals (cross of first two vec's) into the wall\n"
86  "ASCII\n"
87  "DATASET UNSTRUCTURED_GRID\n"
88  "POINTS 8 double\n"
89  "0 0 0\n"
90  "1 0 0\n"
91  "1 1 0\n"
92  "0 1 0\n"
93  "0 0 1\n"
94  "1 0 1\n"
95  "1 1 1\n"
96  "0 1 1\n"
97  "\n"
98  "CELLS 8 32\n"
99  "3 0 1 2\n"
100  "3 0 7 4\n"
101  "3 2 6 7\n"
102  "3 0 2 7\n"
103  "3 1 0 4\n"
104  "3 1 4 7\n"
105  "3 6 2 1\n"
106  "3 1 7 6\n"
107  "\n"
108  "CELL_TYPES 8\n"
109  "5\n"
110  "5\n"
111  "5\n"
112  "5\n"
113  "5\n"
114  "5\n"
115  "5\n"
116  "5");
117 
118  logger(INFO,"To get VTK output, uncomment the relevant lines in the main function.");
119 
120 
121  Mercury3D dpm;
122  dpm.setName("TriangleWallCubeSelfTest");
123  dpm.setMin({-.2,-.2,-.2});
124  dpm.setMax({1.2,1.2,1.2});
125 
126  dpm.setGravity(10*Vec3D(0,0,-1));
127  dpm.setTimeStep(1e-4);
128  dpm.setTimeMax(1e4*dpm.getTimeStep());
129  //setTimeMax(getTimeStep());
130  dpm.setSaveCount(100);
131  dpm.setXBallsAdditionalArguments("-v0 -solidf");
133  dpm.restartFile.setSaveCount(1e5);
134 
135  Mdouble radius = 0.08;
137  s->setDensity(1);
138  s->setCollisionTimeAndRestitutionCoefficient(20.0*dpm.getTimeStep(),0.1,s->getMassFromRadius(radius));
139 
140  //create domain walls
141  InfiniteWall i;
142  i.setSpecies(dpm.speciesHandler.getLastObject());
143  i.set({0,0,-1},dpm.getMin());
145  i.set({0,-1,0},dpm.getMin());
147  i.set({-1,0,0},dpm.getMin());
149  i.set({0,1,0},dpm.getMax());
151  i.set({1,0,0},dpm.getMax());
153 
154  //read in walls
155  dpm.wallHandler.readTriangleWall("TriangulatedWall.vtk",s);
156 
157  //introduce particles
158  SphericalParticle p(s);
159 
160  //random insertion
161  for (unsigned i=0; i<300; i++)
162  {
163  Vec3D r;
164  r.X = dpm.random.getRandomNumber(dpm.getXMin(),dpm.getXMax());
165  r.Y = dpm.random.getRandomNumber(dpm.getYMin(),dpm.getYMax());
166  r.Z = dpm.random.getRandomNumber(dpm.getZMax(),dpm.getZMax()+1.0);
167  p.setPosition(r);
168  p.setRadius(dpm.random.getRandomNumber(radius,1.1*radius));
169  if (dpm.checkParticleForInteraction(p))
171  }
172 
173  logger(INFO,"Inserted % particles",dpm.particleHandler.getNumberOfObjects());
174  //uncomment to get VTK output
175  dpm.setParticlesWriteVTK(true);
177  dpm.solve();
178  return 0;
179 }
@ NO_FILE
file will not be created/read
@ ONE_FILE
all data will be written into/ read from a single file called name_
double Mdouble
Definition: GeneralDefine.h:34
Species< LinearViscoelasticNormalSpecies > LinearViscoelasticSpecies
Definition: LinearViscoelasticSpecies.h:33
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
T * getLastObject()
Gets a pointer to the last Object in this BaseHandler.
Definition: BaseHandler.h:634
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
void setSaveCount(unsigned int saveCount)
Sets File::saveCount_ for all files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:408
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1427
File fStatFile
An instance of class File to handle in- and output into a .fstat file.
Definition: DPMBase.h:1483
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
Vec3D getMax() const
Definition: DPMBase.h:670
void setMin(const Vec3D &min)
Sets the minimum coordinates of the problem domain.
Definition: DPMBase.cc:1118
File restartFile
An instance of class File to handle in- and output into a .restart file.
Definition: DPMBase.h:1493
Vec3D getMin() const
Definition: DPMBase.h:664
void setXBallsAdditionalArguments(std::string newXBArgs)
Set the additional arguments for xballs.
Definition: DPMBase.cc:1347
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
RNG random
This is a random generator, often used for setting up the initial conditions etc.....
Definition: DPMBase.h:1432
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
void solve()
The work horse of the code.
Definition: DPMBase.cc:4270
void setMax(const Vec3D &max)
Sets the maximum coordinates of the problem domain.
Definition: DPMBase.cc:1082
void setGravity(Vec3D newGravity)
Sets a new value for the gravitational acceleration.
Definition: DPMBase.cc:1383
Mdouble getZMax() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMax() returns ZMax.
Definition: DPMBase.h:650
void setSaveCount(unsigned int saveCount)
Sets File::saveCount_.
Definition: File.cc:273
void setFileType(FileType fileType)
Sets the type of file needed to write into or read from. File::fileType_.
Definition: File.cc:215
A infinite wall fills the half-space {point: (position_-point)*normal_<=0}.
Definition: InfiniteWall.h:48
This adds on the hierarchical grid code for 3D problems.
Definition: Mercury3D.h:37
bool checkParticleForInteraction(const BaseParticle &P) final
Checks if given BaseParticle has an interaction with a BaseWall or other BaseParticle.
Definition: MercuryBase.cc:594
unsigned int getNumberOfObjects() const override
Returns the number of objects in the container. In parallel code this practice is forbidden to avoid ...
Definition: ParticleHandler.cc:1325
Mdouble getRandomNumber()
This is a random generating routine can be used for initial positions.
Definition: RNG.cc:143
A spherical particle is the most simple particle used in MercuryDPM.
Definition: SphericalParticle.h:37
Definition: Vector.h:51
Mdouble Y
Definition: Vector.h:66
Mdouble Z
Definition: Vector.h:66
Mdouble X
the vector components
Definition: Vector.h:66
void setWriteVTK(FileType)
Sets whether walls are written into a VTK file.
Definition: WallHandler.cc:467
unsigned readTriangleWall(std::string filename, ParticleSpecies *species, Mdouble scaleFactor=1, Vec3D centerOfRotation={0, 0, 0}, Vec3D velocity={0, 0, 0}, Vec3D angularVelocity={0, 0, 0})
Reads triangulated walls from vtk or stl files, and converts them into a set of TriangleWalls.
Definition: WallHandler.cc:341
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51
bool writeToFile(std::string filename, std::string filecontent)
Writes a string to a file.
Definition: FileIOHelpers.cc:58

References MercuryBase::checkParticleForInteraction(), BaseHandler< T >::copyAndAddObject(), DPMBase::fStatFile, BaseHandler< T >::getLastObject(), DPMBase::getMax(), DPMBase::getMin(), ParticleHandler::getNumberOfObjects(), RNG::getRandomNumber(), DPMBase::getTimeStep(), DPMBase::getXMax(), DPMBase::getXMin(), DPMBase::getYMax(), DPMBase::getYMin(), DPMBase::getZMax(), constants::i, INFO, logger, NO_FILE, ONE_FILE, DPMBase::particleHandler, DPMBase::random, WallHandler::readTriangleWall(), DPMBase::restartFile, File::setFileType(), DPMBase::setGravity(), DPMBase::setMax(), DPMBase::setMin(), DPMBase::setName(), DPMBase::setParticlesWriteVTK(), BaseInteractable::setPosition(), BaseParticle::setRadius(), DPMBase::setSaveCount(), File::setSaveCount(), DPMBase::setTimeMax(), DPMBase::setTimeStep(), WallHandler::setWriteVTK(), DPMBase::setXBallsAdditionalArguments(), DPMBase::solve(), DPMBase::speciesHandler, DPMBase::wallHandler, helpers::writeToFile(), Vec3D::X, Vec3D::Y, and Vec3D::Z.