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[] 
)
91 {
92  // Start measuring elapsed time
93  std::chrono::time_point<std::chrono::system_clock> startClock, endClock;
94  startClock = std::chrono::system_clock::now();
95 
96  logger(INFO, "Hourglass Simulation");
97  // note: this code is based on stefan's implementation, see
98  // /storage2/usr/people/sluding/COMPUTERS/hpc01/sluding/MDCC/MDCLR/DEMO/W7
99  // however, it is scaled to SI units by the scaling factors
100  // d=1e-3, m=1e-6, g=1
101 
102  //all parameters should be set in the main file
103  //here, we use SI units (generally, other, scaled units are possible)
104 
105  //create an instance of the class and name it
106  HourGlass2D HG;
107  HG.setName("HourGlass2D");
109  //LinearViscoelasticSpecies* species = HG.speciesHandler.copyAndAddObject(LinearViscoelasticSpecies());
110  species->setDensity(2000);
111 
112  //specify geometry
113  //specify dimensions of the hourglass
114  Mdouble Width = 10e-2; // 10cm
115  Mdouble Height = 60e-2; // 60cm
116  //specify how big the wedge of the contraction should be
117  Mdouble ContractionWidth = 2.5e-2; //2.5cm
118  Mdouble ContractionHeight = 5e-2; //5cm
119  //set domain accordingly (domain boundaries are not walls!)
120  HG.setXMin(0.0);
121  HG.setXMax(Width);
122  HG.setYMin(0.0);
123  HG.setYMax(Width);
124  HG.setZMin(0.0);
125  HG.setZMax(Height);
126  //these parameters are needed in setupInitialConditions()
127  HG.ContractionWidth = ContractionWidth;
128  HG.ContractionHeight = ContractionHeight;
129 
130  //specify particle properties
131  species->setDensity(2000.0);
132  //these parameters are needed in setupInitialConditions()
133  HG.MinParticleRadius = 6e-3; // 6mm
134  HG.MaxParticleRadius = 10e-3; //10mm
135 
136  //specify body forces
137  HG.setGravity(Vec3D(0.0, 0.0, -9.8));
138 
139  //specify contact properties
140  //normal forces
141  species->setStiffness(1e5);
142  species->setDissipation(0.63);
143  //tangential (sliding) forces
144  species->setSlidingFrictionCoefficient(0.5);
145  species->setSlidingStiffness(1.2e4);
146  species->setSlidingDissipation(0.16);
147  //tangential (rolling) torques
148  species->setRollingFrictionCoefficient(0.2);
149  species->setRollingStiffness(1.2e4);
150  species->setRollingDissipation(6.3e-2);
151  //normal (torsion/spin) torques
152  species->setTorsionFrictionCoefficient(0.1);
153  species->setTorsionStiffness(1.2e4);
154  species->setSlidingDissipation(6.3e-2);
155 
156  //test normal forces
157  Mdouble MinParticleMass =
158  species->getDensity() * 4.0 / 3.0 * constants::pi * mathsFunc::cubic(HG.MinParticleRadius);
159  logger(INFO, "MinParticleMass =%\n", MinParticleMass, Flusher::NO_FLUSH);
160  Mdouble tc = species->getCollisionTime(MinParticleMass);
161  logger(INFO, "tc =%\n"
162  "r =%\n"
163  "vmax=%\n",
164  tc, species->getRestitutionCoefficient(MinParticleMass),
165  species->getMaximumVelocity(HG.MinParticleRadius, MinParticleMass), Flusher::NO_FLUSH);
166 
167  //set other simulation parameters
168  HG.setTimeStep(tc / 50.0);
169  HG.setTimeMax(2.0);//run until 3.0 to see full simulation
170  HG.setSaveCount(500);
171  HG.setXBallsAdditionalArguments("-v0 -solidf");
172  //uncomment next two line 2 to create paraview files
173  HG.setParticlesWriteVTK(true);
175 
176  HG.N = 100; //number of particles
177  logger(INFO, "N = %", HG.N);
178 
179  HG.solve(argc, argv);
180 
181  // Measure elapsed time
182  endClock = std::chrono::system_clock::now();
183  std::chrono::duration<double> elapsed_seconds = endClock - startClock;
184  logger(INFO, "Elapsed time for solving the PDE: % s", elapsed_seconds.count());
185 
186  return 0;
187 }
Array< double, 1, 3 > e(1./3., 0.5, 2.)
@ ONE_FILE
all data will be written into/ read from a single file called name_
Species< LinearViscoelasticNormalSpecies, FrictionSpecies > LinearViscoelasticFrictionSpecies
Definition: LinearViscoelasticFrictionSpecies.h:12
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:360
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
void setYMin(Mdouble newYMin)
Sets the value of YMin, the lower bound of the problem domain in the y-direction.
Definition: DPMBase.cc:1025
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:400
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1453
void setYMax(Mdouble newYMax)
Sets the value of YMax, the upper bound of the problem domain in the y-direction.
Definition: DPMBase.cc:1182
void setZMin(Mdouble newZMin)
Sets the value of ZMin, the lower bound of the problem domain in the z-direction.
Definition: DPMBase.cc:1049
void setXBallsAdditionalArguments(std::string newXBArgs)
Set the additional arguments for xballs.
Definition: DPMBase.cc:1338
void setXMax(Mdouble newXMax)
Sets the value of XMax, the upper bound of the problem domain in the x-direction.
Definition: DPMBase.cc:1156
void setZMax(Mdouble newZMax)
Sets the value of ZMax, the upper bound of the problem domain in the z-direction.
Definition: DPMBase.cc:1208
void setParticlesWriteVTK(bool writeParticlesVTK)
Sets whether particles are written in a VTK file.
Definition: DPMBase.cc:933
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 setXMin(Mdouble newXMin)
Sets the value of XMin, the lower bound of the problem domain in the x-direction.
Definition: DPMBase.cc:1001
void setGravity(Vec3D newGravity)
Sets a new value for the gravitational acceleration.
Definition: DPMBase.cc:1374
void setRollingFrictionCoefficient(Mdouble new_mu)
Allows the (dynamic) Coulomb friction coefficient to be changed; also sets mu_s by default.
Definition: FrictionSpecies.cc:165
void setTorsionStiffness(Mdouble new_kt)
Allows the torsion stiffness to be changed.
Definition: FrictionSpecies.cc:201
void setRollingDissipation(Mdouble new_dispt)
Allows the tangential viscosity to be changed.
Definition: FrictionSpecies.cc:147
void setTorsionFrictionCoefficient(Mdouble new_mu)
Allows the (dynamic) Coulomb torsion friction coefficient to be changed; also sets mu_s by default.
Definition: FrictionSpecies.cc:238
void setRollingStiffness(Mdouble new_kt)
Allows the spring constant to be changed.
Definition: FrictionSpecies.cc:128
Definition: HourGlass2DDemo.cpp:22
Mdouble MinParticleRadius
Definition: HourGlass2DDemo.cpp:85
Mdouble ContractionWidth
Definition: HourGlass2DDemo.cpp:83
Mdouble MaxParticleRadius
Definition: HourGlass2DDemo.cpp:86
Mdouble ContractionHeight
Definition: HourGlass2DDemo.cpp:84
unsigned int N
Definition: HourGlass2DDemo.cpp:87
Mdouble getMaximumVelocity(Mdouble radius, Mdouble mass) const
Calculates the maximum velocity allowed for a collision of two copies of P (for higher velocities par...
Definition: LinearViscoelasticNormalSpecies.cc:154
Mdouble getCollisionTime(Mdouble mass) const
Calculates collision time for two copies of a particle of given disp, k, mass.
Definition: LinearViscoelasticNormalSpecies.cc:116
void setDissipation(Mdouble dissipation)
Allows the normal dissipation to be changed.
Definition: LinearViscoelasticNormalSpecies.cc:96
void setStiffness(Mdouble new_k)
Allows the spring constant to be changed.
Definition: LinearViscoelasticNormalSpecies.cc:72
Mdouble getRestitutionCoefficient(Mdouble mass) const
Calculates restitution coefficient for two copies of given disp, k, mass.
Definition: LinearViscoelasticNormalSpecies.cc:147
void setDensity(Mdouble density)
Definition: ParticleSpecies.cc:88
Mdouble getDensity() const
Allows density_ to be accessed.
Definition: ParticleSpecies.cc:98
void setSlidingStiffness(Mdouble new_kt)
Allows the spring constant to be changed.
Definition: SlidingFrictionSpecies.cc:83
void setSlidingDissipation(Mdouble new_dispt)
Allows the tangential viscosity to be changed.
Definition: SlidingFrictionSpecies.cc:102
void setSlidingFrictionCoefficient(Mdouble new_mu)
Allows the (dynamic) Coulomb friction coefficient to be changed; also sets mu_s by default.
Definition: SlidingFrictionSpecies.cc:120
Definition: Kernel/Math/Vector.h:30
void setWriteVTK(FileType)
Sets whether walls are written into a VTK file.
Definition: WallHandler.cc:445
#define INFO(i)
Definition: mumps_solver.h:54
double Height
Height of domain.
Definition: flow_past_oscillating_cylinder.cc:316
const Mdouble pi
Definition: ExtendedMath.h:23
T cubic(const T val)
calculates the cube of a number
Definition: ExtendedMath.h:95

References HourGlass2D::ContractionHeight, HourGlass2D::ContractionWidth, BaseHandler< T >::copyAndAddObject(), mathsFunc::cubic(), e(), LinearViscoelasticNormalSpecies::getCollisionTime(), ParticleSpecies::getDensity(), LinearViscoelasticNormalSpecies::getMaximumVelocity(), LinearViscoelasticNormalSpecies::getRestitutionCoefficient(), GlobalParameters::Height, INFO, logger, HourGlass2D::MaxParticleRadius, HourGlass2D::MinParticleRadius, HourGlass2D::N, NO_FLUSH, ONE_FILE, constants::pi, ParticleSpecies::setDensity(), LinearViscoelasticNormalSpecies::setDissipation(), DPMBase::setGravity(), DPMBase::setName(), DPMBase::setParticlesWriteVTK(), FrictionSpecies::setRollingDissipation(), FrictionSpecies::setRollingFrictionCoefficient(), FrictionSpecies::setRollingStiffness(), DPMBase::setSaveCount(), SlidingFrictionSpecies::setSlidingDissipation(), SlidingFrictionSpecies::setSlidingFrictionCoefficient(), SlidingFrictionSpecies::setSlidingStiffness(), LinearViscoelasticNormalSpecies::setStiffness(), DPMBase::setTimeMax(), DPMBase::setTimeStep(), FrictionSpecies::setTorsionFrictionCoefficient(), FrictionSpecies::setTorsionStiffness(), WallHandler::setWriteVTK(), DPMBase::setXBallsAdditionalArguments(), DPMBase::setXMax(), DPMBase::setXMin(), DPMBase::setYMax(), DPMBase::setYMin(), DPMBase::setZMax(), DPMBase::setZMin(), DPMBase::solve(), DPMBase::speciesHandler, and DPMBase::wallHandler.