MercuryDPM  0.11
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
DrivenParticleUnitTest.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 <math.h>
27 
28 #include "DPMBase.h"
29 #include "Particles/BaseParticle.h"
31 #include "Math/ExtendedMath.h"
32 
39 {
40 public:
42  {
44 
45  BaseParticle p0;
46  //At the moment, it is still necessary to fix the particle before we can
47  //move it manually.
48  p0.fixParticle();
49  p0.setPrescribedPosition([](double time)
50  {
51  return(Vec3D(cos(time),
52  0.0,
53  sin(time)));
54  });
56 
57  setTimeStep(0.01);
59 
60  setXMax(1.0);
61  setYMax(1.0);
62  setZMax(1.0);
63  }
64 
66  {
68  //check if the particle is still on the unit circle in the (x,z)-plane
69  if (std::abs(pos.getLength() - 1) > 1e-6 )
70  logger(FATAL, "The particle is not on the unit circle anymore!");
71  if (std::abs(pos.X) - 1 > 1e-6)
72  logger(FATAL, "The particle exceeded the bounds in x direction");
73  if (std::abs(pos.Y) > 1e-6)
74  logger(FATAL, "The particle exceeded the bounds in y direction");
75  if (std::abs(pos.Z) - 1 > 1e-6 )
76  logger(FATAL, "The particle exceeded the bounds in z direction");
77  //check if any of the entries in pos equals nan or -nan
78  if (pos.X != pos.X || pos.Y != pos.Y || pos.Z != pos.Z)
79  logger(FATAL, "The position of the particle contains an entry that is not a number.");
80  }
81 };
82 
83 int main(int argc, char *argv[])
84 {
85  // Problem setup
86  DrivenParticleClass problem;
87  problem.setName("DrivenParticleUnitTest");
89  problem.solve();
90 
91  return 0;
92 }
void actionsAfterTimeStep()
A virtual function which allows to define operations to be executed after time step.
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
Mdouble X
the vector components
Definition: Vector.h:52
void setTimeMax(Mdouble newTMax)
Allows the upper time limit to be changed.
Definition: DPMBase.cc:179
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
void setPrescribedPosition(std::function< Vec3D(double)> prescribedPosition)
Allows the position of an infinite mass interactable to be prescribed.
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 setFileType(FileType fileType)
Sets File::fileType_ for all files (ene, data, fstat, restart, stat)
Definition: Files.cc:169
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
static Mdouble getLength(const Vec3D &a)
Calculates the length of a Vec3D: .
Definition: Vector.cc:427
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
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
T * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:415
Species< LinearViscoelasticNormalSpecies > LinearViscoelasticSpecies
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. elastic, linear visco-elastic... et cetera...
Definition: DPMBase.h:868
int main(int argc, char *argv[])
Mdouble Y
Definition: Vector.h:52
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 Z
Definition: Vector.h:52
void setupInitialConditions()
This function allows to set the initial conditions for our problem to be solved, by default particle ...
void fixParticle()
Fix Particle function. It fixes a Particle by setting its inverse mass and inertia and velocities to ...