GranOO 3.0
A robust and versatile workbench to build 3D dynamic simulations based on the Discrete Element Method
Loading...
Searching...
No Matches
EnergyBalance.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 _LibPhysic_EnergyBalance_H
31#define _LibPhysic_EnergyBalance_H
32
33#include <map>
34
40
41
42namespace GranOO3
43{
44
45 namespace Physic
46 {
47
48
49 class EnergyBalance : public Core::Singleton<EnergyBalance>
50 {
51 public:
52 GRANOO_SINGLETON_CLASS(EnergyBalance);
53
54 public:
57
58 void enable();
59 void disable();
60 bool is_enable() const;
61
62 void clear();
63
64 template<typename T> void clear_map(T& map);
65
66 void add_force_on (const Node&, const std::string& label, const Geom::Vector& force);
67 void add_torque_on(const Body&, const std::string& label, const Geom::Vector& torque);
68
69
71 const std::map<std::string, Geom::Vector>& map_forceOn1,
72 const std::map<std::string, Geom::Vector>& map_forceOn2);
73
75 const std::map<std::string, Geom::Vector>& map_torque_on1,
76 const std::map<std::string, Geom::Vector>& map_torque_on2);
77
78
79
80 double compute_kinetic_energy() const;
81 void update();
82 std::vector<double> value() const;
83 std::vector<std::string> label() const;
84
85 const std::map<std::string, double>& get_energy() const;
86 const std::map<std::string, double>& get_energy_for(const Node&) const;
87 const std::map<std::string, double>& get_energy_for(const NodeInteraction&) const;
88 double get_total_energy_for(const Node&) const;
89 double get_total_energy_for(const NodeInteraction&) const;
90
92
93 private:
94 EnergyBalance(const EnergyBalance&) = delete;
96
97 private:
98 std::map<const Node*, std::map<std::string, Geom::Vector> > _force;
99 std::map<const Body*, std::map<std::string, Geom::Vector> > _torque;
100
101 std::map<const NodeInteraction*, const std::map<std::string, Geom::Vector>*> _force_on1;
102 std::map<const NodeInteraction*, const std::map<std::string, Geom::Vector>*> _force_on2;
103 std::map<const BodyInteraction*, const std::map<std::string, Geom::Vector>*> _torque_on1;
104 std::map<const BodyInteraction*, const std::map<std::string, Geom::Vector>*> _torque_on2;
105
106 std::map<const Node*, std::map<std::string, double> > _node_energy;
107 std::map<const NodeInteraction*, std::map<std::string, double> > _interaction_energy;
108
109 std::map<std::string, double> _total_energy;
110
111 private:
113 };
114
115 template<typename T> void
117 for (auto& it1: map)
118 for (auto& it2: it1.second)
119 it2.second.clear();
120 }
121 }
122}
123
124#endif
Definition Singleton.hpp:75
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
EnergyBalance()
Definition EnergyBalance.cpp:37
std::map< const BodyInteraction *, const std::map< std::string, Geom::Vector > * > _torque_on2
Definition EnergyBalance.hpp:104
std::map< std::string, double > _total_energy
Definition EnergyBalance.hpp:109
std::map< const Body *, std::map< std::string, Geom::Vector > > _torque
Definition EnergyBalance.hpp:99
EnergyBalance & operator=(const EnergyBalance &)=delete
bool _enable
Definition EnergyBalance.hpp:112
std::map< const BodyInteraction *, const std::map< std::string, Geom::Vector > * > _torque_on1
Definition EnergyBalance.hpp:103
std::map< const NodeInteraction *, const std::map< std::string, Geom::Vector > * > _force_on2
Definition EnergyBalance.hpp:102
~EnergyBalance()
Definition EnergyBalance.cpp:49
std::vector< double > value() const
Definition EnergyBalance.cpp:270
void disable()
Definition EnergyBalance.cpp:58
void update()
Definition EnergyBalance.cpp:170
void collect_interaction_force(const NodeInteraction &inter, const std::map< std::string, Geom::Vector > &map_forceOn1, const std::map< std::string, Geom::Vector > &map_forceOn2)
Definition EnergyBalance.cpp:74
EnergyBalance(const EnergyBalance &)=delete
std::map< const Node *, std::map< std::string, Geom::Vector > > _force
Definition EnergyBalance.hpp:98
void collect_interaction_torque(const BodyInteraction &inter, const std::map< std::string, Geom::Vector > &map_torque_on1, const std::map< std::string, Geom::Vector > &map_torque_on2)
Definition EnergyBalance.cpp:98
double get_total_energy_for(const Node &) const
Definition EnergyBalance.cpp:307
void clear_map(T &map)
Definition EnergyBalance.hpp:116
std::map< const NodeInteraction *, const std::map< std::string, Geom::Vector > * > _force_on1
Definition EnergyBalance.hpp:101
double compute_kinetic_energy() const
Definition EnergyBalance.cpp:162
void enable()
Definition EnergyBalance.cpp:53
void add_torque_on(const Body &, const std::string &label, const Geom::Vector &torque)
Definition EnergyBalance.cpp:153
void manage_disabled_interaction(const NodeInteraction &inter)
Definition EnergyBalance.cpp:121
void add_force_on(const Node &, const std::string &label, const Geom::Vector &force)
Definition EnergyBalance.cpp:143
std::map< const Node *, std::map< std::string, double > > _node_energy
Definition EnergyBalance.hpp:106
std::map< const NodeInteraction *, std::map< std::string, double > > _interaction_energy
Definition EnergyBalance.hpp:107
const std::map< std::string, double > & get_energy_for(const Node &) const
Definition EnergyBalance.cpp:295
const std::map< std::string, double > & get_energy() const
Definition EnergyBalance.cpp:290
std::vector< std::string > label() const
Definition EnergyBalance.cpp:280
bool is_enable() const
Definition EnergyBalance.cpp:63
void clear()
Definition EnergyBalance.cpp:68
Definition Node.hpp:58
Definition NodeInteraction.hpp:41
This namespace group the entire Physic library.
Definition Common.hpp:198