SPHinXsys
alpha version
|
Classes | |
class | AddedStateVariable |
Class for handling state variable added (allocated) by this StateEngine. More... | |
class | StateVariable |
struct | StateVariableInfo |
To hold related info about discrete variables. More... | |
Public Member Functions | |
void | addStateVariable (std::string statevariablename, SimTK::Stage invalidatestage) |
void | addStateVariable (StateEngine::StateVariable *statevariable) |
SimTK::DefaultSystemSubsystem & | getDefaultSubsystem () |
SimTK::DefaultSystemSubsystem & | updDefaultSubsystem () |
StateVariable * | traverseToStateVariable (std::string &pathname) |
bool | isAllStatesVariablesListValid () |
StateEngine (SimTK::MultibodySystem &system) | |
virtual | ~StateEngine () |
void | InitializeState () |
SimTK::MultibodySystem & | getMultibodySystem () |
SimTK::MultibodySystem & | updMultibodySystem () |
int | getNumOfStateVariables () |
int | getNumStateVariablesAddedByEngine () |
Array< std::string > | getStateVariableNames () |
SimTK::Vector | getStateVariableValues () |
void | reporter (SimTK::State &state_) |
void | writeStateInfoToXml (int ite_rst_, const SimTK::State &state_) |
SimTK::State | readAndSetStateInfoFromXml (int ite_rst_, SimTK::MultibodySystem &system_) |
Realize the Simbody System and State to Computational Stage. | |
Methods in this section enable advanced and scripting users access to realize the Simbody MultibodySystem and the provided state to a desired computational (realization) Stage. | |
void | realizeTime () |
void | realizePosition () |
void | realizeVelocity () |
void | realizeDynamics () |
void | realizeAcceleration () |
void | realizeReport () |
Public Attributes | |
std::map< std::string, StateVariableInfo > | namedstatevariableinfo_ |
SimTK::Array_< SimTK::ReferencePtr< StateVariable > > | allstatevariables_ |
SimTK::ReferencePtr< SimTK::System > | statesassociatedsystem_ |
SimTK::ReferencePtr< SimTK::MultibodySystem > | mbsystem_ |
SimTK::State | working_state_ |
std::string | restart_folder_ |
Protected Member Functions | |
void | resizeXmlDocForSimbody (size_t input_size) |
Protected Attributes | |
XmlEngine | simbody_xml_engine_ |
UniquePtrKeepers< AddedStateVariable > | added_state_variable_ptr_keeper_ |
SPH::StateEngine::StateEngine | ( | SimTK::MultibodySystem & | system | ) |
Default constructor
|
inlinevirtual |
Destructor is virtual to allow concrete StateEngine to cleanup.
void SPH::StateEngine::addStateVariable | ( | std::string | statevariablename, |
SimTK::Stage | invalidatestage | ||
) |
Add a continuous system state variable belonging to this Engine, and assign a name by which to refer to it. Changing the value of this state variable will automatically invalidate everything at and above its invalidatesStage, which is normally Stage::Dynamics meaning that there are forces that depend on this variable. If you define one or more of these variables you must also override computeStateVariableDerivatives() to provide time derivatives for them. Note, all corresponding system indices are automatically determined using this interface. As an advanced option you may choose to hide the state variable from being accessed outside of this component, in which case it is considered to be "hidden". You may also want to create an Output for this state variable; see #OpenSim_DECLARE_OUTPUT_FOR_STATE_VARIABLE for more information. Reporters should use such an Output to get the StateVariable's value (instead of using getStateVariableValue()).
[in] | stateVariableName | string value to access variable by name |
[in] | invalidatesStage | the system realization stage that is invalidated when variable value is changed |
[in] | isHidden | flag (bool) to optionally hide this state variable from being accessed outside this component as an Output |
Allocate space for a new state variable.
void SPH::StateEngine::addStateVariable | ( | StateEngine::StateVariable * | statevariable | ) |
The above method provides a convenient interface to this method, which automatically creates an 'AddedStateVariable' and allocates resources in the SimTK::State for this variable. This interface allows the creator to add/expose state variables that are allocated by underlying Simbody components and specify how the state variable value is accessed by implementing a concrete StateVariable and adding it to the StateEngine using this method. You may also want to create an Output for this state variable; see #OpenSim_DECLARE_OUTPUT_FOR_STATE_VARIABLE for more information. Reporters should use such an Output to get the StateVariable's value (instead of using getStateVariableValue()).
don't add state if there is another state variable with the same name.
assign a "slot" for a state variable by name state variable index will be invalid by default upon allocation during realizeTopology the index will be set
SimTK::MultibodySystem & SPH::StateEngine::getMultibodySystem | ( | ) |
Get the underlying MultibodySystem that this StateEngine is connected to. Make sure you have called Model::initSystem() prior to accessing the System. Throws an Exception if the System has not been created or the StateEngine has not added itself to the System.
int SPH::StateEngine::getNumOfStateVariables | ( | ) |
Get the number of "continuous" state variables maintained by the State Engine.
|
inline |
Get the number of continuous states that the State Engine added to the underlying computational system.
Array< std::string > SPH::StateEngine::getStateVariableNames | ( | ) |
Get the names of "continuous" state variables maintained by the Engine
SimTK::Vector SPH::StateEngine::getStateVariableValues | ( | ) |
Get all values of the state variables allocated by this StateEngine.
state | the State for which to get the value |
StateEngineHasNoSystem | if this object has not been added to a System (i.e., if initSystem has not been called) |
if the StateVariables are invalid, rebuild the list.
void SPH::StateEngine::InitializeState | ( | ) |
Set up the working state in presetn engine
Clear cached list of all related StateVariables if any from a previousSystem.
Set the model's operating state (internal member variable) to the default state that is stored inside the System.
Process the modified modeling option.
Realize instance variables that may have been set above. This means floating point parameters such as mass properties and geometry placements are frozen.
Realize the initial configuration in preparation. This initial configuration does not necessarily satisfy constraints.
bool SPH::StateEngine::isAllStatesVariablesListValid | ( | ) |
Check that the list of _allStateVariables is valid.
Consider the list of all StateVariables to be valid if all of the following conditions are true:
SimTK::State SPH::StateEngine::readAndSetStateInfoFromXml | ( | int | ite_rst_, |
SimTK::MultibodySystem & | system_ | ||
) |
read state infor from xml and set it to sate. For all bodies in the matter system, their generalized coordinates, generalized velocities and transformations of the origin points are read from the restart file
void SPH::StateEngine::realizeAcceleration | ( | ) |
Perform computations that may depend on applied forces.
void SPH::StateEngine::realizeDynamics | ( | ) |
Perform computations (typically forces) that may depend on dynamics-stage state variables, and on computations performed in earlier stages (including velocity, position, and time), but not on other forces, accelerations, constraint multipliers, or reaction forces.
void SPH::StateEngine::realizePosition | ( | ) |
Perform computations that depend only on position-level state variables and computations performed in earlier stages (including time).
void SPH::StateEngine::realizeReport | ( | ) |
Perform computations that may depend on anything but are only used for reporting and cannot affect subsequent simulation behavior.
void SPH::StateEngine::realizeTime | ( | ) |
Perform computations that depend only on time and earlier stages.
void SPH::StateEngine::realizeVelocity | ( | ) |
Perform computations that depend only on velocity-level state variables and computations performed in earlier stages (including position, and time).
void SPH::StateEngine::reporter | ( | SimTK::State & | state_ | ) |
report the state info by requested.
StateEngine::StateVariable * SPH::StateEngine::traverseToStateVariable | ( | std::string & | pathname | ) |
Get a StateVariable anywhere in the state engine, given a StateVariable path. This returns nullptr if a StateVariable does not exist at the specified path or if the path is invalid.
SimTK::MultibodySystem& SPH::StateEngine::updMultibodySystem | ( | ) |
Get writable reference to the MultibodySystem that this component is connected to.
|
mutable |
Array of all state variables for fast access during simulation.
SimTK::ReferencePtr<SimTK::MultibodySystem> SPH::StateEngine::mbsystem_ |
Reference pointer to the system that this engine manage.
|
mutable |
Map names of continuous state variables of the Engine to their underlying SimTK indices.
std::string SPH::StateEngine::restart_folder_ |
Write the state data to xml file. For all bodies in the matter system, their generalized coordinates, generalized velocities and transformations of the origin points are written in the output file
|
mutable |
A handle the System associated with the above state variables.
SimTK::State SPH::StateEngine::working_state_ |
This is the internal 'writable' state of the engine. working_state_ will be set to the system default state when initializeState() is called.