FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
AttractorBase.h
1
9
10#pragma once
11
12#include "sfh/sim/simulation.h"
13
14#include <functional>
15#include <string>
16
18{
19public:
21 struct Motion
22 {
23 double pos[3] = {0.0, 0.0, 0.0};
24 double vel[3] = {0.0, 0.0, 0.0};
25 double relStrength = 1.0;
26 };
27
29 using PosAndVelSource = std::function<void(double T, const double* X, double pos[3], double vel[3])>;
30
32 using StrengthSource = std::function<double(double T)>;
33
35
38
41
46 Motion MotionAt(double T, const double* X) const;
47
48 virtual void GetForce(const Motion& motion, double* const adForce, const double* const adNodePos, const double* const adNodeVel) = 0;
49 virtual void AddForce(const Motion& motion, double* const adForce, const double nodeMass, const double* const adNodePos, const double* const adNodeVel) = 0;
50 virtual void AddForce(const Motion& motion, double* const adForce, const double* const adNodePos, const double* const adNodeVel) = 0;
51 virtual void SetForceIfActive(const Motion& motion, double* const adForce, const double* const adNodePos, const double* const adNodeVel) { };
52 virtual bool IsActive(const Motion& motion, const double* const adNodePos) = 0;
53
54private:
55 PosAndVelSource m_posAndVel;
56 StrengthSource m_strength;
57};
Class modelling the interface of a general attractor.
Definition AttractorBase.h:18
std::function< double(double T)> StrengthSource
Gives the attractor's relative strength at time T.
Definition AttractorBase.h:32
std::function< void(double T, const double *X, double pos[3], double vel[3])> PosAndVelSource
Gives the attractor's position and velocity at (T, X), X the model-global states.
Definition AttractorBase.h:29
Motion MotionAt(double T, const double *X) const
void SetPosAndVelSource(PosAndVelSource source)
Sets what moves the attractor (Seine/Vessel, when it creates it).
void SetStrengthSource(StrengthSource source)
Sets what scales the attractor's pull (Seine/Operation, in its FinalSetup).
Where the attractor is, how fast it moves, and how strongly it pulls.
Definition AttractorBase.h:22