MercuryDPM  0.11
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Tutorial10.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 // Tutorial 10: This tutorial shows how to load restart and data files
27 
28 #include <Mercury3D.h>
29 #include <Math/Helpers.h>
30 
31 int main(int argc, char* argv[])
32 {
33  //writeToFile is used here to create a restart and a data file, which will be loaded below.
34  helpers::writeToFile("Tutorial10.ini.restart",
35  "restart_version 1.0 name Tutorial10\n"
36  "dataFile name Tutorial10.data fileType ONE_FILE saveCount 10 counter 0 nextSavedTimeStep 0\n"
37  "fStatFile name Tutorial10.fstat fileType NO_FILE saveCount 10 counter 0 nextSavedTimeStep 0\n"
38  "eneFile name Tutorial10.ene fileType ONE_FILE saveCount 10 counter 0 nextSavedTimeStep 0\n"
39  "restartFile name Tutorial10.restart fileType ONE_FILE saveCount 10 counter 0 nextSavedTimeStep 0\n"
40  "statFile name Tutorial10.stat fileType ONE_FILE saveCount 10 counter 0 nextSavedTimeStep 0\n"
41  "xMin 0 xMax 2 yMin 0 yMax 2 zMin 0 zMax 2\n"
42  "timeStep 1e-03 time 0 ntimeSteps 0 timeMax 10\n"
43  "systemDimensions 3 particleDimensions 3 gravity 0 0 -1\n"
44  "Species 1\n"
45  "LinearViscoelasticSpecies id 0 density 1.9098593 stiffness 2000 dissipation 10\n"
46  "Walls 1\n"
47  "InfiniteWall id 0 indSpecies 0 position 0 0 0 orientation 0 0 0 1 velocity 0 0 0 angularVelocity 0 0 0 0 force 0 0 0 torque 0 0 0 normal 0 0 -1 factor 1\n"
48  "WallsPeriodic 0\n"
49  "Particles 0\n"
50  "Interactions 0\n"
51  );
52 
53  helpers::writeToFile("Tutorial10.ini.data",
54  "1 0 0 0 0 2 2 2\n"
55  "1 1 1.5 0 0 0 0.5 0 0 0 0 0 0 0\n"
56  );
57 
58  DPMBase Tutorial10;
59  //use readRestartFile to load information from a restart file
60  Tutorial10.readRestartFile("Tutorial10.ini.restart");
61 
62  //use readDataFile to load information from a data file
63  Tutorial10.readDataFile("Tutorial10.ini.data");
64 
65  //now start the calculations
66  Tutorial10.solve();
67 
68  return 0;
69 }
70 
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
bool readDataFile(const std::string fileName, unsigned int format=0)
This allows particle data to be reloaded from data files.
Definition: DPMBase.cc:989
int readRestartFile()
Reads all the particle data corresponding to the current saved time step. Which is what the restart f...
Definition: DPMBase.cc:1375
int main(int argc, char *argv[])
Definition: Tutorial10.cpp:31