MercuryDPM  0.11
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AdhesiveForceUnitTest.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 "Particles/BaseParticle.h"
27 #include "Species/Species.h"
33 #include "DPMBase.h"
34 #include "Walls/InfiniteWall.h"
35 #include "Logger.h"
36 
42 public:
43 
45 
47  {
50  }
51 
53  {
54  relVelocity_ = 1e-1;
55  setName("AdhesiveForceUnitTest_ParticleParticleInteraction");
56 
58  species->setDensity(2000.0);
59  species->setStiffness(1e2);
64 
66  setGravity(Vec3D(0,0,0));
67  setTimeStep(5e-6 / 2.0);
68  Mdouble R = 1e-3;
69  setXMax( 2*R);
70  setYMax( R);
71  setZMax( R);
72  setXMin(-2*R);
73  setYMin(-R);
74  setZMin(-R);
75 
77  BaseParticle P;
78  P.setRadius(R);
79 
81  P.setVelocity(Vec3D(relVelocity_/2,0,0));
84  P.setVelocity(Vec3D(-relVelocity_/2,0,0));
86 
87  setTimeMax(getTimeStep()*250*2);
89  setSaveCount(1);
90 
91  }
92 
93 private:
95 };
96 
98 
99 public:
101 
103  {
106  }
107 
109  {
110  relVelocity_ = 1e-1;
113  setGravity(Vec3D(0,0,0));
114  setTimeStep(5e-6 / 2.0);
115  Mdouble R = 1e-3;
116  setXMax( 2*R);
117  setYMax( R);
118  setZMax( R);
119  setXMin(-2*R);
120  setYMin(-R);
121  setZMin(-R);
122 
123  species->setDensity(2000.0);
132 
134  BaseParticle P;
135  P.setRadius(R);
136 
138  P.setVelocity(Vec3D(relVelocity_/2,0,0));
141  P.setVelocity(Vec3D(-relVelocity_/2,0,0));
143  setName("AdhesiveForceUnitTest_ParticleParticleInteractionWithPlasticForces");
144  setTimeMax(getTimeStep()*250*5);
146  setSaveCount(1);
147 
148  }
149 
150 private:
152 };
153 
154 
156 public:
157 
159 
161  {
164  }
165 
166 protected:
168  {
169  relVelocity_ = 1e-1;
170  setName("AdhesiveForceUnitTest_ParticleWallInteractionWithPlasticForces");
171 
174  setGravity(Vec3D(0,0,0));
175 
176  species->setDensity(2000.0);
177  species->setStiffness(1e2);
180  Mdouble R = 1e-3;
183  setTimeStep(5e-6 / 2.0);
184 
185  setXMax( 2*R);
186  setYMax( R);
187  setZMax( R);
188  setXMin(0);
189  setYMin(-R);
190  setZMin(-R);
191 
193  BaseParticle P;
194  P.setRadius(R);
196  P.setVelocity(Vec3D(-relVelocity_/2,0,0));
198 
199  wallHandler.clear();
200  InfiniteWall w;
201  w.set(Vec3D(-1, 0, 0), Vec3D(getXMin(), 0, 0));
203 
204  setTimeMax(getTimeStep()*250*4);
206  setSaveCount(1);
207  }
208 public:
210 };
211 
212 int main(int argc UNUSED, char *argv[] UNUSED)
213 {
214  //First test Particle Particle interactions with no plastic forces so reverseable.
215  ParticleParticleInteraction ParticleParticleInteractionProblem;
216  ParticleParticleInteractionProblem.solve();
217 
218  logger(INFO,"Testing particle-particle collision for elastic adhesive forces");
219  std::vector<BaseParticle*>::iterator pIt = ParticleParticleInteractionProblem.particleHandler.begin();
220  if (!(*pIt)->getPosition().isEqualTo(Vec3D(-0.00101582359198137,0.0,0.0), 1e-7))
221  logger(FATAL,"First particle is in the wrong position. It is at %",(*pIt)->getPosition());
222  if (!(*pIt)->getVelocity().isEqualTo(Vec3D(-0.0436824,0.0,0.0) , 1e-7))
223  logger(FATAL,"First particle has the wrong velocity. It is at %",(*pIt)->getVelocity());
224  ++pIt;
225  if (!(*pIt)->getPosition().isEqualTo(Vec3D(0.00101582359198137,0.0,0.0), 1e-7))
226  logger(FATAL,"Second particle is in the wrong position. It is at %",(*pIt)->getPosition());
227  if (!(*pIt)->getVelocity().isEqualTo(Vec3D(0.0436824,0.0,0.0) , 1e-7))
228  logger(FATAL,"Second particle has the wrong velocity. It is at %",(*pIt)->getVelocity());
229 
230  //Second test Particle Particle interaction with a plastic force (non reverseable)
231  ParticleParticleInteractionWithPlasticForces ParticleParticleInteractionWithPlasticForcesProblem;
232  ParticleParticleInteractionWithPlasticForcesProblem.solve();
233 
234  logger(INFO,"Testing particle particles collision for plastic adhesive forces");
235  std::vector<BaseParticle*>::iterator pIt2 = ParticleParticleInteractionWithPlasticForcesProblem.particleHandler.begin();
236  if (!(*pIt2)->getPosition().isEqualTo(Vec3D(-0.00107858,0.0,0.0), 1e-7))
237  logger(FATAL,"First particle is in the wrong position. It is at %",(*pIt2)->getPosition());
238  if (!(*pIt2)->getVelocity().isEqualTo(Vec3D(-0.0352526,0.0,0.0) , 1e-7))
239  logger(FATAL,"First particle has the wrong velocity. It is at %",(*pIt2)->getVelocity());
240  ++pIt2;
241  if (!(*pIt2)->getPosition().isEqualTo(Vec3D(0.00107858,0.0,0.0), 1e-7))
242  logger(FATAL,"Second particle is in the wrong position. It is at %",(*pIt2)->getPosition());
243  if (!(*pIt2)->getVelocity().isEqualTo(Vec3D(0.0352526,0.0,0.0) , 1e-7))
244  logger(FATAL,"Second particle has the wrong velocity. It is at %",(*pIt2)->getVelocity());
245 
246  //Final test Particle-Wall interactions with a plastic force (non reversable)
248  ParticleWallInteraction.solve();
249 
250  logger(INFO,"Testing particle-wall collision for plastic adhesive forces");
251  std::vector<BaseParticle*>::iterator pIt3 = ParticleWallInteraction.particleHandler.begin();
252  if (!(*pIt3)->getPosition().isEqualTo(Vec3D(0.00104381,0.0,0.0), 1e-7))
253  logger(FATAL,"The particle is in the wrong position. It is at %",(*pIt3)->getPosition());
254  if (!(*pIt3)->getVelocity().isEqualTo(Vec3D(0.0362122,0.0,0.0) , 1e-7))
255  logger(FATAL,"The particle has the wrong velocity. It is at %",(*pIt3)->getVelocity());
256 
257  return 0;
258 }
259 // now plot
260 // p 'interactionRadius.fstat' u 7:($9/100) every 4::5 w lp
void setCohesionStiffness(Mdouble cohesionStiffness)
Sets the cohesive stiffness of the linear plastic-viscoelastic normal force.
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
The DPMBase header includes quite a few header files, defining all the handlers, which are essential...
Definition: DPMBase.h:61
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
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Species< LinearViscoelasticNormalSpecies, SlidingFrictionSpecies, IrreversibleAdhesiveSpecies > * species
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 getXMin() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMin() returns XMin...
Definition: DPMBase.cc:224
LL< Log::INFO > INFO
Info log level.
Definition: Logger.cc:28
void setAdhesionStiffness(Mdouble new_k0)
Allows the spring constant to be changed.
void setParticleDimensions(unsigned int particleDimensions)
Allows the dimension of the particle (f.e. for mass) to be changed. e.g. discs or spheres...
Definition: DPMBase.cc:474
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
void setSystemDimensions(unsigned int newDim)
Allows for the dimension of the simulation to be changed.
Definition: DPMBase.cc:453
void setFileType(FileType fileType)
Sets File::fileType_ for all files (ene, data, fstat, restart, stat)
Definition: Files.cc:169
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) ...
const std::vector< T * >::const_iterator begin() const
Gets the begin of the const_iterator over all Object in this BaseHandler.
Definition: BaseHandler.h:482
void clear()
Empties the whole ParticleHandler by removing all BaseParticle.
Mdouble getInteractionDistance() const final
Returns the particle distance below which adhesive forces can occur (needed for contact detection) ...
Definition: Species.h:333
Species< LinearPlasticViscoelasticNormalSpecies, SlidingFrictionSpecies, IrreversibleAdhesiveSpecies > * species
void setPenetrationDepthMax(Mdouble penetrationDepthMax)
Sets the maximum penetration depth of the linear plastic-viscoelastic normal force.
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 setStiffness(Mdouble new_k)
Allows the spring constant to be changed.
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
virtual void addObject(ParticleSpecies *const S)
Adds a new ParticleSpecies to the SpeciesHandler.
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
all data will be written into/ read from a single file called name_
void setDensity(Mdouble density)
Allows the density to be changed.
#define UNUSED
Definition: GeneralDefine.h:37
LL< Log::FATAL > FATAL
Fatal log level.
Definition: Logger.cc:25
void setLoadingStiffness(Mdouble loadingStiffness)
Sets the loading stiffness of the linear plastic-viscoelastic normal force.
void setSaveCount(unsigned int saveCount)
Sets File::saveCount_ for all files (ene, data, fstat, restart, stat)
Definition: Files.cc:138
void setSlidingStiffness(Mdouble new_kt)
Allows the spring constant to be changed.
void setSlidingFrictionCoefficient(Mdouble new_mu)
Allows the (dynamic) Coulomb friction coefficient to be changed; also sets mu_s by default...
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
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. elastic, linear visco-elastic... et cetera...
Definition: DPMBase.h:868
void setupInitialConditions()
This function allows to set the initial conditions for our problem to be solved, by default particle ...
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:883
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 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
This code is written to test short-distance non-contact forces such as van-der-Waals or liquid bridge...
Mdouble getAdhesionStiffness() const
Allows the spring constant to be accessed.
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
Mdouble getTimeStep() const
Allows the time step dt to be accessed.
Definition: DPMBase.cc:368
void setUnloadingStiffnessMax(Mdouble unloadingStiffnessMax)
Sets the maximum unloading stiffness of the linear plastic-viscoelastic normal force.
Species< LinearViscoelasticNormalSpecies, SlidingFrictionSpecies, IrreversibleAdhesiveSpecies > * species
void setAdhesionForceMax(Mdouble new_f0)
Allows the spring constant to be changed.
void clear()
Empties the whole BaseHandler by removing all Objects and setting all other variables to 0...
Definition: BaseHandler.h:360
void setupInitialConditions()
This function allows to set the initial conditions for our problem to be solved, by default particle ...
void setupInitialConditions()
This function allows to set the initial conditions for our problem to be solved, by default particle ...
Mdouble getLoadingStiffness() const
Returns the loading stiffness of the linear plastic-viscoelastic normal force.
int main(int argc UNUSED, char *argv[] UNUSED)