MercuryDPM  0.11
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
1Particle4WallsOldRestartVersionUnitTest.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 #include <Math/Helpers.h>
26 #include "DPMBase.h"
27 
30 int main(int argc UNUSED, char *argv[] UNUSED)
31 {
32 
33  helpers::writeToFile("1Particle4WallsOldRestartVersionUnitTest.restart",
34  "restart_version 3\n"
35  "name 1Particle4WallsOldRestartVersionUnitTest\n"
36  "xmin 0 xmax 1 ymin 0 ymax 1.1 zmin 0 zmax 1\n"
37  "dt 0.0001 t 0 tmax 0.01 save_count_data 5 save_count_ene 5 save_count_stat 5 save_count_fstat 5\n"
38  "dim 3 gravity 0 0 0\n"
39  "options_fstat 1 options_data 1 options_ene 1 options_restart 1\n"
40  "Species 2\n"
41  "k 200000 disp 50 kt 57142.857 dispt 0 mu 0.5 rho 1.9098593 dim_particle 3\n"
42  "k 200000 disp 50 kt 57142.857 dispt 0 mu 0.5 rho 1.9098593 dim_particle 3\n"
43  "k 200000 disp 50 kt 57142.857 dispt 0 mu 0.5 (mixed)\n"
44  "Walls 4\n"
45  "numFiniteWalls 0 normal -1 0 0 position 0\n"
46  "numFiniteWalls 0 normal 1 0 0 position .96\n"
47  "numFiniteWalls 0 normal 0 0 -1 position 0\n"
48  "numFiniteWalls 0 normal 0 0 1 position .96\n"
49  "WallsPeriodic 1\n"
50  "normal 0 1 0 pos_left 0 pos_right 1.1 shift 0 1.1 0\n"
51  "Particles 1\n"
52  "0.48 0 0.48 0 0 0 0.5 0 0 0 0 60 0 1 10 0\n"
53  "NUM_BUCKETS 16 HGRID_MAX_LEVELS 1 MIN_CELL_SIZE 1 SPHERE_TO_CELL_RATIO 1 CELL_TO_CELL_RATIO 2\n"
54  "FixedParticleRadius 0.5 MinInflowParticleRadius 0.5 MaxInflowParticleRadius 0.5\n"
55  "RandomizedBottom 2 ChuteAngle 20 max_failed 1 num_created 2000\n"
56  "InflowVelocity 0.1 InflowVelocityVariance 0 InflowHeight 10\n"
57  );
58  DPMBase problem;
59  problem.setName("1Particle4WallsOldRestartVersionUnitTest");
60  problem.readRestartFile();
61  problem.setAppend(false);
62  problem.solve();
63  problem.writeRestartFile();
64 
65  //Now check the rotational energy in the system; it should loose some rotational energy in the first loop due to
66  //sliding, then conserve energy as no tangential dissipation is used.
67  //gnuplot:
68  // p '1Particle4WallsRestartUnitTest_restart.ene' u 1:4 w l t 'rotational energy', '1Particle4WallsRestartUnitTest_restart.ene' u 1:($3+$4+$5-160) w l t 'total energy - normal elastic energy'
69 }
bool writeToFile(std::string filename, std::string filecontent)
Writes a string to a file.
Definition: Helpers.cc:411
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 setAppend(bool newAppendFlag)
Allows to set the append option.
Definition: DPMBase.cc:544
int main(int argc UNUSED, char *argv[] UNUSED)
This code tests if the old restart format can still be read.
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
#define UNUSED
Definition: GeneralDefine.h:37
virtual void writeRestartFile()
Stores all the particle data for current save time step. Calls the write function.
Definition: DPMBase.cc:1365