HourGlass2DDemo.cpp File Reference
#include <iostream>
#include "Mercury3D.h"
#include "Walls/IntersectionOfWalls.h"
#include "Species/LinearViscoelasticFrictionSpecies.h"
#include <cstdlib>
#include <chrono>

Classes

class  HourGlass2D
 

Functions

int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int argc  ,
char argv[] 
)
112 {
113  // Start measuring elapsed time
114  std::chrono::time_point<std::chrono::system_clock> startClock, endClock;
115  startClock = std::chrono::system_clock::now();
116 
117  logger(INFO, "Hourglass Simulation");
118  // note: this code is based on stefan's implementation, see
119  // /storage2/usr/people/sluding/COMPUTERS/hpc01/sluding/MDCC/MDCLR/DEMO/W7
120  // however, it is scaled to SI units by the scaling factors
121  // d=1e-3, m=1e-6, g=1
122 
123  //all parameters should be set in the main file
124  //here, we use SI units (generally, other, scaled units are possible)
125 
126  //create an instance of the class and name it
127  HourGlass2D HG;
128  HG.setName("HourGlass2D");
130  //LinearViscoelasticSpecies* species = HG.speciesHandler.copyAndAddObject(LinearViscoelasticSpecies());
131  species->setDensity(2000);
132 
133  //specify geometry
134  //specify dimensions of the hourglass
135  Mdouble Width = 10e-2; // 10cm
136  Mdouble Height = 60e-2; // 60cm
137  //specify how big the wedge of the contraction should be
138  Mdouble ContractionWidth = 2.5e-2; //2.5cm
139  Mdouble ContractionHeight = 5e-2; //5cm
140  //set domain accordingly (domain boundaries are not walls!)
141  HG.setXMin(0.0);
142  HG.setXMax(Width);
143  HG.setYMin(0.0);
144  HG.setYMax(Width);
145  HG.setZMin(0.0);
146  HG.setZMax(Height);
147  //these parameters are needed in setupInitialConditions()
148  HG.ContractionWidth = ContractionWidth;
149  HG.ContractionHeight = ContractionHeight;
150 
151  //specify particle properties
152  species->setDensity(2000.0);
153  //these parameters are needed in setupInitialConditions()
154  HG.MinParticleRadius = 6e-3; // 6mm
155  HG.MaxParticleRadius = 10e-3; //10mm
156 
157  //specify body forces
158  HG.setGravity(Vec3D(0.0, 0.0, -9.8));
159 
160  //specify contact properties
161  //normal forces
162  species->setStiffness(1e5);
163  species->setDissipation(0.63);
164  //tangential (sliding) forces
165  species->setSlidingFrictionCoefficient(0.5);
166  species->setSlidingStiffness(1.2e4);
167  species->setSlidingDissipation(0.16);
168  //tangential (rolling) torques
169  species->setRollingFrictionCoefficient(0.2);
170  species->setRollingStiffness(1.2e4);
171  species->setRollingDissipation(6.3e-2);
172  //normal (torsion/spin) torques
173  species->setTorsionFrictionCoefficient(0.1);
174  species->setTorsionStiffness(1.2e4);
175  species->setSlidingDissipation(6.3e-2);
176 
177  //test normal forces
178  Mdouble MinParticleMass =
179  species->getDensity() * 4.0 / 3.0 * constants::pi * mathsFunc::cubic(HG.MinParticleRadius);
180  logger(INFO, "MinParticleMass =%\n", MinParticleMass, Flusher::NO_FLUSH);
181  Mdouble tc = species->getCollisionTime(MinParticleMass);
182  logger(INFO, "tc =%\n"
183  "r =%\n"
184  "vmax=%\n",
185  tc, species->getRestitutionCoefficient(MinParticleMass),
186  species->getMaximumVelocity(HG.MinParticleRadius, MinParticleMass), Flusher::NO_FLUSH);
187 
188  //set other simulation parameters
189  HG.setTimeStep(tc / 50.0);
190  HG.setTimeMax(2.0);//run until 3.0 to see full simulation
191  HG.setSaveCount(500);
192  HG.setXBallsAdditionalArguments("-v0 -solidf");
193  //uncomment next two line 2 to create paraview files
194  HG.setParticlesWriteVTK(true);
196 
197  HG.N = 100; //number of particles
198  logger(INFO, "N = %", HG.N);
199 
200  HG.solve(argc, argv);
201 
202  // Measure elapsed time
203  endClock = std::chrono::system_clock::now();
204  std::chrono::duration<double> elapsed_seconds = endClock - startClock;
205  logger(INFO, "Elapsed time for solving the PDE: % s", elapsed_seconds.count());
206 
207  return 0;
208 }
@ ONE_FILE
all data will be written into/ read from a single file called name_
double Mdouble
Definition: GeneralDefine.h:34
Species< LinearViscoelasticNormalSpecies, FrictionSpecies > LinearViscoelasticFrictionSpecies
Definition: LinearViscoelasticFrictionSpecies.h:34
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
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
void setYMin(Mdouble newYMin)
Sets the value of YMin, the lower bound of the problem domain in the y-direction.
Definition: DPMBase.cc:1034
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:422
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1447
void setYMax(Mdouble newYMax)
Sets the value of YMax, the upper bound of the problem domain in the y-direction.
Definition: DPMBase.cc:1191
void setZMin(Mdouble newZMin)
Sets the value of ZMin, the lower bound of the problem domain in the z-direction.
Definition: DPMBase.cc:1058
void setXBallsAdditionalArguments(std::string newXBArgs)
Set the additional arguments for xballs.
Definition: DPMBase.cc:1347
void setXMax(Mdouble newXMax)
Sets the value of XMax, the upper bound of the problem domain in the x-direction.
Definition: DPMBase.cc:1165
void setZMax(Mdouble newZMax)
Sets the value of ZMax, the upper bound of the problem domain in the z-direction.
Definition: DPMBase.cc:1217
void setParticlesWriteVTK(bool writeParticlesVTK)
Sets whether particles are written in a VTK file.
Definition: DPMBase.cc:942
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 setXMin(Mdouble newXMin)
Sets the value of XMin, the lower bound of the problem domain in the x-direction.
Definition: DPMBase.cc:1010
void setGravity(Vec3D newGravity)
Sets a new value for the gravitational acceleration.
Definition: DPMBase.cc:1383
Definition: HourGlass2DDemo.cpp:43
Mdouble MinParticleRadius
Definition: HourGlass2DDemo.cpp:106
Mdouble ContractionWidth
Definition: HourGlass2DDemo.cpp:104
Mdouble MaxParticleRadius
Definition: HourGlass2DDemo.cpp:107
Mdouble ContractionHeight
Definition: HourGlass2DDemo.cpp:105
unsigned int N
Definition: HourGlass2DDemo.cpp:108
void setDensity(Mdouble density)
Definition: ParticleSpecies.cc:108
Mdouble getDensity() const
Allows density_ to be accessed.
Definition: ParticleSpecies.cc:118
Contains material and contact force properties.
Definition: Species.h:35
Definition: Vector.h:51
void setWriteVTK(FileType)
Sets whether walls are written into a VTK file.
Definition: WallHandler.cc:467
const Mdouble pi
Definition: ExtendedMath.h:45
T cubic(const T val)
calculates the cube of a number
Definition: ExtendedMath.h:115

References HourGlass2D::ContractionHeight, HourGlass2D::ContractionWidth, BaseHandler< T >::copyAndAddObject(), mathsFunc::cubic(), ParticleSpecies::getDensity(), INFO, logger, HourGlass2D::MaxParticleRadius, HourGlass2D::MinParticleRadius, HourGlass2D::N, NO_FLUSH, ONE_FILE, constants::pi, ParticleSpecies::setDensity(), DPMBase::setGravity(), DPMBase::setName(), DPMBase::setParticlesWriteVTK(), DPMBase::setSaveCount(), DPMBase::setTimeMax(), DPMBase::setTimeStep(), WallHandler::setWriteVTK(), DPMBase::setXBallsAdditionalArguments(), DPMBase::setXMax(), DPMBase::setXMin(), DPMBase::setYMax(), DPMBase::setYMin(), DPMBase::setZMax(), DPMBase::setZMin(), DPMBase::solve(), DPMBase::speciesHandler, and DPMBase::wallHandler.