MercuryDPM  0.11
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FreeCoolingAdhesiveDemo.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 
28 #include <iostream>
29 #include "Mercury2D.h"
30 #include "Particles/BaseParticle.h"
32 #include "Walls/InfiniteWall.h"
33 
38 
39 class my_problem_HGRID : public Mercury2D{
40 public:
41 
43  {
44  int N1=static_cast<int>(ceil(sqrt(N)));
45  BaseParticle p0;
46  p0.setRadius(0.0001);
47  for (int i=0;i<N;i++)
48  {
49  int ix=static_cast<int>(i%N1);
50  int iy=static_cast<int>(i/N1);
51 
52  double x=(getXMax()-getXMin())*(ix+1)/(N1+1);
53  double y=(getYMax()-getYMin())*(iy+1)/(N1+1);
54 
55 
56  p0.setPosition(Vec3D(x,y,0.0));
57  Vec3D vel;
58  vel.X=random.getRandomNumber(-1,1);
59  vel.Y=random.getRandomNumber(-1,1);
60  p0.setVelocity(1.0*vel);
62  p0.setRadius(0.0001*random.getRandomNumber(0.7,1));
63  }
64 
66  InfiniteWall w0;
67  w0.set(Vec3D(-1, 0, 0), Vec3D(getXMin(), 0, 0));
69  w0.set(Vec3D( 1, 0, 0), Vec3D(getXMax(), 0, 0));
71  w0.set(Vec3D( 0,-1, 0), Vec3D(0, getYMin(), 0));
73  w0.set(Vec3D( 0, 1, 0), Vec3D(0, getYMax(), 0));
75  }
76 
77  int N;
78 };
79 
80 int main(int argc UNUSED, char *argv[] UNUSED)
81 {
82  std::cout<<"In this file 32^2 particles with the same velocity are placed "
83  "in a bi-axial box. This makes them collide with the walls and eachother. "
84  "Afterwards the same run is performed with hgrid on. It tests the working "
85  "(and speedup) of the hgrid."<<std::endl;
86 
88  my_problem_HGRID problem;
90  species->setDensity(2000);
91  species->setDissipation(0.01);
92  species->setStiffness(1e4);
93  species->setSlidingFrictionCoefficient(0.1);
94  species->setDensity(2000);
95  species->setAdhesionStiffness(0.05* species->getStiffness());
96  species->setAdhesionForceMax(1.1e-4*0.05* species->getStiffness());
97 
98  problem.N=25;
99  problem.setName("free_cooling_adhesive");
100  problem.setXMax(0.0018);
101  problem.setYMax(0.0018);
102  problem.setGravity(Vec3D(0.0,0.0,0.0));
103  problem.setTimeStep(3e-6);
104  problem.setSaveCount(50);
105  problem.setTimeMax(0.05);
106  problem.setHGridMaxLevels(1);
107  //problem.setHGridCellOverSizeRatio(1.2);
108  problem.setHGridUpdateEachTimeStep(true);
109 
110 
113  problem.solve();
114  std::cout << problem.particleHandler.getObject(0)->getRadius() << std::endl;
115  std::cout << problem.particleHandler.getObject(0)->getInteractionRadius() << std::endl;
116  return 0;
117 }
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
Mdouble X
the vector components
Definition: Vector.h:52
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 getXMin() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMin() returns XMin...
Definition: DPMBase.cc:224
void setHGridUpdateEachTimeStep(bool updateEachTimeStep)
Sets whether or not the HGrid must be updated every time step.
Definition: MercuryBase.cc:172
Mdouble getYMin() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMin() returns YMin...
Definition: DPMBase.cc:238
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) ...
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
file will not be created/read
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
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:878
all data will be written into/ read from a single file called name_
T * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:415
#define UNUSED
Definition: GeneralDefine.h:37
File fStatFile
An instance of class File to handle in- and output into a .fstat file.
Definition: Files.h:209
void setSaveCount(unsigned int saveCount)
Sets File::saveCount_ for all files (ene, data, fstat, restart, stat)
Definition: Files.cc:138
File dataFile
An instance of class File to handle in- and output into a .data file.
Definition: Files.h:204
Mdouble getRadius() const
Returns the particle's radius_.
void setHGridMaxLevels(unsigned int HGridMaxLevels)
Sets the maximum number of levels of the HGrid in this MercuryBase.
Definition: MercuryBase.cc:500
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. elastic, linear visco-elastic... et cetera...
Definition: DPMBase.h:868
todo{This code is not working as is wanted}
Mdouble getYMax() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMax() returns XMax...
Definition: DPMBase.cc:245
Mdouble Y
Definition: Vector.h:52
void setFileType(FileType fileType)
Sets the type of file needed to write into or read from. File::fileType_.
Definition: File.cc:209
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
void setupInitialConditions()
This function allows to set the initial conditions for our problem to be solved, by default particle ...
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
Species< LinearViscoelasticNormalSpecies, SlidingFrictionSpecies, ReversibleAdhesiveSpecies > LinearViscoelasticSlidingFrictionReversibleAdhesiveSpecies
int main(int argc UNUSED, char *argv[] UNUSED)
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
Mdouble getInteractionRadius() const
Returns the particle's interaction radius, which might be different from radius_ (e.g., when dealing with wet particles)
Mdouble getRandomNumber(Mdouble min, Mdouble max)
This is a random generating routine can be used for initial positions.
Definition: RNG.cc:69
void clear()
Empties the whole BaseHandler by removing all Objects and setting all other variables to 0...
Definition: BaseHandler.h:360
This adds on the hierarchical grid code for 2D problems.
Definition: Mercury2D.h:35