FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
NetStructureWithConstraints.h
1#pragma once
2#include "CommonTypes.h"
3
12// #define NetStructureWithConstraints_DO_PROFILE
13
14// Includes
15#include "NetBottomContactFilter.h"
16#include "NetCableElementSpec.h"
17#include "NetCableElementWithConstraints.h"
18#include "NetElement3NWithConstraints.h"
19#include "NetElementDef.h"
20#include "NetStructureSpec.h"
21
22#include "sfh/timers/ProfilerWallclock.h"
23
24#include <fhsim/simobject/SimObject.h>
25#include <fhsim_coribo/JointConstraint.h>
26#include <fhsim_environment/EnvironmentProvider.h>
27#include <fhsim_environment/SeafloorForcesInterface.h>
28#include <string>
29
30
31#ifdef FH_VISUALIZATION
32# include "sfh/ogre/C3DLine.h"
33# include "sfh/ogre/NMeshGenerators.h"
34
35# include <fhsim/visual/renderer/TextRenderer.h>
36#endif
37
38// Class definition
39class NetStructureWithConstraints : public SimObject
40{
41public:
43 NetStructureWithConstraints(std::string simObjectName, ISimObjectCreator* creator);
46 virtual void OdeFcn(const double dT, const double* const adX, double* const adXDot) const;
47 virtual void InitialConditionSetup(const double dT, const double* const adCurrentIC, double* const adUpdatedIC, ISimObjectCreator* const creator);
48 virtual void FinalSetup(const double dT, const double* const adX, ISimObjectCreator* const creator);
49 const double* const outExternalNodeForce(const double dT, const double* const adX, int extNode);
50
51#ifdef FH_VISUALIZATION
53 virtual void RenderInit(Ogre::Root* const ogreRoot, ISimObjectCreator* const creator);
55 virtual void RenderUpdate(const double dT, const double* const adX);
56
57 void CreateCapsule(Ogre::ManualObject* capsule_manual);
58 C3DLine* myline;
59#endif
60 const virtual double* const NodePos(const double dT, const double* const adX, int extNode);
61 const virtual double* const NodeVel(const double dT, const double* const adX, int extNode);
62 const virtual double* const BottomContact(const double dT, const double* const adX);
63 void SetAddedDragPerMPS(double AddedDragPerMPS);
64 const virtual double* const NodeForce(const double dT, const double* const adX, int extNode) const; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
65protected:
66 virtual void CalcStateDerivatives(const double* const adX, double* const adXDot) const;
67 virtual void AddExternalForces(const double dT, const double* const adX) const;
68 virtual void AddNetForces(const double dT, const double* const adX) const;
69 virtual void AddCableForces(const double dT, const double* const adX) const;
70 virtual double AddNodeBottomForce(const double* const adX, int node, double diam, double adForceInOut[3]) const;
71 virtual void AddBottomForces(const double* const adX) const;
72 virtual void AddInputPorts(ISimObjectCreator* creator);
73 virtual void CreateNetPanels(std::vector<const NetElementDef*> VNetElementDefs, ISimObjectCreator* creator);
74 virtual void CreateNetCables(std::vector<const NetCableElementSpec*> VCableElements, ISimObjectCreator* creator);
75 virtual void CreateDataStructures();
76 virtual void CreateOutputPorts(ISimObjectCreator* creator);
77 VSPairStrInt CreateExternalNodeMap(std::string tag, int* piUsed, NetStructureSpec& NetSpec, ISimObjectCreator* creator);
78 void PRINTALLNODEFORCES(std::string spec, double dT);
79
80 void SetExternalPos(const double dT, const double* const adX) const; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
81 void SetExternalVel(const double dT, const double* const adX) const; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
82
84
85 // ISignalPort **m_inExternalForces;
86 /*ISignalPort **m_InConstraintsPos; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
87 ISignalPort **m_InConstraintsVel; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects*/
88 ISignalPort** m_InTopConstraintsPos;
89 ISignalPort** m_InTopConstraintsVel;
90 int* m_iStatePos;
91 int* m_iStateVel;
93 double* m_NodeExternalForces;
94 double* m_NodeConstraintsPos; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
95 double* m_NodeConstraintsVel; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
97
99 int m_numNodesOutputPosAndVel;
100 int m_numPanelsCalc;
101 int m_numCablesCalc;
102 int m_numNodesOriginal;
103 int m_numNodesCalc;
104 int m_numNodeOutputs;
106
107 double* m_NodeInternalForces; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
108
109 int (*m_hasPosAndVelStates)[2]; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
110
111 int m_NumNodesInputPosAndVel; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
112 int m_NumNodesOutputForce; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
113
114 VSPairStrInt m_VsNodesInputPosAndVel; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
115 VSPairStrInt m_VsNodesOutputForce; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
116 // VSPairStrInt m_VsNodesTopConstraintsInputPos;
117
118
120
122 double m_bottomContact[6];
123
124 environment::EnvironmentProvider* m_environment;
125 environment::SeafloorForcesInterface* m_seafloor;
127
129
130 std::vector<NetCableElementWithConstraints*> m_VpCableElements;
131 std::vector<NetElement3NWithConstraints*> m_VpNetElements;
132 float* m_inertia;
133 int* m_netConn;
134 int** m_aaiCableConn;
135 SAdaptationSpec_t m_SAdaptations;
136 bool m_foldingPointRefinementUsed;
138
139
141
143 VSPairStrInt m_VsNodesInputForce;
144 bool m_useTagForExternalNodes;
146
147 double* m_nodeForce;
148 mutable sfh::timers::StopWatch m_OdeTimer;
149
150 bool m_CageWakeEffectsActive;
151
152 // CONSTRAINTS (NB LOTS OF HARD CODING HERE NOW)
153 CoRiBoDynamics::ConstraintSolver* m_constraintSolver;
154 struct states
155 {
156 int p;
157 int q;
158 int w;
159 int v;
160 };
161 std::vector<states> m_stateVector;
162 CoRiBoDynamics::JointConstraint* m_jointConstr;
163 // Coordinates for attachment of the constraints chains
164 mutable double m_topPosition1[3];
165 mutable double m_topVelocity1[3];
166 double m_topOrientation1[4];
167 double m_topangularVel1[3];
168 mutable double m_topPosition2[3];
169 mutable double m_topVelocity2[3];
170 double m_topOrientation2[4];
171
172 double m_topangularVel2[3];
173 double* m_nodeWeight;
174
175 double m_YoungsModulus;
176 int m_numConstraintsElements;
177 double m_depthOfConstraintsCable;
178#ifdef FH_VISUALIZATION
179 Ogre::SceneNode** m_renderNodes;
180 // Ogre::SceneNode* m_renderNode2; ///< The node to which the rendered entity is attached.
181#endif
182
183#ifdef NetStructureWithConstraints_DO_PROFILE
184 sfh::timers::ProfilerWallclock m_Profiler;
185#endif
186};
Definition NetBottomContactFilter.h:7
Definition NetStructureSpec.h:38
Definition NetStructureWithConstraints.h:40
VSPairStrInt m_VsNodesOutputPosAndVel
Nodes reachable directly through input or output ports.
Definition NetStructureWithConstraints.h:142
ISignalPort ** m_InTopConstraintsPos
Interface member variables.
Definition NetStructureWithConstraints.h:88
virtual ~NetStructureWithConstraints()
The destructor deletes dynamically allocated memory.
std::vector< NetCableElementWithConstraints * > m_VpCableElements
Element properties.
Definition NetStructureWithConstraints.h:130
int m_numNodesInputForce
Node counts.
Definition NetStructureWithConstraints.h:98
NetBottomContactFilter m_BottomContactFilter
Environment.
Definition NetStructureWithConstraints.h:121
NetStructureWithConstraints(std::string simObjectName, ISimObjectCreator *creator)
The constructor sets the pointer to the output object and the parser object.
Definition NetStructureWithConstraints.h:155
Class containing the specification for a net object.
Definition NetStructureSpec.h:22