TriangleWallCubeSelfTest.cpp File Reference

Functions

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

Function Documentation

◆ main()

int main ( )

Tests the implementation of TriangulatedWall.

17 {
18  //write input files
19  helpers::writeToFile("TriangulatedWallSimple.vtk","# vtk DataFile Version 2.0\n"
20  "Defines a domain outside of a tetrahedron\n"
21  "ASCII\n"
22  "DATASET UNSTRUCTURED_GRID\n"
23  "POINTS 4 double\n"
24  "0 0 0\n"
25  "1 0 0\n"
26  "0 1 0\n"
27  "0 0 1\n"
28  "\n"
29  "CELLS 4 16\n"
30  "3 0 1 2\n"
31  "3 0 2 3\n"
32  "3 0 3 1\n"
33  "3 1 3 2\n"
34  "\n"
35  "CELL_TYPES 4\n"
36  "5\n"
37  "5\n"
38  "5\n"
39  "5");
40 
41  helpers::writeToFile("TriangulatedWallInverted.vtk","# vtk DataFile Version 2.0\n"
42  "Defines a domain inside of a tetrahedron\n"
43  "ASCII\n"
44  "DATASET UNSTRUCTURED_GRID\n"
45  "POINTS 4 double\n"
46  "0 0 0\n"
47  "1 0 0\n"
48  "0 1 0\n"
49  "0 0 1\n"
50  "\n"
51  "CELLS 4 16\n"
52  "3 0 2 1\n"
53  "3 0 3 2\n"
54  "3 0 1 3\n"
55  "3 1 2 3\n"
56  "\n"
57  "CELL_TYPES 4\n"
58  "5\n"
59  "5\n"
60  "5\n"
61  "5");
62 
63  helpers::writeToFile("TriangulatedWall.vtk","# vtk DataFile Version 2.0\n"
64  "Cube Normals (cross of first two vec's) into the wall\n"
65  "ASCII\n"
66  "DATASET UNSTRUCTURED_GRID\n"
67  "POINTS 8 double\n"
68  "0 0 0\n"
69  "1 0 0\n"
70  "1 1 0\n"
71  "0 1 0\n"
72  "0 0 1\n"
73  "1 0 1\n"
74  "1 1 1\n"
75  "0 1 1\n"
76  "\n"
77  "CELLS 8 32\n"
78  "3 0 1 2\n"
79  "3 0 7 4\n"
80  "3 2 6 7\n"
81  "3 0 2 7\n"
82  "3 1 0 4\n"
83  "3 1 4 7\n"
84  "3 6 2 1\n"
85  "3 1 7 6\n"
86  "\n"
87  "CELL_TYPES 8\n"
88  "5\n"
89  "5\n"
90  "5\n"
91  "5\n"
92  "5\n"
93  "5\n"
94  "5\n"
95  "5");
96 
97  logger(INFO,"To get VTK output, uncomment the relevant lines in the main function.");
98 
99 
100  Mercury3D dpm;
101  dpm.setName("TriangleWallCubeSelfTest");
102  dpm.setMin({-.2,-.2,-.2});
103  dpm.setMax({1.2,1.2,1.2});
104 
105  dpm.setGravity(10*Vec3D(0,0,-1));
106  dpm.setTimeStep(1e-4);
107  dpm.setTimeMax(1e4*dpm.getTimeStep());
108  //setTimeMax(getTimeStep());
109  dpm.setSaveCount(100);
110  dpm.setXBallsAdditionalArguments("-v0 -solidf");
112  dpm.restartFile.setSaveCount(1e5);
113 
114  Mdouble radius = 0.08;
116  s->setDensity(1);
117  s->setCollisionTimeAndRestitutionCoefficient(20.0*dpm.getTimeStep(),0.1,s->getMassFromRadius(radius));
118 
119  //create domain walls
120  InfiniteWall i;
121  i.setSpecies(dpm.speciesHandler.getLastObject());
122  i.set({0,0,-1},dpm.getMin());
124  i.set({0,-1,0},dpm.getMin());
126  i.set({-1,0,0},dpm.getMin());
128  i.set({0,1,0},dpm.getMax());
130  i.set({1,0,0},dpm.getMax());
132 
133  //read in walls
134  dpm.wallHandler.readTriangleWall("TriangulatedWall.vtk",s);
135 
136  //introduce particles
138 
139  //random insertion
140  for (unsigned i=0; i<300; i++)
141  {
142  Vec3D r;
143  r.X = dpm.random.getRandomNumber(dpm.getXMin(),dpm.getXMax());
144  r.Y = dpm.random.getRandomNumber(dpm.getYMin(),dpm.getYMax());
145  r.Z = dpm.random.getRandomNumber(dpm.getZMax(),dpm.getZMax()+1.0);
146  p.setPosition(r);
147  p.setRadius(dpm.random.getRandomNumber(radius,1.1*radius));
150  }
151 
152  logger(INFO,"Inserted % particles",dpm.particleHandler.getNumberOfObjects());
153  //uncomment to get VTK output
154  dpm.setParticlesWriteVTK(true);
156  dpm.solve();
157  return 0;
158 }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Array< double, 1, 3 > e(1./3., 0.5, 2.)
@ NO_FILE
file will not be created/read
@ ONE_FILE
all data will be written into/ read from a single file called name_
Species< LinearViscoelasticNormalSpecies > LinearViscoelasticSpecies
Definition: LinearViscoelasticSpecies.h:11
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
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
T * getLastObject()
Gets a pointer to the last Object in this BaseHandler.
Definition: BaseHandler.h:642
Mdouble getXMin() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMin() returns XMin.
Definition: DPMBase.h:603
Mdouble getXMax() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMax() returns XMax.
Definition: DPMBase.h:610
void setSaveCount(unsigned int saveCount)
Sets File::saveCount_ for all files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:386
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1433
File fStatFile
An instance of class File to handle in- and output into a .fstat file.
Definition: DPMBase.h:1489
Mdouble getYMin() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMin() returns YMin.
Definition: DPMBase.h:616
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:400
Mdouble getTimeStep() const
Returns the simulation time step.
Definition: DPMBase.cc:1241
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1453
Vec3D getMax() const
Returns the maximum coordinates of the problem domain.
Definition: DPMBase.h:659
void setMin(const Vec3D &min)
Sets the minimum coordinates of the problem domain.
Definition: DPMBase.cc:1109
File restartFile
An instance of class File to handle in- and output into a .restart file.
Definition: DPMBase.h:1499
Vec3D getMin() const
Returns the minimum coordinates of the problem domain.
Definition: DPMBase.h:653
void setXBallsAdditionalArguments(std::string newXBArgs)
Set the additional arguments for xballs.
Definition: DPMBase.cc:1338
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
RNG random
This is a random generator, often used for setting up the initial conditions etc.....
Definition: DPMBase.h:1438
Mdouble getYMax() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMax() returns XMax.
Definition: DPMBase.h:622
void setTimeStep(Mdouble newDt)
Sets a new value for the simulation time step.
Definition: DPMBase.cc:1225
void setTimeMax(Mdouble newTMax)
Sets a new value for the maximum simulation duration.
Definition: DPMBase.cc:864
void solve()
The work horse of the code.
Definition: DPMBase.cc:4334
void setMax(const Vec3D &max)
Sets the maximum coordinates of the problem domain.
Definition: DPMBase.cc:1073
void setGravity(Vec3D newGravity)
Sets a new value for the gravitational acceleration.
Definition: DPMBase.cc:1374
Mdouble getZMax() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMax() returns ZMax.
Definition: DPMBase.h:634
void setSaveCount(unsigned int saveCount)
Sets File::saveCount_.
Definition: File.cc:251
void setFileType(FileType fileType)
Sets the type of file needed to write into or read from. File::fileType_.
Definition: File.cc:193
A infinite wall fills the half-space {point: (position_-point)*normal_<=0}.
Definition: InfiniteWall.h:27
This adds on the hierarchical grid code for 3D problems.
Definition: Mercury3D.h:16
bool checkParticleForInteraction(const BaseParticle &P) final
Checks if given BaseParticle has an interaction with a BaseWall or other BaseParticle.
Definition: MercuryBase.cc:573
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:1323
Mdouble getRandomNumber()
This is a random generating routine can be used for initial positions.
Definition: RNG.cc:123
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
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:319
RealScalar s
Definition: level1_cplx_impl.h:130
#define INFO(i)
Definition: mumps_solver.h:54
r
Definition: UniformPSDSelfTest.py:20
radius
Definition: UniformPSDSelfTest.py:15
bool writeToFile(const std::string &filename, const std::string &filecontent)
Writes a string to a file.
Definition: FileIOHelpers.cc:29

References MercuryBase::checkParticleForInteraction(), BaseHandler< T >::copyAndAddObject(), e(), 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(), i, INFO, logger, NO_FILE, ONE_FILE, p, DPMBase::particleHandler, UniformPSDSelfTest::r, UniformPSDSelfTest::radius, DPMBase::random, WallHandler::readTriangleWall(), DPMBase::restartFile, s, File::setFileType(), DPMBase::setGravity(), DPMBase::setMax(), DPMBase::setMin(), DPMBase::setName(), DPMBase::setParticlesWriteVTK(), DPMBase::setSaveCount(), File::setSaveCount(), DPMBase::setTimeMax(), DPMBase::setTimeStep(), WallHandler::setWriteVTK(), DPMBase::setXBallsAdditionalArguments(), DPMBase::solve(), DPMBase::speciesHandler, DPMBase::wallHandler, and helpers::writeToFile().