MercuryProb.h
Go to the documentation of this file.
1 //
2 // Created by cheng on 2/13/19.
3 //
4 
5 #ifndef PROJECT_MERCURYPROB_H
6 #define PROJECT_MERCURYPROB_H
7 
8 // Generic MercuryDPM header
9 #include <Mercury3D.h>
11 #include "Walls/TriangleWall.h"
12 
13 //=======start_namespace==========================================
19 //================================================================
20 
21 namespace units {
22  // mass: 1 ug = kg
23  Mdouble mUnit = 1e-9;
24  // length: 1 mm = 1e-3 m
25  Mdouble lUnit = 1e-3;
26  // time: 1 ms = 1e-3 s
27  Mdouble tUnit = 1e-3;
28 
29  // force: 1 uN = 1e-6 N
30  inline Mdouble fUnit() { return mUnit * lUnit / pow(tUnit, 2); }
31 
32  // stiffness: 1 N/m = 1e-3 uN/mm
33  inline Mdouble kUnit() { return fUnit() / lUnit; }
34 
35  // stress: ug/(mm*ms^2) = 1 Pa
36  inline Mdouble sigUnit() { return mUnit / (lUnit * pow(tUnit, 2)); }
37 
38  // density: 1 ug/mm^3 = 1 kg/m^3
39  inline Mdouble rhoUnit() { return mUnit / pow(lUnit, 3); }
40 
41  // velocity
42  inline Mdouble velUnit() { return lUnit / tUnit; }
43 
44  // acceleration
45  inline Mdouble accUnit() { return lUnit / pow(tUnit, 2); }
46 
47  // simulation name
48  std::string name;
49 }
50 
51 //=============begin_MercuryDPM_problem====================================
53 //======================================================================
54 
55 class MercuryProblem : public Mercury3D {
56 public:
57 
58  MercuryProblem() = default;
59 
60  void setupMercuryProblem(const char *name, const unsigned &dim, const double &rveSize, const unsigned &rve,
61  const Mdouble &g, const Mdouble &tMax, const unsigned &nWrite) {
62  units::name = name;
63  setName(name);
65  nParticlesPerRVE1D = rve;
66  RVESize = rveSize;
67  setGravity(Vec3D(0.0, 0.0, g));
68  setXMin(-0.5 / units::lUnit);
69  setXMax(0.5 / units::lUnit);
70  setYMin(-5.0 / units::lUnit);
71  setYMax(5.0 / units::lUnit);
72  setZMin(-0.5 / units::lUnit);
73  setZMax(5.0 / units::lUnit);
75  setTimeMax(tMax);
76 // setSaveCount(1);
77  setSaveCount(unsigned(getTimeMax() / getTimeStep() / nWrite));
80  }
81 
82  void setSpeciesProperties(const unsigned &flag) {
85  eps = 1.0;
86 
88  const Mdouble density = 2500.0 / units::rhoUnit();
90  species->setDensity(density);
91  Mdouble mass = species->getMassFromRadius(radius);
93  species->setStiffnessAndRestitutionCoefficient(1e8 * pow(2 * radius, 2) / (2 * radius), eps, mass);
94  tc = species->getCollisionTime(mass);
95  setTimeStep(tc * 0.02);
96  }
97 
98  void setupInitialConditions() override;
99 
100  void createWalls();
101 
102  TriangleWall *createTriangleWall(std::array<Vec3D, 3> vertex) {
103  TriangleWall wall;
104  auto species = speciesHandler.getObject(0);
105  wall.setSpecies(species);
106  wall.setVertices(vertex[0], vertex[1], vertex[2]);
107  auto w = wallHandler.copyAndAddObject(wall);
108  return w;
109  }
110 
111  void actionsAfterTimeStep() override {
112 /*
113  for (auto inter : interactionHandler) {
114  std::cout << inter->getI()->getGroupId() << inter->getI()->getName() << " " << inter->getP()->getGroupId()
115  << inter->getP()->getName() << std::endl;
116  }
117 */
118  // check if equilibrium is broken
121  if (a.getZ() > 1.0e-5*f.getZ())
122  {
123  logger(INFO,"interaction force: % % % , body force: % % %",f.getX(),f.getY(),f.getZ(),a.getX(),a.getY(),a.getZ());
124  }
125 
126  // check if each particle-wall interaction is unique
127  unsigned n = 0;
128  for (auto w : wallHandler) {
129  for (auto inter : w->getInteractions())
130  {
131  Vec3D f = inter->getForce();
132  logger(INFO, "wallID#% has force %, % , %", w->getId(), f.getX(), f.getY(), f.getZ());
133  }
134  n += w->getInteractions().size();
135  }
136  if (n>particleHandler.getNumberOfObjects()) logger(INFO, "% walls have interactions with the particle",n);
137  }
138 
139 private:
140 
143  Mdouble tc = 0.01;
144 
145  double RVESize = 0;
146  unsigned nParticlesPerRVE1D = 1;
148  std::vector<TriangleWall *> listOfTriangleWalls;
149 
150 };
151 
152 #endif //PROJECT_MERCURYPROB_H
153 
const unsigned n
Definition: CG3DPackingUnitTest.cpp:32
Species< LinearViscoelasticNormalSpecies > LinearViscoelasticSpecies
Definition: LinearViscoelasticSpecies.h:33
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
@ INFO
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 * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:613
T * getLastObject()
Gets a pointer to the last Object in this BaseHandler.
Definition: BaseHandler.h:634
const Vec3D & getForce() const
Returns the force on this BaseInteractable.
Definition: BaseInteractable.h:126
const Vec3D & getForce() const
Gets the current force (vector) between the two interacting objects.
Definition: BaseInteraction.h:210
void setSpecies(const ParticleSpecies *species)
Defines the species of the current wall.
Definition: BaseWall.cc:169
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
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
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 setXMax(Mdouble newXMax)
Sets the value of XMax, the upper bound of the problem domain in the x-direction.
Definition: DPMBase.cc:1165
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1467
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created.
Definition: DPMBase.h:1437
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 setSystemDimensions(unsigned int newDim)
Sets the system dimensionality.
Definition: DPMBase.cc:1417
void setXMin(Mdouble newXMin)
Sets the value of XMin, the lower bound of the problem domain in the x-direction.
Definition: DPMBase.cc:1010
Mdouble getTimeMax() const
Returns the maximum simulation duration.
Definition: DPMBase.cc:888
void setGravity(Vec3D newGravity)
Sets a new value for the gravitational acceleration.
Definition: DPMBase.cc:1383
This adds on the hierarchical grid code for 3D problems.
Definition: Mercury3D.h:37
Problem class for a single particle bouncing on a "beam" structure.
Definition: MercuryProb.h:55
MercuryProblem()=default
Mdouble tc
Definition: MercuryProb.h:143
double RVESize
Definition: MercuryProb.h:145
void createWalls()
Definition: SingleSphere.cpp:47
Mdouble posZ0
Definition: MercuryProb.h:147
Mdouble radius
Definition: MercuryProb.h:141
unsigned nParticlesPerRVE1D
Definition: MercuryProb.h:146
Mdouble eps
Definition: MercuryProb.h:142
void actionsAfterTimeStep() override
A virtual function which allows to define operations to be executed after time step.
Definition: MercuryProb.h:111
void setSpeciesProperties(const unsigned &flag)
Definition: MercuryProb.h:82
std::vector< TriangleWall * > listOfTriangleWalls
Definition: MercuryProb.h:148
void setupMercuryProblem(const char *name, const unsigned &dim, const double &rveSize, const unsigned &rve, const Mdouble &g, const Mdouble &tMax, const unsigned &nWrite)
Definition: MercuryProb.h:60
TriangleWall * createTriangleWall(std::array< Vec3D, 3 > vertex)
Definition: MercuryProb.h:102
void setupInitialConditions() override
This function allows to set the initial conditions for our problem to be solved, by default particle ...
Definition: SingleSphere.cpp:28
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
A TriangleWall is convex polygon defined as an intersection of InfiniteWall's.
Definition: TriangleWall.h:57
void setVertices(Vec3D A, Vec3D B, Vec3D C)
Sets member variables such that the wall represents a triangle with vertices A, B,...
Definition: TriangleWall.cc:165
Definition: Vector.h:51
Mdouble getZ() const
Definition: Vector.h:408
Mdouble getX() const
Definition: Vector.h:402
Mdouble getY() const
Definition: Vector.h:405
void setWriteVTK(FileType)
Sets whether walls are written into a VTK file.
Definition: WallHandler.cc:467
Definition: MercuryProb.h:21
Mdouble mUnit
Definition: MercuryProb.h:23
Mdouble accUnit()
Definition: MercuryProb.h:45
Mdouble rhoUnit()
Definition: MercuryProb.h:39
Mdouble velUnit()
Definition: MercuryProb.h:42
Mdouble lUnit
Definition: MercuryProb.h:25
Mdouble tUnit
Definition: MercuryProb.h:27
Mdouble kUnit()
Definition: MercuryProb.h:33
Mdouble fUnit()
Definition: MercuryProb.h:30
std::string name
Definition: MercuryProb.h:48
Mdouble sigUnit()
Definition: MercuryProb.h:36