GranOO  3.0
A robust and versatile workbench to build 3D dynamic simulations based on the Discrete Element Method
Contact.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 
31 #ifndef _LibCollision_Contact_HPP
32 #define _LibCollision_Contact_HPP
33 
34 
35 
38 #include "GranOO3/Geom/Frame.hpp"
39 #include <map>
40 
41 namespace GranOO3
42 {
43  namespace Collision
44  {
45 
46  constexpr unsigned long long int unique_pair_from(unsigned long long int x, unsigned long long int y) {
47  return x>y ? (x+y)*(x+y+1)/2 + y : (x+y)*(x+y+1)/2 + x;
48  //return (x+y)*(x+y+1)/2 + y;
49  }
50 
51 
52  // The main class that manages contact that manage contacts between T1 class and T2 class..
53  template<class T1, class T2>
54  class Contact
55  {
56  public:
57  static std::string class_ID() {return "Contact<" + T1::class_ID() + ", " + T2::class_ID() + ">";}
58  static unsigned long long int compute_ID(const T1& t1, const T2& t2);
59  static void manage(const T1& t1, const T2& t2, Data& d);
60  static void disable_all();
62  static Contact* get(const T1& t1, const T2& t2);
63 
64  public:
65  static std::map<unsigned long long int, Contact<T1,T2>*> _all_map;
66 
67  public:
68  void update(const Data& d);
69 
70  private:
71  Contact(const T1& t1, const T2& t2, Data& d);
73 
74  public:
75  const T1& _body1;
76  const T2& _body2;
77  bool _enable;
89  };
90 
91 
92 
93 
94  }
95 }
96 
97 
98 #include "GranOO3/Collision/Contact.tpp"
99 
100 
101 #endif
Definition: Contact.hpp:55
static void remove_all_disabled_contact()
Geom::Frame _F
Definition: Contact.hpp:84
static unsigned long long int compute_ID(const T1 &t1, const T2 &t2)
Geom::Vector _tangent_disp1
Definition: Contact.hpp:87
static void manage(const T1 &t1, const T2 &t2, Data &d)
static std::map< unsigned long long int, Contact< T1, T2 > * > _all_map
Definition: Contact.hpp:65
bool _enable
Definition: Contact.hpp:77
Geom::Quaternion _Q2
Definition: Contact.hpp:82
Geom::Frame _F1
Definition: Contact.hpp:86
Geom::Quaternion _Q
Definition: Contact.hpp:83
static Contact * get(const T1 &t1, const T2 &t2)
Geom::Point _point2
Definition: Contact.hpp:80
Contact(const T1 &t1, const T2 &t2, Data &d)
Geom::Vector _tangent_disp2
Definition: Contact.hpp:88
Geom::Point _point1
Definition: Contact.hpp:79
void update(const Data &d)
Geom::Point _point
Definition: Contact.hpp:78
static std::string class_ID()
Definition: Contact.hpp:57
Geom::Quaternion _Q1
Definition: Contact.hpp:81
const T2 & _body2
Definition: Contact.hpp:76
Geom::Point _P1
Definition: Contact.hpp:85
const T1 & _body1
Definition: Contact.hpp:75
Definition: Frame.hpp:68
Definition: Point.hpp:62
Definition: Quaternion.hpp:54
Definition: Vector.hpp:75
constexpr unsigned long long int unique_pair_from(unsigned long long int x, unsigned long long int y)
Definition: Contact.hpp:46
Definition: Common.hpp:198
const T1
Definition: Exprtk.hpp:16489
const T1 const T2
Definition: Exprtk.hpp:16511
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 x(y+z)
Definition: Data.hpp:43