FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
NetStructureWithConstraints.h
1#pragma once
2
3#include <limits>
4#include "CommonTypes.h"
5
311// #define NetStructureWithConstraints_DO_PROFILE
312
313// Includes
314#include "NetBottomContactFilter.h"
315#include "NetCableElementSpec.h"
316#include "NetCableElementWithConstraints.h"
317#include "NetElement3NWithConstraints.h"
318#include "NetElementDef.h"
319#include "NetPanelSetup.h"
320#include "NetStructureSpec.h"
321#include "NetFlowInteraction.h"
322
323#include "sfh/timers/ProfilerWallclock.h"
324
325#include <fhsim/simobject/SimObject.h>
326#include <fhsim_coribo/JointConstraint.h>
327#include <fhsim_environment/EnvironmentProvider.h>
328#include <fhsim_environment/SeafloorForcesInterface.h>
329#include <memory>
330#include <string>
331
332
333#ifdef FH_VISUALIZATION
334# include "sfh/ogre/C3DLine.h"
335# include "sfh/ogre/NMeshGenerators.h"
336#endif
337
338// Class definition
339class NetStructureWithConstraints : public SimObject
340{
341public:
343 NetStructureWithConstraints(std::string simObjectName, ISimObjectCreator* creator);
346 virtual void OdeFcn(const double dT, const double* const adX, double* const adXDot) const;
347 virtual void InitialConditionSetup(const double dT, const double* const adCurrentIC, double* const adUpdatedIC, ISimObjectCreator* const creator);
348 virtual void FinalSetup(const double dT, const double* const adX, ISimObjectCreator* const creator);
350 void PreOdeFcn(double T, const double* X, IStateUpdater* updater) override;
351 const double* const outExternalNodeForce(const double dT, const double* const adX, int extNode);
352
353#ifdef FH_VISUALIZATION
355 virtual void RenderInit(Ogre::Root* const ogreRoot, ISimObjectCreator* const creator);
357 virtual void RenderUpdate(const double dT, const double* const adX);
358
359 void CreateCapsule(Ogre::ManualObject* capsule_manual);
360 C3DLine* myline;
361#endif
362 const virtual double* const NodePos(const double dT, const double* const adX, int extNode);
363 const virtual double* const NodeVel(const double dT, const double* const adX, int extNode);
364 const virtual double* const BottomContact(const double dT, const double* const adX);
365 void SetAddedDragPerMPS(double AddedDragPerMPS);
366 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
367protected:
368 virtual void CalcStateDerivatives(const double* const adX, double* const adXDot) const;
369 virtual void AddExternalForces(const double dT, const double* const adX) const;
370 virtual void AddNetForces(const double dT, const double* const adX) const;
371 virtual void AddCableForces(const double dT, const double* const adX) const;
373 void AddNetAndCableForcesInParallel(double T, const double* X) const;
375 void AddNetForceRange(double T, const double* X, int begin, int end, double* nodeForce) const;
378 void AddCableForceRange(double T, const double* X, int begin, int end, double* nodeForce, bool waterFollowsElement = false) const;
380 void CableHydrodynamicForce(double T, const double* X, double force[3]) const;
382 void FlowAt(double T, int point, const double pos[3], double vel[3]) const;
384 void UpdateNodeWaveVelocities(double T, const double* X, int firstNode, int endNode) const;
385 mutable std::vector<double> m_nodeWaveVelocity;
386 virtual double AddNodeBottomForce(const double* const adX, int node, double diam, double adForceInOut[3]) const;
387 virtual void AddBottomForces(const double* const adX) const;
388 virtual void AddInputPorts(ISimObjectCreator* creator);
389 virtual void CreateNetPanels(std::vector<const NetElementDef*> VNetElementDefs, ISimObjectCreator* creator);
390 virtual void CreateNetCables(std::vector<const NetCableElementSpec*> VCableElements, ISimObjectCreator* creator);
391 virtual void CreateDataStructures();
392 virtual void CreateOutputPorts(ISimObjectCreator* creator);
393 VSPairStrInt CreateExternalNodeMap(std::string tag, int* piUsed, NetStructureSpec& NetSpec, ISimObjectCreator* creator);
394 void ValidateConstraintInput(ISimObjectCreator* creator) const;
395 void PRINTALLNODEFORCES(std::string spec, double dT);
396
397 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
398 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
399
401
402 // ISignalPort **m_inExternalForces;
403 /*ISignalPort **m_InConstraintsPos; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
404 ISignalPort **m_InConstraintsVel; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects*/
406 ISignalPort** m_InTopConstraintsVel;
407 int* m_iStatePos;
408 int* m_iStateVel;
410 double* m_NodeExternalForces;
411 double* m_NodeConstraintsPos; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
412 double* m_NodeConstraintsVel; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
414
416 int m_numNodesOutputPosAndVel;
417 int m_numPanelsCalc;
418 int m_numCablesCalc;
419 int m_numNodesOriginal;
420 int m_numNodesCalc;
421 int m_numNodeOutputs;
423
424 double* m_NodeInternalForces; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
425
426 int (*m_hasPosAndVelStates)[2]; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
427
428 int m_NumNodesInputPosAndVel; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
429 int m_NumNodesOutputForce; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
430
431 VSPairStrInt m_VsNodesInputPosAndVel; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
432 VSPairStrInt m_VsNodesOutputForce; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
433 // VSPairStrInt m_VsNodesTopConstraintsInputPos;
434
435
437
439 double m_bottomContact[6];
440
441 environment::EnvironmentProvider* m_environment;
442 environment::SeafloorForcesInterface* m_seafloor;
444
446
448 net_solidity::SolidityModel m_solidityModel = net_solidity::kDefaultSolidityModel;
450
452
453 template<class> friend class NetWakePanels;
454 std::unique_ptr<NetFlowInteraction> m_flow;
455 ISimObjectLogger* m_logger = nullptr;
456 hydrodynamics::PanelClampLog m_clampLog;
458
460
461 std::vector<NetCableElementWithConstraints*> m_VpCableElements;
462 std::vector<NetElement3NWithConstraints*> m_VpNetElements;
463 float* m_inertia;
464 int* m_netConn;
465 int** m_aaiCableConn;
466 SAdaptationSpec_t m_SAdaptations;
467 bool m_foldingPointRefinementUsed;
469
470
472
474 VSPairStrInt m_VsNodesInputForce;
475 bool m_useTagForExternalNodes;
477
478 double* m_nodeForce;
480 double m_meanTensionTime = std::numeric_limits<double>::quiet_NaN();
481
482 bool m_CageWakeEffectsActive;
483
484 // CONSTRAINTS (NB LOTS OF HARD CODING HERE NOW)
485 CoRiBoDynamics::ConstraintSolver* m_constraintSolver;
486 struct states
487 {
488 int p;
489 int q;
490 int w;
491 int v;
492 };
493 std::vector<states> m_stateVector;
494
501 const double* NodePositionState(const double* X, int node) const { return X + (NodeHasOwnStates(node) ? m_iStatePos[node] : DrivingElement(node).p); }
503 const double* NodeVelocityState(const double* X, int node) const { return X + (NodeHasOwnStates(node) ? m_iStateVel[node] : DrivingElement(node).v); }
505 bool NodeHasOwnStates(int node) const { return m_hasPosAndVelStates[node][1] == 1; }
507 const states& DrivingElement(int node) const { return m_stateVector[m_hasPosAndVelStates[node][0]]; }
508
509 CoRiBoDynamics::JointConstraint* m_jointConstr;
510 // Coordinates for attachment of the constraints chains
511 mutable double m_topPosition1[3];
512 mutable double m_topVelocity1[3];
513 double m_topOrientation1[4];
514 double m_topangularVel1[3];
515 mutable double m_topPosition2[3];
516 mutable double m_topVelocity2[3];
517 double m_topOrientation2[4];
518
519 double m_topangularVel2[3];
520
521 double m_YoungsModulus;
523 int m_numThreads = 1;
524 mutable std::vector<double> m_threadNodeForces;
525 int m_numConstraintsElements;
526 double m_depthOfConstraintsCable;
527#ifdef FH_VISUALIZATION
528 Ogre::SceneNode** m_renderNodes;
529 // Ogre::SceneNode* m_renderNode2; ///< The node to which the rendered entity is attached.
530#endif
531
532#ifdef NetStructureWithConstraints_DO_PROFILE
533 sfh::timers::ProfilerWallclock m_Profiler;
534#endif
535};
Definition NetBottomContactFilter.h:7
Definition NetStructureSpec.h:37
Definition NetStructureWithConstraints.h:340
VSPairStrInt m_VsNodesOutputPosAndVel
Nodes reachable directly through input or output ports.
Definition NetStructureWithConstraints.h:473
void AddNetForceRange(double T, const double *X, int begin, int end, double *nodeForce) const
Adds the forces of panels [begin, end) to nodeForce.
double m_meanTensionTime
The time of the last per-step mean-tension update of the cable elements (owner ruling R64),...
Definition NetStructureWithConstraints.h:480
bool NodeHasOwnStates(int node) const
True unless a rigid element drives the node.
Definition NetStructureWithConstraints.h:505
const states & DrivingElement(int node) const
The state indices of the rigid element that drives the node.
Definition NetStructureWithConstraints.h:507
const double * NodePositionState(const double *X, int node) const
Definition NetStructureWithConstraints.h:501
ISignalPort ** m_InTopConstraintsPos
Interface member variables.
Definition NetStructureWithConstraints.h:405
virtual ~NetStructureWithConstraints()
The destructor deletes dynamically allocated memory.
std::vector< NetCableElementWithConstraints * > m_VpCableElements
Element properties.
Definition NetStructureWithConstraints.h:461
void AddCableForceRange(double T, const double *X, int begin, int end, double *nodeForce, bool waterFollowsElement=false) const
std::vector< double > m_threadNodeForces
One node-force buffer per chunk of the parallel loops, set in FinalSetup.
Definition NetStructureWithConstraints.h:524
net_panel_setup::PanelHydrodynamics m_panelHydrodynamics
Panel hydrodynamics (MARE-0095)
Definition NetStructureWithConstraints.h:447
double m_solverFrequencyCoefficient
Frequency coefficient of the constraint solver [1/s].
Definition NetStructureWithConstraints.h:522
void FlowAt(double T, int point, const double pos[3], double vel[3]) const
The water velocity at a panel centroid (point = panel) or a cable midpoint (point = number of panels ...
int m_numThreads
Threads of the panel and cable loops (NumThreads, R63).
Definition NetStructureWithConstraints.h:523
int m_numNodesInputForce
Node counts.
Definition NetStructureWithConstraints.h:415
void PreOdeFcn(double T, const double *X, IStateUpdater *updater) override
Rebuilds the cast wake when due (with CastWake) and takes the wakes at the panel centroids and cable ...
std::vector< double > m_nodeWaveVelocity
The wave particle velocity at each node of the state being evaluated (R62), 3 per node.
Definition NetStructureWithConstraints.h:385
NetBottomContactFilter m_BottomContactFilter
Environment.
Definition NetStructureWithConstraints.h:438
std::unique_ptr< NetFlowInteraction > m_flow
The wakes cast and received and the water velocity at the panels and cables (MARE-0333); from the con...
Definition NetStructureWithConstraints.h:454
void AddNetAndCableForcesInParallel(double T, const double *X) const
The panel and cable loops on m_numThreads threads, deterministic for a fixed count (owner ruling R63)...
void CableHydrodynamicForce(double T, const double *X, double force[3]) const
The sum of the cables' hydrodynamic forces on the nodes, N (MARE-0141); for the wake caster's log.
void UpdateNodeWaveVelocities(double T, const double *X, int firstNode, int endNode) const
Sets m_nodeWaveVelocity at nodes [firstNode, endNode) of state X (R62).
NetStructureWithConstraints(std::string simObjectName, ISimObjectCreator *creator)
The constructor sets the pointer to the output object and the parser object.
hydrodynamics::PanelClampLog m_clampLog
Which clamps of the load law the panels have hit; reported once each in PreOdeFcn (MARE-0140).
Definition NetStructureWithConstraints.h:456
const double * NodeVelocityState(const double *X, int node) const
The velocity of a calculation node, 3 states in X (as NodePositionState()).
Definition NetStructureWithConstraints.h:503
ISimObjectLogger * m_logger
The FhSim log, kept from FinalSetup for the clamp lines.
Definition NetStructureWithConstraints.h:455
Definition NetWakePanels.h:27
Definition NetStructureWithConstraints.h:487
Class containing the specification for a net object.
Definition NetStructureSpec.h:22
The panel load law and the fluid shared by all panels of a structure.
Definition NetPanelSetup.h:38