FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
TrawlCableConstraintSets.h
1#ifndef TRAWLCABLE_CONSTRAINT_SETS_H
2#define TRAWLCABLE_CONSTRAINT_SETS_H
3#include "CableSegmentWaterForce.h"
4
5#include <fhsim_environment/BodyWake.h>
6#include <fhsim_environment/EnvironmentProvider.h>
7#include <fhsim_environment/ElementFlowInteraction.h>
8#include <fhsim_environment/SeafloorForcesInterface.h>
9#include <fhsim_coribo/CollisionManager.h>
10#include <fhsim_coribo/JointConstraint.h>
11#include <vector>
12#include <string>
13
14namespace trawl_mooring{
15
16class TrawlCableJointConstraint: public CoRiBoDynamics::JointConstraint{
17public:
19 double AlphaN;
20 double BetaN;
21 double GammaN;
22 CoRiBoDynamics::Quat AlphaM;
23 CoRiBoDynamics::Quat BetaM;
24 CoRiBoDynamics::Quat GammaM;
25 double elementLength;
26 std::vector<int> elements;
27 };
28
29 TrawlCableJointConstraint(CoRiBoDynamics::ConstraintSolver* solver);
30 size_t AddCableSegment(const CableProperties& cable_properties);
32 virtual void ComputeConstraints(const double T, const double * const X);
33
34 CoRiBoDynamics::vec3 GetBallJointCouplingForce(int i);
35
36protected:
39 public:
40 CableSegmentTask(TrawlCableJointConstraint* master, RigidCoupling& data, std::vector<int> elements/*, int start, int end*/){
41 m_master = master;
42 m_CouplingData = data;
43 m_elements = elements;
44 }
45
46 void SetStates(double T, const double* X){
47 m_T = T;
48 m_X = X;
49 }
50
51 void ExecuteTask(){
52 for(int i = 0; i < m_elements.size()-1; ++i){
53 m_CouplingData.elementA = m_elements[i];
54 m_CouplingData.elementB = m_elements[i+1];
55 m_master->ComputeRigidCoupling(m_CouplingData);
56 }
57 }
58
59 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
60 protected:
61 double m_T;
62 const double* m_X;
63 RigidCoupling m_CouplingData;
64 std::vector<int> m_elements;
66 };
67
68 std::vector<CableSegmentTask*> m_CableSegmentTask;
69
70 std::vector<CoRiBoDynamics::vec3> m_BallJointForces;
71 //vec3 TrawlCableComputeBallJointCoupling( BallJointCoupling& Constraint, const double * const X );
72};
73
74class TrawlCableCollisionManager: public CoRiBoDynamics::CollisionManager{
75public:
77 double elementLength;
78 double elementRadius;
79 double elementContactStiffness;
80 double frictionCoefficient;
81 double contactDamping;
82 std::vector<int> elements;
83 };
84
85 TrawlCableCollisionManager(CoRiBoDynamics::ConstraintSolver* solver, double timeConstant);
86 void AddCableSegment(const CableCollisionManagerProperties& properties);
87 void AddMainCableSegment(const CableCollisionManagerProperties& properties);
88
89 double getFrequencyCoefficient() {
90 return m_timeConstant;
91 }
92
93 void setStartTimeCollision(double time) {
94 m_startTimeCollision = time;
95 }
96
98 int ia;
99 int ib;
100 double la;
101 double lb;
103 CoRiBoDynamics::vec3 Fn;
104 };
105 std::vector<ElementContact>* GetContactPoints();
106
107protected:
108 double m_startTimeCollision;
109 void ComputeConstraints(const double T, const double * const X);
110 struct CableSegment {int start; int end; double elementLength; int firstElementInSegment; int lastElementInSegment;};
111 std::vector<CableSegment> m_CableSegments;
112
113 std::vector<ElementContact> m_ContactPoints;
114 void CollisionTest( InternalObject* objectA, InternalObject* objectB , const double * const X, ElementContact& contact);
116 void TestAgainstMainSegments(int i, const double * const X);
117
118public:
119
120};
121
136class EnvironmentForces: public CoRiBoDynamics::ConstraintSet{
137public:
139 std::vector<int> elements;
140 double cableRadius;
141 double elementLength;
142 double elementMass;
143 double elementDisplacementVolume;
145 bool gaussPointDrag = false;
146 };
147 struct TrawlDoor {
148 double length;
149 double width;
150 double DoorMass;
151 double WeightMass;
152 double displacementVolume;
153 int DoorIndex;
154 int WeightIndex;
155 //vec3 HydroCenter;
156
158 trawl_cable_water::Door Law() const { return {length, width, DoorMass, displacementVolume}; }
159 };
160
161 struct ClumpWeight {
162 double length;
163 double radius;
164 double Mass;
165 int Index;
166
168 trawl_cable_water::ClumpWeight Law() const { return {length, radius, Mass}; }
169 };
170
174 EnvironmentForces(CoRiBoDynamics::ConstraintSolver* solver, double timeConstant, const environment::wake::BodyWake& bodyWake);
175 void AddNewCableSegment(CableSegment cable);
176 void ComputeConstraints(const double T, const double * const X);
177 void AddTrawlDoor(TrawlDoor Door);
178 void AddClumpWeight(ClumpWeight Weight);
187 void FinalSetup(const std::string& objectName, ISimObjectCreator* creator);
199 void TakeWakes(const double T, const double * const X);
201 environment::EnvironmentProvider* const* EnvironmentPointerAddress() const { return &m_environment; }
203 int NumBodies() const;
205 const TrawlDoor* DoorOfBody(int body) const;
207 const ClumpWeight* ClumpOfBody(int body) const;
208protected:
216 void BuildGaussPoints(const double * const X, const CableSegment& cable);
217 void QueryGaussPointWater(const double T, const double * const X, const CableSegment& cable, const int firstPoint);
218
219 friend class DoorAndClumpWakeBodies; // reads the elements of the doors and clump weights
220
221 std::vector<CableSegment> m_Cables;
222 std::vector<TrawlDoor> m_TrawlDoors;
223 std::vector<ClumpWeight> m_ClumpWeights;
225
226 double m_timeConstant;
227 environment::EnvironmentProvider* m_environment;
228 environment::SeafloorForcesInterface* m_seafloor = nullptr;
229 const environment::wake::BodyWake& m_bodyWake;
230 environment::wake::ElementFlowInteraction m_flow;
231};
232}
233
234#endif
Definition DoorAndClumpWakeBodies.h:46
Definition TrawlCableConstraintSets.h:136
void BuildGaussPoints(const double *const X, const CableSegment &cable)
Fills m_gaussPoints from the segment's elements.
environment::wake::ElementFlowInteraction m_flow
The flow at the centres of the cable elements, the other objects' wakes taken per step as the owner r...
Definition TrawlCableConstraintSets.h:230
const environment::wake::BodyWake & m_bodyWake
The owner's: the water velocity of the doors and clump weights, and the query the cables receive with...
Definition TrawlCableConstraintSets.h:229
void TakeWakes(const double T, const double *const X)
environment::EnvironmentProvider *const * EnvironmentPointerAddress() const
The address of the environment pointer, which FinalSetup sets later: what the elements with added mas...
Definition TrawlCableConstraintSets.h:201
const ClumpWeight * ClumpOfBody(int body) const
The clump weight that is body body of the owner's BodyWake, or nullptr if the body is a door.
environment::SeafloorForcesInterface * m_seafloor
The shared SeafloorForces, set in FinalSetup: the soil load of each cable element,...
Definition TrawlCableConstraintSets.h:228
int NumBodies() const
The number of bodies of the owner's BodyWake: the trawl doors (bodies 0 to their number − 1),...
void FinalSetup(const std::string &objectName, ISimObjectCreator *creator)
wet_cylinder_water::ElementGaussPoints m_gaussPoints
The Gauss points of the segment being computed, for the Gauss-point drag (MARE-0396); buffers kept fr...
Definition TrawlCableConstraintSets.h:224
EnvironmentForces(CoRiBoDynamics::ConstraintSolver *solver, double timeConstant, const environment::wake::BodyWake &bodyWake)
const TrawlDoor * DoorOfBody(int body) const
The door that is body body of the owner's BodyWake, or nullptr if the body is a clump weight.
Definition TrawlCableConstraintSets.h:74
void TestAgainstMainSegments(int i, const double *const X)
Test the non-mooring body i against the mooring segments in the collision map (steps 4a-4d).
The rigid couplings along one cable segment, computed in ComputeConstraints.
Definition TrawlCableConstraintSets.h:38
Definition TrawlCableConstraintSets.h:16
Definition GaussPointDrag.h:56
The properties of a clump weight, a cylinder along the body's z axis.
Definition CableSegmentWaterForce.h:151
The properties of a trawl door, a flat plate in the body's x-z plane (normal Ny).
Definition CableSegmentWaterForce.h:142
Definition TrawlCableConstraintSets.h:138
bool gaussPointDrag
Gauss-point drag with the water at the Gauss points (MARE-0396): the elements are in chain order.
Definition TrawlCableConstraintSets.h:145
Definition TrawlCableConstraintSets.h:161
trawl_cable_water::ClumpWeight Law() const
The clump weight's water law.
Definition TrawlCableConstraintSets.h:168
Definition TrawlCableConstraintSets.h:147
trawl_cable_water::Door Law() const
The door's water law.
Definition TrawlCableConstraintSets.h:158
Definition TrawlCableConstraintSets.h:110
Definition TrawlCableConstraintSets.h:97
double MainSegmentPosition
contact point on element B
Definition TrawlCableConstraintSets.h:102
double la
index of element B
Definition TrawlCableConstraintSets.h:100
double lb
contact point on element A
Definition TrawlCableConstraintSets.h:101
int ib
index of element A
Definition TrawlCableConstraintSets.h:99
Definition TrawlCableConstraintSets.h:18