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
312// #define NetStructureWithConstraints_DO_PROFILE
313
314// Includes
315#include "NetBottomContactFilter.h"
316#include "NetCableElementSpec.h"
317#include "NetCableElementWithConstraints.h"
318#include "NetElement3NWithConstraints.h"
319#include "NetElementDef.h"
320#include "NetPanelSetup.h"
321#include "NetStructureSpec.h"
322#include "NetFlowInteraction.h"
323
324#include "sfh/timers/ProfilerWallclock.h"
325
326#include <fhsim/simobject/SimObject.h>
327#include <fhsim_coribo/JointConstraint.h>
328#include <fhsim_environment/EnvironmentProvider.h>
329#include <fhsim_environment/SeafloorForcesInterface.h>
330#include <memory>
331#include <string>
332
333
334#ifdef FH_VISUALIZATION
335# include "sfh/ogre/C3DLine.h"
336# include "sfh/ogre/NMeshGenerators.h"
337#endif
338
339// Class definition
340class NetStructureWithConstraints : public SimObject
341{
342public:
344 NetStructureWithConstraints(std::string simObjectName, ISimObjectCreator* creator);
347 virtual void OdeFcn(const double dT, const double* const adX, double* const adXDot) const;
348 virtual void InitialConditionSetup(const double dT, const double* const adCurrentIC, double* const adUpdatedIC, ISimObjectCreator* const creator);
349 virtual void FinalSetup(const double dT, const double* const adX, ISimObjectCreator* const creator);
351 void PreOdeFcn(double T, const double* X, IStateUpdater* updater) override;
352 const double* const outExternalNodeForce(const double dT, const double* const adX, int extNode);
353
354#ifdef FH_VISUALIZATION
356 virtual void RenderInit(Ogre::Root* const ogreRoot, ISimObjectCreator* const creator);
358 virtual void RenderUpdate(const double dT, const double* const adX);
359
360 void CreateCapsule(Ogre::ManualObject* capsule_manual);
361 C3DLine* myline;
362#endif
363 const virtual double* const NodePos(const double dT, const double* const adX, int extNode);
364 const virtual double* const NodeVel(const double dT, const double* const adX, int extNode);
365 const virtual double* const BottomContact(const double dT, const double* const adX);
366 void SetAddedDragPerMPS(double AddedDragPerMPS);
367 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
368protected:
369 virtual void CalcStateDerivatives(const double* const adX, double* const adXDot) const;
370 virtual void AddExternalForces(const double dT, const double* const adX) const;
371 virtual void AddNetForces(const double dT, const double* const adX) const;
372 virtual void AddCableForces(const double dT, const double* const adX) const;
374 void AddNetAndCableForcesInParallel(double T, const double* X) const;
376 void AddNetForceRange(double T, const double* X, int begin, int end, double* nodeForce) const;
379 void AddCableForceRange(double T, const double* X, int begin, int end, double* nodeForce, bool waterFollowsElement = false) const;
381 void CableHydrodynamicForce(double T, const double* X, double force[3]) const;
383 void FlowAt(double T, int point, const double pos[3], double vel[3]) const;
385 void UpdateNodeWaveVelocities(double T, const double* X, int firstNode, int endNode) const;
386 mutable std::vector<double> m_nodeWaveVelocity;
387 virtual double AddNodeBottomForce(const double* const adX, int node, double diam, double adForceInOut[3]) const;
388 virtual void AddBottomForces(const double* const adX) const;
389 virtual void AddInputPorts(ISimObjectCreator* creator);
390 virtual void CreateNetPanels(std::vector<const NetElementDef*> VNetElementDefs, ISimObjectCreator* creator);
391 virtual void CreateNetCables(std::vector<const NetCableElementSpec*> VCableElements, ISimObjectCreator* creator);
392 virtual void CreateDataStructures();
393 virtual void CreateOutputPorts(ISimObjectCreator* creator);
394 VSPairStrInt CreateExternalNodeMap(std::string tag, int* piUsed, NetStructureSpec& NetSpec, ISimObjectCreator* creator);
395 void ValidateConstraintInput(ISimObjectCreator* creator) const;
396 void PRINTALLNODEFORCES(std::string spec, double dT);
397
398 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
399 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
400
402
403 // ISignalPort **m_inExternalForces;
404 /*ISignalPort **m_InConstraintsPos; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
405 ISignalPort **m_InConstraintsVel; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects*/
407 ISignalPort** m_InTopConstraintsVel;
408 int* m_iStatePos;
409 int* m_iStateVel;
411 double* m_NodeExternalForces;
412 double* m_NodeConstraintsPos; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
413 double* m_NodeConstraintsVel; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
415
417 int m_numNodesOutputPosAndVel;
418 int m_numPanelsCalc;
419 int m_numCablesCalc;
420 int m_numNodesOriginal;
421 int m_numNodesCalc;
422 int m_numNodeOutputs;
424
425 double* m_NodeInternalForces; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
426
427 int (*m_hasPosAndVelStates)[2]; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
428
429 int m_NumNodesInputPosAndVel; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
430 int m_NumNodesOutputForce; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
431
432 VSPairStrInt m_VsNodesInputPosAndVel; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
433 VSPairStrInt m_VsNodesOutputForce; // NEW: added to test new approach where pos and vel for selected nodes are set by external objects
434 // VSPairStrInt m_VsNodesTopConstraintsInputPos;
435
436
438
440 double m_bottomContact[6];
441
442 environment::EnvironmentProvider* m_environment;
443 environment::SeafloorForcesInterface* m_seafloor;
445
447
449 net_solidity::SolidityModel m_solidityModel = net_solidity::kDefaultSolidityModel;
451
453
454 template<class> friend class NetWakePanels;
455 std::unique_ptr<NetFlowInteraction> m_flow;
456 ISimObjectLogger* m_logger = nullptr;
457 hydrodynamics::PanelClampLog m_clampLog;
459
461
462 std::vector<NetCableElementWithConstraints*> m_VpCableElements;
463 std::vector<NetElement3NWithConstraints*> m_VpNetElements;
464 float* m_inertia;
465 int* m_netConn;
466 int** m_aaiCableConn;
467 SAdaptationSpec_t m_SAdaptations;
468 bool m_foldingPointRefinementUsed;
470
471
473
475 VSPairStrInt m_VsNodesInputForce;
476 bool m_useTagForExternalNodes;
478
479 double* m_nodeForce;
481 double m_meanTensionTime = std::numeric_limits<double>::quiet_NaN();
482
483 bool m_CageWakeEffectsActive;
484
485 // CONSTRAINTS (NB LOTS OF HARD CODING HERE NOW)
486 CoRiBoDynamics::ConstraintSolver* m_constraintSolver;
487 struct states
488 {
489 int p;
490 int q;
491 int w;
492 int v;
493 };
494 std::vector<states> m_stateVector;
495
502 const double* NodePositionState(const double* X, int node) const { return X + (NodeHasOwnStates(node) ? m_iStatePos[node] : DrivingElement(node).p); }
504 const double* NodeVelocityState(const double* X, int node) const { return X + (NodeHasOwnStates(node) ? m_iStateVel[node] : DrivingElement(node).v); }
506 bool NodeHasOwnStates(int node) const { return m_hasPosAndVelStates[node][1] == 1; }
508 const states& DrivingElement(int node) const { return m_stateVector[m_hasPosAndVelStates[node][0]]; }
509
510 CoRiBoDynamics::JointConstraint* m_jointConstr;
511 // Coordinates for attachment of the constraints chains
512 mutable double m_topPosition1[3];
513 mutable double m_topVelocity1[3];
514 double m_topOrientation1[4];
515 double m_topangularVel1[3];
516 mutable double m_topPosition2[3];
517 mutable double m_topVelocity2[3];
518 double m_topOrientation2[4];
519
520 double m_topangularVel2[3];
521
522 double m_YoungsModulus;
524 int m_numThreads = 1;
525 mutable std::vector<double> m_threadNodeForces;
526 int m_numConstraintsElements;
527 double m_depthOfConstraintsCable;
528#ifdef FH_VISUALIZATION
529 Ogre::SceneNode** m_renderNodes;
530 // Ogre::SceneNode* m_renderNode2; ///< The node to which the rendered entity is attached.
531#endif
532
533#ifdef NetStructureWithConstraints_DO_PROFILE
534 sfh::timers::ProfilerWallclock m_Profiler;
535#endif
536};
Definition NetBottomContactFilter.h:7
Definition NetStructureSpec.h:39
Definition NetStructureWithConstraints.h:341
VSPairStrInt m_VsNodesOutputPosAndVel
Nodes reachable directly through input or output ports.
Definition NetStructureWithConstraints.h:474
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:481
bool NodeHasOwnStates(int node) const
True unless a rigid element drives the node.
Definition NetStructureWithConstraints.h:506
const states & DrivingElement(int node) const
The state indices of the rigid element that drives the node.
Definition NetStructureWithConstraints.h:508
const double * NodePositionState(const double *X, int node) const
Definition NetStructureWithConstraints.h:502
ISignalPort ** m_InTopConstraintsPos
Interface member variables.
Definition NetStructureWithConstraints.h:406
virtual ~NetStructureWithConstraints()
The destructor deletes dynamically allocated memory.
std::vector< NetCableElementWithConstraints * > m_VpCableElements
Element properties.
Definition NetStructureWithConstraints.h:462
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:525
net_panel_setup::PanelHydrodynamics m_panelHydrodynamics
Panel hydrodynamics (MARE-0095)
Definition NetStructureWithConstraints.h:448
double m_solverFrequencyCoefficient
Frequency coefficient of the constraint solver [1/s].
Definition NetStructureWithConstraints.h:523
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:524
int m_numNodesInputForce
Node counts.
Definition NetStructureWithConstraints.h:416
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:386
NetBottomContactFilter m_BottomContactFilter
Environment.
Definition NetStructureWithConstraints.h:439
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:455
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:457
const double * NodeVelocityState(const double *X, int node) const
The velocity of a calculation node, 3 states in X (as NodePositionState()).
Definition NetStructureWithConstraints.h:504
ISimObjectLogger * m_logger
The FhSim log, kept from FinalSetup for the clamp lines.
Definition NetStructureWithConstraints.h:456
Definition NetWakePanels.h:27
Definition NetStructureWithConstraints.h:488
Class containing the specification for a net object.
Definition NetStructureSpec.h:24
The panel load law and the fluid shared by all panels of a structure.
Definition NetPanelSetup.h:38