GlasPeriodic.h
Go to the documentation of this file.
1 //Copyright (c) 2013-2023, The MercuryDPM Developers Team. All rights reserved.
2 //For the list of developers, see <http://www.MercuryDPM.org/Team>.
3 //
4 //Redistribution and use in source and binary forms, with or without
5 //modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name MercuryDPM nor the
12 // names of its contributors may be used to endorse or promote products
13 // derived from this software without specific prior written permission.
14 //
15 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 //DISCLAIMED. IN NO EVENT SHALL THE MERCURYDPM DEVELOPERS TEAM BE LIABLE FOR ANY
19 //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 #include <string.h>
27 #include "Chute.h"
29 #include "Walls/InfiniteWall.h"
31 
32 class SilbertPeriodic : public Chute
33 {
34 public:
35 
37  // Problem parameters
38  setName("silbert");
39 
40  //time stepping
41  setTimeStep(1e-4);
42  setTimeMax(2000);
43 
44  //output parameters
45  setSaveCount(50e4);
46 
47  //particle radii
49  setFixedParticleRadius(.5);//getInflowParticleRadius());
51 
52  //particle properties
53  baseSpecies = nullptr;
56  //~ setStiffnessAndRestitutionCoefficient(2e5,0.97,1);
57  double tc=5e-3, r=0.97, beta=0.44, mu=0.092, mur=0.042;
58  species->setCollisionTimeAndNormalAndTangentialRestitutionCoefficient(tc,r,beta,1.0);// need to consider effective mass
59  species->setSlidingFrictionCoefficient(mu);
60  species->setRollingFrictionCoefficient(mur);
61 
62  //chute properties
64  setChuteLength(20);
65  setChuteWidth(10);
66  set_H(20);
67  nCreated_=0;
68 
69  }
70 
71  //void fix_hgrid() {
72  //assume 1-2 levels are optimal (which is the case for mono and bidispersed) and set the cell size to min and max
73  // !this is not optimal for polydispersed
74  // double minCell = 2.*min(getFixedParticleRadius(),getMinInflowParticleRadius());
75  // double maxCell = 2.*max(getFixedParticleRadius(),getMaxInflowParticleRadius());
76  // if ((minCell==maxCell)|(minCell==0.)) set_HGRID_max_levels(1);
77  // else set_HGRID_max_levels(2);
78  // set_HGRID_cell_to_cell_ratio (1.0000001*maxCell/minCell);
79  //}
80 
82  if (baseSpecies!= nullptr)
83  return baseSpecies->getSlidingFrictionCoefficient();
84  else return species->getSlidingFrictionCoefficient();
85  }
88  baseSpecies->setSlidingFrictionCoefficient(new_);
89  }
90  virtual void createBaseSpecies() {
91  //only create once
92  static bool created=false;
93  if (!created) {
94  auto species1 = speciesHandler.copyAndAddObject(species);
96  for (unsigned int i=0; i<particleHandler.getNumberOfObjects(); i++) {
98  }
99  }
100  }
101 
102  void set_study() {
103  std::stringstream name;
104  name << "H" << getInflowHeight()
105  << "A" << getChuteAngleDegrees()
106  << "L" << round(100.*getFixedParticleRadius()*2.)/100.
107  << "M" << species->getSlidingFrictionCoefficient()
109  dataFile.setName(name.str().c_str());
110  //set_data_filename();
111  }
112 
113  void set_study(int study_num) {
114  //S=0-5: lambda = 0, 3./6., 4./6., 5./6., 1, 2
115  //S=6-8: mu = 0, 1, inf
116  //S=9-13: mub = 0,1,inf,1/4,1/8
117  //S=14-15: mu = 1/4, 1/8
118  //S=16-19: lambda = 1./6., 2./6., 1.5, 4
119  //S=21-25: mub=1/16,1/32,1/64,1/128,1/1024
120  //S=26-28: lambda=1/2, mub=1/16,1/128,1/1024
121  //S=29-32: lambda=0, mub=1/16,1/128,1/1024,0
122 
123  if (study_num < 6) {
124  // set mu_all = 0.5, vary lambda
125  double Lambdas[] = {0, 3./6., 4./6., 5./6., 1, 2};
126  setFixedParticleRadius(Lambdas[study_num]/2.);
127  } else {
128  //If study_num is complete quit
129  logger(VERBOSE, "Study is complete ");
130  exit(0);
131  }
132  //Note make sure h and a is defined
133  set_study();
134  }
135 
136  void set_study(std::vector<int> study_num) {
137  double Heights[] = {10, 20, 30, 40};
138  double Angles[] = {20, 22, 24, 26, 28, 30, 40, 50, 60};
139  setInflowHeight(Heights[study_num[1]-1]);
140  setChuteAngle(Angles[study_num[2]-1]);
141  set_study(study_num[0]);
142  }
143 
144  //Do not add or remove particles
145  void actionsBeforeTimeStep() override { };
146 
147  //Set up periodic walls, rough bottom, add flow particles
148  void setupInitialConditions() override
149  {
150  //fix_hgrid();
151  //set_Nmax(particleHandler.getNumberOfObjects()+getChuteLength()*getChuteWidth()*getZMax());//why is this line needed?
152 
153  createBottom();
154  //~ write(std::cout,false);
155  //cout << "correct fixed" << endl;
157  for (int i=0; i<particleHandler.getNumberOfObjects(); i++)
160  }
161 
162  //set_NWall(1);
163  InfiniteWall w0;
164  if (getFixedParticleRadius()) {
165  w0.set(Vec3D(0,0,-1), Vec3D(0,0,-3.4* getMaxInflowParticleRadius()));
166  } else {
167  w0.set(Vec3D(0,0,-1), Vec3D(0,0,0));
168  }
170 
171  PeriodicBoundary b0;//set_NWallPeriodic(2);
172  b0.set(Vec3D( 1.0, 0.0, 0.0), getXMin(), getXMax());
174  b0.set(Vec3D( 0.0, 1.0, 0.0), getYMin(), getYMax());
177 
178 // std::cout << std::endl << "Status before solve:" << std::endl;
179 // std::cout
180 // << "tc=" << getCollisionTime()
181 // << ", eps=" << getRestitutionCoefficient()
182 // //<< ", vmax=" << getMaximumVelocity()
183 // << ", getInflowHeight()/zmax=" << getInflowHeight()/getZMax()
184 // << std::endl << std::endl;
185  //~ timer.set(t,tmax);
186 
187  //optimize number of buckets
188  //std::cout << "Nmax" << get_Nmax() << std::endl;
189  //setHGridNumberOfBucketsToPower(particleHandler.getNumberOfObjects()*1.5);
190  }
191 
192  //add flow particles
194  {
195  //setHGridNumberBucketsToPower(get_Nmax());
199  //set_Nmax(N); // automated in the new version
200  double H = getInflowHeight();
201  setZMax(1.2*getInflowHeight());
202 
203  //writeRestartFile();
204  //try to find new insertable particles
210  }
211  setInflowHeight(H);
212  //setHGridNumberOfBucketsToPower();
213  write(std::cout,false);
214  }
215 
216  //defines type of flow particles
218  {
220  //inflowParticle_.computeMass();
221  Vec3D position;
223  position.Y = random.getRandomNumber(getYMin() + 2.0 * inflowParticle_.getRadius(), getYMax());
225  inflowParticle_.setPosition(position);
226  inflowParticle_.setVelocity(Vec3D(0.0, 0.0, 0.0));
227  }
228 
229  //set approximate height of flow
230  void set_H(double new_)
231  {
232  setInflowHeight(new_);
234  }
235 
236  double get_H()
237  { return getInflowHeight(); }
238 
239  void printTime() const override
240  {
241  logger(INFO, "t=%3.6"
242  ", tmax=%3.6"
243  ", N=%3.6",
245  //<< ", time left=" << setprecision(3) << left << setw(6) << timer.getTime2Finish(t)
246  //~ << ", finish by " << setprecision(3) << left << setw(6) << timer.getFinishTime(t)
247  }
248 
249  bool readNextArgument(int& i, int argc, char* argv[]) override
250  {
251  if (!strcmp(argv[i], "-muBottom"))
252  {
253  setSlidingFrictionCoefficientBottom(atof(argv[i + 1]));
255  }
256  else return Chute::readNextArgument(i, argc, argv); //if argv[i] is not found, check the commands in Chute
257  return true; //returns true if argv[i] is found
258  }
259 
260  int getNCreated() const
261  {
262  return nCreated_;
263  }
264 
266  {
267  nCreated_++;
268  }
269 
270  int nCreated_;
272 public:
275 };
@ MULTILAYER
Definition: Chute.h:53
Species< LinearViscoelasticNormalSpecies, FrictionSpecies > LinearViscoelasticFrictionSpecies
Definition: LinearViscoelasticFrictionSpecies.h:34
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:648
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
void setVelocity(const Vec3D &velocity)
set the velocity of the BaseInteractable.
Definition: BaseInteractable.cc:350
virtual void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
Definition: BaseInteractable.h:239
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:93
Mdouble getRadius() const
Returns the particle's radius.
Definition: BaseParticle.h:348
virtual void setRadius(Mdouble radius)
Sets the particle's radius_ (and adjusts the mass_ accordingly, based on the particle's species)
Definition: BaseParticle.cc:553
void setSpecies(const ParticleSpecies *species)
Definition: BaseParticle.cc:818
Creates chutes with different bottoms. Inherits from Mercury3D (-> MercuryBase -> DPMBase).
Definition: Chute.h:65
void setChuteWidth(Mdouble chuteWidth)
Sets the chute width (Y-direction)
Definition: Chute.cc:1039
void setInflowParticleRadius(Mdouble inflowParticleRadius)
Sets the radius of the inflow particles to a single one (i.e. ensures a monodisperse inflow).
Definition: Chute.cc:848
void setRoughBottomType(RoughBottomType roughBottomType)
Sets the type of rough bottom of the chute.
Definition: Chute.cc:714
virtual void setChuteLength(Mdouble chuteLength)
Sets the chute length (X-direction)
Definition: Chute.cc:1059
Mdouble getFixedParticleRadius() const
Returns the particle radius of the fixed particles which constitute the (rough) chute bottom.
Definition: Chute.cc:671
Mdouble getMaxInflowParticleRadius() const
Returns the maximum radius of inflow particles.
Definition: Chute.cc:947
Mdouble getInflowHeight() const
Returns the maximum inflow height (Z-direction)
Definition: Chute.cc:974
virtual void createBottom()
Creates the chute bottom, which can be either flat or one of three flavours of rough.
Definition: Chute.cc:323
bool readNextArgument(int &i, int argc, char *argv[]) override
This method can be used for reading object properties from a string.
Definition: Chute.cc:555
void setChuteAngleAndMagnitudeOfGravity(Mdouble chuteAngle, Mdouble gravity)
Sets gravity vector according to chute angle (in degrees)
Definition: Chute.cc:789
Mdouble getChuteLength() const
Returns the chute length (X-direction)
Definition: Chute.cc:1069
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:206
Mdouble getChuteWidth() const
Returns the chute width (Y-direction)
Definition: Chute.cc:1049
void setChuteAngle(Mdouble chuteAngle)
Sets gravity vector according to chute angle (in degrees)
Definition: Chute.cc:768
void setInflowHeight(Mdouble inflowHeight)
Sets maximum inflow height (Z-direction)
Definition: Chute.cc:957
void setFixedParticleRadius(Mdouble fixedParticleRadius)
Sets the particle radius of the fixed particles which constitute the (rough) chute bottom.
Definition: Chute.cc:653
Mdouble getChuteAngleDegrees() const
Returns the chute angle (in degrees)
Definition: Chute.cc:816
Mdouble getXMin() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMin() returns XMin.
Definition: DPMBase.h:619
Mdouble getXMax() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMax() returns XMax.
Definition: DPMBase.h:626
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
Mdouble getYMin() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMin() returns YMin.
Definition: DPMBase.h:632
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 getTime() const
Returns the current simulation time.
Definition: DPMBase.cc:808
File dataFile
An instance of class File to handle in- and output into a .data file.
Definition: DPMBase.h:1478
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1447
BoundaryHandler boundaryHandler
An object of the class BoundaryHandler which concerns insertion and deletion of particles into or fro...
Definition: DPMBase.h:1452
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
RNG random
This is a random generator, often used for setting up the initial conditions etc.....
Definition: DPMBase.h:1432
Mdouble getYMax() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMax() returns XMax.
Definition: DPMBase.h:638
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
Mdouble getTimeMax() const
Returns the maximum simulation duration.
Definition: DPMBase.cc:888
Mdouble getZMin() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMin() returns ZMin.
Definition: DPMBase.h:644
void setName(const std::string &name)
Sets the file name, e.g. "Name.data".
Definition: File.cc:198
A infinite wall fills the half-space {point: (position_-point)*normal_<=0}.
Definition: InfiniteWall.h:48
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:118
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:94
bool checkParticleForInteraction(const BaseParticle &P) final
Checks if given BaseParticle has an interaction with a BaseWall or other BaseParticle.
Definition: MercuryBase.cc:594
void hGridActionsBeforeTimeStep() override
Performs all necessary actions before a time-step, like updating the particles and resetting all the ...
Definition: MercuryBase.cc:323
Contains contact force properties for contacts between particles with two different species.
Definition: MixedSpecies.h:43
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
void setDensity(Mdouble density)
Definition: ParticleSpecies.cc:108
Defines a pair of periodic walls. Inherits from BaseBoundary.
Definition: PeriodicBoundary.h:41
void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight)
Defines a PeriodicBoundary by its normal and positions.
Definition: PeriodicBoundary.cc:84
Mdouble getRandomNumber()
This is a random generating routine can be used for initial positions.
Definition: RNG.cc:143
Definition: flowRuleDiego_HeightAngle.cpp:35
virtual void createBaseSpecies()
Definition: flowRuleDiego_HeightAngle.cpp:89
LinearViscoelasticMixedSpecies * baseSpecies
Definition: flowRuleDiego_HeightAngle.cpp:266
void setSlidingFrictionCoefficientBottom(Mdouble new_)
Definition: GlasPeriodic.h:86
void add_flow_particles()
Definition: flowRuleDiego_HeightAngle.cpp:165
void create_inflow_particle()
Definition: flowRuleDiego_HeightAngle.cpp:210
LinearViscoelasticSpecies * species
Definition: flowRuleDiego_HeightAngle.cpp:265
void increaseNCreated()
Definition: flowRuleDiego_HeightAngle.cpp:256
void set_study()
Definition: GlasPeriodic.h:102
void set_H(Mdouble new_)
Definition: flowRuleDiego_HeightAngle.cpp:231
SphericalParticle inflowParticle_
Definition: flowRuleDiego_HeightAngle.cpp:263
SilbertPeriodic()
Definition: GlasPeriodic.h:36
void actionsBeforeTimeStep() override
A virtual function which allows to define operations to be executed before the new time step.
Definition: GlasPeriodic.h:145
double get_H()
Definition: GlasPeriodic.h:236
bool readNextArgument(int &i, int argc, char *argv[]) override
Interprets the i^th command-line argument.
Definition: GlasPeriodic.h:249
int nCreated_
Definition: flowRuleDiego_HeightAngle.cpp:261
void set_H(double new_)
Definition: GlasPeriodic.h:230
LinearViscoelasticFrictionSpecies * species
Definition: GlasPeriodic.h:273
Mdouble getSlidingFrictionCoefficientBottom()
Definition: GlasPeriodic.h:81
void set_study(std::vector< int > study_num)
Definition: GlasPeriodic.h:136
void set_study(int study_num)
Definition: GlasPeriodic.h:113
void printTime() const override
Displays the current simulation time and the maximum simulation duration.
Definition: GlasPeriodic.h:239
int getNCreated() const
Definition: GlasPeriodic.h:260
void setupInitialConditions() override
This function allows to set the initial conditions for our problem to be solved, by default particle ...
Definition: GlasPeriodic.h:148
LinearViscoelasticFrictionMixedSpecies * baseSpecies
Definition: GlasPeriodic.h:274
std::enable_if<!std::is_pointer< typename U::MixedSpeciesType >::value, typename U::MixedSpeciesType * >::type getMixedObject(const U *S, const U *T)
Definition: SpeciesHandler.h:74
Contains material and contact force properties.
Definition: Species.h:35
A spherical particle is the most simple particle used in MercuryDPM.
Definition: SphericalParticle.h:37
Definition: Vector.h:51
Mdouble Y
Definition: Vector.h:66
Mdouble Z
Definition: Vector.h:66
Mdouble X
the vector components
Definition: Vector.h:66
const Mdouble pi
Definition: ExtendedMath.h:45
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51
Mdouble round(Mdouble value, unsigned int precision)
rounds a floating point number with a given precision
Definition: MathHelpers.cc:28
Mdouble beta(Mdouble z, Mdouble w)
This is the beta function, returns the approximation based on cmath's implementation of ln(gamma)
Definition: ExtendedMath.cc:164
std::string name
Definition: MercuryProb.h:48