GranOO  3.0
A robust and versatile workbench to build 3D dynamic simulations based on the Discrete Element Method
Material.hpp
Go to the documentation of this file.
1 // This file is part of GranOO, a workbench for DEM simulation.
2 //
3 // Author(s) : - Damien Andre IRCER/UNILIM, Limoges France
4 // <damien.andre@unilim.fr>
5 // - Jean-luc Charles Arts et Metiers ParisTech, CNRS, I2M, Bordeaux France
6 // <jean-luc.charles@ensam.eu>
7 // - Jeremie Girardot Arts et Metiers ParisTech, CNRS, I2M, Bordeaux France
8 // <jeremie.girardot@ensam.eu>
9 // - Cedric Hubert LAMIH/UPHF, Valenciennes France
10 // <cedric.hubert@uphf.fr>
11 // - Ivan Iordanoff Arts et Metiers ParisTech, CNRS, I2M, Bordeaux France
12 // <ivan.iordanoff@ensam.eu>
13 //
14 // Copyright (C) 2008-2019 D. Andre, JL. Charles, J. Girardot, C. Hubert, I. Iordanoff
15 //
16 // This program is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 // This program is distributed in the hope that it will be useful,
22 // but WITHOUT ANY WARRANTY; without even the implied warranty of
23 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 // GNU General Public License for more details.
25 //
26 // You should have received a copy of the GNU General Public License
27 // along with this program. If not, see <http://www.gnu.org/licenses/>.
28 
29 
30 #ifndef _Physic_Prop_Material_HPP
31 #define _Physic_Prop_Material_HPP
32 
33 #include <boost/serialization/vector.hpp>
34 #include <boost/serialization/string.hpp>
35 #include <boost/serialization/serialization.hpp>
36 #include <map>
37 
38 #include "GranOO3/Core/Macro.hpp"
39 
40 
41 namespace GranOO3 {
42  namespace Physic {
43 
44  // a class that stores physical properties of material
45  class Material;
46 
47  // a simple struct that stores property that emerges when two materials interact
48  struct MaterialCouple {
49  void parse_xml();
50 
51  double _normal_stiffness = 0.;
52  double _adhesion_force = 0.;
53  double _restitution_coeff = 0.;
54  double _damping_factor = 0.;
55  double _tangential_stiffness = 0.;
56  double _static_friction = 0.;
57  double _dynamic_friction = 0.;
58  double _friction_slope = 1e5;
59  double _rolling_stiffness = 0.;
60  double _rolling_limit = 0.;
61  };
62 
63 
64  // the Material class, here we can put all physical properties related
65  // to a particular material such as density, elastic properties... Note that
66  // a Core::Base object can own a Physic::Material. So, a material can be applied
67  // to all GranOO's main classes and objects. The material is not serialized.
68  // This class can be used with the NEW-MATERIAL and the NEW-MATERIAL-COUPLE plugins.
69  class Material {
70  friend class MaterialCouple;
71 
72  // the default material
73  public:
74  static Material* get_default();
75  static Material* get(const std::string& name);
76  static bool exist(const std::string& name);
77 
78  private:
79  static Material* _default;
80  static std::map<std::string, Material*> _all;
81  static void add(Material*);
82 
83  private:
84  Material();
85 
86  public:
87  Material(const std::string& name);
88  virtual ~Material();
89 
90  void parse_xml();
91 
92  void add_bimat(Material* other_mat, MaterialCouple& bi);
93  const MaterialCouple& get_bimat(Material* other_mat) const;
94  // Accessors and mutators
95  GRANOO_ACCESS(name , std::string, _name );
96  GRANOO_ACCESS(young_modulus, double , _young_modulus );
97  GRANOO_ACCESS(poisson_ratio, double , _poisson_ratio );
98 
99  private:
100  //SERIALIZATION (not used)
102  template<class Archive> void save(Archive &, const unsigned int) const;
103  template<class Archive> void load(Archive &, const unsigned int);
105 
106  private:
107  std::string _name;
110  std::map<Material*, MaterialCouple> _bimat;
111  };
112 
113 
114  template<class Archive>
115  void
116  Material::save(Archive& ar, const unsigned int v) const {
117  ar << _name;
118  ar << _young_modulus;
119  ar << _poisson_ratio;
120  ar << _bimat;
121  }
122 
123  template<class Archive>
124  void
125  Material::load(Archive& ar, const unsigned int v) {
126  ar >> _name;
127  ar >> _young_modulus;
128  ar >> _poisson_ratio;
129  ar >> _bimat;
130  add(this);
131  }
132 
133  }
134 }
135 
136 
137 
138 #endif
Definition: Material.hpp:69
static Material * _default
Definition: Material.hpp:79
std::map< Material *, MaterialCouple > _bimat
Definition: Material.hpp:110
void add_bimat(Material *other_mat, MaterialCouple &bi)
Definition: Material.cpp:80
Material()
Definition: Material.cpp:61
double _young_modulus
Definition: Material.hpp:108
void load(Archive &, const unsigned int)
Definition: Material.hpp:125
static std::map< std::string, Material * > _all
Definition: Material.hpp:80
void save(Archive &, const unsigned int) const
Definition: Material.hpp:116
static bool exist(const std::string &name)
Definition: Material.cpp:52
virtual ~Material()
Definition: Material.cpp:76
static Material * get(const std::string &name)
Definition: Material.cpp:47
static void add(Material *)
Definition: Material.cpp:56
static Material * get_default()
Definition: Material.cpp:41
double _poisson_ratio
Definition: Material.hpp:109
void parse_xml()
Definition: Material.cpp:92
friend class boost::serialization::access
Definition: Material.hpp:101
const MaterialCouple & get_bimat(Material *other_mat) const
Definition: Material.cpp:86
std::string _name
Definition: Material.hpp:107
Definition: Common.hpp:198
Definition: Material.hpp:48
double _rolling_stiffness
Definition: Material.hpp:59
double _normal_stiffness
Definition: Material.hpp:51
double _adhesion_force
Definition: Material.hpp:52
double _damping_factor
Definition: Material.hpp:54
double _friction_slope
Definition: Material.hpp:58
double _restitution_coeff
Definition: Material.hpp:53
void parse_xml()
Definition: Material.cpp:101
double _dynamic_friction
Definition: Material.hpp:57
double _tangential_stiffness
Definition: Material.hpp:55
double _rolling_limit
Definition: Material.hpp:60
double _static_friction
Definition: Material.hpp:56