MercuryProb.h
Go to the documentation of this file.
1 // This file is part of the MercuryDPM project (https://www.mercurydpm.org).
2 // Copyright (c), The MercuryDPM Developers Team. All rights reserved.
3 // License: BSD 3-Clause License; see the LICENSE file in the root directory.
4 
5 //
6 // Created by cheng on 2/13/19.
7 //
8 
9 #ifndef PROJECT_MERCURYPROB_H
10 #define PROJECT_MERCURYPROB_H
11 
12 // Generic MercuryDPM header
13 #include <Mercury3D.h>
15 #include "Walls/TriangleWall.h"
16 
17 //=======start_namespace==========================================
23 //================================================================
24 
25 namespace units {
26  // mass: 1 ug = kg
27  Mdouble mUnit = 1e-9;
28  // length: 1 mm = 1e-3 m
29  Mdouble lUnit = 1e-3;
30  // time: 1 ms = 1e-3 s
31  Mdouble tUnit = 1e-3;
32 
33  // force: 1 uN = 1e-6 N
34  inline Mdouble fUnit() { return mUnit * lUnit / pow(tUnit, 2); }
35 
36  // stiffness: 1 N/m = 1e-3 uN/mm
37  inline Mdouble kUnit() { return fUnit() / lUnit; }
38 
39  // stress: ug/(mm*ms^2) = 1 Pa
40  inline Mdouble sigUnit() { return mUnit / (lUnit * pow(tUnit, 2)); }
41 
42  // density: 1 ug/mm^3 = 1 kg/m^3
43  inline Mdouble rhoUnit() { return mUnit / pow(lUnit, 3); }
44 
45  // velocity
46  inline Mdouble velUnit() { return lUnit / tUnit; }
47 
48  // acceleration
49  inline Mdouble accUnit() { return lUnit / pow(tUnit, 2); }
50 
51  // simulation name
53 }
54 
55 //=============begin_MercuryDPM_problem====================================
57 //======================================================================
58 
59 class MercuryProblem : public Mercury3D {
60 public:
61 
62  MercuryProblem() = default;
63 
64  void setupMercuryProblem(const char *name, const unsigned &dim, const double &rveSize, const unsigned &rve,
65  const Mdouble &g, const Mdouble &tMax, const unsigned &nWrite) {
66  units::name = name;
67  setName(name);
69  nParticlesPerRVE1D = rve;
70  RVESize = rveSize;
71  setGravity(Vec3D(0.0, 0.0, g));
72  setXMin(-0.5 / units::lUnit);
73  setXMax(0.5 / units::lUnit);
74  setYMin(-5.0 / units::lUnit);
75  setYMax(5.0 / units::lUnit);
76  setZMin(-0.5 / units::lUnit);
77  setZMax(5.0 / units::lUnit);
79  setTimeMax(tMax);
80 // setSaveCount(1);
81  setSaveCount(unsigned(getTimeMax() / getTimeStep() / nWrite));
84  }
85 
86  void setSpeciesProperties(const unsigned &flag) {
89  eps = 1.0;
90 
92  const Mdouble density = 2500.0 / units::rhoUnit();
94  species->setDensity(density);
95  Mdouble mass = species->getMassFromRadius(radius);
97  species->setStiffnessAndRestitutionCoefficient(1e8 * pow(2 * radius, 2) / (2 * radius), eps, mass);
98  tc = species->getCollisionTime(mass);
99  setTimeStep(tc * 0.02);
100  }
101 
102  void setupInitialConditions() override;
103 
104  void createWalls();
105 
106  TriangleWall *createTriangleWall(std::array<Vec3D, 3> vertex) {
107  TriangleWall wall;
108  auto species = speciesHandler.getObject(0);
109  wall.setSpecies(species);
110  wall.setVertices(vertex[0], vertex[1], vertex[2]);
111  auto w = wallHandler.copyAndAddObject(wall);
112  return w;
113  }
114 
115  void actionsAfterTimeStep() override {
116 /*
117  for (auto inter : interactionHandler) {
118  std::cout << inter->getI()->getGroupId() << inter->getI()->getName() << " " << inter->getP()->getGroupId()
119  << inter->getP()->getName() << std::endl;
120  }
121 */
122  // check if equilibrium is broken
125  if (a.getZ() > 1.0e-5*f.getZ())
126  {
127  logger(INFO,"interaction force: % % % , body force: % % %",f.getX(),f.getY(),f.getZ(),a.getX(),a.getY(),a.getZ());
128  }
129 
130  // check if each particle-wall interaction is unique
131  unsigned n = 0;
132  for (auto w : wallHandler) {
133  for (auto inter : w->getInteractions())
134  {
135  Vec3D f = inter->getForce();
136  logger(INFO, "wallID#% has force %, % , %", w->getId(), f.getX(), f.getY(), f.getZ());
137  }
138  n += w->getInteractions().size();
139  }
140  if (n>particleHandler.getNumberOfObjects()) logger(INFO, "% walls have interactions with the particle",n);
141  }
142 
143 private:
144 
147  Mdouble tc = 0.01;
148 
149  double RVESize = 0;
150  unsigned nParticlesPerRVE1D = 1;
152  std::vector<TriangleWall *> listOfTriangleWalls;
153 
154 };
155 
156 #endif //PROJECT_MERCURYPROB_H
157 
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
Array< double, 1, 3 > e(1./3., 0.5, 2.)
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.
@ INFO
RowVector3d w
Definition: Matrix_resize_int.cpp:3
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 * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:621
T * getLastObject()
Gets a pointer to the last Object in this BaseHandler.
Definition: BaseHandler.h:642
const Vec3D & getForce() const
Returns the force on this BaseInteractable.
Definition: BaseInteractable.h:105
const Vec3D & getForce() const
Gets the current force (vector) between the two interacting objects.
Definition: BaseInteraction.h:189
void setSpecies(const ParticleSpecies *species)
Defines the species of the current wall.
Definition: BaseWall.cc:148
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
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
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 setXMax(Mdouble newXMax)
Sets the value of XMax, the upper bound of the problem domain in the x-direction.
Definition: DPMBase.cc:1156
InteractionHandler interactionHandler
An object of the class InteractionHandler.
Definition: DPMBase.h:1473
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created.
Definition: DPMBase.h:1443
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 setSystemDimensions(unsigned int newDim)
Sets the system dimensionality.
Definition: DPMBase.cc:1408
void setXMin(Mdouble newXMin)
Sets the value of XMin, the lower bound of the problem domain in the x-direction.
Definition: DPMBase.cc:1001
Mdouble getTimeMax() const
Returns the maximum simulation duration.
Definition: DPMBase.cc:879
void setGravity(Vec3D newGravity)
Sets a new value for the gravitational acceleration.
Definition: DPMBase.cc:1374
This adds on the hierarchical grid code for 3D problems.
Definition: Mercury3D.h:16
Problem class for a single particle bouncing on a "beam" structure.
Definition: MercuryProb.h:59
MercuryProblem()=default
Mdouble tc
Definition: MercuryProb.h:147
double RVESize
Definition: MercuryProb.h:149
void createWalls()
Definition: SingleSphere.cpp:26
Mdouble posZ0
Definition: MercuryProb.h:151
Mdouble radius
Definition: MercuryProb.h:145
unsigned nParticlesPerRVE1D
Definition: MercuryProb.h:150
Mdouble eps
Definition: MercuryProb.h:146
void actionsAfterTimeStep() override
A virtual function which allows to define operations to be executed after time step.
Definition: MercuryProb.h:115
void setSpeciesProperties(const unsigned &flag)
Definition: MercuryProb.h:86
std::vector< TriangleWall * > listOfTriangleWalls
Definition: MercuryProb.h:152
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:64
TriangleWall * createTriangleWall(std::array< Vec3D, 3 > vertex)
Definition: MercuryProb.h:106
void setupInitialConditions() override
This function allows to set the initial conditions for our problem to be solved, by default particle ...
Definition: SingleSphere.cpp:7
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
A TriangleWall is convex polygon defined as an intersection of InfiniteWall's.
Definition: TriangleWall.h:36
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:144
Definition: Kernel/Math/Vector.h:30
void setWriteVTK(FileType)
Sets whether walls are written into a VTK file.
Definition: WallHandler.cc:445
static int f(const TensorMap< Tensor< int, 3 > > &tensor)
Definition: cxx11_tensor_map.cpp:237
const Scalar * a
Definition: level2_cplx_impl.h:32
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 pow(const bfloat16 &a, const bfloat16 &b)
Definition: BFloat16.h:625
density
Definition: UniformPSDSelfTest.py:19
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286
Definition: MercuryProb.h:25
Mdouble mUnit
Definition: MercuryProb.h:27
Mdouble accUnit()
Definition: MercuryProb.h:49
Mdouble rhoUnit()
Definition: MercuryProb.h:43
Mdouble velUnit()
Definition: MercuryProb.h:46
Mdouble lUnit
Definition: MercuryProb.h:29
Mdouble tUnit
Definition: MercuryProb.h:31
Mdouble kUnit()
Definition: MercuryProb.h:37
Mdouble fUnit()
Definition: MercuryProb.h:34
std::string name
Definition: MercuryProb.h:52
Mdouble sigUnit()
Definition: MercuryProb.h:40