1 #ifndef SimTK_SimTKCOMMON_SYSTEM_H_
2 #define SimTK_SimTKCOMMON_SYSTEM_H_
36 class DecorativeGeometry;
37 class DefaultSystemSubsystem;
38 class ScheduledEventHandler;
39 class ScheduledEventReporter;
40 class TriggeredEventHandler;
41 class TriggeredEventReporter;
133 System& setUseUniformBackground(
bool useUniformBackground);
148 System& setDefaultTimeScale(Real tc);
157 System& setDefaultLengthScale(Real lc);
164 void setHasTimeAdvancedEvents(
bool);
170 bool getUseUniformBackground()
const;
173 Real getDefaultTimeScale()
const;
176 Real getDefaultLengthScale()
const;
179 bool hasTimeAdvancedEvents()
const;
234 const State& realizeTopology()
const;
250 const State& getDefaultState()
const;
253 State& updDefaultState();
273 void realizeModel(
State& state)
const;
367 void project(
State& state, Real accuracy=-1)
const;
384 void projectQ(
State& state, Real accuracy=-1)
const;
403 void projectU(
State& state, Real accuracy=-1)
const;
512 bool prescribeQ(
State& state)
const;
529 bool prescribeU(
State& state)
const;
572 void handleEvents(
State& state,
581 void reportEvents(
const State& state,
593 void calcEventTriggerInfo(
const State& state,
601 void calcTimeOfNextScheduledEvent(
const State& state,
604 bool includeCurrentTime)
const;
609 void calcTimeOfNextScheduledReport(
const State& state,
612 bool includeCurrentTime)
const;
645 void relax(
State& state,
Stage stage, Real accuracy=-1)
const;
670 void multiplyByN(
const State& state,
const Vector& u,
673 void multiplyByNTranspose(
const State& state,
const Vector& fq,
676 void multiplyByNPInv(
const State& state,
const Vector& dq,
679 void multiplyByNPInvTranspose(
const State& state,
const Vector& fu,
694 void resetAllCountersToZero();
701 int getNumRealizationsOfThisStage(
Stage)
const;
706 int getNumRealizeCalls()
const;
711 int getNumPrescribeQCalls()
const;
713 int getNumPrescribeUCalls()
const;
719 int getNumProjectQCalls()
const;
721 int getNumFailedProjectQCalls()
const;
724 int getNumQProjections()
const;
727 int getNumQErrorEstimateProjections()
const;
731 int getNumProjectUCalls()
const;
733 int getNumFailedProjectUCalls()
const;
736 int getNumUProjections()
const;
739 int getNumUErrorEstimateProjections()
const;
746 int getNumHandlerCallsThatChangedStage(
Stage)
const;
750 int getNumHandleEventCalls()
const;
754 int getNumReportEventCalls()
const;
775 const String& getName()
const;
777 const String& getVersion()
const;
784 int getNumSubsystems()
const;
799 inline operator const Subsystem&()
const;
809 bool systemTopologyHasBeenRealized()
const;
825 void setSystemTopologyCacheVersion(
StageVersion topoVersion)
const;
836 void invalidateSystemTopologyCache()
const;
845 void calcDecorativeGeometryAndAppend(
const State&,
Stage,
851 bool isSameSystem(
const System& otherSystem)
const;
874 bool isOwnerHandle()
const;
876 bool isEmptyHandle()
const;
903 void findSubsystemEventIds
912 const Guts& getGuts()
const;
925 inline System::operator
const Subsystem&()
const {
return getDefaultSubsystem();}
926 inline System::operator
Subsystem&() {
return updDefaultSubsystem();}
978 { optionSet=0; setAccuracyDefaults();
return *
this; }
985 requiredAccuracy = accuracy > 0 ? accuracy
993 assert(0 < overshoot && overshoot <= 1);
994 desiredOvershoot = overshoot;
1002 projectionLimit = limit;
1009 { optionSet &= ~(unsigned)opt;
return *
this; }
1012 { optionSet |= (unsigned)opt;
return *
this; }
1029 { optionSet |= opts.optionSet;
return *
this; }
1031 { optionSet &= opts.optionSet;
return *
this; }
1033 { optionSet &= ~opts.optionSet;
return *
this; }
1039 Real requiredAccuracy;
1040 Real desiredOvershoot;
1041 Real projectionLimit;
1044 void setAccuracyDefaults() {
1076 m_anyChangeMade = m_projectionLimitExceeded =
false;
1077 m_numIterations = 0;
1079 m_normOnEntrance = m_normOnExit =
NaN;
1090 { assert(
isValid());
return m_worstError; }
1092 { assert(
isValid());
return m_projectionLimitExceeded; }
1095 { m_exitStatus=status;
return *
this; }
1097 { m_anyChangeMade=changeMade;
return *
this; }
1099 { m_projectionLimitExceeded=limitExceeded;
return *
this; }
1101 { m_numIterations=numIterations;
return *
this; }
1103 { m_normOnEntrance=
norm; m_worstError=worstError;
return *
this; }
1105 { m_normOnExit=
norm;
return *
this; }
1108 bool m_anyChangeMade;
1109 bool m_projectionLimitExceeded;
1110 int m_numIterations;
1112 Real m_normOnEntrance;
1123 unsigned int optionSet;
1139 operator bool()
const {
return optionSet != 0;}
1164 #endif // SimTK_SimTKCOMMON_SYSTEM_H_
DefaultSystemSubsystem & updDefaultSubsystem()
Get writable access to the default subsystem which is present in every system.
ScheduledEventReporter is a subclass of EventReporter for events that occur at a particular time that...
Definition: EventReporter.h:72
System(System::Guts *g)
Constructor for internal use only.
Definition: System.h:869
ScheduledEventHandler is a subclass of EventHandler for events that occur at a particular time that i...
Definition: EventHandler.h:84
Definition: System.h:1129
bool isOptionSet(Option opt) const
Definition: System.h:1142
The abstract parent of all Subsystems.
Definition: Subsystem.h:61
ProjectResults()
Definition: System.h:1054
#define SimTK_SimTKCOMMON_EXPORT
Definition: SimTKcommon/include/SimTKcommon/internal/common.h:202
Normally a project() method will return immediately after evaluating the norm if it is already at or ...
Definition: System.h:955
A project() method is free to use an out-of-date Jacobian when solving the nonlinear system...
Definition: System.h:959
ProjectResults & setNumIterations(int numIterations)
Definition: System.h:1100
ProjectOptions & operator|=(const ProjectOptions &opts)
Definition: System.h:1028
ProjectOptions & operator-=(const ProjectOptions &opts)
Definition: System.h:1032
RealizeOptions & operator|=(RealizeOptions opts)
Definition: System.h:1148
(NOT USED YET) Results for advanced users of realize() methods.
Definition: System.h:1156
ProjectOptions(Real accuracy)
This constructor allows the default accuracy to be overridden while leaving all other options at thei...
Definition: System.h:967
bool isEmpty() const
Definition: System.h:1140
int getNumIterations() const
Definition: System.h:1086
ProjectOptions & operator&=(const ProjectOptions &opts)
Definition: System.h:1030
void addEventHandler(ScheduledEventHandler *handler)
Definition: System.h:1128
A CoordinateDirection is a CoordinateAxis plus a direction indicating the positive or negative direct...
Definition: CoordinateAxis.h:246
Status getExitStatus() const
Definition: System.h:1083
ProjectOptions(Option opt)
This constructor creates default options except one setting one non-default Option.
Definition: System.h:971
This class is basically a glorified enumerated type, type-safe and range checked but permitting conve...
Definition: Stage.h:50
bool getAnyChangeMade() const
Definition: System.h:1085
Real getOvershootFactor() const
Return the factor by which a project() method should try to do better than the required accuracy...
Definition: System.h:1018
void addEventReporter(ScheduledEventReporter *handler) const
Add a ScheduledEventReporter to this System, which takes over ownership of the event reporter object...
Definition: System.h:920
ProjectOptions & setProjectionLimit(Real limit)
Project will fail immediately if the initial norm is greater than the projection limit, with status FailureToConverge.
Definition: System.h:1000
ProjectResults & clear()
Restore this object to its default-constructed state, with the return status set to Invalid...
Definition: System.h:1074
ProjectOptions & clear()
Restore this object to its default-constructed state (no options selected, default accuracy and overs...
Definition: System.h:977
static Real getDefaultOvershootFactor()
Definition: System.h:1025
System()
Default constructor creates an empty handle.
Definition: System.h:765
ProjectResults & setNormOnExit(Real norm)
Definition: System.h:1104
void addEventReporter(ScheduledEventReporter *handler) const
Guts & updSystemGuts()
Obtain a writable reference to the System::Guts object to which this handle refers.
Definition: System.h:861
This is the handle class for the hidden State implementation.
Definition: State.h:264
const Real NaN
This is the IEEE "not a number" constant for this implementation of the default-precision Real type; ...
Results for advanced users of project() methods.
Definition: System.h:1052
These are all the possible causes for events.
Definition: Event.h:123
static Real getDefaultRequiredAccuracy()
Definition: System.h:1024
int getWorstErrorOnEntrance() const
Definition: System.h:1089
bool getProjectionLimitExceeded() const
Definition: System.h:1091
Options for the advanced project() methods.
Definition: System.h:935
This object has not been filled in yet and holds no results.
Definition: System.h:1058
Option
Definition: System.h:1127
The project() was successful either because no projection was necessary or projection was able to ach...
Definition: System.h:1061
ProjectResults & setProjectionLimitExceeded(bool limitExceeded)
Definition: System.h:1098
The SimTK::Array_<T> container class is a plug-compatible replacement for the C++ standard template l...
Definition: Array.h:50
Option
Definition: System.h:937
(NOT USED YET) Options for the advanced realize() methods.
Definition: System.h:1122
bool isValid() const
Definition: System.h:1082
Normally failure to meet the accuracy requirements throws an exception.
Definition: System.h:948
const Guts & getSystemGuts() const
Obtain a const reference to the System::Guts object to which this handle refers.
Definition: System.h:857
RealizeOptions()
Definition: System.h:1133
ProjectOptions & operator-=(Option opt)
Definition: System.h:1036
Spatial configuration available.
Definition: Stage.h:58
ProjectOptions & setRequiredAccuracy(Real accuracy)
The norm of the constraint errors must be driven to below this value for a project() to be considered...
Definition: System.h:984
The abstract parent of all Subsystem "Guts" implementation classes.
Definition: SubsystemGuts.h:42
bool isOptionSet(Option opt) const
Definition: System.h:1022
const DefaultSystemSubsystem & getDefaultSubsystem() const
Get read-only access to the default subsystem which is present in every system.
float norm(const conjugate< float > &c)
Definition: conjugate.h:775
The Newton iterations were diverging.
Definition: System.h:1069
This option says we expect the state to be close to a solution already and restricts projection to mo...
Definition: System.h:944
RealizeOptions & operator-=(Option opt)
Definition: System.h:1152
void addEventHandler(ScheduledEventHandler *handler)
Add a ScheduledEventHandler to this System, which takes over ownership of the event handler object...
Definition: System.h:916
ProjectResults & setAnyChangeMade(bool changeMade)
Definition: System.h:1096
const Real Infinity
This is the IEEE positive infinity constant for this implementation of the default-precision Real typ...
ProjectResults & setExitStatus(Status status)
Definition: System.h:1094
RealizeOptions & operator&=(RealizeOptions opts)
Definition: System.h:1149
Use the stricter infinity (max absolute value) norm rather than the default RMS norm to determine whe...
Definition: System.h:951
SimTK::String is a plug-compatible std::string replacement (plus some additional functionality) inten...
Definition: String.h:62
Real getRequiredAccuracy() const
Return the current value for the required accuracy option.
Definition: System.h:1015
This is the declaration for the System::Guts class, the abstract object to which a System handle poin...
Definition: SystemGuts.h:71
Status
Definition: System.h:1056
TriggeredEventHandler is a subclass of EventHandler for events that occur when some condition is sati...
Definition: EventHandler.h:109
ProjectOptions & setOption(Option opt)
Set a particular option.
Definition: System.h:1011
This is the base class that serves as the parent of all SimTK System objects; most commonly Simbody's...
Definition: System.h:96
void clear()
Definition: System.h:1143
void clearOption(Option opt)
Definition: System.h:1144
bool hasGuts() const
Return true if this System handle is not empty.
Definition: System.h:871
ProjectOptions()
Default constructor sets options to their default values.
Definition: System.h:963
Provide a unique integer type for identifying Subsystems.
This is a concrete Subsystem that is part of every System. It provides a variety of services for the ...
Definition: System.h:895
Real getProjectionLimit() const
Return the maximum norm we're allowed to attempt to correct.
Definition: System.h:1020
Real getNormOnEntrance() const
Definition: System.h:1087
Results returned by the handleEvent() method.
Definition: Event.h:341
A new time has been realized.
Definition: Stage.h:57
This is the header which should be included in user programs that would like to make use of all the S...
Take all defaults.
Definition: System.h:939
TriggeredEventReporter is a subclass of EventReporter for events that occur when some condition is sa...
Definition: EventReporter.h:96
Includes internal headers providing declarations for the basic SimTK Core classes.
ProjectOptions & setOvershootFactor(Real overshoot)
Project will attempt to reach accuracy*overshoot but settle for just accuracy.
Definition: System.h:992
Real getNormOnExit() const
Definition: System.h:1088
ProjectOptions & clearOption(Option opt)
Remove a given option from the set.
Definition: System.h:1008
RealizeOptions(Option opt)
Definition: System.h:1136
RealizeOptions & operator|=(Option opt)
Definition: System.h:1151
ProjectOptions & operator|=(Option opt)
Definition: System.h:1035
int StageVersion
This is the type to use for Stage version numbers.
Definition: State.h:154
void prescribe(State &state) const
Set values for prescribed positions q and velocities u.
Definition: System.h:487
ProjectResults & setNormOnEntrance(Real norm, int worstError)
Definition: System.h:1102
void setOption(Option opt)
Definition: System.h:1145
Options for the handleEvent() method.
Definition: Event.h:265
Projection converged but was unable to achieve the required accuracy.
Definition: System.h:1064
This is a class to represent unique IDs for events in a type-safe way.