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