MercuryDPM  0.11
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
FullRestartTest.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 "Walls/Coil.h"
28 #include "Walls/CylindricalWall.h"
31 #include "Walls/InfiniteWall.h"
33 #include "Walls/Screw.h"
34 
43 
45 
46 #include "Particles/BaseParticle.h"
47 
48 
49 class FullRestartTest : public DPMBase
50 {
51 public:
52 
54  {
56 
57  Coil coil(Vec3D(0.1, 0.2, 0.3), 0.4, 0.5, 0.6, 0.7, 0.8);
58 
59  CylindricalWall cylindricalWall;
60  cylindricalWall.set(0.1);
61 
62  AxisymmetricIntersectionOfWalls axisymmetricIntersectionOfWalls;
63  axisymmetricIntersectionOfWalls.setPosition(Vec3D(0.1,0.2,0.3));
64  axisymmetricIntersectionOfWalls.setOrientation(Vec3D(0.4,0.5,0.6));
65  axisymmetricIntersectionOfWalls.addObject(Vec3D(0.7,0.8,0.9),0.11*Vec3D(0.7,0.8,0.9));
66 
67  IntersectionOfWalls intersectionOfWalls;
68  intersectionOfWalls.addObject(Vec3D(0.1, 0.2, 0.3), Vec3D(0.4, 0.5, 0.6));
69 
70  InfiniteWall infiniteWall;
71  infiniteWall.set(Vec3D(0.1, 0.2, 0.3), 0.4*Vec3D(0.1, 0.2, 0.3));
72 
73  InfiniteWallWithHole infiniteWallWithHole;
74  infiniteWallWithHole.set(Vec3D(0.1, 0.2, 0.3), 0.4, 0.5);
75 
76  Screw screw(Vec3D(0.1, 0.2, 0.3), 0.4, 0.5, 0.6, 0.7, 0.8);
77 
79  wallHandler.copyAndAddObject(cylindricalWall);
80  wallHandler.copyAndAddObject(axisymmetricIntersectionOfWalls);
81  wallHandler.copyAndAddObject(intersectionOfWalls);
82  wallHandler.copyAndAddObject(infiniteWall);
83  wallHandler.copyAndAddObject(infiniteWallWithHole);
85 
86  AngledPeriodicBoundary angledPeriodicBoundary;
87  angledPeriodicBoundary.set(Vec3D(0.1, 0.2, 0.3), Vec3D(0.4, 0.5, 0.6), Vec3D(0.7, 0.8, 0.9));
88 
89  ChuteInsertionBoundary chuteInsertionBoundary;
90  chuteInsertionBoundary.set(new BaseParticle, 13, Vec3D(0.1, 0.2, 0.3), Vec3D(0.4, 0.5, 0.6), 0.33, 0.44, 0.55, 1.1, 1.2);
91 
92  CubeInsertionBoundary cubeInsertionBoundary;
93  cubeInsertionBoundary.set(new BaseParticle, 13, Vec3D(0.1, 0.2, 0.3), Vec3D(0.4, 0.5, 0.6), Vec3D(0.11, 0.22, 0.33), Vec3D(0.44, 0.55, 0.66), 0.77, 0.88);
94 
95  HopperInsertionBoundary hopperInsertionBoundary;
96  hopperInsertionBoundary.set(new BaseParticle, 13, 0.2, 0.3, 0.66, 0.77, 3.1, 0.69, false, 3, 0.11, 0.21, 0.09, 2.31, 0.001, 30);
97 
98  PeriodicBoundary periodicBoundary;
99  periodicBoundary.set(Vec3D(0.1, 0.2, 0.3), 1.1, 2.2, Vec3D(0.4, 0.5, 0.6));
100 
101  CircularPeriodicBoundary circularPeriodicBoundary(0.3);
102 
103  DeletionBoundary deletionBoundary;
104  deletionBoundary.set(Vec3D(0.1, 0.2, 0.3), 3.14);
105 
106  LeesEdwardsBoundary leesEdwardsBoundary;
107  leesEdwardsBoundary.set(
108  [&] (double time UNUSED){
109  return 0.1;},
110  [&] (double time UNUSED) {
111  return 0.2;},
112  0.3,0.4,0.5,0.6);
113 
114  boundaryHandler.copyAndAddObject(angledPeriodicBoundary);
115  boundaryHandler.copyAndAddObject(chuteInsertionBoundary);
116  boundaryHandler.copyAndAddObject(cubeInsertionBoundary);
117  boundaryHandler.copyAndAddObject(hopperInsertionBoundary);
118  boundaryHandler.copyAndAddObject(periodicBoundary);
119  boundaryHandler.copyAndAddObject(circularPeriodicBoundary);
120  boundaryHandler.copyAndAddObject(deletionBoundary);
121  boundaryHandler.copyAndAddObject(leesEdwardsBoundary);
122 
123  BaseParticle baseParticle;
124  particleHandler.copyAndAddObject(baseParticle);
125 
126  }
127 };
128 
129 int main(int argc UNUSED, char *argv[] UNUSED)
130 {
131  FullRestartTest normal;
132  normal.setName("FullRestartTest_Normal");
133  normal.setupInitialConditions();
134  normal.restartFile.open();
135  normal.writeRestartFile();
136 
137  FullRestartTest restart;
138  restart.readRestartFile("FullRestartTest_Normal.restart");
139  restart.setName("FullRestartTest_Restart");
140  restart.restartFile.close();
141  restart.restartFile.setOpenMode(std::fstream::out);
142  restart.restartFile.open();
143  restart.writeRestartFile();
144  restart.write(std::cout);
145 }
void setupInitialConditions()
This function allows to set the initial conditions for our problem to be solved, by default particle ...
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 set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight)
Defines a periodic wall.
The DPMBase header includes quite a few header files, defining all the handlers, which are essential...
Definition: DPMBase.h:61
void set(std::function< double(double)> shift, std::function< double(double)> velocity, Mdouble left, Mdouble right, Mdouble down, Mdouble up)
Sets all boundary properties.
Class which creates a boundary with Lees-Edwards type periodic boundary conditions.
A IntersectionOfWalls is convex polygon defined as an intersection of InfiniteWall's.
This function defines an Archimedes' screw in the z-direction from a (constant) starting point...
Definition: Screw.h:38
void setOrientation(const Vec3D &orientation)
Sets the orientation of this BaseInteractable.
File restartFile
An instance of class File to handle in- and output into a .restart file.
Definition: Files.h:219
Used for removing particles from the problem. Inherits from BaseBoundary.
void addObject(Vec3D normal, Vec3D point)
Adds a wall to the set of infinite walls, given an outward normal vector s.t. normal*x=normal*point.
used to create a circular periodic boundary
void set(BaseParticle *particleToCopy, int maxFailed, Vec3D posMin, Vec3D posMax, Vec3D velMin, Vec3D velMax, double radMin, double radMax)
Sets the properties of the cuboidal insertion boundary.
Defines a pair of periodic walls. Inherits from BaseBoundary.
void set(Vec3D normal, Mdouble position, Mdouble holeRadius)
Defines a standard wall, given an outward normal vector s. t. normal*x=position.
void close()
Closes the file by calling fstream_.close()
Definition: File.cc:360
int readRestartFile()
Reads all the particle data corresponding to the current saved time step. Which is what the restart f...
Definition: DPMBase.cc:1375
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: Files.cc:149
It's an insertion boundary which has cuboidal shape (yes, 'CuboidalInsertionBoundary' would have been...
U * copyAndAddObject(const U &O)
Creates a copy of a Object and adds it to the BaseHandler.
Definition: BaseHandler.h:268
BoundaryHandler boundaryHandler
An object of the class BoundaryHandler which concerns insertion and deletion of particles into or fro...
Definition: DPMBase.h:888
int main(int argc UNUSED, char *argv[] UNUSED)
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:878
#define UNUSED
Definition: GeneralDefine.h:37
void set(Vec3D normalLeft, Vec3D normalRight, Vec3D origin)
Defines a periodic wall.
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
A AxisymmetricIntersectionOfWalls is a axisymmetric wall, defined by rotating a twodimensional Inters...
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.
bool open()
Checks if the file stream fstream_ has any issues while opening. Alongside, it also increments the ne...
Definition: File.cc:318
Inherits from InsertionBoundary Some images are useful to better understand the structure of both the...
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 set(BaseParticle *particleToCopy, int maxFailed, double yMin, double yMax, double radMin, double radMax, double chuteAngle, double fixedParticleRadius, bool isHopperCentred_, int hopperDim, double hopperAngle, double hopperLength, double hopperExitLength, double hopperHeight, double lift, double fillPercent)
Sets all boundary properties at once.
Used for modeling chute inflow. Inherits from InsertionBoundary.
virtual void writeRestartFile()
Stores all the particle data for current save time step. Calls the write function.
Definition: DPMBase.cc:1365
This is a class defining walls.
Definition: InfiniteWall.h:43
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
void set(Mdouble radius)
Defines a standard wall, given an outward normal vector s. t. normal*x=position.
void set(BaseParticle *particleToCopy, unsigned int maxFailed, Vec3D posMin, Vec3D posMax, double radMin, double radMax, double fixedParticleRadius, double inflowVelocity, double inflowVelocityVariance)
Sets all boundary properties at once.
This class defines a coil in the z-direction from a (constant) starting point, a (constant) length L...
Definition: Coil.h:40
void setOpenMode(std::fstream::openmode openMode)
Allows the user to Sets File::openMode_.
Definition: File.cc:267
void set(const Vec3D &normal, Mdouble distance)
Sets boundary position based on a normal and distance.