GlasPeriodic.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 #include <string.h>
6 #include "Chute.h"
8 #include "Walls/InfiniteWall.h"
10 
11 class SilbertPeriodic : public Chute
12 {
13 public:
14 
16  // Problem parameters
17  setName("silbert");
18 
19  //time stepping
20  setTimeStep(1e-4);
21  setTimeMax(2000);
22 
23  //output parameters
24  setSaveCount(50e4);
25 
26  //particle radii
28  setFixedParticleRadius(.5);//getInflowParticleRadius());
30 
31  //particle properties
32  baseSpecies = nullptr;
35  //~ setStiffnessAndRestitutionCoefficient(2e5,0.97,1);
36  double tc=5e-3, r=0.97, beta=0.44, mu=0.092, mur=0.042;
37  species->setCollisionTimeAndNormalAndTangentialRestitutionCoefficient(tc,r,beta,1.0);// need to consider effective mass
38  species->setSlidingFrictionCoefficient(mu);
39  species->setRollingFrictionCoefficient(mur);
40 
41  //chute properties
43  setChuteLength(20);
44  setChuteWidth(10);
45  set_H(20);
46  nCreated_=0;
47 
48  }
49 
50  //void fix_hgrid() {
51  //assume 1-2 levels are optimal (which is the case for mono and bidispersed) and set the cell size to min and max
52  // !this is not optimal for polydispersed
53  // double minCell = 2.*min(getFixedParticleRadius(),getMinInflowParticleRadius());
54  // double maxCell = 2.*max(getFixedParticleRadius(),getMaxInflowParticleRadius());
55  // if ((minCell==maxCell)|(minCell==0.)) set_HGRID_max_levels(1);
56  // else set_HGRID_max_levels(2);
57  // set_HGRID_cell_to_cell_ratio (1.0000001*maxCell/minCell);
58  //}
59 
61  if (baseSpecies!= nullptr)
62  return baseSpecies->getSlidingFrictionCoefficient();
63  else return species->getSlidingFrictionCoefficient();
64  }
67  baseSpecies->setSlidingFrictionCoefficient(new_);
68  }
69  virtual void createBaseSpecies() {
70  //only create once
71  static bool created=false;
72  if (!created) {
73  auto species1 = speciesHandler.copyAndAddObject(species);
75  for (unsigned int i=0; i<particleHandler.getNumberOfObjects(); i++) {
77  }
78  }
79  }
80 
81  void set_study() {
82  std::stringstream name;
83  name << "H" << getInflowHeight()
84  << "A" << getChuteAngleDegrees()
85  << "L" << round(100.*getFixedParticleRadius()*2.)/100.
86  << "M" << species->getSlidingFrictionCoefficient()
88  dataFile.setName(name.str().c_str());
89  //set_data_filename();
90  }
91 
92  void set_study(int study_num) {
93  //S=0-5: lambda = 0, 3./6., 4./6., 5./6., 1, 2
94  //S=6-8: mu = 0, 1, inf
95  //S=9-13: mub = 0,1,inf,1/4,1/8
96  //S=14-15: mu = 1/4, 1/8
97  //S=16-19: lambda = 1./6., 2./6., 1.5, 4
98  //S=21-25: mub=1/16,1/32,1/64,1/128,1/1024
99  //S=26-28: lambda=1/2, mub=1/16,1/128,1/1024
100  //S=29-32: lambda=0, mub=1/16,1/128,1/1024,0
101 
102  if (study_num < 6) {
103  // set mu_all = 0.5, vary lambda
104  double Lambdas[] = {0, 3./6., 4./6., 5./6., 1, 2};
105  setFixedParticleRadius(Lambdas[study_num]/2.);
106  } else {
107  //If study_num is complete quit
108  logger(VERBOSE, "Study is complete ");
109  exit(0);
110  }
111  //Note make sure h and a is defined
112  set_study();
113  }
114 
115  void set_study(std::vector<int> study_num) {
116  double Heights[] = {10, 20, 30, 40};
117  double Angles[] = {20, 22, 24, 26, 28, 30, 40, 50, 60};
118  setInflowHeight(Heights[study_num[1]-1]);
119  setChuteAngle(Angles[study_num[2]-1]);
120  set_study(study_num[0]);
121  }
122 
123  //Do not add or remove particles
124  void actionsBeforeTimeStep() override { };
125 
126  //Set up periodic walls, rough bottom, add flow particles
127  void setupInitialConditions() override
128  {
129  //fix_hgrid();
130  //set_Nmax(particleHandler.getNumberOfObjects()+getChuteLength()*getChuteWidth()*getZMax());//why is this line needed?
131 
132  createBottom();
133  //~ write(std::cout,false);
134  //cout << "correct fixed" << endl;
136  for (int i=0; i<particleHandler.getNumberOfObjects(); i++)
139  }
140 
141  //set_NWall(1);
142  InfiniteWall w0;
143  if (getFixedParticleRadius()) {
144  w0.set(Vec3D(0,0,-1), Vec3D(0,0,-3.4* getMaxInflowParticleRadius()));
145  } else {
146  w0.set(Vec3D(0,0,-1), Vec3D(0,0,0));
147  }
149 
150  PeriodicBoundary b0;//set_NWallPeriodic(2);
151  b0.set(Vec3D( 1.0, 0.0, 0.0), getXMin(), getXMax());
153  b0.set(Vec3D( 0.0, 1.0, 0.0), getYMin(), getYMax());
156 
157 // std::cout << std::endl << "Status before solve:" << std::endl;
158 // std::cout
159 // << "tc=" << getCollisionTime()
160 // << ", eps=" << getRestitutionCoefficient()
161 // //<< ", vmax=" << getMaximumVelocity()
162 // << ", getInflowHeight()/zmax=" << getInflowHeight()/getZMax()
163 // << std::endl << std::endl;
164  //~ timer.set(t,tmax);
165 
166  //optimize number of buckets
167  //std::cout << "Nmax" << get_Nmax() << std::endl;
168  //setHGridNumberOfBucketsToPower(particleHandler.getNumberOfObjects()*1.5);
169  }
170 
171  //add flow particles
173  {
174  //setHGridNumberBucketsToPower(get_Nmax());
178  //set_Nmax(N); // automated in the new version
179  double H = getInflowHeight();
180  setZMax(1.2*getInflowHeight());
181 
182  //writeRestartFile();
183  //try to find new insertable particles
189  }
191  //setHGridNumberOfBucketsToPower();
192  write(std::cout,false);
193  }
194 
195  //defines type of flow particles
197  {
199  //inflowParticle_.computeMass();
200  Vec3D position;
202  position.Y = random.getRandomNumber(getYMin() + 2.0 * inflowParticle_.getRadius(), getYMax());
204  inflowParticle_.setPosition(position);
205  inflowParticle_.setVelocity(Vec3D(0.0, 0.0, 0.0));
206  }
207 
208  //set approximate height of flow
209  void set_H(double new_)
210  {
211  setInflowHeight(new_);
213  }
214 
215  double get_H()
216  { return getInflowHeight(); }
217 
218  void printTime() const override
219  {
220  logger(INFO, "t=%3.6"
221  ", tmax=%3.6"
222  ", N=%3.6",
224  //<< ", time left=" << setprecision(3) << left << setw(6) << timer.getTime2Finish(t)
225  //~ << ", finish by " << setprecision(3) << left << setw(6) << timer.getFinishTime(t)
226  }
227 
228  bool readNextArgument(int& i, int argc, char* argv[]) override
229  {
230  if (!strcmp(argv[i], "-muBottom"))
231  {
232  setSlidingFrictionCoefficientBottom(atof(argv[i + 1]));
234  }
235  else return Chute::readNextArgument(i, argc, argv); //if argv[i] is not found, check the commands in Chute
236  return true; //returns true if argv[i] is found
237  }
238 
239  int getNCreated() const
240  {
241  return nCreated_;
242  }
243 
245  {
246  nCreated_++;
247  }
248 
249  int nCreated_;
251 public:
254 };
int i
Definition: BiCGSTAB_step_by_step.cpp:9
@ MULTILAYER
Definition: Chute.h:32
Array< double, 1, 3 > e(1./3., 0.5, 2.)
MatrixXf H
Definition: HessenbergDecomposition_matrixH.cpp:4
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.
@ INFO
@ VERBOSE
virtual unsigned int getNumberOfObjects() const
Gets the number of real Object in this BaseHandler. (i.e. no mpi or periodic particles)
Definition: BaseHandler.h:656
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
void setVelocity(const Vec3D &velocity)
set the velocity of the BaseInteractable.
Definition: BaseInteractable.cc:328
virtual void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
Definition: BaseInteractable.h:218
bool isFixed() const override
Is fixed Particle function. It returns whether a Particle is fixed or not, by checking its inverse Ma...
Definition: BaseParticle.h:72
Mdouble getRadius() const
Returns the particle's radius.
Definition: BaseParticle.h:331
virtual void setRadius(Mdouble radius)
Sets the particle's radius_ (and adjusts the mass_ accordingly, based on the particle's species)
Definition: BaseParticle.cc:548
virtual void setSpecies(const ParticleSpecies *species)
Definition: BaseParticle.cc:798
Creates chutes with different bottoms. Inherits from Mercury3D (-> MercuryBase -> DPMBase).
Definition: Chute.h:44
void setChuteWidth(Mdouble chuteWidth)
Sets the chute width (Y-direction)
Definition: Chute.cc:1018
void setInflowParticleRadius(Mdouble inflowParticleRadius)
Sets the radius of the inflow particles to a single one (i.e. ensures a monodisperse inflow).
Definition: Chute.cc:827
void setRoughBottomType(RoughBottomType roughBottomType)
Sets the type of rough bottom of the chute.
Definition: Chute.cc:693
virtual void setChuteLength(Mdouble chuteLength)
Sets the chute length (X-direction)
Definition: Chute.cc:1038
Mdouble getFixedParticleRadius() const
Returns the particle radius of the fixed particles which constitute the (rough) chute bottom.
Definition: Chute.cc:650
Mdouble getMaxInflowParticleRadius() const
Returns the maximum radius of inflow particles.
Definition: Chute.cc:926
Mdouble getInflowHeight() const
Returns the maximum inflow height (Z-direction)
Definition: Chute.cc:953
virtual void createBottom()
Creates the chute bottom, which can be either flat or one of three flavours of rough.
Definition: Chute.cc:302
bool readNextArgument(int &i, int argc, char *argv[]) override
This method can be used for reading object properties from a string.
Definition: Chute.cc:534
void setChuteAngleAndMagnitudeOfGravity(Mdouble chuteAngle, Mdouble gravity)
Sets gravity vector according to chute angle (in degrees)
Definition: Chute.cc:768
Mdouble getChuteLength() const
Returns the chute length (X-direction)
Definition: Chute.cc:1048
void write(std::ostream &os, bool writeAllParticles=true) const override
This function writes the Chute properties to an ostream, and adds the properties of ALL chute particl...
Definition: Chute.cc:185
Mdouble getChuteWidth() const
Returns the chute width (Y-direction)
Definition: Chute.cc:1028
void setChuteAngle(Mdouble chuteAngle)
Sets gravity vector according to chute angle (in degrees)
Definition: Chute.cc:747
void setInflowHeight(Mdouble inflowHeight)
Sets maximum inflow height (Z-direction)
Definition: Chute.cc:936
void setFixedParticleRadius(Mdouble fixedParticleRadius)
Sets the particle radius of the fixed particles which constitute the (rough) chute bottom.
Definition: Chute.cc:632
Mdouble getChuteAngleDegrees() const
Returns the chute angle (in degrees)
Definition: Chute.cc:795
Mdouble getXMin() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMin() returns XMin.
Definition: DPMBase.h:603
Mdouble getXMax() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMax() returns XMax.
Definition: DPMBase.h:610
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
Mdouble getYMin() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMin() returns YMin.
Definition: DPMBase.h:616
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 getTime() const
Returns the current simulation time.
Definition: DPMBase.cc:799
File dataFile
An instance of class File to handle in- and output into a .data file.
Definition: DPMBase.h:1484
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1453
BoundaryHandler boundaryHandler
An object of the class BoundaryHandler which concerns insertion and deletion of particles into or fro...
Definition: DPMBase.h:1458
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
RNG random
This is a random generator, often used for setting up the initial conditions etc.....
Definition: DPMBase.h:1438
Mdouble getYMax() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMax() returns XMax.
Definition: DPMBase.h:622
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
Mdouble getTimeMax() const
Returns the maximum simulation duration.
Definition: DPMBase.cc:879
Mdouble getZMin() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMin() returns ZMin.
Definition: DPMBase.h:628
void setName(const std::string &name)
Sets the file name, e.g. "Name.data".
Definition: File.cc:176
A infinite wall fills the half-space {point: (position_-point)*normal_<=0}.
Definition: InfiniteWall.h:27
void set(Vec3D normal, Vec3D point)
Defines a standard wall, given an outward normal vector s.t. normal*x=normal*point for all x of the w...
Definition: InfiniteWall.cc:97
void hGridActionsBeforeTimeLoop() override
This sets up the broad phase information, has to be done at this stage because it requires the partic...
Definition: MercuryBase.cc:73
bool checkParticleForInteraction(const BaseParticle &P) final
Checks if given BaseParticle has an interaction with a BaseWall or other BaseParticle.
Definition: MercuryBase.cc:573
void hGridActionsBeforeTimeStep() override
Performs all necessary actions before a time-step, like updating the particles and resetting all the ...
Definition: MercuryBase.cc:302
Contains contact force properties for contacts between particles with two different species.
Definition: MixedSpecies.h:22
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
void setDensity(Mdouble density)
Definition: ParticleSpecies.cc:88
Defines a pair of periodic walls. Inherits from BaseBoundary.
Definition: PeriodicBoundary.h:20
void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight)
Defines a PeriodicBoundary by its normal and positions.
Definition: PeriodicBoundary.cc:63
Mdouble getRandomNumber()
This is a random generating routine can be used for initial positions.
Definition: RNG.cc:123
Definition: flowRuleDiego_HeightAngle.cpp:14
virtual void createBaseSpecies()
Definition: flowRuleDiego_HeightAngle.cpp:68
LinearViscoelasticMixedSpecies * baseSpecies
Definition: flowRuleDiego_HeightAngle.cpp:245
void setSlidingFrictionCoefficientBottom(Mdouble new_)
Definition: GlasPeriodic.h:65
void add_flow_particles()
Definition: flowRuleDiego_HeightAngle.cpp:144
void create_inflow_particle()
Definition: flowRuleDiego_HeightAngle.cpp:189
LinearViscoelasticSpecies * species
Definition: flowRuleDiego_HeightAngle.cpp:244
void increaseNCreated()
Definition: flowRuleDiego_HeightAngle.cpp:235
void set_study()
Definition: GlasPeriodic.h:81
void set_H(Mdouble new_)
Definition: flowRuleDiego_HeightAngle.cpp:210
SphericalParticle inflowParticle_
Definition: flowRuleDiego_HeightAngle.cpp:242
SilbertPeriodic()
Definition: GlasPeriodic.h:15
void actionsBeforeTimeStep() override
A virtual function which allows to define operations to be executed before the new time step.
Definition: GlasPeriodic.h:124
double get_H()
Definition: GlasPeriodic.h:215
bool readNextArgument(int &i, int argc, char *argv[]) override
Interprets the i^th command-line argument.
Definition: GlasPeriodic.h:228
int nCreated_
Definition: flowRuleDiego_HeightAngle.cpp:240
void set_H(double new_)
Definition: GlasPeriodic.h:209
LinearViscoelasticFrictionSpecies * species
Definition: GlasPeriodic.h:252
Mdouble getSlidingFrictionCoefficientBottom()
Definition: GlasPeriodic.h:60
void set_study(std::vector< int > study_num)
Definition: GlasPeriodic.h:115
void set_study(int study_num)
Definition: GlasPeriodic.h:92
void printTime() const override
Displays the current simulation time and the maximum simulation duration.
Definition: GlasPeriodic.h:218
int getNCreated() const
Definition: GlasPeriodic.h:239
void setupInitialConditions() override
This function allows to set the initial conditions for our problem to be solved, by default particle ...
Definition: GlasPeriodic.h:127
LinearViscoelasticFrictionMixedSpecies * baseSpecies
Definition: GlasPeriodic.h:253
std::enable_if<!std::is_pointer< typename U::MixedSpeciesType >::value, typename U::MixedSpeciesType * >::type getMixedObject(const U *S, const U *T)
Definition: SpeciesHandler.h:52
A spherical particle is the most simple particle used in MercuryDPM.
Definition: SphericalParticle.h:16
Definition: Kernel/Math/Vector.h:30
Mdouble Y
Definition: Kernel/Math/Vector.h:45
Mdouble Z
Definition: Kernel/Math/Vector.h:45
Mdouble X
the vector components
Definition: Kernel/Math/Vector.h:45
@ N
Definition: constructor.cpp:22
Scalar beta
Definition: level2_cplx_impl.h:36
EIGEN_STRONG_INLINE EIGEN_DEVICE_FUNC bfloat16 round(const bfloat16 &a)
Definition: BFloat16.h:646
std::complex< double > mu
Definition: time_harmonic_fourier_decomposed_linear_elasticity/cylinder/cylinder.cc:52
r
Definition: UniformPSDSelfTest.py:20
const Mdouble pi
Definition: ExtendedMath.h:23
list mur
Definition: plotDoE.py:18
string name
Definition: plotDoE.py:33