FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
NetNodeStates.h
1#pragma once
2
14#include <vector>
15
19{
20 std::vector<int> posIndex;
21 std::vector<int> velIndex;
22};
23
26{
27 const double* X = nullptr;
28 const NetNodeLayout* layout = nullptr;
29 int stateBase = 0;
30
32 const double* Position(int node) const { return X + layout->posIndex[node] - stateBase; }
34 const double* Velocity(int node) const { return X + layout->velIndex[node] - stateBase; }
35};
36
39{
40public:
41 virtual ~NetNodeStates() = default;
42
44 virtual NetNodeLayout Layout() const = 0;
45
53 virtual void AddExternalForces(double T, const double* X, double* nodeForce) const = 0;
54
64 virtual void TakeNodeForces(double T, const double* X, const double* nodeForce, double* XDot) const = 0;
65};
Definition NetNodeStates.h:39
virtual NetNodeLayout Layout() const =0
Where each node's position and velocity sit in X. Called once, from NetCore::FinalSetup.
virtual void AddExternalForces(double T, const double *X, double *nodeForce) const =0
virtual void TakeNodeForces(double T, const double *X, const double *nodeForce, double *XDot) const =0
Definition NetNodeStates.h:19
std::vector< int > posIndex
Per node: the global index of its position (3 states).
Definition NetNodeStates.h:20
std::vector< int > velIndex
Per node: the global index of its velocity (3 states).
Definition NetNodeStates.h:21
The nodes of one state vector, as the net core reads them: plain index arithmetic,...
Definition NetNodeStates.h:26
const double * Position(int node) const
The position of node, 3 states.
Definition NetNodeStates.h:32
const double * X
The state vector.
Definition NetNodeStates.h:27
const double * Velocity(int node) const
The velocity of node, 3 states.
Definition NetNodeStates.h:34
int stateBase
Subtracted from every index: 0 for a global X, the SimObject's first state for a local one (Jacobian)...
Definition NetNodeStates.h:29
const NetNodeLayout * layout
From NetNodeStates::Layout().
Definition NetNodeStates.h:28