Virtual Testbed
Ship dynamics simulator for extreme conditions
ship_hull_panel.hh
1 #ifndef VTESTBED_CORE_SHIP_HULL_PANEL_HH
2 #define VTESTBED_CORE_SHIP_HULL_PANEL_HH
3 
4 #include <vtestbed/core/grid.hh>
5 #include <vtestbed/core/types.hh>
6 #include <vtestbed/geometry/math.hh>
7 
8 namespace vtb {
9 
10  namespace core {
11 
17  template <class T, int N>
18  class alignas(16) Ship_hull_panel {
19 
20  public:
21  static constexpr const int
22  Centre = 0,
23  Normal = 1,
24  Force = 2,
25  Polyhedron = 3;
26 
27  public:
28  using vec = blitz::TinyVector<T,N>;
29 
30  private:
31  vec _centre{T{}};
32  vec _normal{T{}};
33  vec _force{T{}};
34  T _area{T{}};
35  T _volume{T{}};
36  union {
37  struct { bool _wetted = false; bool _waterline = false; };
38  T padding[1];
39  };
40 
41  public:
42 
43  Ship_hull_panel(const vec& centre, vec n, T area, T volume);
44  Ship_hull_panel() = default;
45  ~Ship_hull_panel() = default;
46  Ship_hull_panel& operator=(const Ship_hull_panel&) = default;
47 
49  inline const vec& centre() const { return this->_centre; }
50  inline void centre(const vec& rhs) { this->_centre = rhs; }
51 
53  inline const vec& normal() const { return this->_normal; }
54  inline void normal(const vec& rhs) { this->_normal = rhs; }
55 
57  inline T area() const { return this->_area; }
58  inline void area(T rhs) { this->_area = rhs; }
59 
61  inline T volume() const { return this->_volume; }
62  inline void volume(T rhs) { this->_volume = rhs; }
63 
68  inline const vec& force() const { return this->_force; }
69  inline vec& force() { return this->_force; }
70 
71  inline bool wetted() const { return this->_wetted; }
72  inline void wetted(bool rhs) { this->_wetted = rhs; }
73 
74  inline bool waterline() const { return this->_waterline; }
75  inline void waterline(bool rhs) { this->_waterline = rhs; }
76 
77  };
78 
83  template <class T>
84  Grid<T,3>
85  clamp(const Grid<T,3>& grid_xyz, const std::vector<Ship_hull_panel<T,3>>& panels);
86 
87  }
88 
89 }
90 
91 #endif // vim:filetype=cpp
T area() const
Get surface area.
Triangular ship hull panel (face).
Main namespace.
Definition: convert.hh:9
T volume() const
Get tetrahedron volume.
const vec & centre() const
Get the centre of the panel in body-fixed coordinate system.
const vec & normal() const
Get surface normal.
const vec & force() const