revision: v0.14
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);
195  HG.setWallsWriteVTK(FileType::ONE_FILE);
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 }

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

DPMBase::setName
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:420
LinearViscoelasticFrictionSpecies
Species< LinearViscoelasticNormalSpecies, FrictionSpecies > LinearViscoelasticFrictionSpecies
Definition: LinearViscoelasticFrictionSpecies.h:34
DPMBase::setTimeStep
void setTimeStep(Mdouble newDt)
Sets a new value for the simulation time step.
Definition: DPMBase.cc:1225
constants::pi
const Mdouble pi
Definition: ExtendedMath.h:45
Flusher::FLUSH
@ FLUSH
DPMBase::setParticlesWriteVTK
void setParticlesWriteVTK(bool writeParticlesVTK)
Sets whether particles are written in a VTK file.
Definition: DPMBase.cc:934
logger
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
HourGlass2D::N
unsigned int N
Definition: HourGlass2DDemo.cpp:108
DPMBase::setYMax
void setYMax(Mdouble newYMax)
Sets the value of YMax, the upper bound of the problem domain in the y-direction.
Definition: DPMBase.cc:1182
HourGlass2D::MinParticleRadius
Mdouble MinParticleRadius
Definition: HourGlass2DDemo.cpp:106
INFO
LL< Log::INFO > INFO
Info log level.
Definition: Logger.cc:55
DPMBase::setWallsWriteVTK
void setWallsWriteVTK(FileType writeWallsVTK)
Sets whether walls are written into a VTK file.
Definition: DPMBase.cc:908
Vec3D
Definition: Vector.h:50
DPMBase::solve
void solve()
The work horse of the code.
Definition: DPMBase.cc:4003
DPMBase::setZMax
void setZMax(Mdouble newZMax)
Sets the value of ZMax, the upper bound of the problem domain in the z-direction.
Definition: DPMBase.cc:1208
Mdouble
double Mdouble
Definition: GeneralDefine.h:34
Species
Contains material and contact force properties.
Definition: Species.h:35
DPMBase::setXMax
void setXMax(Mdouble newXMax)
Sets the value of XMax, the upper bound of the problem domain in the x-direction.
Definition: DPMBase.cc:1156
DPMBase::speciesHandler
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1385
DPMBase::setTimeMax
void setTimeMax(Mdouble newTMax)
Sets a new value for the maximum simulation duration.
Definition: DPMBase.cc:870
DPMBase::setGravity
void setGravity(Vec3D newGravity)
Sets a new value for the gravitational acceleration.
Definition: DPMBase.cc:1374
DPMBase::setYMin
void setYMin(Mdouble newYMin)
Sets the value of YMin, the lower bound of the problem domain in the y-direction.
Definition: DPMBase.cc:1025
HourGlass2D::ContractionWidth
Mdouble ContractionWidth
Definition: HourGlass2DDemo.cpp:104
BaseHandler::copyAndAddObject
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
DPMBase::setXBallsAdditionalArguments
void setXBallsAdditionalArguments(std::string newXBArgs)
Set the additional arguments for xballs.
Definition: DPMBase.cc:1338
HourGlass2D::ContractionHeight
Mdouble ContractionHeight
Definition: HourGlass2DDemo.cpp:105
DPMBase::setXMin
void setXMin(Mdouble newXMin)
Sets the value of XMin, the lower bound of the problem domain in the x-direction.
Definition: DPMBase.cc:1001
HourGlass2D::MaxParticleRadius
Mdouble MaxParticleRadius
Definition: HourGlass2DDemo.cpp:107
DPMBase::setSaveCount
void setSaveCount(unsigned int saveCount)
Sets File::saveCount_ for all files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:406
mathsFunc::cubic
T cubic(const T val)
calculates the cube of a number
Definition: ExtendedMath.h:115
HourGlass2D
Definition: HourGlass2DDemo.cpp:43
DPMBase::setZMin
void setZMin(Mdouble newZMin)
Sets the value of ZMin, the lower bound of the problem domain in the z-direction.
Definition: DPMBase.cc:1049