|
FhSim
3.1.0
Marine systems simulation
|
#include <JacobianStates.h>
Public Member Functions | |
| StateFrame (const double *localStates, int firstStateIndex) | |
| StateFrame (int firstStateIndex) | |
| int | Local (int globalIndex) const |
Index within the slice of the state with global index globalIndex. | |
| const double * | State (int globalIndex) const |
The state with global index globalIndex, in the slice. | |
| const double * | Global () const |
The global state vector, as OdeFcn is handed it. | |
A Jacobian callback's view of the global state vector.
AddState returns indices into the global state vector, the one OdeFcn is handed. FhSim hands SimObject::OdeJacobian, OutputPortJacobian and InputPortJacobian only the pointer state + offset, where offset is the object's first state, the value its first AddState returned (fhsim/src/engine/model/JacobianAssembler.cpp, SimObjectJacobianBlock.cpp, PortCouplingEvaluator.cpp), and a block sized to its own states. The callback indexes that slice with local indices.
A StateFrame pairs the slice with the object's first global state index so a callback never mixes the two up:
Local(i) turns a global state index into an index within the slice, for writing the Jacobian blocks;State(i) points at the state with global index i in the slice, for reading its value;Global() is the global state vector. Anything that expects what OdeFcn is handed must be given this: ISignalPort::GetPortValue, ICommonComputation::ComputeFunction and the object's own functions that index with AddState values. A port or common computation evaluates its source with the vector it is given whenever its cache is empty, so a local slice would make it read the wrong states (BASE-0042).A frame is built per callback; it holds the two values and nothing else.
|
inline |
| localStates | The slice the callback was handed. |
| firstStateIndex | The object's first global state index, as its first AddState returned it. |
|
inlineexplicit |
A frame for a callback that is handed no slice, such as GetJacobianSparsity. Only Local may be used on it.