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
13namespace CoRiBoDynamics{
14
15class TrawlCableJointConstraint: public JointConstraint{
16public:
18 double AlphaN;
19 double BetaN;
20 double GammaN;
21 Quat AlphaM;
22 Quat BetaM;
23 Quat GammaM;
24 double elementLength;
25 std::vector<int> elements;
26 };
27
28 TrawlCableJointConstraint(ConstraintSolver* solver);
29 size_t AddCableSegment(const CableProperties& cable_properties);
31 virtual void ComputeConstraints(const double T, const double * const X);
32
33 vec3 GetBallJointCouplingForce(int i);
34
35protected:
38 public:
39 CableSegmentTask(TrawlCableJointConstraint* master, RigidCoupling& data, std::vector<int> elements/*, int start, int end*/){
40 m_master = master;
41 m_CouplingData = data;
42 m_elements = elements;
43 }
44
45 void SetStates(double T, const double* X){
46 m_T = T;
47 m_X = X;
48 }
49
50 void ExecuteTask(){
51 for(int i = 0; i < m_elements.size()-1; ++i){
52 m_CouplingData.elementA = m_elements[i];
53 m_CouplingData.elementB = m_elements[i+1];
54 m_master->ComputeRigidCoupling(m_CouplingData);
55 }
56 }
57
58 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
59 protected:
60 double m_T;
61 const double* m_X;
62 RigidCoupling m_CouplingData;
63 std::vector<int> m_elements;
65 };
66
67 std::vector<CableSegmentTask*> m_CableSegmentTask;
68
69 std::vector<vec3> m_BallJointForces;
70 //vec3 TrawlCableComputeBallJointCoupling( BallJointCoupling& Constraint, const double * const X );
71};
72
73class TrawlCableCollisionManager: public CollisionManager{
74public:
76 double elementLength;
77 double elementRadius;
78 double elementContactStiffness;
79 double frictionCoefficient;
80 double contactDamping;
81 std::vector<int> elements;
82 };
83
84 TrawlCableCollisionManager(ConstraintSolver* solver, double timeConstant);
85 void AddCableSegment(const CableCollisionManagerProperties& properties);
86 void AddMainCableSegment(const CableCollisionManagerProperties& properties);
87
88 double getFrequencyCoefficient() {
89 return m_timeConstant;
90 }
91
92 void setStartTimeCollision(double time) {
93 m_startTimeCollision = time;
94 }
95
97 int ia;
98 int ib;
99 double la;
100 double lb;
102 vec3 Fn;
103 };
104 std::vector<ElementContact>* GetContactPoints();
105
106protected:
107 double m_startTimeCollision;
108 void ComputeConstraints(const double T, const double * const X);
109 struct CableSegment {int start; int end; double elementLength; int firstElementInSegment; int lastElementInSegment;};
110 std::vector<CableSegment> m_CableSegments;
111
112 std::vector<ElementContact> m_ContactPoints;
113 void CollisionTest( InternalObject* objectA, InternalObject* objectB , const double * const X, ElementContact& contact);
115 void TestAgainstMainSegments(int i, const double * const X);
116
117public:
118
119};
120
135class EnvironmentForces: public ConstraintSet{
136public:
138 std::vector<int> elements;
139 double cableRadius;
140 double elementLength;
141 double elementMass;
142 double elementDisplacementVolume;
143 };
144 struct TrawlDoor {
145 double length;
146 double width;
147 double DoorMass;
148 double WeightMass;
149 double displacementVolume;
150 int DoorIndex;
151 int WeightIndex;
152 //vec3 HydroCenter;
153
155 trawl_cable_water::Door Law() const { return {length, width, DoorMass, displacementVolume}; }
156 };
157
158 struct ClumpWeight {
159 double length;
160 double radius;
161 double Mass;
162 int Index;
163
165 trawl_cable_water::ClumpWeight Law() const { return {length, radius, Mass}; }
166 };
167
171 EnvironmentForces(ConstraintSolver* solver, double timeConstant, const environment::wake::BodyWake& bodyWake);
172 void AddNewCableSegment(CableSegment cable);
173 void ComputeConstraints(const double T, const double * const X);
174 void AddTrawlDoor(TrawlDoor Door);
175 void AddClumpWeight(ClumpWeight Weight);
184 void FinalSetup(const std::string& objectName, ISimObjectCreator* creator);
196 void TakeWakes(const double T, const double * const X);
198 environment::EnvironmentProvider* const* EnvironmentPointerAddress() const { return &m_environment; }
200 int NumBodies() const;
202 const TrawlDoor* DoorOfBody(int body) const;
204 const ClumpWeight* ClumpOfBody(int body) const;
205protected:
206 friend class DoorAndClumpWakeBodies; // reads the elements of the doors and clump weights
207
208 std::vector<CableSegment> m_Cables;
209 std::vector<TrawlDoor> m_TrawlDoors;
210 std::vector<ClumpWeight> m_ClumpWeights;
211
212 double m_timeConstant;
213 environment::EnvironmentProvider* m_environment;
214 environment::SeafloorForcesInterface* m_seafloor = nullptr;
215 const environment::wake::BodyWake& m_bodyWake;
216 environment::wake::ElementFlowInteraction m_flow;
217};
218}
219
220#endif
Definition DoorAndClumpWakeBodies.h:46
Definition TrawlCableConstraintSets.h:135
environment::EnvironmentProvider *const * EnvironmentPointerAddress() const
The address of the environment pointer, which FinalSetup sets later: what the elements with added mas...
Definition TrawlCableConstraintSets.h:198
environment::SeafloorForcesInterface * m_seafloor
The shared SeafloorForces, set in FinalSetup: the soil load of each cable element,...
Definition TrawlCableConstraintSets.h:214
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:215
EnvironmentForces(ConstraintSolver *solver, double timeConstant, const environment::wake::BodyWake &bodyWake)
void FinalSetup(const std::string &objectName, ISimObjectCreator *creator)
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:216
void TakeWakes(const double T, const double *const X)
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.
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.
int NumBodies() const
The number of bodies of the owner's BodyWake: the trawl doors (bodies 0 to their number − 1),...
Definition TrawlCableConstraintSets.h:73
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:37
Definition TrawlCableConstraintSets.h:15
Definition TrawlCableConstraintSets.h:137
Definition TrawlCableConstraintSets.h:158
trawl_cable_water::ClumpWeight Law() const
The clump weight's water law.
Definition TrawlCableConstraintSets.h:165
Definition TrawlCableConstraintSets.h:144
trawl_cable_water::Door Law() const
The door's water law.
Definition TrawlCableConstraintSets.h:155
Definition TrawlCableConstraintSets.h:109
Definition TrawlCableConstraintSets.h:96
double MainSegmentPosition
contact point on element B
Definition TrawlCableConstraintSets.h:101
double la
index of element B
Definition TrawlCableConstraintSets.h:99
int ib
index of element A
Definition TrawlCableConstraintSets.h:98
double lb
contact point on element A
Definition TrawlCableConstraintSets.h:100
Definition TrawlCableConstraintSets.h:17
The properties of a clump weight, a cylinder along the body's z axis.
Definition CableSegmentWaterForce.h:140
The properties of a trawl door, a flat plate in the body's x-z plane (normal Ny).
Definition CableSegmentWaterForce.h:131