MercuryDPM  0.11
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HourGlass3DDemo.cpp
Go to the documentation of this file.
1 //Copyright (c) 2013-2014, 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 "Mercury3D.h"
27 #include "Particles/BaseParticle.h"
30 #include <iostream>
32 
33 class HourGlass : public Mercury3D{
34 public:
35 
37  {
39  w1.setPosition(Vec3D((getXMin()+getXMax())/2.0,(getYMin()+getYMax())/2.0,0));
40  w1.setOrientation(Vec3D(0, 0, 1));
41  w1.addObject(Vec3D(1,0,0),Vec3D((getXMax()-getXMin())/2.0,0,0));
43 
45  w2.setPosition(Vec3D((getXMin()+getXMax())/2.0,(getYMin()+getYMax())/2.0,0));
46  w2.setOrientation(Vec3D(0, 0, 1));
47  std::vector<Vec3D> Points(3);
48  //left neck wall
49  //define the corners of your prismatic wall in clockwise direction
50  Points[0] = Vec3D((getXMax()-getXMin())/2.0 ,0.0,(getZMin()+getZMax())/2.0+ContractionHeight);
51  Points[1] = Vec3D((getXMax()-getXMin())/2.0-ContractionWidth,0.0,(getZMin()+getZMax())/2.0 );
52  Points[2] = Vec3D((getXMax()-getXMin())/2.0 ,0.0,(getZMin()+getZMax())/2.0-ContractionHeight);
53  w2.createOpenPrism(Points);
55 
56  InfiniteWall w0;
57  w0.set(Vec3D(0,0,-1), Vec3D(0,0,0.5*(getZMin()+getZMax())));
59 
60  BaseParticle p0;
61  p0.setVelocity(Vec3D(0.0,0.0,0.0));
62  Mdouble Width = getXMax()-getXMin();
64  for (double R=Width/2.0-MaxParticleRadius; R>0; R-=1.999*MaxParticleRadius)
65  for (double C=2.0*MaxParticleRadius; C<=2*constants::pi*R; C+=2.0*MaxParticleRadius)
66  {
68  //std::cout<<z<<" "<<R<<" "<<C<<" "<<std::endl;
69  p0.setPosition(Vec3D((getXMin()+getXMax())/2.0+R*sin(C/R),(getYMin()+getYMax())/2.0+R*cos(C/R),z+p0.getRadius()));
72  }
73 
74  //write(std::cout,false);
75  }
76 
78  {
79  if (getTime()<0.9 && getTime()+ getTimeStep()>0.9)
80  {
81  std::cout<<"Shifting bottom wall downward"<<std::endl;
82  dynamic_cast<InfiniteWall*>(wallHandler.getLastObject())->set(Vec3D( 0, 0,-1), Vec3D(0, 0, getZMin()));
83  }
84  }
85 
90  unsigned int N;
91 };
92 
93 int main(int argc, char *argv[])
94 {
95  std::cout<< "Hourglass Simulation" <<std::endl;
96  // note: this code is based on stefan's implementation, see
97  // /storage2/usr/people/sluding/COMPUTERS/hpc01/sluding/MDCC/MDCLR/DEMO/W7
98  // however, it is scaled to SI units by the scaling factors
99  // d=1e-3, m=1e-6, g=1
100 
101  //all parameters should be set in the main file
102  //here, we use SI units (generally, other, scaled units are possible)
103 
104  //create an instance of the class and name it
105  HourGlass HG;
106  HG.setName("HourGlass");
108  species->setDensity(2000);
109 
110  //specify geometry
111  //specify dimensions of the hourglass
112  Mdouble Width = 10e-2; // 10cm
113  Mdouble Height = 60e-2; // 60cm
114  //specify how big the wedge of the contraction should be
115  Mdouble ContractionWidth = 2.5e-2; //2.5cm
116  Mdouble ContractionHeight = 5e-2; //5cm
117  //set domain accordingly (domain boundaries are not walls!)
118  HG.setXMin(0.0);
119  HG.setXMax(Width);
120  HG.setYMin(0.0);
121  HG.setYMax(Width);
122  HG.setZMin(0.0);
123  HG.setZMax(Height);
124  //these parameters are needed in setupInitialConditions()
125  HG.ContractionWidth = ContractionWidth;
126  HG.ContractionHeight = ContractionHeight;
127 
128  //specify particle properties
129  species->setDensity(2000.0);
130  //these parameters are needed in setupInitialConditions()
131  HG.MinParticleRadius = 6e-3; // 6mm
132  HG.MaxParticleRadius = 10e-3; //10mm
133 
134  //specify body forces
135  HG.setGravity( Vec3D(0.0, 0.0, -9.8) );
136 
137  //specify contact properties
138  //normal forces
139  species->setStiffness(1e5);
140  species->setDissipation(0.63);
141  //tangential (sliding) forces
142  species->setSlidingFrictionCoefficient(0.5);
143  species->setSlidingStiffness(1.2e4);
144  species->setSlidingDissipation(0.16);
145  //tangential (rolling) torques
146  species->setRollingFrictionCoefficient(0.2);
147  species->setRollingStiffness(1.2e4);
148  species->setRollingDissipation(6.3e-2);
149  //normal (torsion/spin) torques
150  species->setTorsionFrictionCoefficient(0.1);
151  species->setTorsionStiffness(1.2e4);
152  species->setSlidingDissipation(6.3e-2);
153 
154  //test normal forces
155  Mdouble MinParticleMass = species->getDensity()*4.0/3.0*constants::pi*mathsFunc::cubic(HG.MinParticleRadius);
156  //Calculates collision time for two copies of a particle of given dissipation_, k, effective mass
157  std::cout << "MinParticleMass =" << MinParticleMass << std::endl;
158  //Calculates collision time for two copies of a particle of given dissipation_, k, effective mass
159  Mdouble tc = species->getCollisionTime(MinParticleMass);
160  std::cout << "tc =" << tc << std::endl;
161  //Calculates restitution coefficient for two copies of given dissipation_, k, effective mass
162  Mdouble r = species->getRestitutionCoefficient(MinParticleMass);
163  std::cout << "r =" << r << std::endl;
164  //Calculates the maximum relative velocity allowed for a normal collision of two particles of radius r and particle mass m (for higher velocities particles could pass through each other)
165  //std::cout << "vmax=" << helpers::getMaximumVelocity(species->getStiffness(), HGgetSpecies(0)->getDissipation(), HG.MinParticleRadius, MinParticleMass) << std::endl;
166 
167  //set other simulation parameters
168  HG.setTimeStep(tc / 50.0);
169  HG.setTimeMax(10.0);
170  HG.setSaveCount(500);
171  HG.setXBallsAdditionalArguments("-v0 -solidf");
172  HG.N=600; //number of particles
173 
174  HG.solve(argc, argv);
175  return 0;
176 }
177 
void setXMax(Mdouble newXMax)
If the length of the problem domain in x-direction is XMax - XMin, this method sets XMax...
Definition: DPMBase.cc:309
void solve()
The work horse of the code.
Definition: DPMBase.cc:1895
void setVelocity(const Vec3D &velocity)
set the velocity of the BaseInteractable.
void setTimeMax(Mdouble newTMax)
Allows the upper time limit to be changed.
Definition: DPMBase.cc:179
Mdouble ContractionWidth
void setOrientation(const Vec3D &orientation)
Sets the orientation of this BaseInteractable.
void setYMin(Mdouble newYMin)
If the length of the problem domain in y-direction is YMax - YMin, this method sets YMin...
Definition: DPMBase.cc:280
Mdouble MinParticleRadius
Mdouble getZMax() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMax() returns ZMax...
Definition: DPMBase.cc:259
Mdouble getXMin() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMin() returns XMin...
Definition: DPMBase.cc:224
Mdouble getYMin() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMin() returns YMin...
Definition: DPMBase.cc:238
double Mdouble
void setZMax(Mdouble newZMax)
If the length of the problem domain in z-direction is XMax - XMin, this method sets ZMax...
Definition: DPMBase.cc:338
Species< LinearViscoelasticNormalSpecies, FrictionSpecies > LinearViscoelasticFrictionSpecies
void setGravity(Vec3D newGravity)
Allows to modify the gravity vector.
Definition: DPMBase.cc:431
void addObject(Vec3D normal, Vec3D point)
Adds a wall to the set of infinite walls, given an outward normal vector s.t. normal*x=normal*point.
void setRadius(const Mdouble radius)
Sets the particle's radius_ (and adjusts the mass_ accordingly, based on the particle's species) ...
void createOpenPrism(std::vector< Vec3D > points, Vec3D prismAxis)
Creates an open prism which is a polygon between the points, except the first and last point...
void actionsAfterTimeStep()
A virtual function which allows to define operations to be executed after time step.
Mdouble getXMax() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMax() returns XMax...
Definition: DPMBase.cc:231
void setYMax(Mdouble newYMax)
If the length of the problem domain in y-direction is YMax - YMin, this method sets YMax...
Definition: DPMBase.cc:324
void setupInitialConditions()
This function allows to set the initial conditions for our problem to be solved, by default particle ...
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: Files.cc:149
U * copyAndAddObject(const U &O)
Creates a copy of a Object and adds it to the BaseHandler.
Definition: BaseHandler.h:268
const Mdouble pi
Definition: ExtendedMath.h:42
This adds on the hierarchical grid code for 3D problems.
Definition: Mercury3D.h:35
void setXMin(Mdouble newXMin)
If the length of the problem domain in x-direction is XMax - XMin, this method sets XMin...
Definition: DPMBase.cc:266
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:878
T cubic(T val)
calculates the cube of a number
Definition: ExtendedMath.h:99
void setSaveCount(unsigned int saveCount)
Sets File::saveCount_ for all files (ene, data, fstat, restart, stat)
Definition: Files.cc:138
Mdouble getRadius() const
Returns the particle's radius_.
void setZMin(Mdouble newZMin)
If the length of the problem domain in z-direction is ZMax - ZMin, this method sets ZMin...
Definition: DPMBase.cc:295
unsigned int getNumberOfObjects() const
Gets the number of Object in this BaseHandler.
Definition: BaseHandler.h:464
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. elastic, linear visco-elastic... et cetera...
Definition: DPMBase.h:868
A AxisymmetricIntersectionOfWalls is a axisymmetric wall, defined by rotating a twodimensional Inters...
void setXBallsAdditionalArguments(std::string newXBArgs)
Set the additional arguments for xballs.
Definition: DPMBase.cc:403
Mdouble getYMax() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMax() returns XMax...
Definition: DPMBase.cc:245
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:883
RNG random
This is a random generator, often used for setting up the initial conditions etc...
Definition: DPMBase.h:873
void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
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:70
Mdouble getZMin() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMin() returns ZMin...
Definition: DPMBase.cc:252
Mdouble MaxParticleRadius
void setTimeStep(Mdouble newDt)
Allows the time step dt to be changed.
Definition: DPMBase.cc:353
This is a class defining walls.
Definition: InfiniteWall.h:43
T * getLastObject()
Gets a pointer to the last Object in this BaseHandler.
Definition: BaseHandler.h:452
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
unsigned int N
Mdouble getTimeStep() const
Allows the time step dt to be accessed.
Definition: DPMBase.cc:368
int main(int argc, char *argv[])
Mdouble getTime() const
Access function for the time.
Definition: DPMBase.cc:158
Mdouble getRandomNumber(Mdouble min, Mdouble max)
This is a random generating routine can be used for initial positions.
Definition: RNG.cc:69
Mdouble ContractionHeight