FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
Crowfoot.h
1#pragma once
2
79#include "trawl/subroutines/CrowfootMath.h"
80
81#include "sfh/filters/FIR.h"
82
83#include <fhsim/simobject/SimObject.h>
84#include <array>
85#include <float.h>
86#include <string>
87#include <vector>
88
89class Crowfoot : public SimObject
90{
91public:
108 Crowfoot(const std::string& simObjectName, ISimObjectCreator* const creator);
109 // virtual void FinalSetup(const double T, const double* const X, ISimObjectCreator* const creator);
110 virtual ~Crowfoot();
111
112 void OdeFcn(const double T, const double* const X, double* const XDot) const override;
113 void PreOdeFcn(double T, const double* X) override;
114 void AcceptedStep(const double T, const double* const X) override;
115
126 void UpdateVelocity(const double T);
127
135 void Solve(const double T, const double* const X) const;
136
138 void SeedFilterOnce(const double T, const double* const X) const;
139
140 // virtual void FinalSetup(const double dT, const double *const adX, ISimObjectCreator *const creator);
141
142 const virtual double* PositionOut(const double t, const double* const x);
143 const virtual double* VelocityOut(const double t, const double* const x);
144 const virtual double* LineForceOut(const double t, const double* const x, int lineIndex);
145 const virtual double* LineTensionOut(const double t, const double* const x, int lineIndex);
146
147
148#ifdef FH_VISUALIZATION
157 void RenderInit(Ogre::Root* const ogreRoot, ISimObjectCreator* const creator);
158
167 void RenderUpdate(const double T, const double* const X);
168#endif
169
170
171protected:
172 int m_numLines;
173 std::vector<const double*> m_linesPos;
174 std::vector<std::array<double, 3>> m_linesForce;
175 // std::vector<double> m_linesLength;
176 std::vector<double> m_linesTension;
177
178 std::vector<ISignalPort*> m_inFasteningPositions;
179 std::vector<ISignalPort*> m_inLengths;
180 ISignalPort* m_inExternalForce;
181 CrowfootMath* m_crowfoot;
182 ICommonComputation* m_solve = nullptr;
183 mutable bool m_filterSeeded = false;
184
185 // int m_IStatePos;
186 // int m_IStateVel;
187 // int m_IStateErrorIntegral;
188 mutable double m_velocity[3];
189 mutable double m_instantPos[3];
190 double m_prevPos[3];
191 double m_prevTime;
193 // double m_integratorGain;
194 // double m_proportionalGain;
195 // double m_dampingGain;
196 // double m_distForMaxSpeed;
197 // double m_maximumSpeed;
198 // sfh::timers::StopWatch m_derivativeTimer;
199 // double m_timeStep;
200 // double m_lastError[3];
201 // double m_tmpError[3];
202 mutable sfh::filters::FIR m_filter;
203
204#ifdef FH_VISUALIZATION
205
206#endif
207};
Definition CrowfootMath.h:40
Definition Crowfoot.h:90
bool m_filterSeeded
Whether the force filter holds the force of the first solve.
Definition Crowfoot.h:183
ICommonComputation * m_solve
Solve, once per evaluation.
Definition Crowfoot.h:182
bool m_hasPrevPos
Whether an accepted step has been seen yet.
Definition Crowfoot.h:192
Crowfoot(const std::string &simObjectName, ISimObjectCreator *const creator)
Reads parameters, registers states, input/output ports and shared resources.
void UpdateVelocity(const double T)
Backward-differences the solved collecting point position.
double m_prevPos[3]
Solved position at the previous accepted step.
Definition Crowfoot.h:190
double m_prevTime
Time of the previous accepted step.
Definition Crowfoot.h:191
void Solve(const double T, const double *const X) const
Solves the collecting point at (T, X) and stores it and the line forces.
void SeedFilterOnce(const double T, const double *const X) const
Seeds the force filter with the external force at (T, X), the first time it is called.