Marine systems simulation
SupergridLineStructure.h
1#pragma once
2
3#include "JointConstraint.h"
4#include "CollisionManager.h"
5#include <SimObject.h>
6#include <tinyxml.h>
7#include <vector>
8
9#ifdef FH_VISUALIZATION
10#include <sfh/ogre/C3DLine.h>
11#endif
12
13namespace CoRiBoDynamics {
14
16 public:
17 virtual ~Environment_Interface(){};
18 virtual vec3 Current (double T, const double* X, const double* Position) = 0;
19 virtual double OceanSurfaceElevation(double T, const double* X, const double* Position) = 0;
20 virtual void CurrentQuery(double T, const double* X, const vec3& Position, vec3& current, double& surface_elevation, double& density) = 0;
21 virtual double SeaDepth (const double* Position) = 0;
22 };
23
24namespace Structures {
25 class DiscreteElement;
26 class LineSegment;
27 class CableSegment;
28 class SupergridLineStructure;
29
30
39static const mat6 Identity_memory = mat6::Identity();
41
42public:
43 ModifiableRigidElement(int ix_P, int ix_Q, int ix_V, int ix_W);
44 void SetDiscreteElement(DiscreteElement* discrete_element){m_discrete_element = discrete_element;}
45
50
51 virtual void Setup(double T, const double * const X);
52 virtual const mat6& InertialMatrix();
53 virtual const vec6& Forces();
54
55 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
56protected:
57 DiscreteElement* m_discrete_element;
58
59 mat6 m_FullInertiaMatrix;
60 vec6 m_Force;
61};
62
74public:
75 DiscreteElement(LineSegment* line_segment, double length);
76
77 virtual ~DiscreteElement();
78
83
87 const std::vector<DiscreteElement*>* GetSubElements();
88
93
98
99
100 void SetRigidElement(ModifiableRigidElement* rigid_element);
101 virtual void Setup(double T, const double * const X, mat6& InertiaMatrix, vec6& Force) = 0;
102
103 double GetElementLength();
104 double GetElementRadius();
105 double GetElementMass();
106
107
109 Quat Q;
110 vec3 P;
111 vec3 V;
112 vec3 W;
113 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
114 };
115
116 /*
117 Copy current states from the currently bound rigid element into the discrete object. State values are stored in a buffer from temp_states_buffer.
118 */
119 virtual void StoreTempStates(const double* X, ObjectFactoryStack<DiscreteElement::TempStates>& temp_states_buffer);
120
121 /*
122 Set the given states to the discrete object. State values are stored in a buffer from temp_states_buffer.
123 */
124 virtual void SetTempStates(const vec3& P,const Quat& Q, const vec3& V, const vec3& W, ObjectFactoryStack<DiscreteElement::TempStates>& temp_states_buffer);
125
126 /*
127 Divide the states of this discrete elements into its sub-elements
128 'next' and 'prev' are optional parameters.
129 they refer to the next and previous element in the chain, and are used to initialize the distance between sub elements so initial tension is correct
130 State values are stored in a buffer from temp_states_buffer.
131 */
132 virtual void SplitTempStates(DiscreteElement* prev, DiscreteElement* next, ObjectFactoryStack<DiscreteElement::TempStates>& temp_states_buffer);
133
134 /*
135 Gather an 'average' state from all sub elements into the super element.
136 State values are stored in a buffer from temp_states_buffer.
137 */
138 virtual void CollectTempStates(ObjectFactoryStack<DiscreteElement::TempStates>& temp_states_buffer);
139
140 /*
141 Overwrite the state vector with previously stored values.
142 The state vector index is given by the currently bound rigid element
143 */
144 virtual void OverrideStates(double T, double * X);
145
146 /*
147 retrieve currently stored state values
148 */
149 virtual void GetTempStates( vec3& P, Quat& Q, vec3& V, vec3& W);
150
151 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
152
153
154protected:
155 ModifiableRigidElement* m_rigid_element;
156 LineSegment* m_line_segment;
157 DiscreteElement* m_super_element;
158 std::vector<DiscreteElement*> m_sub_element;
159 TempStates* m_temp_states;
160 float m_length;
161 float m_radius;
162 float m_mass;
163};
164
165
166/*
167 Discrete line segment with uniform material parameters.
168 A LineSegment is subdivided into DiscreteElements.
169*/
171public:
172 struct cable_spec {
173 double D;
174 double W;
175 double EA;
176 double EI;
178 cable_spec (){}
179 cable_spec (double Diameter, double rho, double E);
180 };
181
182
183 LineSegment(cable_spec spec, double segment_length);
184
185 virtual ~LineSegment();
186
187 const std::vector<DiscreteElement*>* GetDiscreteElements();
188
189
190 const cable_spec& GetCableSpecification();
191 double GetAxialStiffness(){return m_cable_spec.EA;}
192 double GetBendingStiffness(){return m_cable_spec.EI;}
193 double GetStabilizer(){return m_cable_spec.Stabilizer;}
194
195 double GetSegmentLength();
196 double GetCableStartPosition();
197 int GetCableIndex();
198
199 CollisionManager::MaterialCharacteristic GetMaterialCharacteristic(){return m_material_characteristics;}
200
201 virtual void XmlInfo(TiXmlElement& xml_node);
202 virtual std::string GetSegmentTypeName() = 0;
203
204#ifdef FH_VISUALIZATION
205 std::string Material(){return m_material;}
206 double GetMaxTension(){return m_max_tension;}
207 void SetMaxTension(double max_tension){m_max_tension = max_tension;}
208#endif
209
210 virtual void SetLineStructure(SupergridLineStructure* linestructure);
211protected:
212 cable_spec m_cable_spec;
213 double m_length;
214 double m_line_structure_start_length;
215 int m_line_structure_ix;
216 CollisionManager::MaterialCharacteristic m_material_characteristics;
217
218 SupergridLineStructure* m_line_structure;
219 std::vector<DiscreteElement*> m_discrete_element;
220
221#ifdef FH_VISUALIZATION
222 double m_max_tension;
223 std::string m_material;
224#endif
225};
226
227
238 friend class LineSegment;
239public:
244 virtual void AddSegment(LineSegment* l);
245
249 const std::vector<DiscreteElement*>* GetDiscreteElements();
250
254 const std::vector<ModifiableRigidElement*>* GetRigidElements();
255
259 const std::vector<double>* GetRigidElementTension();
260
264 const std::vector<LineSegment*>* GetLineSegments();
265
269 double GetLength();
270
271
275 SupergridLineStructure(ConstraintSolver* solver, ISimObjectCreator* creator, Environment_Interface* environment, int rigid_element_buffer_size, double beta, std::string name);
276
277 virtual ~SupergridLineStructure();
278
279 virtual void XmlInfo(TiXmlElement& xml_node);
280
281 virtual void ComputeConstraints(const double T, const double * const X);
282
283#ifdef FH_VISUALIZATION
284 virtual void RenderInit(Ogre::Root* const ogreRoot);
285 virtual void RenderUpdate(const double T, const double* const X);
286 void UpdateData(const double* const X);
287 virtual Ogre::ColourValue Color(size_t ix);
288 void SetHQ_Render(bool HQ_render){m_HQ_render = HQ_render;}
289 static double log_scale(const double max_limit, double x);
290 static Ogre::ColourValue RYGCBM(double f);
291#endif
292
293 double GetBeta();
294 Environment_Interface* GetEnvironment();
295
296
297protected:
298 double m_length;
299 double m_beta;
300 Environment_Interface* m_environment;
301 std::vector<ModifiableRigidElement*> m_rigid_element_buffer;
302 std::vector<LineSegment*> m_segment;
303 std::vector<DiscreteElement*> m_super_element;
304 std::vector<double> m_rigid_element_tension;
305 std::string m_name;
306
307#ifdef FH_VISUALIZATION
308 C3DLine* m_line;
309 std::vector<Ogre::SceneNode*> m_nodes;
310 bool m_HQ_render;
311 int m_colour_counter;
312#endif
313};
314
315}
316}
Definition: ConstraintSolver.h:31
Definition: SupergridLineStructure.h:15
Definition: JointConstraint.h:17
Definition: ObjectFactoryStack.h:22
Definition: RigidElement.h:15
int ix_Q()
index of Position state
Definition: RigidElement.h:42
int ix_W()
index of Velocity state
Definition: RigidElement.h:44
int ix_V()
index of Orientation state
Definition: RigidElement.h:43
int ix_P()
Angular velocity.
Definition: RigidElement.h:41
Definition: SupergridLineStructure.h:73
const std::vector< DiscreteElement * > * GetSubElements()
ModifiableRigidElement * GetRigidElement()
Definition: SupergridLineStructure.h:170
Definition: SupergridLineStructure.h:40
virtual void Setup(double T, const double *const X)
virtual const vec6 & Forces()
full 6x6 Inertia Matrix
Definition: SupergridLineStructure.h:237
SupergridLineStructure(ConstraintSolver *solver, ISimObjectCreator *creator, Environment_Interface *environment, int rigid_element_buffer_size, double beta, std::string name)
const std::vector< DiscreteElement * > * GetDiscreteElements()
double GetBeta()
Computes structural connections.
const std::vector< double > * GetRigidElementTension()
virtual void ComputeConstraints(const double T, const double *const X)
const std::vector< LineSegment * > * GetLineSegments()
const std::vector< ModifiableRigidElement * > * GetRigidElements()
Definition: CollisionManager.h:6
Definition: SupergridLineStructure.h:108
Definition: SupergridLineStructure.h:172
double Stabilizer
youngs modulus times cross section second area moment [Pa*m^4] or [N*m^2]
Definition: SupergridLineStructure.h:177
double W
diameter [m]
Definition: SupergridLineStructure.h:174
double EA
weight [kg/m]
Definition: SupergridLineStructure.h:175
double EI
youngs modulus times cross section area [Pa*m^2] or [N]
Definition: SupergridLineStructure.h:176