Marine systems simulation
CNetStructureTest.h
1
9
10#ifndef CNetStructureTest_H
11#define CNetStructureTest_H
12
13//#define CNetStructure_DO_PROFILE
14
15// Includes
16#include <assert.h>
17#include <string>
18#include <vector>
19#include <map>
20
21#include <SimObject.h>
22#include <CEnvironment.h>
23
24#include "CNetCableElementTestSpec.h"
25#include "CNetTwineElementSpec.h"
26//#include "CNetMeshElementSpec.h"
27
28#include "CNetCableElementTest.h"
29#include "CNetTwineElement.h"
30//#include "CNetMeshElement.h"
31
32#include "CNetStructureTestSpec.h"
33#ifdef FH_VISUALIZATION
34 #include "sfh/ogre/NMeshGenerators.h"
35 #include "sfh/ogre/C3DLine.h"
36 #include <CTextRenderer.h>
37#endif
38
39
40
41//Class definition
42class CNetStructureTest : public SimObject
43{
44public:
46 CNetStructureTest(std::string sSimObjectName, ISimObjectCreator *pCreator);
49 virtual void OdeFcn(const double dT, const double *const adX, double *const adXDot, const bool bIsMajorTimeStep);
50 virtual void InitialConditionSetup(const double dT, const double *const adCurrentIC, double *const adUpdatedIC, ISimObjectCreator *const pCreator);
51 virtual void FinalSetup(const double dT, const double *const adX, ISimObjectCreator *const pCreator);
52 const double * outExternalNodeForce(const double dT, const double *const adX, int iExtNode);
53
54#ifdef FH_VISUALIZATION
55 // Initial specification of the simObject geometry for rendering.
56 virtual void RenderInit(Ogre::Root *const pOgreRoot, ISimObjectCreator *const pCreator);
57 // Updating the simObject for rendering the next frame.
58 virtual void RenderUpdate(const double dT, const double *const adX);
59#endif
60 const virtual double * dragReduction(const double T, const double *const X);
61 const virtual double * projectedArea(const double T, const double *const X);
62 const virtual double * projectedVelocity(const double T, const double *const X);
63 const virtual double * dragForce( const double T, const double *const X );
64 const virtual double * cableForce( const double T, const double *const X );
65 const virtual double * appendixForce( const double T, const double *const X );
66
67
68 double m_dragReduction;
69 double m_projectedArea;
70 double m_projectedVelocity;
71
72 const virtual double * NodePos(const double dT, const double *const adX, int iExtNode);
73 const virtual double * NodeVel(const double dT, const double *const adX, int iExtNode);
74protected:
75 virtual void AddExternalForces(const double dT, const double *const adX);
76 virtual void AddCableForces(const double dT, const double *const adX);
77 virtual void AddInputPorts(ISimObjectCreator *pCreator);
78
79 virtual void CreateNetCables(std::vector<CNetCableElementTestSpec*> VCableElements, ISimObjectCreator *pCreator);
80 virtual void CreateNetTwines(std::vector<const CNetTwineElementSpec*> VCableElements, ISimObjectCreator *pCreator);
81 //virtual void CreateNetMeshes(std::vector<const CNetMeshElementSpec*> VCableElements, ISimObjectCreator *pCreator);
82
83 virtual void CreateDataStructures();
84 virtual void CreateOutputPorts(ISimObjectCreator *pCreator);
85 std::vector< std::pair<std::string,int> > CreateExternalNodeMap( std::string sTag, int* piUsed, CNetStructureTestSpec & NetSpec, ISimObjectCreator *pCreator);
86
87#ifdef FH_VISUALIZATION
88 # pragma warning (disable : 4244)
89 bool m_bLineVisualization;
90 int m_colorBy;
91 //C3DLine *m_LineVisualizationPressure;
92 C3DLine *m_Lines;
93
94 static Ogre::ColourValue mapToColor( double val )
95 {
96 if(val <= 0.0){
97 return Ogre::ColourValue(0.0 ,0.0 ,1.0 ); // Blue
98 }else if(val >= 1.0){
99 return Ogre::ColourValue(1.0 ,0.0 ,0.0 ); // Red
100 }else if(val >= 0.75){
101 return Ogre::ColourValue(1.0 ,4.0-val/0.25 ,0.0 ); // Red -> Yellow
102 }else if(val >= 0.5){
103 return Ogre::ColourValue(val/0.25-2.0 ,1.0 ,0.0 ); // Yellow -> Green
104 }else if(val >= 0.25){
105 return Ogre::ColourValue(0.0 ,1.0 ,2.0-val/0.25 ); // Green -> BlueGreen
106 }else{
107 return Ogre::ColourValue(0.0 ,val/0.25 ,1.0 ); // BlueGreen -> Blue
108 }
109 }
110#endif
111
112 //bool m_bSymplecticHack;
113 double m_dSymplecticStepsize;
114
115
117
118 ISignalPort **m_apInExternalForces;
119 ISignalPort *m_colorLimits;
120 int *m_aIStatePos;
121 int *m_aIStateVel;
123 double* m_NodeExternalForces;
125
127 int m_iNumNodesOutputPosAndVel;
128 int m_numCables;
129 //int m_iNumNodesOriginal;
130 int m_iNumNodesCalc;
131 //int m_iNumNodeOutputs;
133
135
137 double m_currentVel[3];
138 const double* currentVelocity(const double dT, const double * const adX);
140
142
143 std::vector<CNetCableElementTest*> m_cableElements;
144 std::vector<CNetTwineElement*> m_VpTwineElements;
145 //std::vector<CNetMeshElement*> m_VpMeshElements;
146 float* m_afInertia;
147 //float* m_afInertiaReciprocal;
148 int** m_aaiCableConn;
149 bool m_bFoldingPointRefinementUsed;
151
152
154
155 std::vector< std::pair<std::string,int> > m_VsNodesOutputPosAndVel;
156 std::vector< std::pair<std::string,int> > m_VsNodesInputForce;
157 bool m_bUseTagForExternalNodes;
159
160 double* m_adNodeForce;
161 unsigned int m_iNumTwinesCalc;
162
163 int **m_netsurface;
164
165 sfh::linalg::sse_vec3f *omp_posa;
166 sfh::linalg::sse_vec3f *omp_posb;
167 sfh::linalg::sse_vec3f *omp_vela;
168 sfh::linalg::sse_vec3f *omp_velb;
169 sfh::linalg::sse_vec3f *omp_velf;
170
171 sfh::linalg::sse_vec3f *omp_forceA;
172 sfh::linalg::sse_vec3f *omp_forceB;
173 double m_dragForce[3];
174 double m_cableForce[3];
175 double m_appendixForce[3];
176};
177
178
179#endif
180
Definition: CEnvironment.h:10
Definition: CNetStructureTestSpec.h:15
Class containing a net object.
Definition: CNetStructureTest.h:43
CEnvironment * m_pEnvironment
Environment.
Definition: CNetStructureTest.h:136
std::vector< CNetCableElementTest * > m_cableElements
Element properties.
Definition: CNetStructureTest.h:143
int m_iNumNodesInputForce
Node counts.
Definition: CNetStructureTest.h:126
virtual ~CNetStructureTest()
The destructor deletes dynamically allocated memory.
ISignalPort ** m_apInExternalForces
Interface member variables.
Definition: CNetStructureTest.h:118
std::vector< std::pair< std::string, int > > m_VsNodesOutputPosAndVel
Nodes reachable directly through input or output ports.
Definition: CNetStructureTest.h:155
CNetStructureTest(std::string sSimObjectName, ISimObjectCreator *pCreator)
The constructor sets the pointer to the output object and the parser object.