GranOO 3.0
A robust and versatile workbench to build 3D dynamic simulations based on the Discrete Element Method
Loading...
Searching...
No Matches
Element.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 _LibDEM_Element_T
31#define _LibDEM_Element_T
32
33
34
35#include <boost/serialization/version.hpp>
36#include <boost/serialization/map.hpp>
37
43
44namespace GranOO3
45{
46 namespace DEM
47 {
48 class Bond;
49 template<class T> class ElementT;
50
51
52 class Element : public Physic::Body,
53 public Core::PropClass< Element >,
54 public Core::Register< Element >
55 {
56
57 GRANOO_CLASS(DEM::Element, Physic::Body);
58 GRANOO_CLASS_DEFAULT_COLOR(.8, .0, .1, 1.);
59
60 public:
61 static Element* new_object(const TiXmlElement* el);
62
63 public:
64 // Constructors and destructor
65 Element(Shape::Volume& shape, const Geom::Point & point);
66 Element(Shape::Volume& shape);
67
68 virtual ~Element() = 0;
69
70 //INTERNAL USE (Not documented)
71 virtual std::string shape_class_ID() const = 0;
72
73 // Bond management
74 void add_bond (Bond& b);
75 void erase_bond(Bond& b);
76
77
78 // Bond management
79 bool is_bonded(const Element& el) const;
80 bool is_bonded(const Element& el, Bond*& commonBond);
81 bool is_bonded(const Element& el, const Bond*& commonBond) const;
82 bool is_bonded(const Bond& bond) const;
83 Bond& common_bond(const Element& el);
84 const Bond& common_bond(const Element& el) const;
85 void delete_all_bond();
87 size_t get_bond_number() const;
89 bool is_unbonded() const;
90 bool is_bonded() const;
91
92 double compute_kinetic_energy() const;
93
94 // Bonded cluster management
96 Core::SetOfBase< DEM::Bond >& parsed_bond);
97
98 virtual std::string info() const;
99
102
105
106 // cloning
107 void make_equal_to(const Element& el);
108
109 // IO
110 virtual std::ostream& write_ascii (std::ostream& os) const;
111 virtual std::istream& read_ascii (std::istream& is);
112
113 // SHAPE CASTING
114 virtual bool is_spherical_element() const = 0;
115 virtual bool is_polyhedral_element() const = 0;
116
117 private:
118 Element(const Element&) = delete;
119 Element & operator=(const Element &) = delete;
120
121 //BOOST SERIALIZATION
123 template<class Archive> void serialize(Archive&, const unsigned int);
124
125 protected:
128 };
129
130
133 return _bondset;
134 }
135
136 inline size_t
138 return _bondset.size();
139 }
140
141 inline double
143 const double V = get_linear_velocity().norm();
144 const double W = get_angular_velocity().norm();
145 return 0.5*( (get_mass()*V*V) + (get_inertia_tensor().xx()*W*W));
146 }
147
150 return _neighbour;
151 }
152
153 inline const NeighbourManager<Element>&
155 return _neighbour;
156 }
157
160 return _neighbour.set();
161 }
162
163 inline const Core::SetOfBase< Element >&
165 return _neighbour.set();
166 }
167
168
169 template<class Archive> void
170 Element::serialize(Archive & ar, const unsigned int version) {
171 ar & boost::serialization::base_object<Physic::Body>(*this);
172 ar & boost::serialization::base_object<Core::PropClass<Element> >(*this);
173 }
174
175 }
176}
177
178#include <boost/serialization/version.hpp>
180
181
182namespace GranOO3
183{
184 GRANOO_CLASS_DECLARE_TPL(DEM::Element);
185 extern template class Core::PropClass< DEM::Element >;
186}
187
188
189
190#endif
191
BOOST_CLASS_VERSION(GranOO3::DEM::Element, 0) namespace GranOO3
Definition Element.hpp:179
bool is() const
Definition Base.hpp:150
Definition PropClass.hpp:47
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
virtual std::ostream & write_ascii(std::ostream &os) const
dump the current state of the element in a ascii file (standard *.lgdd format)
Definition Element.cpp:218
void serialize(Archive &, const unsigned int)
complete serializing of the element in the *.gdd format
Definition Element.hpp:170
void make_equal_to(const Element &el)
for equalizing two elements
Definition Element.cpp:205
bool is_unbonded() const
util method to know if the current element is unbonded
Definition Element.cpp:142
virtual std::string info() const
get some info on a given element
Definition Element.cpp:210
virtual std::string shape_class_ID() const =0
get the related shape classID
Core::SetOfBase< Bond > _bondset
the always up-to-date list of bond which are bonded to the current element
Definition Element.hpp:126
Core::SetOfBase< Element > & neighbour_set()
get a list of neighbour element
Definition Element.hpp:159
virtual ~Element()=0
destructor
Definition Element.cpp:80
Element(const Element &)=delete
void erase_bond(Bond &b)
erase a bond from the _bondset list
Definition Element.cpp:176
virtual bool is_polyhedral_element() const =0
util method for knowing if the element is polyhedral or not
void add_bond(Bond &b)
add a bond to the _bondset list
Definition Element.cpp:170
Bond & common_bond(const Element &el)
returns the bond that bonds the current element with the el element
Definition Element.cpp:111
virtual bool is_spherical_element() const =0
util method for knowing if the element is spherical or not
virtual std::istream & read_ascii(std::istream &is)
update the current state of the element from an ascii file format *.lgdd
Definition Element.cpp:224
NeighbourManager< Element > _neighbour
the always up-to-date list of bond which are bonded to the current element
Definition Element.hpp:127
Core::SetOfBase< Bond > & get_bond_set()
get the bond list of the current element
Definition Element.hpp:132
Element & operator=(const Element &)=delete
void compute_bond_cluster(Core::SetOfBase< DEM::Element > &cluster_set, Core::SetOfBase< DEM::Bond > &parsed_bond)
util method for detecting a cluster
Definition Element.cpp:152
friend class boost::serialization::access
Definition Element.hpp:122
size_t get_bond_number() const
get the number of bond connected to the current element
Definition Element.hpp:137
double compute_kinetic_energy() const
compute the kinetic energy of the current element
Definition Element.hpp:142
void delete_all_bond()
delete all the bond connected to the current element
Definition Element.cpp:197
Core::SetOfBase< Element > get_bonded_element()
get a list of bonded element
Definition Element.cpp:182
NeighbourManager< Element > & neighbour()
get a list of neighbour element
Definition Element.hpp:149
Element(Shape::Volume &shape, const Geom::Point &point)
constructor
Definition Element.cpp:70
bool is_bonded() const
util method to know if the current element is bonded
Definition Element.cpp:147
a template class that model an element with a given shape
Definition ElementT.hpp:59
a util class for representing neighbouring (mainly DEM::Element) items
Definition NeighbourManager.hpp:41
Definition Point.hpp:62
a class that represents a body
Definition Body.hpp:43
double get_mass() const
get the current mass value of the body
Definition Body.cpp:58
Definition Volume.hpp:103
This namespace group the entire DEM library.
Definition Common.hpp:198