MercuryDPM  0.11
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
HourGlass2DDemo.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 HourGlass2D : public Mercury3D{
34 public:
35 
37  {
38  //define side walls
39  InfiniteWall w0;
40  w0.set(Vec3D(-1,0,0), Vec3D(getXMin(), 0, 0));
42  w0.set(Vec3D( 1,0,0), Vec3D(getXMax(), 0, 0));
44 
46  std::vector<Vec3D> Points(3);
47  //left neck wall
48  //define the corners of your prismatic wall in clockwise direction
49  Points[0] = Vec3D(getXMin() ,0.0,(getZMin()+getZMax())/2.0+ContractionHeight);
50  Points[1] = Vec3D(getXMin()+ContractionWidth,0.0,(getZMin()+getZMax())/2.0 );
51  Points[2] = Vec3D(getXMin() ,0.0,(getZMin()+getZMax())/2.0-ContractionHeight);
52  w1.createOpenPrism(Points);
54  //right neck wall
55  Points[0] = Vec3D(getXMax() ,0.0,(getZMin()+getZMax())/2.0+ContractionHeight);
56  Points[1] = Vec3D(getXMax()-ContractionWidth,0.0,(getZMin()+getZMax())/2.0 );
57  Points[2] = Vec3D(getXMax() ,0.0,(getZMin()+getZMax())/2.0-ContractionHeight);
58  w1.createOpenPrism(Points);
60 
61  // The above wall definition is equivalent to
62  //~ IntersectionOfWalls w1;
63  //~ Vec3D A(getXMin() ,0.0,(getZMin()+getZMax())/2.0+ContractionHeight);
64  //~ Vec3D B(getXMin()+ContractionWidth,0.0,(getZMin()+getZMax())/2.0 );
65  //~ Vec3D C(getXMin() ,0.0,(getZMin()+getZMax())/2.0-ContractionHeight);
66  //~ Vec3D D(0,1,0); //Periodic direction of the prism
67  //~ w1.addObject(Vec3D::Cross(A-B,D),A);
68  //~ w1.addObject(Vec3D::Cross(B-C,D),B);
69  //~ wallHandler.copyAndAddObject(w1);
70 
71 
72  w0.set(Vec3D(0,0,-1), Vec3D(0,0,-0.5*(getZMin()+getZMax())));
74 
75  BaseParticle p0;
76  p0.setVelocity(Vec3D(0.0,0.0,0.0));
77  //Mdouble Width = getXMax()-getXMin();
79  for (double x=MaxParticleRadius; x<getXMax(); x+=1.999*MaxParticleRadius)
80  {
82  p0.setPosition(Vec3D(x, 0.0, z+p0.getRadius()));
85  }
86 
87  //write(std::cout,false);
88  }
89 
91  {
92  //if (getTime()<0.9 && getTime()+getTimeStep()>0.9)
93  {
94  std::cout<<"Shifting bottom wall downward"<<getTime()<<std::endl;
95  dynamic_cast<InfiniteWall*>(wallHandler.getLastObject())->set(Vec3D(0,0,-1), Vec3D(0, 0, getZMin()));
96  }
97  }
98 
103  unsigned int N;
104 };
105 
106 int main(int argc, char *argv[])
107 {
108  std::cout<< "Hourglass Simulation" <<std::endl;
109  // note: this code is based on stefan's implementation, see
110  // /storage2/usr/people/sluding/COMPUTERS/hpc01/sluding/MDCC/MDCLR/DEMO/W7
111  // however, it is scaled to SI units by the scaling factors
112  // d=1e-3, m=1e-6, g=1
113 
114  //all parameters should be set in the main file
115  //here, we use SI units (generally, other, scaled units are possible)
116 
117  //create an instance of the class and name it
118  HourGlass2D HG;
119  HG.setName("HourGlass2D");
121  species->setDensity(2000);
122 
123  //specify geometry
124  //specify dimensions of the hourglass
125  Mdouble Width = 10e-2; // 10cm
126  Mdouble Height = 60e-2; // 60cm
127  //specify how big the wedge of the contraction should be
128  Mdouble ContractionWidth = 2.5e-2; //2.5cm
129  Mdouble ContractionHeight = 5e-2; //5cm
130  //set domain accordingly (domain boundaries are not walls!)
131  HG.setXMin(0.0);
132  HG.setXMax(Width);
133  HG.setYMin(0.0);
134  HG.setYMax(Width);
135  HG.setZMin(0.0);
136  HG.setZMax(Height);
137  //these parameters are needed in setupInitialConditions()
138  HG.ContractionWidth = ContractionWidth;
139  HG.ContractionHeight = ContractionHeight;
140 
141  //specify particle properties
142  species->setDensity(2000.0);
143  //these parameters are needed in setupInitialConditions()
144  HG.MinParticleRadius = 6e-3; // 6mm
145  HG.MaxParticleRadius = 10e-3; //10mm
146 
147  //specify body forces
148  HG.setGravity( Vec3D(0.0, 0.0, -9.8) );
149 
150  //specify contact properties
151  //normal forces
152  species->setStiffness(1e5);
153  species->setDissipation(0.63);
154  //tangential (sliding) forces
155  species->setSlidingFrictionCoefficient(0.5);
156  species->setSlidingStiffness(1.2e4);
157  species->setSlidingDissipation(0.16);
158  //tangential (rolling) torques
159  species->setRollingFrictionCoefficient(0.2);
160  species->setRollingStiffness(1.2e4);
161  species->setRollingDissipation(6.3e-2);
162  //normal (torsion/spin) torques
163  species->setTorsionFrictionCoefficient(0.1);
164  species->setTorsionStiffness(1.2e4);
165  species->setSlidingDissipation(6.3e-2);
166 
167  //test normal forces
168  Mdouble MinParticleMass = species->getDensity()*4.0/3.0*constants::pi*mathsFunc::cubic(HG.MinParticleRadius);
169  //Calculates collision time for two copies of a particle of given dissipation_, k, effective mass
170  std::cout << "MinParticleMass =" << MinParticleMass << std::endl;
171  //Calculates collision time for two copies of a particle of given dissipation_, k, effective mass
172  Mdouble tc = species->getCollisionTime(MinParticleMass);
173  std::cout << "tc =" << tc << std::endl;
174  //Calculates restitution coefficient for two copies of given dissipation_, k, effective mass
175  Mdouble r = species->getRestitutionCoefficient(MinParticleMass);
176  std::cout << "r =" << r << std::endl;
177  //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)
178  //std::cout << "vmax=" << helpers::getMaximumVelocity(species->getStiffness(), HGgetSpecies(0)->getDissipation(), HG.MinParticleRadius, MinParticleMass) << std::endl;
179 
180  //set other simulation parameters
181  HG.setTimeStep(tc / 50.0);
182  HG.setTimeMax(3.0);
183  HG.setSaveCount(500);
184  HG.setXBallsAdditionalArguments("-v0 -solidf");
185  HG.N=100; //number of particles
186  std::cout << "N =" << HG.N << std::endl;
187 
188  HG.solve(argc, argv);
189  return 0;
190 }
191 
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
unsigned int N
void solve()
The work horse of the code.
Definition: DPMBase.cc:1895
void actionsAfterTimeStep()
A virtual function which allows to define operations to be executed after time step.
void setVelocity(const Vec3D &velocity)
set the velocity of the BaseInteractable.
A IntersectionOfWalls is convex polygon defined as an intersection of InfiniteWall's.
void setTimeMax(Mdouble newTMax)
Allows the upper time limit to be changed.
Definition: DPMBase.cc:179
Mdouble MinParticleRadius
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 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
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 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...
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 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
void setupInitialConditions()
This function allows to set the initial conditions for our problem to be solved, by default particle ...
void setDensity(Mdouble density)
Allows the density to be changed.
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
Mdouble ContractionWidth
void setXBallsAdditionalArguments(std::string newXBArgs)
Set the additional arguments for xballs.
Definition: DPMBase.cc:403
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
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
Mdouble MaxParticleRadius
Mdouble getDensity() const
Allows the density to be accessed.
Contains material and contact force properties.
Definition: Interaction.h:35
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
Mdouble ContractionHeight
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