MercuryDPM  0.11
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TangentialSpringUnitTest.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 <iostream>
28 #include "DPMBase.h"
29 #include "Particles/BaseParticle.h"
30 #include "Logger.h"
31 
34 public:
36  {
37  setXMax(1);
38  setYMax(1);
39  setZMax(1);
42 
43  BaseParticle P0,P1;
44 
45  P0.setPosition(Vec3D(0.5,0.5,0.25));
46  P1.setPosition(Vec3D(0.5,0.5,0.75));
47 
48  P0.fixParticle();
49  P1.setVelocity(Vec3D(0.1,0.0,0.0));
50 
51  P0.setRadius(0.25);
52  P1.setRadius(0.25);
53 
56  }
57 };
58 
59 Logger<Log::ERROR> testLogger("Tangential Spring Unit Test");
60 
61 int main(int argc, char *argv[])
62 {
63 
64  TangentialSpringUnitTest tangentialSpringUnitTestProblem;
65  auto species = tangentialSpringUnitTestProblem.speciesHandler.copyAndAddObject(LinearViscoelasticSlidingFrictionSpecies());
66  tangentialSpringUnitTestProblem.setName("TangentialSpringUnitTest");
67  species->setDensity(6./constants::pi);
68  species->setCollisionTimeAndRestitutionCoefficient(1e-3,.2,1./8);
69  species->setSlidingStiffness(species->getStiffness()*2/7);
70  species->setSlidingFrictionCoefficient(1e20);
71  tangentialSpringUnitTestProblem.setTimeStep(2e-5);
72  //tangentialSpringUnitTestProblem.setFileType(FileType::NO_FILE);
73  tangentialSpringUnitTestProblem.setGravity(Vec3D(0,0,-1));
74  tangentialSpringUnitTestProblem.setTimeMax(2.5);
75  tangentialSpringUnitTestProblem.solve(argc,argv);
76 
77  std::vector<BaseParticle*>::iterator pIt = tangentialSpringUnitTestProblem.particleHandler.begin();
78 
79  if (!(*pIt)->getPosition().isEqualTo(Vec3D(0.5,0.5,0.25), 1e-7)) logger(FATAL, "First particles is in the wrong position. It is %",(*pIt)->getPosition());
80  if (!(*pIt)->getVelocity().isEqualTo(Vec3D(0.0,0.0,0.0) , 1e-7)) logger(FATAL, "First particle has the wrong velocity");
81  ++pIt;
82 
83  if (!((*pIt)->getPosition().isEqualTo(Vec3D(0.961524052956078, 0.5, 0.450153103106219), 1e-7))) logger(FATAL, "Second particle has the wrong position. It is % at time %",(*pIt)->getPosition(),tangentialSpringUnitTestProblem.getTime());
84  if (!(*pIt)->getVelocity().isEqualTo(Vec3D(0.325869890236916, 0, -0.623251003973752) , 1e-7)) logger(FATAL, "Second particle has the wrong velocity. It is %",(*pIt)->getVelocity());
85  if (!(*pIt)->getAngularVelocity().isEqualTo(Vec3D(0.0,2.11896618998424,0.0) , 1e-7)) logger(FATAL, "Second particles has the wrong angular velocity. It is %", (*pIt)->getAngularVelocity());
86 
87 }
Logger.
Definition: Logger.h:161
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
In this file, the rolling behaviour of the tangential spring is tested. This is done by placing one n...
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")
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
Species< LinearViscoelasticNormalSpecies, SlidingFrictionSpecies > LinearViscoelasticSlidingFrictionSpecies
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
Logger< Log::ERROR > testLogger("Tangential Spring Unit Test")
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
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:878
LL< Log::FATAL > FATAL
Fatal log level.
Definition: Logger.cc:25
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. elastic, linear visco-elastic... et cetera...
Definition: DPMBase.h:868
void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
void setTimeStep(Mdouble newDt)
Allows the time step dt to be changed.
Definition: DPMBase.cc:353
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
Mdouble getTime() const
Access function for the time.
Definition: DPMBase.cc:158
int main(int argc, char *argv[])
void fixParticle()
Fix Particle function. It fixes a Particle by setting its inverse mass and inertia and velocities to ...