GranOO 3.0
A robust and versatile workbench to build 3D dynamic simulations based on the Discrete Element Method
Loading...
Searching...
No Matches
BodyInteraction.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 _libPhysic_BodyInteraction_tpp_
30#define _libPhysic_BodyInteraction_tpp_
31
34
35
36namespace GranOO3
37{
38 namespace Physic
39 {
40
41 class Body;
42
43 class BodyInteraction : public NodeInteraction, public Core::Register<BodyInteraction>
44 {
46
47 public:
48 // Constructors and destructor
50 virtual ~BodyInteraction();
51
52 void apply_torque();
53 void clear_torque();
54
55 Geom::Vector& torque_on(const Body& b);
56 const Geom::Vector& torque_on(const Body& b) const;
57
58 // Accessing to discrete elements
59 GRANOO_ACCESS_GET_PTR (body1, Body, _body1);
60 GRANOO_ACCESS_REF_PTR (body1, Body, _body1);
61 GRANOO_ACCESS_REF_CONST_PTR(body1, Body, _body1);
62
63 GRANOO_ACCESS_GET_PTR (body2, Body, _body2);
64 GRANOO_ACCESS_REF_PTR (body2, Body, _body2);
65 GRANOO_ACCESS_REF_CONST_PTR(body2, Body, _body2);
66
67 GRANOO_ACCESS_GET(torque_on1, Geom::Vector, _torque_on1);
68 GRANOO_ACCESS_GET(torque_on2, Geom::Vector, _torque_on2);
69
70 void add_label_torque(const std::string &label, const Geom::Vector &t1, const Geom::Vector &t2);
71 void swap(Body& from, Body& to);
72
73 private:
74 BodyInteraction() = delete;
75 BodyInteraction(const BodyInteraction &frame) = delete;
77
78 //SERIALIZATION
80 template<class Archive> void serialize(Archive &, const unsigned int);
81
82
83 protected:
88
89 private:
90 std::map<std::string, Geom::Vector> _energy_balance_torque1;
91 std::map<std::string, Geom::Vector> _energy_balance_torque2;
92
93 };
94
95 template<class Archive>
96 void
97 BodyInteraction::serialize(Archive &ar, const unsigned int ) {
98
99 ar & boost::serialization::base_object<NodeInteraction>(*this);
100 }
101 }
102}
103
104#include <boost/serialization/version.hpp>
106
107// need placement new snippet because no default constructor exist
108namespace boost
109{
110 namespace serialization
111 {
112
113 template<class Archive>
114 inline void save_construct_data(Archive &ar, const GranOO3::Physic::BodyInteraction *t, const unsigned int) {
115
116 const GranOO3::Physic::Body* de1 = &t->get_body1();
117 const GranOO3::Physic::Body* de2 = &t->get_body2();
118 ar << de1;
119 ar << de2;
120 }
121
122 template<class Archive>
123 inline void load_construct_data(Archive &ar, GranOO3::Physic::BodyInteraction *t, const unsigned int) {
124
125 GranOO3::Physic::Body* de1 = nullptr;
126 GranOO3::Physic::Body* de2 = nullptr;
127 ar >> de1;
128 ar >> de2;
129 ::new(t)GranOO3::Physic::BodyInteraction(*de1,*de2, true);
130 }
131 }
132} // namespace ...
133
134namespace GranOO3
135{
136 GRANOO_CLASS_DECLARE_TPL(Physic::BodyInteraction);
137}
138
139#endif
BOOST_CLASS_VERSION(GranOO3::Physic::BodyInteraction, 0) namespace boost
Definition BodyInteraction.hpp:105
Definition SetOf.hpp:346
Definition Vector.hpp:75
a class that represents a body
Definition Body.hpp:43
a class that represents a generic physical interaction between two bodies
Definition BodyInteraction.hpp:44
void swap(Body &from, Body &to)
swap one body
Definition BodyInteraction.cpp:100
Geom::Vector _torque_on2
the current value of the applied torque on the body 2
Definition BodyInteraction.hpp:87
Body * _body1
a pointer the first body
Definition BodyInteraction.hpp:84
void serialize(Archive &, const unsigned int)
complete serializing of the item in the *.gdd format
Definition BodyInteraction.hpp:97
Geom::Vector & torque_on(const Body &b)
get the torque value applied on b
Definition BodyInteraction.cpp:55
BodyInteraction(Body &b1, Body &b2, bool contact_interaction)
constructor
Definition BodyInteraction.cpp:41
void add_label_torque(const std::string &label, const Geom::Vector &t1, const Geom::Vector &t2)
add a label for the torque
Definition BodyInteraction.cpp:93
BodyInteraction & operator=(const BodyInteraction &)=delete
BodyInteraction(const BodyInteraction &frame)=delete
Body * _body2
a pointer the second body
Definition BodyInteraction.hpp:85
virtual ~BodyInteraction()
destructor
Definition BodyInteraction.cpp:50
void clear_torque()
set the torques to zero
Definition BodyInteraction.cpp:87
Geom::Vector _torque_on1
the current value of the applied torque on the body 1
Definition BodyInteraction.hpp:86
friend class boost::serialization::access
Definition BodyInteraction.hpp:79
std::map< std::string, Geom::Vector > _energy_balance_torque1
a map of label for computing energy balance (internal usage only)
Definition BodyInteraction.hpp:90
void apply_torque()
apply the current torque value
Definition BodyInteraction.cpp:77
std::map< std::string, Geom::Vector > _energy_balance_torque2
a map of label for computing energy balance (internal usage only)
Definition BodyInteraction.hpp:91
bool contact_interaction() const
Definition NodeInteraction.cpp:57
NodeInteraction(Node &de1, Node &de2, bool build_node_interaction)
Definition NodeInteraction.cpp:42
This namespace group the entire Physic library.
Definition Common.hpp:198
Definition Pair.hpp:202