Marine systems simulation
CNetCage.h
1
9
10#pragma once
11
12#include <stdio.h>
13#include <string>
14
15#include "ISimObjectCreator.h"
16#include "SimObject.h"
17#include "Eigen/Eigen"
18#include <net/CNetStructure.h>
19
20#ifdef FH_VISUALIZATION
21//#include "CFhVis.h"
22#endif
23
24namespace Netcage {
25
26const double g_PI = 3.1415926;
27
28class CNetCage : public CNetStructure
29{
30public:
32 CNetCage(const string& simobjectname, ISimObjectCreator* const creator);
33
36
38 //virtual void OdeFcn(const double T, const double *const X, double *const XDot, const bool bIsMajorTimeStep);
39
41 const double* outSumHydDynForce(const double T, const double* const X);
42 const double* outNodeSumForce(const double T, const double* const X);
43 const double* outNodeSumDragForceAbs(const double T, const double* const X);
44 const double* outNodeSumDragForceDirection(const double T, const double* const X);
45 const double* outNodeSumLiftForce(const double T, const double* const X);
46 const double* outBottomPosition(const double T, const double* const X);
47 const double* outSteadyStateEst_Tau(const double T, const double* const X);
48 const double* outSteadyStateEst_K(const double T, const double* const X);
49 const double* LowerMembranePosition(const double dT, const double* const adX);
50
51 const virtual double * InternalNodeForce(const double dT, const double *const adX, int iExtNode); // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
52 const virtual double * NodeForce(const double T, const double *const X, int iNode);
53 virtual void FinalSetup(const double dT, const double *const adX, ISimObjectCreator *const pCreator); // NEW: overridden to test new approach where pos and vel for selected nodes are set by external objects
54 //const double *const outExternalNodeForce(const double dT, const double *const adX, int iExtNode);
55 //const double* const outCurrentVel(const double T, const double* const X);
56
57 // Overloads the function in CNetStructure
58 //void AddNetForces(const double dT, const double* const adX);
59 virtual void OdeFcn(const double dT, const double* const adX, double* const adXDot, const bool bIsMajorTimeStep);
60
61 void GetNodePositionIndices( std::vector<int> &NodePositions);
62 void GetNodeVelocityIndices( std::vector<int> &NodeVelocities);
63
64#ifdef FH_VISUALIZATION
65
67 void RenderInit(Ogre::Root* const pOgreRoot, ISimObjectCreator* const pCreator); // Overridden to be able to run two NetCageSim simobjects.
68 virtual void RenderUpdate(const double T, const double* const X); // NEW: overridden to test new approach where pos and vel for selected nodes are set by external objects
69
70#endif
71
72protected:
73 void DecomposeDragForcesInCurrentDirection(double* const DragForcesProjected, const double T, const double* const X);
74 void SteadyStateEstimator(const double T, const double* const X);
75
76 void SetExternalPos(const double dT, const double *const adX); // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
77 void SetExternalVel(const double dT, const double *const adX); // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
78
79 virtual void CreateDataStructures(); // NEW: overridden to test new approach where pos and vel for selected nodes are set by external objects
80 virtual void AddInputPorts(ISimObjectCreator *pCreator); // NEW: overridden to test new approach where pos and vel for selected nodes are set by external objects
81 virtual void CreateOutputPorts(ISimObjectCreator *pCreator); // NEW: overridden to test new approach where pos and vel for selected nodes are set by external objects
82 virtual void CalcStateDerivatives(const double *const adX, double *const adXDot); // NEW: overridden to test new approach where pos and vel for selected nodes are set by external objects
83 virtual double AddNodeBottomForce(const double *const adX, int iNode, double dDiam, double adForceInOut[3]);// NEW: overridden to test new approach where pos and vel for selected nodes are set by external objects
84 virtual void AddNetForces(const double dT, const double *const adX); // NEW: overridden to test new approach where pos and vel for selected nodes are set by external objects
85 virtual void AddCableForces(const double dT, const double *const adX); // NEW: overridden to test new approach where pos and vel for selected nodes are set by external objects
86
87 //ISignalPort* m_CurrentVel; // Current velocity input
88 ISignalPort **m_InExternalPos; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
89 ISignalPort **m_InExternalVel; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
90 ISignalPort *m_MembraneDepth; // Depth of membrane (Perma skirt.)
91
92 double* m_NodeExternalPos; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
93 double* m_NodeExternalVel; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
94
95 double m_adNodeSumForce[3];
96 double m_adSumHydDynForce[3];
97 double m_dNodeSumDragForceAbs;
98 double m_dNodeSumDragDirection;
99 double m_dNodeSumLiftForce;
100
101 double* m_adNodeHydDynForce;
102
103 double* m_NodeInternalForces; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
104
105 int(* m_hasPosAndVelStates)[2]; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
106
107 int m_NumNodesInputPosAndVel; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
108 int m_NumNodesOutputForce; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
109
110 VSPairStrInt m_VsNodesInputPosAndVel; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
111 VSPairStrInt m_VsNodesOutputForce; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
112
113 Eigen::MatrixXd m_SSPhi; // Regression matrix for steady state estimation
114 Eigen::MatrixXd m_SSY; // Output matrix for steady state estimation
115 double m_SS_Tau; // Estimated first order time constant
116 double m_SS_K; // Estimated gain
117 double m_SSPrevT; // Time for prevoius time step for steady state calculations
118
119 int m_IsMembrane; // True if simobject is (membrane)
120 int m_MembraneIsInSystem; // True if membrane is added
121 double m_LowerMembraneDepth;
122 std::string m_simobjectname; // for debug
123
124#ifdef FH_VISUALIZATION
125/*
126 double m_Scale; ///< Scale factor for the visualization.
127 const Ogre::Root* m_OgreRoot;
128 Ogre::SceneNode* m_renderNode;
129*/
130#endif
131};
132
133} // namespace
Definition: CNetStructure.h:203
Definition: CNetCage.h:29
CNetCage(const string &simobjectname, ISimObjectCreator *const creator)
The constructor sets the pointer to the output object and the parser object.
~CNetCage()
The destructor cleans up.
const double * outSumHydDynForce(const double T, const double *const X)
Calculates the state derivatives.
Class modelling a Net cage.
Definition: CBottomRing.h:35