MercuryDPM  0.11
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AngledPeriodicBoundarySecondUnitTest.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 "Species/Species.h"
28 #include "DPMBase.h"
30 
37 {
38 public:
39 
40  //sets species and periodic boundary
41 
43  {
45  //set density such that mass is 1.0 for diameter 1.0 particles
46  species.setDensity(6.0 / constants::pi);
47  species.setStiffness(1e2);
48  species.setAdhesionStiffness(1e2);
49  //set such that the overlap for force balance is 10%
50  species.setAdhesionForceMax(1e-1 * species.getAdhesionStiffness());
51  species.setRollingFrictionCoefficient(1e20);
52  species.setRollingStiffness(1.0);
54  setTimeStep(0.01 * species.getCollisionTime(1.0));
55 
57  Mdouble c = cos(constants::pi / 2.0);
58  Mdouble s = sqrt(1.0 - c * c);
59  Vec3D normal_left(s, -c, 0.0);
60  Vec3D normal_right(0.0, -1.0, 0.0);
61  Vec3D origin(0.0, 0.0, 0.0);
62  b.set(normal_left, normal_right, origin);
63  //comment the line below to see how the system behaves without
64  //the AngledPeriodicBoundary
66  }
67 
68  //computes body force
69 
71  {
72  if (!p->isFixed())
73  {
74  // Gravitational force
75  Vec3D normal = p->getPosition() / Vec3D::getLength(p->getPosition());
76  p->addForce(-normal * p->getMass());
77  // Still calls this in compute External Forces.
79  }
80  }
81 
82  //sets initial particle positions
83 
85  {
86  //centrifugal acc. a=v^2/R;
87  Mdouble velocity = 2.0;
88  Mdouble R = 4.0;
89  BaseParticle p;
91  p.setRadius(0.5);
92  p.setPosition({R, 0, 0});
93  p.setVelocity({0, sqrt(R), 0});
94  //p.setAngularVelocity({0,0,1});
96 
97  //http://www.mathsisfun.com/algebra/trig-cosine-law.html
98  Mdouble d = 0.9;
99  Mdouble c = (2.0 * R * R - d * d) / (2.0 * R * R);
100  Mdouble s = sqrt(1.0 - c * c);
101  p.setRadius(0.5);
102  p.setPosition({R*c, R*s, 0});
103  p.setVelocity({-sqrt(R) * s, sqrt(R) * c, 0});
104  p.setAngularVelocity({0, 0, 1});
106 
107  setXMin(-R-1);
108  setXMax(R+1);
109  setYMin(-R-1);
110  setYMax(R+1);
111  setZMin(-R-1);
112  setZMax(R+1);
113 
114  }
115 };
116 
117 int main(int argc UNUSED, char *argv[] UNUSED)
118 {
120  dpm.setName("AngledPeriodicBoundarySecondUnitTest");
121  dpm.setTimeMax(4.0 * constants::pi);
122  dpm.solve(argc, argv);
123 
125  dpm2.setName("AngledPeriodicBoundarySecondUnitTest2");
126  dpm2.boundaryHandler.clear();
127  dpm2.setTimeMax(4.0 * constants::pi);
128  dpm2.solve(argc, argv);
129 
131  dpm2.particleHandler.getObject(0)->getAngularVelocity(), 1e-10))
132  {
133  logger(ERROR, "angular velocity of the two simulations doesn't match");
134  }
135 
136  //Note:: currently the rolling spring is not conserved!!
137  return 0;
138 }
139 // now plot
140 // p 'interactionRadius.fstat' u 7:($9/100) every 4::5 w lp
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")
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
void setupInitialConditions()
This function allows to set the initial conditions for our problem to be solved, by default particle ...
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
virtual const Vec3D & getAngularVelocity() const
Returns the angular velocity of this interactable.
void setSpecies(const ParticleSpecies *species)
LL< Log::ERROR > ERROR
Error log level.
Definition: Logger.cc:26
void setRadius(const Mdouble radius)
Sets the particle's radius_ (and adjusts the mass_ accordingly, based on the particle's species) ...
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
int main(int argc UNUSED, char *argv[] UNUSED)
void computeExternalForces(BaseParticle *p)
Computes the external forces acting on particles (e.g. gravitational)
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
Mdouble getMass() const
Returns the particle's mass_.
const Mdouble pi
Definition: ExtendedMath.h:42
BoundaryHandler boundaryHandler
An object of the class BoundaryHandler which concerns insertion and deletion of particles into or fro...
Definition: DPMBase.h:888
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 * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:415
void setDensity(Mdouble density)
Allows the density to be changed.
#define UNUSED
Definition: GeneralDefine.h:37
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
bool isEqual(Mdouble v1, Mdouble v2, double absError)
Compares the difference of two Mdouble with an absolute error, useful in UnitTests.
void setPosition(const Vec3D &position)
Sets the position of this BaseInteractable.
Mdouble getLength() const
Calculates the length of this Vec3D: .
Definition: Vector.cc:416
void setTimeStep(Mdouble newDt)
Allows the time step dt to be changed.
Definition: DPMBase.cc:353
Contains material and contact force properties.
Definition: Interaction.h:35
virtual void computeForcesDueToWalls(BaseParticle *PI)
Computes the forces on the particles due to the walls (normals are outward normals) ...
Definition: DPMBase.cc:1465
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
void addForce(Vec3D addForce)
Adds an amount to the force on this BaseInteractable.
bool isFixed() const
Is fixed Particle function. It returns whether a Particle is fixed or not, by checking its inverse Ma...
void setAngularVelocity(const Vec3D &angularVelocity)
set the angular velocity of the BaseInteractble.
void clear()
Empties the whole BaseHandler by removing all Objects and setting all other variables to 0...
Definition: BaseHandler.h:360