GranOO  3.0
A robust and versatile workbench to build 3D dynamic simulations based on the Discrete Element Method
Spring.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 #ifndef _libDEM_Spring_hpp_
30 #define _libDEM_Spring_hpp_
31 
32 #include <string>
33 #include <vector>
34 
35 #include "GranOO3/DEM/Bond.hpp"
36 #include "GranOO3/Core/SetOf.hpp"
37 #include "GranOO3/DEM/Element.hpp"
38 #include "GranOO3/Geom/Point.hpp"
39 
40 namespace GranOO3
41 {
42  namespace DEM
43  {
44  class Spring : public Bond,
45  public Core::Register<Spring >,
47 
48  GRANOO_CLASS(DEM::Spring, Bond);
49 
50 
51  public:
52  //CONSTRUCTORS & DESTRUCTORS
53  Spring(Element& el1, Element& el2);
54  Spring(Element& el1, Element& el2, double stiffness, double damping, double max_relative_elongation = 0);
55  Spring(Element& el1, Element& el2, double stiffness, double damping, double attrac_coef, double rep_coeff, double max_relative_elongation = 0);
56  virtual ~Spring();
57 
58  //USEFULL
59  void init();
60  virtual void update();
61  void process();
62  virtual void compute_load();
63  virtual double get_linear_stiffness() const;
64  virtual double get_angular_stiffness() const;
65  virtual double compute_critical_time_step() const;
66  virtual std::string info() const;
67 
68  //ACCESSORS
69  GRANOO_ACCESS (stiffness , double , _stiffness );
70  GRANOO_ACCESS_GET(direction , Geom::Vector, _direction );
71  GRANOO_ACCESS_GET(elongation_energy, double , _elongation_energy);
72 
73  double get_restitution_coeff() const;
74  void set_restitution_coeff(double val);
75 
76  private:
77  Spring() = delete;
78  Spring(const Spring&) = delete;
79  Spring & operator=(const Spring &) = delete;
80 
81  private:
82  //Initial Parameter
83  double _stiffness;
86 
87  //Parameter
89 
90  //Deformation energies
92 
93  //To compute deformation energies
98 
99 
100 
101  private:
102  //BOOST SERIALIZATION
104  template<class Archive> void serialize(Archive&, const unsigned int);
105  };
106 
107  //BOOST SERIALIZATION
108 
109  template<class Archive> void
110  Spring::serialize(Archive & ar, const unsigned int version) {
111  ar & boost::serialization::base_object<Bond>(*this);
112  ar & _stiffness;
113  ar & _elongation_energy;
114  ar & _attractive_coeff;
115  ar & _repulsive_coeff;
116  }
117  }
118 }
119 
120 
121 #include <boost/serialization/version.hpp>
123 
124 
125 // need placement new snippet because no default constructor exist
126 namespace boost
127 {
128  namespace serialization
129  {
130  template<class Archive>
131  inline void save_construct_data(Archive &ar, const GranOO3::DEM::Spring *t, const unsigned int) {
132 
133  const GranOO3::DEM::Element* de1 = &t->get_element1();
134  const GranOO3::DEM::Element* de2 = &t->get_element2();
135  ar << de1;
136  ar << de2;
137  }
138 
139  template<class Archive>
140  inline void load_construct_data(Archive &ar, GranOO3::DEM::Spring *t, const unsigned int) {
141 
142  GranOO3::DEM::Element* de1 = nullptr;
143  GranOO3::DEM::Element* de2 = nullptr;
144  ar >> de1;
145  ar >> de2;
146  ::new(t)GranOO3::DEM::Spring(*de1,*de2);
147  }
148  }
149 } // namespace ...
150 
151 
152 namespace GranOO3
153 {
154  GRANOO_CLASS_DECLARE_TPL(DEM::Spring);
155 }
156 
157 
158 #endif
159 
160 
BOOST_CLASS_VERSION(GranOO3::DEM::Spring, 0) namespace boost
Definition: Spring.hpp:122
Definition: SetOf.hpp:346
the base class for all bonds between discrete elements.
Definition: Bond.hpp:49
a base class that represents an element
Definition: Element.hpp:55
a bond spring
Definition: Spring.hpp:46
double _attractive_coeff
the attractive coefficient which is used as a multiplication factor on the reaction force when the el...
Definition: Spring.hpp:84
double _elongation_energy
the current elongation energy of the spring
Definition: Spring.hpp:91
virtual void update()
update the current values of elongation, local frame, etc...
Definition: Spring.cpp:83
Geom::Vector _d1
the current relative displacement of the element1 for energy computation (internal usage)
Definition: Spring.hpp:96
Spring & operator=(const Spring &)=delete
virtual ~Spring()
destructor
Definition: Spring.cpp:75
void set_restitution_coeff(double val)
set the current value of the restitution coefficient
Definition: Spring.cpp:134
virtual double compute_critical_time_step() const
compute the critical time of the bond
Definition: Spring.cpp:141
double _repulsive_coeff
the repulsive coefficient which is used as a multiplication factor on the reaction force when the elo...
Definition: Spring.hpp:85
virtual std::string info() const
Display some useful info in the terminal
Definition: Spring.cpp:154
virtual double get_angular_stiffness() const
always return 0 in case of spring
Definition: Spring.cpp:123
void serialize(Archive &, const unsigned int)
complete serializing of the bond in the *.gdd format
Definition: Spring.hpp:110
Geom::Vector _F2
the current force acting on the element2 for energy computation (internal usage)
Definition: Spring.hpp:95
virtual double get_linear_stiffness() const
compute the linear stiffness of the bond
Definition: Spring.cpp:118
double get_restitution_coeff() const
get the current value of the restitution coefficient
Definition: Spring.cpp:129
double _stiffness
the stiffness of the spring in [N/m]
Definition: Spring.hpp:83
void init()
initialize the spring (it does nothing)
Definition: Spring.cpp:79
virtual void compute_load()
trigger the computation of the reaction force and torque of the spring
Definition: Spring.cpp:111
friend class boost::serialization::access
Definition: Spring.hpp:103
void process()
update the current value of reaction force
Definition: Spring.cpp:93
Geom::Vector _direction
the current direction of the spring (for internal usage)
Definition: Spring.hpp:88
Geom::Vector _F1
the current force acting on the element1 for energy computation (internal usage)
Definition: Spring.hpp:94
Spring(const Spring &)=delete
Geom::Vector _d2
the current relative displacement of the element2 for energy computation (internal usage)
Definition: Spring.hpp:97
Definition: Vector.hpp:75
pure virtual class for modeling classes able to compute a critical time step
Definition: CriticalTimeStep.hpp:50
Definition: Common.hpp:198
void save_construct_data(Archive &ar, const GranOO3::Core::Pair< type > *t, const unsigned int)
Definition: Pair.hpp:207
void load_construct_data(Archive &ar, GranOO3::Core::Pair< type > *t, const unsigned int)
Definition: Pair.hpp:217
Definition: Pair.hpp:202
x y t t *t x y t t t x y t t t x *y t *t t x *y t *t t x y t t t x y t t t t(t+t)") define_sfop3(16
static char_cptr version
Definition: Exprtk.hpp:44221