Marine systems simulation
CoriboNet.h
1#pragma once
2
3#include <memory>
4#include <mutex>
5#include "eigen_matrix_defs.h"
6#include <sfh/constants.h>
7#include <Eigen/StdVector>
8#include <CEnvironment.h>
9
10class FloatingCollar;
11class BottomRing;
12#include "RingStructureGravityHydro.h"
13
14
15#ifdef FH_VISUALIZATION
16 #include <sfh/ogre/C3DLine.h>
17#endif
18
19namespace CoRiBoDynamics{
20
21class CoRiBoNet {
22public:
23 CoRiBoNet(){}
24 CoRiBoNet(const CoRiBoNet& copy) { throw std::runtime_error("Illegal copy constructor call on CoRiBoNet"); }
25 void Init(ISimObjectCreator* creator, std::string prefix, FloatingCollar * floating_collar, BottomRing * bottom_ring, double diameter, double height);
26 void InitStates(double* updatedIC);
27 void OdeFcn(double T, const double* X);
28 void Kinematics(const double* X, double* XDot, double delta_t);
29 void SetEnvironment(CEnvironment* environment);
30
31 int cols() { return m_nc; }
32 int rows() { return m_nr; }
33
34 const Eigen::Matrix<double, Eigen::Dynamic, 1>& GetFloatingCollarReactionForce(double T, const double* X);
35 const Eigen::Matrix<double, Eigen::Dynamic, 1>& GetBottomRingReactionForce(double T, const double* X);
36 double Gamma() { return m_gamma; }
37
38#ifdef FH_VISUALIZATION
39 virtual void RenderInit(Ogre::Root *const ogreRoot, ISimObjectCreator *const creator);
40 virtual void RenderUpdate(const double T, const double *const X);
41 std::unique_ptr<C3DLine> m_net_line;
42 std::unique_ptr<C3DLine> m_net_normals;
43#endif
44
45private:
46 void Recompute(double T, const double* X);
47
48 void distance_constraint(vec3& PA, vec3& PB, vec3& VA, vec3& VB, vec3& F, mat3& M, double L, double L_dot);
49
50 FloatingCollar* m_floating_collar;
51 BottomRing* m_bottom_ring;
52 int m_element_stride;
53
54 std::mutex m_mutex;
55 bool m_recompute;
56 CoRiBoDynamics::Vector m_FA; // reaction force on upper ring points
57 CoRiBoDynamics::Vector m_FB; // reaction force on lower ring points
58 CoRiBoDynamics::Vector m_PA; // position of upper points
59 CoRiBoDynamics::Vector m_PB; // position of lower points
60 CoRiBoDynamics::Vector m_VA; // velocity of upper points
61 CoRiBoDynamics::Vector m_VB; // velocity of lower points
62
63
64 double m_cage_radius;
65 int m_nc;
66 int m_nr;
67 int m_num_nodes;
68
69 double m_Lx;
70 double m_Ly;
71 double m_ring_connection_bar_length;
72
73 double m_node_mass;
74 double m_node_added_mass;
75 double m_node_projected_area;
76 double m_node_submerged_weight;
77
78 std::vector<mat3,Eigen::aligned_allocator<mat3>> m_connection_matrices;
79 std::vector<mat3,Eigen::aligned_allocator<mat3>> m_node_matrices;
80
81 struct ix_pair{ uint16_t i; uint16_t j; ix_pair(uint16_t a, uint16_t b){i=a;j=b;}};
82 std::vector<ix_pair> m_connections; // structural connections
83
84 std::vector<vec3, Eigen::aligned_allocator<vec3>> m_N; // node normal vector
85 std::vector<vec3, Eigen::aligned_allocator<vec3>> m_P; // node position
86 std::vector<vec3, Eigen::aligned_allocator<vec3>> m_V; // node velocity
87 CoRiBoDynamics::Vector m_A; // node accelerations
88
89 double m_tau;
90 double m_gamma;
91 SparseMat m_system_matrix;
92 std::unique_ptr<Eigen::SimplicialLLT<SparseMat,Eigen::Upper>> m_solver;
93
94 int m_position_states;
95 int m_velocity_states;
96
97 CEnvironment* m_environment;
98};
99};
Definition: RingStructureGravityHydro.h:74
Definition: CEnvironment.h:10
Definition: CoriboNet.h:21
Definition: RingStructureGravityHydro.h:67
Definition: CollisionManager.h:6