3#include "eigen_matrix_defs.h"
4#include "sfh/constants.h"
7#include "Eigen/StdVector"
8#include "CEnvironment.h"
9#include <CPrintDuringExec.h>
11#ifdef FH_VISUALIZATION
12#include "sfh/ogre/C3DLine.h"
19 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
23 void Init(ISimObjectCreator* creator);
24 void OdeFcn(
double T,
const double* X,
double* XDot);
25 void PreOdeFcn(
const double T,
const double* X, IStateUpdater* updater);
27 double Radius(){
return m_cage_radius;}
28 double Depth(){
return m_Depth;}
38 CageEdge GetClosestEdge(
const vec3& P);
50 struct ix_pair { uint16_t i; uint16_t j;
ix_pair(uint16_t a, uint16_t b) { i = a; j = b; } };
52 NetPanel GetClosestNetPanel(
const vec3& P,
double& velR,
const vec3& V);
60 bool GetRayIntersection(
const vec3& rayOrigin,
const vec3& rayDirection,
double& outDistance);
61 bool RayIntersectsTriangle(
const Triangle* inTriangle,
const vec3& rayOrigin,
const vec3& rayVector,
double& outDistance);
64 double m_dragForceNet[3];
65 double m_dragForceSkirt[3];
66 double m_dragForceDepth[3];
70 double* m_TopOutForce;
73 double m_RingOutPos[3];
74 double m_BotOutPos[3];
75 double m_NetOutPos[3];
76 double m_BotOutVel[3];
84 double m_ExtTopBodyForce[6];
86 bool m_PortPosToForce;
89 double m_PortConLength;
90 double* m_PortOutForce;
92 bool m_PortForceToPos;
94 int* m_PortForceIndex;
102 double m_CageTopCentre[3];
104 double m_FlowReduction;
111 int m_PortCDIndex[2];
112 double m_PortCDDepth;
113 double* m_PortNodeCD;
117 bool m_InBottomForce;
118 ISignalPort* m_AddBottomForce;
121 ISignalPort* m_AddRingForce;
126 ISignalPort** m_AddCd;
129 ISignalPort** m_InRingPos;
130 ISignalPort** m_InRingVel;
131 double* m_OutRingForce;
134 ISignalPort** m_InChainPos;
135 ISignalPort** m_InChainVel;
136 double* m_OutChainForce;
137 std::vector<double> m_ChainPos;
142 int m_ExtChainDepIdx;
149 bool m_BotRingInState;
150 ISignalPort* m_BotRingInPos;
151 ISignalPort* m_BotRingInVel;
157 double m_NetTrackDis;
158 ISignalPort* m_NetTrackPos;
163 double* m_NetPanelArea;
164 double m_NetPanelAreaTrack;
165 double m_NetPanelOutDT;
166 int m_NetPanelOutNum;
167 std::string m_NetPanelOutFile;
169 double m_CageNodeOutDT;
170 int m_CageNodeOutNum;
171 std::string m_CageNodeOutFile;
172 double m_CageNodeOutTSta;
173 double m_CageNodeOutTStp;
176 double m_NetTrackAng;
179 ISignalPort* m_NetIdentifyNum;
181 bool m_NetTrackHeadingToPosition;
182 ISignalPort* m_NetTrackHeading;
184 int m_NetTrack_States;
185 double m_NetTrackPosOut[12];
186 double m_NetTrackPosIn[6];
187 double m_NetTrackMaxDiff;
188 double m_NetTrackCenDiff[4];
189 double m_NetTrackInitialTime[3];
191 double m_CageHeading;
196 int NodeNumber() {
return m_num_nodes;}
197 vec3 NodePosition(
int index) {
return m_P[index];};
202 bool m_useDummyTankVel;
205 void GetDummyTankVel(
const double* pos,
double* outVal);
209#ifdef FH_VISUALIZATION
210 virtual void RenderInit(Ogre::Root *
const ogreRoot, ISimObjectCreator *
const creator);
211 virtual void RenderUpdate(
const double T,
const double *
const X);
214 C3DLine* m_ring_line;
216 C3DLine* m_node_unit_hydro_force;
217 Ogre::SceneNode* m_ring_node;
218 std::vector<ix_pair> m_net_pair;
219 C3DLine* m_top_line_ext;
221 C3DLine* m_chain_line;
224 C3DLine* m_net_triangle;
227 C3DLine* m_skirt_triangle;
232 C3DLine* m_track_triangle;
233 double m_track_color[4];
239 void distance_constraint(vec3& PA, vec3& PB, vec3& VA, vec3& VB, vec3& NA, vec3& NB, vec3& F, mat3& M,
double L,
double L_dot,
double igamma);
240 void distance_constraint_t(vec3& PA, vec3& PB, vec3& VA, vec3& VB, vec3& NA, vec3& NB, vec3& F, mat3& M,
double L,
double L_dot,
double igamma);
241 void ring_constraint(vec3& P, vec3 V,
double angle, vec3& F, vec3& T, mat3& NN, mat3& NK, mat3& KK,
double igamma,
double ST,
const double* SX,
int ic);
242 void ring_constraint_ext(vec3& P, vec3 V,
double angle, vec3& F, vec3& T, mat3& NN, mat3& NK, mat3& KK,
double igamma,
double ST,
const double* SX,
int ic);
243 void chain_constraint(vec3& P, vec3 V,
double angle, vec3& F, vec3& T, mat3& NN, mat3& NK, mat3& KK,
double igamma,
double ST,
const double* SX,
int ic, vec3& FR, mat3& NNR,
int dIdx, mat3& NNC, vec3& FC);
245 uint16_t ConvertToZindex(
const vec3& P);
246 vec3 ConvertFromZindex(uint16_t Z_index);
248 std::vector<int> m_EdgeLookupArray;
250 Eigen::Matrix<double,15,1> m_net_bottom_function_approximation_coefficients;
252 double m_cage_radius;
253 int m_num_nodes_circumference;
254 int m_num_nodes_vertical;
257 double m_net_diameter;
259 double m_net_solidity;
260 double m_ring_connection_bar_length;
264 double m_node_added_mass;
265 double m_node_projected_area;
266 double m_node_submerged_weight;
268 vec3 TopRingConnectionPoint(
int ix,
double T,
const double* X);
270 ISignalPort* m_WinchLength;
271 ISignalPort* m_WinchSpeed;
273 std::vector<mat3,Eigen::aligned_allocator<mat3>> m_connection_matrices;
274 std::vector<mat3,Eigen::aligned_allocator<mat3>> m_node_matrices;
275 std::vector<mat36,Eigen::aligned_allocator<mat36>> m_ring_matrices;
277 std::vector<ix_pair> m_connections;
279 std::vector<vec3,Eigen::aligned_allocator<vec3>> m_N;
280 std::vector<vec3,Eigen::aligned_allocator<vec3>> m_P;
281 std::vector<vec3,Eigen::aligned_allocator<vec3>> m_V;
283 std::vector<vec3, Eigen::aligned_allocator<vec3>> m_unitHydF;
291 SparseMat m_system_matrix;
292 Eigen::SimplicialLDLT<SparseMat,Eigen::Upper> m_solver;
294 int m_position_states;
295 int m_velocity_states;
300 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
312 void UpdateStates(
const double* X);
313 void HydroDynamics(vec6& Forces, mat6& Inertia,
double T,
const double* X);
314 void Kinematics(
const vec6& Accelerations,
double* XDot);
317 vec3 translational_inertia;
318 vec3 angular_inertia;
327 void UpdateStatesInput(
const double* X,
const double* InPos,
const double* InVel);
328 void KinematicsInput(
const vec6& Accelerations,
double* XDot);
332 std::vector<int> m_TI;
337 std::vector<int> m_TopI;
340 std::vector<int> m_BotI;
345 std::vector<double> m_A;
347 std::vector<double> m_BL;
352 std::vector<int> m_BotELookupArray;
359 ISignalPort* m_WinchTime;
361 ISignalPort** m_TopInPos;
362 ISignalPort** m_TopInVel;
364 ISignalPort* m_TopInBodyPos;
365 ISignalPort* m_TopInBodyQuat;
375 double* m_MatNetOutR;
377 std::vector<double> m_RingPos;
379 double m_RingOutR[2];
384 double m_BotRingForce;
389 std::vector<vec3, Eigen::aligned_allocator<vec3>> m_TopPPos;
390 std::vector<vec3, Eigen::aligned_allocator<vec3>> m_TopTPos;
392 double m_VelRedFactor;
394 ISignalPort** m_PortInPos;
395 ISignalPort** m_PortInVel;
396 ISignalPort** m_PortInForce;
398 bool PointInsideTriangle(vec3& P, vec3& A, vec3& B, vec3& C);
399 int Factorial(
int n);
401 ISignalPort* m_BotConForce;
407 CPrintDuringExec* m_logger;
Definition: RingStructureGravityHydro.h:74
Definition: CEnvironment.h:10
Definition: FishCage.h:17
Definition: FishCage.h:32
double depth
edge normal vector. Points "out" of cage
Definition: FishCage.h:35
vec3 N
edge node position
Definition: FishCage.h:34
Definition: FishCage.h:40
Definition: FishCage.h:55
Definition: FishCage.h:50