MercuryDPM  0.11
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
wallSpecies_demo.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 "DPMBase.h"
27 #include "Particles/BaseParticle.h"
28 #include "Walls/InfiniteWall.h"
30 #include <cmath>
31 #include <iostream>
32 #include <iomanip>
33 
34 
39 class WallSpecies : public DPMBase {
40 public:
41 
43  {
44  setXMax(20);
45  setYMax(20);
46  setZMax(20);
49  setGravity(Vec3D(0,0,0));
50  setTimeStep(.0002);
51  setTimeMax(15);
52  setSaveCount(2587);
53 
54  //I don't know how to write this in a neat way.
55  std::cout << "X" << std::endl;
57  std::cout << "X" << std::endl;
59  std::cout << "X" << std::endl;
60  LinearViscoelasticMixedSpecies* species01 = speciesHandler.getMixedObject(species0, species1);
61  std::cout << "X" << std::endl;
62  species0->setDensity(6.0/constants::pi);
63  std::cout << "Y" << std::endl;
64  species0->setCollisionTimeAndRestitutionCoefficient(0.01,0.25,2);
65  std::cout << "Z" << std::endl;
66  write(std::cout,false);
67  species01->setCollisionTimeAndRestitutionCoefficient(0.01,0.5,2);
68  std::cout << "Y" << std::endl;
69 
70 
71  //set particles
72  BaseParticle P0;
73  P0.setRadius(0.5);
74  P0.setPosition(Vec3D(5,10,10));
75  P0.setVelocity(Vec3D(-1,0,-1));
77 
78  //set walls
79  InfiniteWall w0;
80  w0.set(Vec3D(0, 0, -1), Vec3D(0, 0, getZMin()));
82 
83  w0.set(Vec3D(-1,0,0), Vec3D(getZMin(), 0, 0));
84  w0.setIndSpecies(1);
86 
87  std::cout << "X" << std::endl;
88  }
89 
90  //Write the speed of the particles as the info line.
91  double getInfo(const BaseParticle& P0) const
92  {
94  }
95 };
96 
97 
98 
99 int main(int argc UNUSED, char *argv[] UNUSED)
100 {
101  std::cout << std::endl << "Simulation of one particle, d=0.1, interacting with walls with different coefficeient of resitution" << std::endl;
102  std::cout << std::endl << "The purpose of the test is to check walls species information is correctly picked up" << std::endl;
103  WallSpecies problem;
104  problem.setName("wallSpecies");
105  problem.solve();
106  std::cout << "v_z(tmax) = " << std::setprecision(14) << problem.particleHandler.getObject(0)->getVelocity().Z << " (should be 0.25 give or take)" << std::endl;
107  std::cout << "v_x(tmax) = " << std::setprecision(14) << problem.particleHandler.getObject(0)->getVelocity().X << " (should be 0.5 give or take)" << std::endl;
108 }
virtual void write(std::ostream &os, bool writeAllParticles=true) const
Loads all MD data and plots statistics for all timesteps in the .data file.
Definition: DPMBase.cc:1642
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 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
void setIndSpecies(unsigned int indSpecies)
Define the species of this wall using the index of the species in the SpeciesHandler in this DPMBase...
Definition: BaseWall.cc:93
int main(int argc UNUSED, char *argv[] UNUSED)
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 setGravity(Vec3D newGravity)
Allows to modify the gravity vector.
Definition: DPMBase.cc:431
T square(T val)
squares a number
Definition: ExtendedMath.h:91
void setRadius(const Mdouble radius)
Sets the particle's radius_ (and adjusts the mass_ accordingly, based on the particle's species) ...
this tests if moving the wall works with CWall::move(Vec3D velocity,Vec3D dt).
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
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
void setDensity(Mdouble density)
Allows the density to be changed.
#define UNUSED
Definition: GeneralDefine.h:37
void setSaveCount(unsigned int saveCount)
Sets File::saveCount_ for all files (ene, data, fstat, restart, stat)
Definition: Files.cc:138
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
U::MixedSpeciesType * getMixedObject(const U *S, const U *T)
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
Contains contact force properties for contacts between particles with two different species...
Definition: MixedSpecies.h:40
Mdouble getZMin() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMin() returns ZMin...
Definition: DPMBase.cc:252
double getInfo(const BaseParticle &P0) const
A virtual method that allows the user to overrride and set what is written into the info column in th...
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
Contains material and contact force properties.
Definition: Interaction.h:35
virtual const Vec3D & getVelocity() const
Returns the velocity of this interactable.
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 ...