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 <fhsim_environment/EnvironmentProvider.h>
4#include <fhsim_coribo/CollisionManager.h>
5#include <fhsim_coribo/JointConstraint.h>
6#include <fhsim/ThreadPool.h>
7#include <vector>
8
9namespace CoRiBoDynamics{
10
11class TrawlCableJointConstraint: public JointConstraint{
12public:
14 double AlphaN;
15 double BetaN;
16 double GammaN;
17 Quat AlphaM;
18 Quat BetaM;
19 Quat GammaM;
20 double elementLength;
21 std::vector<int> elements;
22 };
23
24 TrawlCableJointConstraint(ConstraintSolver* solver);
25 size_t AddCableSegment(const CableProperties& cable_properties);
27 virtual void ComputeConstraints(const double T, const double * const X);
28
29 vec3 GetBallJointCouplingForce(int i);
30
31protected:
32 class CableSegmentTask: public ThreadPool::Task{
33 public:
34 CableSegmentTask(int ID, TrawlCableJointConstraint* master, RigidCoupling& data, std::vector<int> elements/*, int start, int end*/):Task(ID){
35 m_master = master;
36 m_CouplingData = data;
37 m_elements = elements;
38 }
39
40 void SetStates(double T, const double* X){
41 m_T = T;
42 m_X = X;
43 }
44
45 void ExecuteTask(){
46 for(int i = 0; i < m_elements.size()-1; ++i){
47 m_CouplingData.elementA = m_elements[i];
48 m_CouplingData.elementB = m_elements[i+1];
49 m_master->ComputeRigidCoupling(m_CouplingData);
50 }
51 }
52
53 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
54 protected:
55 double m_T;
56 const double* m_X;
57 RigidCoupling m_CouplingData;
58 std::vector<int> m_elements;
60 };
61
62 std::vector<CableSegmentTask*> m_CableSegmentTask;
63 //ThreadPool::ThreadManager* m_ThreadManager;
64 CoreBoundThreadPool *m_ThreadManager;
65 int m_ThreadManagerGroupID;
66
67 std::vector<vec3> m_BallJointForces;
68 //vec3 TrawlCableComputeBallJointCoupling( BallJointCoupling& Constraint, const double * const X );
69};
70
71class TrawlCableCollisionManager: public CollisionManager{
72public:
74 double elementLength;
75 double elementRadius;
76 double elementContactStiffness;
77 double frictionCoefficient;
78 double contactDamping;
79 std::vector<int> elements;
80 };
81
82 TrawlCableCollisionManager(ConstraintSolver* solver, double timeConstant);
83 void AddCableSegment(const CableCollisionManagerProperties& properties);
84 void AddMainCableSegment(const CableCollisionManagerProperties& properties);
85
86 double getFrequencyCoefficient() {
87 return m_timeConstant;
88 }
89
90 void setStartTimeCollision(double time) {
91 m_startTimeCollision = time;
92 }
93
95 int ia;
96 int ib;
97 double la;
98 double lb;
100 vec3 Fn;
101 };
102 std::vector<ElementContact>* GetContactPoints();
103
104protected:
105 double m_startTimeCollision;
106 void ComputeConstraints(const double T, const double * const X);
107 struct CableSegment {int start; int end; double elementLength; int firstElementInSegment; int lastElementInSegment;};
108 std::vector<CableSegment> m_CableSegments;
109
110 std::vector<ElementContact> m_ContactPoints;
111 void CollisionTest( InternalObject* objectA, InternalObject* objectB , const double * const X, ElementContact& contact);
113 void TestAgainstMainSegments(int i, const double * const X);
114
115public:
116
117};
118
119class EnvironmentForces: public ConstraintSet{
120public:
122 std::vector<int> elements;
123 double cableRadius;
124 double elementLength;
125 double elementMass;
126 double elementDisplacementVolume;
127 };
128 struct TrawlDoor {
129 double length;
130 double width;
131 double DoorMass;
132 double WeightMass;
133 double displacementVolume;
134 int DoorIndex;
135 int WeightIndex;
136 //vec3 HydroCenter;
137 };
138
139 struct ClumpWeight {
140 double length;
141 double radius;
142 double Mass;
143 int Index;
144 };
145
146 EnvironmentForces(ConstraintSolver* solver, double timeConstant/*, CableSegment Cable*/);
147 void AddNewCableSegment(CableSegment cable);
148 void ComputeConstraints(const double T, const double * const X);
149 void AddTrawlDoor(TrawlDoor Door);
150 void AddClumpWeight(ClumpWeight Weight);
151 void setEnvironmentPointer(environment::EnvironmentProvider* environment);
152protected:
153 std::vector<CableSegment> m_Cables;
154 std::vector<TrawlDoor> m_TrawlDoors;
155 std::vector<ClumpWeight> m_ClumpWeights;
156
157 double m_timeConstant;
158 environment::EnvironmentProvider* m_environment;
159};
160
161}
162
163#endif
Definition TrawlCableConstraintSets.h:119
Definition TrawlCableConstraintSets.h:71
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).
Definition TrawlCableConstraintSets.h:32
Definition TrawlCableConstraintSets.h:11
Definition TrawlCableConstraintSets.h:121
Definition TrawlCableConstraintSets.h:139
Definition TrawlCableConstraintSets.h:128
Definition TrawlCableConstraintSets.h:107
Definition TrawlCableConstraintSets.h:94
double MainSegmentPosition
contact point on element B
Definition TrawlCableConstraintSets.h:99
double la
index of element B
Definition TrawlCableConstraintSets.h:97
int ib
index of element A
Definition TrawlCableConstraintSets.h:96
double lb
contact point on element A
Definition TrawlCableConstraintSets.h:98
Definition TrawlCableConstraintSets.h:13