Marine systems simulation
ParametricNet.h
1#pragma once
2#include <vector>
3#include <eigen_matrix_defs.h>
4#include <memory>
5#include <CEnvironment.h>
6
7#ifdef FH_VISUALIZATION
8#include "Ogre.h"
9#include <sfh/ogre/C3DLine.h>
10#endif
11
12typedef Eigen::Matrix<double, Eigen::Dynamic, Eigen::Dynamic> MatriX;
13
15public:
16 void Init(double diameter, int num_circumference, double height);
17 void InitStates(CoRiBoDynamics::Vector& PA, CoRiBoDynamics::Vector& PB);
18 void SetEnvironment(CEnvironment* environment);
19 CoRiBoDynamics::Vector Points(CoRiBoDynamics::Vector& PA, CoRiBoDynamics::Vector& PB, double T, const double * X);
20
21 int cols() { return m_nc; }
22 int rows() { return m_nr; }
23
24#ifdef FH_VISUALIZATION
25 void RenderInit(Ogre::Root* const ogreRoot);
26 void RenderUpdate(const double T, const double* const X);
27 std::unique_ptr<C3DLine> m_h_line; // horizontal lines
28 std::unique_ptr<C3DLine> m_v_line; // vertical lines
29 double max_tension;
30#endif
31
32private:
33 bool m_first_time;
34
35 CEnvironment* m_environment;
36 double m_node_weight;
37 double m_node_drag;
38
39 double m_EA;
40 double m_Lx; // horizontal element length
41 double m_Ly; // vertical element length
42
43 int m_nc; // number of point columns
44 int m_nr; // number of point rows
45 int m_nP; // number of points total
46 int m_nT;
47
48 int ixP (int r, int c) { return 3*(r + c*m_nr); } // point index
49 int ixTL(int r, int c) { return 3*m_nP + r + c*m_nr; } // tension left index
50 int ixTR(int r, int c) { return 3*m_nP + r + ((c + m_nc-1)%m_nc)*m_nr; } // tension right index
51 int ixTU(int r, int c) { return 4*m_nP + r + c*(m_nr+1); } // tension up index
52 int ixTD(int r, int c) { return 4*m_nP + (r+1)%(m_nr+1) + c*(m_nr+1); } // tension down index
53
54 int ixNL(int r, int c) { return 3*(r + c*m_nr); } // normal left index
55 int ixNR(int r, int c) { return 3*(r + ((c + m_nc - 1) % m_nc)*m_nr); } // normal right index
56 int ixNU(int r, int c) { return 3*(m_nP + r + c*(m_nr + 1)); } // normal up index
57 int ixND(int r, int c) { return 3*(m_nP + (r + 1) % (m_nr + 1) + c*(m_nr + 1)); } // normal down index
58
59 CoRiBoDynamics::Vector m_X; // state vector. contains node positions and tensions
60 CoRiBoDynamics::Vector m_PA; // position of upper points
61 CoRiBoDynamics::Vector m_PB; // position of lower points
62 CoRiBoDynamics::Vector m_U; // edge unit vectors
63 CoRiBoDynamics::Vector m_F; // vertex forces
64
65 CoRiBoDynamics::Vector Constraint(const CoRiBoDynamics::Vector& X);
66
67 MatriX Jacobian(const CoRiBoDynamics::Vector& X);
68
69 CoRiBoDynamics::Vector DeltaX(const CoRiBoDynamics::Vector& X);
70
71 void NewtonRhapson(CoRiBoDynamics::Vector& X);
72
73};
74
75
Definition: CEnvironment.h:10
Definition: ParametricNet.h:14