Problem.h
Go to the documentation of this file.
1 //Copyright (c) 2013-2023, 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 /*
27  * File: Problem.h
28  * Author: dducks
29  *
30  * Created on April 12, 2014, 2:20 PM
31  */
32 
33 #ifndef SERIALIZATION_PROBLEM_H
34 #define SERIALIZATION_PROBLEM_H
35 
36 #include <cereal/cereal.hpp>
37 #include <Mercury3D.h>
38 
39 class SerializedProblem : public Mercury3D {
40 public:
41  //SerializedProblem();
42 };
43 
44 template<class Archive>
45 void load(Archive& ar, SerializedProblem & base) {
46  using namespace cereal;
47 
48  std::string name;
49  Mdouble tMax;
50  Mdouble tStep;
51  Vec3D gravity;
52  Vec3D minimum;
53  Vec3D maximum;
54 
55  ar( CEREAL_NVP( name )
56  ,CEREAL_NVP( tMax )
57  ,CEREAL_NVP( tStep )
58  ,CEREAL_NVP( gravity )
59  ,CEREAL_NVP( minimum )
60  ,CEREAL_NVP( maximum )
61  ,cereal::make_nvp("particles", base.particleHandler)
62  ,cereal::make_nvp("walls", base.wallHandler)
63  );
64 
65  base.setName( name );
66  base.setTimeMax( tMax );
67  base.setTimeStep( tStep );
68  base.setGravity( gravity );
69  base.setXMin(minimum.X);
70  base.setYMin(minimum.Y);
71  base.setZMin(minimum.Z);
72 
73  base.setXMax(maximum.X);
74  base.setYMax(maximum.Y);
75  base.setZMax(maximum.Z);
76 }
77 
78 template<class Archive>
79 void save(Archive& ar, const SerializedProblem & base) {
80  Vec3D minimum;
81  Vec3D maximum;
82 
83  minimum.X = base.getXMin();
84  minimum.Y = base.getYMin();
85  minimum.Z = base.getZMin();
86  maximum.X = base.getXMax();
87  maximum.Y = base.getYMax();
88  maximum.Z = base.getZMax();
89 
90  ar ( cereal::make_nvp("name", base.getName())
91  ,CEREAL_NVP(minimum)
92  ,CEREAL_NVP(maximum)
93  ,cereal::make_nvp("tMax", base.getTimeMax())
94  ,cereal::make_nvp("tStep", base.getTimeStep())
95  ,cereal::make_nvp("gravity", base.getGravity())
96  ,cereal::make_nvp("particles", base.particleHandler)
97  ,cereal::make_nvp("walls", base.wallHandler)
98  );
99 }
100 
101 
102 #endif /* PROBLEM_H */
103 
double Mdouble
Definition: GeneralDefine.h:34
void load(Archive &ar, SerializedProblem &base)
Definition: Problem.h:45
void save(Archive &ar, const SerializedProblem &base)
Definition: Problem.h:79
Mdouble getXMin() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMin() returns XMin.
Definition: DPMBase.h:619
Mdouble getXMax() const
If the length of the problem domain in x-direction is XMax - XMin, then getXMax() returns XMax.
Definition: DPMBase.h:626
void setYMin(Mdouble newYMin)
Sets the value of YMin, the lower bound of the problem domain in the y-direction.
Definition: DPMBase.cc:1034
Mdouble getYMin() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMin() returns YMin.
Definition: DPMBase.h:632
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:422
Mdouble getTimeStep() const
Returns the simulation time step.
Definition: DPMBase.cc:1250
const std::string & getName() const
Returns the name of the file. Does not allow to change it though.
Definition: DPMBase.cc:399
WallHandler wallHandler
An object of the class WallHandler. Contains pointers to all the walls created.
Definition: DPMBase.h:1447
void setYMax(Mdouble newYMax)
Sets the value of YMax, the upper bound of the problem domain in the y-direction.
Definition: DPMBase.cc:1191
void setZMin(Mdouble newZMin)
Sets the value of ZMin, the lower bound of the problem domain in the z-direction.
Definition: DPMBase.cc:1058
void setXMax(Mdouble newXMax)
Sets the value of XMax, the upper bound of the problem domain in the x-direction.
Definition: DPMBase.cc:1165
Vec3D getGravity() const
Returns the gravitational acceleration.
Definition: DPMBase.cc:1391
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created.
Definition: DPMBase.h:1437
void setZMax(Mdouble newZMax)
Sets the value of ZMax, the upper bound of the problem domain in the z-direction.
Definition: DPMBase.cc:1217
Mdouble getYMax() const
If the length of the problem domain in y-direction is YMax - YMin, then getYMax() returns XMax.
Definition: DPMBase.h:638
void setTimeStep(Mdouble newDt)
Sets a new value for the simulation time step.
Definition: DPMBase.cc:1234
void setTimeMax(Mdouble newTMax)
Sets a new value for the maximum simulation duration.
Definition: DPMBase.cc:873
void setXMin(Mdouble newXMin)
Sets the value of XMin, the lower bound of the problem domain in the x-direction.
Definition: DPMBase.cc:1010
Mdouble getTimeMax() const
Returns the maximum simulation duration.
Definition: DPMBase.cc:888
void setGravity(Vec3D newGravity)
Sets a new value for the gravitational acceleration.
Definition: DPMBase.cc:1383
Mdouble getZMax() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMax() returns ZMax.
Definition: DPMBase.h:650
Mdouble getZMin() const
If the length of the problem domain in z-direction is ZMax - ZMin, then getZMin() returns ZMin.
Definition: DPMBase.h:644
This adds on the hierarchical grid code for 3D problems.
Definition: Mercury3D.h:37
Definition: Problem.h:39
Definition: Vector.h:51
Mdouble Y
Definition: Vector.h:66
Mdouble Z
Definition: Vector.h:66
Mdouble X
the vector components
Definition: Vector.h:66
std::string name
Definition: MercuryProb.h:48