Marine systems simulation
CNetStructureWithConstraints.h
1#pragma once
2
9//#define CNetStructureWithConstraints_DO_PROFILE
10
11// Includes
12#include <string>
13#include <SimObject.h>
14#include <CEnvironment.h>
15#include <IBasicBottom.h>
16#include <ICurrentVel.h>
17#include "sfh/timers/ProfilerWallclock.h"
18#include <JointConstraint.h>
19
20#include "CNetElement3NWithConstraints.h"
21#include "CNetCableElementSpec.h"
22#include "CNetCableElementWithConstraints.h"
23#include "CNetElementDef.h"
24#include "CNetBottomContactFilter.h"
25#include "CNetStructureSpec.h"
26
27
28
29#ifdef FH_VISUALIZATION
30 #include "sfh/ogre/NMeshGenerators.h"
31 #include "sfh/ogre/C3DLine.h"
32 #include <CTextRenderer.h>
33#endif
34
35//Class definition
36class CNetStructureWithConstraints : public SimObject
37{
38public:
40 CNetStructureWithConstraints(std::string sSimObjectName, ISimObjectCreator *pCreator);
43 virtual void OdeFcn(const double dT, const double *const adX, double *const adXDot, const bool bIsMajorTimeStep);
44 virtual void InitialConditionSetup(const double dT, const double *const adCurrentIC, double *const adUpdatedIC, ISimObjectCreator *const pCreator);
45 virtual void FinalSetup(const double dT, const double *const adX, ISimObjectCreator *const pCreator);
46 const double *const outExternalNodeForce(const double dT, const double *const adX, int iExtNode);
47
48#ifdef FH_VISUALIZATION
50 virtual void RenderInit(Ogre::Root *const pOgreRoot, ISimObjectCreator *const pCreator);
52 virtual void RenderUpdate(const double dT, const double *const adX);
53
54 void CreateCapsule( Ogre::ManualObject *capsule_manual);
55 C3DLine *myline;
56#endif
57 const virtual double *const NodePos(const double dT, const double *const adX, int iExtNode);
58 const virtual double *const NodeVel(const double dT, const double *const adX, int iExtNode);
59 const virtual double *const BottomContact(const double dT, const double *const adX);
60 void SetAddedDragPerMPS(double AddedDragPerMPS);
61 const virtual double *const NodeForce(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
62protected:
63 virtual void CalcStateDerivatives(const double *const adX, double *const adXDot);
64 virtual void AddExternalForces(const double dT, const double *const adX);
65 virtual void AddNetForces(const double dT, const double *const adX);
66 virtual void AddCableForces(const double dT, const double *const adX);
67 virtual double AddNodeBottomForce(const double *const adX, int iNode, double dDiam, double adForceInOut[3]);
68 virtual void AddBottomForces(const double *const adX);
69 virtual void AddInputPorts(ISimObjectCreator *pCreator);
70 virtual void CreateNetPanels(std::vector<const CNetElementDef*> VNetElementDefs, ISimObjectCreator *pCreator);
71 virtual void CreateNetCables(std::vector<const CNetCableElementSpec*> VCableElements, ISimObjectCreator *pCreator);
72 virtual void CreateDataStructures();
73 virtual void CreateOutputPorts(ISimObjectCreator *pCreator);
74 VSPairStrInt CreateExternalNodeMap( std::string sTag, int* piUsed, CNetStructureSpec & NetSpec, ISimObjectCreator *pCreator);
75 void PRINTALLNODEFORCES(std::string spec, double dT);
76
77 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
78 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
79
81
82 //ISignalPort **m_apInExternalForces;
83 /*ISignalPort **m_InConstraintsPos; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
84 ISignalPort **m_InConstraintsVel; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects*/
85 ISignalPort **m_InTopConstraintsPos;
86 ISignalPort **m_InTopConstraintsVel;
87 int *m_aIStatePos;
88 int *m_aIStateVel;
90 double* m_NodeExternalForces;
91 double* m_NodeConstraintsPos; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
92 double* m_NodeConstraintsVel; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
94
96 int m_iNumNodesOutputPosAndVel;
97 int m_iNumPanelsCalc;
98 int m_iNumCablesCalc;
99 int m_iNumNodesOriginal;
100 int m_iNumNodesCalc;
101 int m_iNumNodeOutputs;
103
104 double* m_NodeInternalForces; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
105
106 int(* m_hasPosAndVelStates)[2]; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
107
108 int m_NumNodesInputPosAndVel; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
109 int m_NumNodesOutputForce; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
110
111 VSPairStrInt m_VsNodesInputPosAndVel; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
112 VSPairStrInt m_VsNodesOutputForce; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
113 //VSPairStrInt m_VsNodesTopConstraintsInputPos;
114
115
117
119 double m_adBottomContact[6];
120
121 IBasicBottom** m_ppBottom;
122 ICurrentVel** m_ppCurrentVel;
123 CEnvironment* m_pEnvironment;
125
127
128 std::vector<CNetCableElementWithConstraints*> m_VpCableElements;
129 std::vector<CNetElement3NWithConstraints*> m_VpNetElements;
130 float* m_afInertia;
131 int* m_aiNetConn;
132 int** m_aaiCableConn;
133 SAdaptationSpec_t m_SAdaptations;
134 bool m_bFoldingPointRefinementUsed;
136
137
139
141 VSPairStrInt m_VsNodesInputForce;
142 bool m_bUseTagForExternalNodes;
144
145 double* m_adNodeForce;
146 sfh::timers::StopWatch m_OdeTimer;
147
148 bool m_CageWakeEffectsActive;
149
150 // CONSTRAINTS (NB LOTS OF HARD CODING HERE NOW)
151 CoRiBoDynamics::ConstraintSolver* m_constraintSolver;
152 struct states {int p; int q; int w; int v;};
153 std::vector<states> m_stateVector;
154 CoRiBoDynamics::JointConstraint* m_jointConstr;
155 // Coordinates for attachment of the constraints chains
156 double m_topPosition1[3];
157 double m_topVelocity1[3];
158 double m_topOrientation1[4];
159 double m_topangularVel1[3];
160 double m_topPosition2[3];
161 double m_topVelocity2[3];
162 double m_topOrientation2[4];
163
164 double m_topangularVel2[3];
165 double* m_nodeWeight;
166
167 double m_YoungsModulus;
168 int m_numConstraintsElements;
169 double m_depthOfConstraintsCable;
170#ifdef FH_VISUALIZATION
171 Ogre::SceneNode** m_pRenderNodes;
172 //Ogre::SceneNode* m_pRenderNode2; ///< The node to which the rendered entity is attached.
173#endif
174
175#ifdef CNetStructureWithConstraints_DO_PROFILE
176 sfh::timers::ProfilerWallclock m_Profiler;
177#endif
178
179
180};
Definition: CEnvironment.h:10
Definition: CNetBottomContactFilter.h:7
Definition: CNetStructureSpec.h:38
Definition: CNetStructureWithConstraints.h:37
CNetBottomContactFilter m_BottomContactFilter
Environment.
Definition: CNetStructureWithConstraints.h:118
virtual ~CNetStructureWithConstraints()
The destructor deletes dynamically allocated memory.
ISignalPort ** m_InTopConstraintsPos
Interface member variables.
Definition: CNetStructureWithConstraints.h:85
VSPairStrInt m_VsNodesOutputPosAndVel
Nodes reachable directly through input or output ports.
Definition: CNetStructureWithConstraints.h:140
CNetStructureWithConstraints(std::string sSimObjectName, ISimObjectCreator *pCreator)
The constructor sets the pointer to the output object and the parser object.
int m_iNumNodesInputForce
Node counts.
Definition: CNetStructureWithConstraints.h:95
std::vector< CNetCableElementWithConstraints * > m_VpCableElements
Element properties.
Definition: CNetStructureWithConstraints.h:128
Definition: ConstraintSolver.h:31
Definition: JointConstraint.h:17
Interface for calculating the bottom force on various objects.
Definition: IBasicBottom.h:23
Definition: ICurrentVel.h:12
Definition: CNetStructureWithConstraints.h:152
Class containing the specification for a net object.
Definition: CNetStructureSpec.h:22