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);
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;
586 void handleEvents(
State& state,
595 void reportEvents(
const State& state,
607 void calcEventTriggerInfo(
const State& state,
615 void calcTimeOfNextScheduledEvent(
const State& state,
618 bool includeCurrentTime)
const;
623 void calcTimeOfNextScheduledReport(
const State& state,
626 bool includeCurrentTime)
const;
684 void multiplyByN(
const State& state,
const Vector& u,
687 void multiplyByNTranspose(
const State& state,
const Vector& fq,
690 void multiplyByNPInv(
const State& state,
const Vector& dq,
693 void multiplyByNPInvTranspose(
const State& state,
const Vector& fu,
708 void resetAllCountersToZero();
715 int getNumRealizationsOfThisStage(
Stage)
const;
720 int getNumRealizeCalls()
const;
725 int getNumPrescribeQCalls()
const;
727 int getNumPrescribeUCalls()
const;
733 int getNumProjectQCalls()
const;
735 int getNumFailedProjectQCalls()
const;
738 int getNumQProjections()
const;
741 int getNumQErrorEstimateProjections()
const;
745 int getNumProjectUCalls()
const;
747 int getNumFailedProjectUCalls()
const;
750 int getNumUProjections()
const;
753 int getNumUErrorEstimateProjections()
const;
760 int getNumHandlerCallsThatChangedStage(
Stage)
const;
764 int getNumHandleEventCalls()
const;
768 int getNumReportEventCalls()
const;
789 const String& getName()
const;
791 const String& getVersion()
const;
798 int getNumSubsystems()
const;
813 inline operator const Subsystem&()
const;
823 bool systemTopologyHasBeenRealized()
const;
839 void setSystemTopologyCacheVersion(
StageVersion topoVersion)
const;
850 void invalidateSystemTopologyCache()
const;
859 void calcDecorativeGeometryAndAppend(
const State&,
Stage,
865 bool isSameSystem(
const System& otherSystem)
const;
888 bool isOwnerHandle()
const;
890 bool isEmptyHandle()
const;
917 void findSubsystemEventIds
926 const Guts& getGuts()
const;
939 inline System::operator
const Subsystem&()
const {
return getDefaultSubsystem();}
940 inline System::operator
Subsystem&() {
return updDefaultSubsystem();}
992 { optionSet=0; setAccuracyDefaults();
return *
this; }
999 requiredAccuracy = accuracy > 0 ? accuracy
1007 assert(0 < overshoot && overshoot <= 1);
1008 desiredOvershoot = overshoot;
1016 projectionLimit = limit;
1023 { optionSet &= ~(unsigned)opt;
return *
this; }
1026 { optionSet |= (unsigned)opt;
return *
this; }
1043 { optionSet |= opts.optionSet;
return *
this; }
1045 { optionSet &= opts.optionSet;
return *
this; }
1047 { optionSet &= ~opts.optionSet;
return *
this; }
1053 Real requiredAccuracy;
1054 Real desiredOvershoot;
1055 Real projectionLimit;
1058 void setAccuracyDefaults() {
1090 m_anyChangeMade = m_projectionLimitExceeded =
false;
1091 m_numIterations = 0;
1093 m_normOnEntrance = m_normOnExit =
NaN;
1104 { assert(
isValid());
return m_worstError; }
1106 { assert(
isValid());
return m_projectionLimitExceeded; }
1109 { m_exitStatus=status;
return *
this; }
1111 { m_anyChangeMade=changeMade;
return *
this; }
1113 { m_projectionLimitExceeded=limitExceeded;
return *
this; }
1115 { m_numIterations=numIterations;
return *
this; }
1117 { m_normOnEntrance=
norm; m_worstError=worstError;
return *
this; }
1119 { m_normOnExit=
norm;
return *
this; }
1122 bool m_anyChangeMade;
1123 bool m_projectionLimitExceeded;
1124 int m_numIterations;
1126 Real m_normOnEntrance;
1137 unsigned int optionSet;
1153 operator bool()
const {
return optionSet != 0;}
1178 #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:883
ScheduledEventHandler is a subclass of EventHandler for events that occur at a particular time that i...
Definition: EventHandler.h:84
Definition: System.h:1143
bool isOptionSet(Option opt) const
Definition: System.h:1156
The abstract parent of all Subsystems.
Definition: Subsystem.h:61
ProjectResults()
Definition: System.h:1068
#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:969
A project() method is free to use an out-of-date Jacobian when solving the nonlinear system...
Definition: System.h:973
ProjectResults & setNumIterations(int numIterations)
Definition: System.h:1114
ProjectOptions & operator|=(const ProjectOptions &opts)
Definition: System.h:1042
ProjectOptions & operator-=(const ProjectOptions &opts)
Definition: System.h:1046
RealizeOptions & operator|=(RealizeOptions opts)
Definition: System.h:1162
(NOT USED YET) Results for advanced users of realize() methods.
Definition: System.h:1170
ProjectOptions(Real accuracy)
This constructor allows the default accuracy to be overridden while leaving all other options at thei...
Definition: System.h:981
bool isEmpty() const
Definition: System.h:1154
This is the top-level SimTK namespace into which all SimTK names are placed to avoid collision with o...
Definition: Assembler.h:37
int getNumIterations() const
Definition: System.h:1100
ProjectOptions & operator&=(const ProjectOptions &opts)
Definition: System.h:1044
void addEventHandler(ScheduledEventHandler *handler)
Definition: System.h:1142
A CoordinateDirection is a CoordinateAxis plus a direction indicating the positive or negative direct...
Definition: CoordinateAxis.h:246
Status getExitStatus() const
Definition: System.h:1097
ProjectOptions(Option opt)
This constructor creates default options except one setting one non-default Option.
Definition: System.h:985
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:1099
Real getOvershootFactor() const
Return the factor by which a project() method should try to do better than the required accuracy...
Definition: System.h:1032
void addEventReporter(ScheduledEventReporter *handler) const
Add a ScheduledEventReporter to this System, which takes over ownership of the event reporter object...
Definition: System.h:934
ProjectOptions & setProjectionLimit(Real limit)
Project will fail immediately if the initial norm is greater than the projection limit, with status FailureToConverge.
Definition: System.h:1014
The SimTK::Array_ container class is a plug-compatible replacement for the C++ standard template l...
Definition: Array.h:50
ProjectResults & clear()
Restore this object to its default-constructed state, with the return status set to Invalid...
Definition: System.h:1088
SimTK_Real Real
This is the default compiled-in floating point type for SimTK, either float or double.
Definition: SimTKcommon/include/SimTKcommon/internal/common.h:565
ProjectOptions & clear()
Restore this object to its default-constructed state (no options selected, default accuracy and overs...
Definition: System.h:991
static Real getDefaultOvershootFactor()
Definition: System.h:1039
System()
Default constructor creates an empty handle.
Definition: System.h:779
ProjectResults & setNormOnExit(Real norm)
Definition: System.h:1118
void addEventReporter(ScheduledEventReporter *handler) const
Guts & updSystemGuts()
Obtain a writable reference to the System::Guts object to which this handle refers.
Definition: System.h:875
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:1066
These are all the possible causes for events.
Definition: Event.h:123
static Real getDefaultRequiredAccuracy()
Definition: System.h:1038
int getWorstErrorOnEntrance() const
Definition: System.h:1103
bool getProjectionLimitExceeded() const
Definition: System.h:1105
Options for the advanced project() methods.
Definition: System.h:949
This object has not been filled in yet and holds no results.
Definition: System.h:1072
Option
Definition: System.h:1141
The project() was successful either because no projection was necessary or projection was able to ach...
Definition: System.h:1075
ProjectResults & setProjectionLimitExceeded(bool limitExceeded)
Definition: System.h:1112
Option
Definition: System.h:951
(NOT USED YET) Options for the advanced realize() methods.
Definition: System.h:1136
bool isValid() const
Definition: System.h:1096
Normally failure to meet the accuracy requirements throws an exception.
Definition: System.h:962
const Guts & getSystemGuts() const
Obtain a const reference to the System::Guts object to which this handle refers.
Definition: System.h:871
RealizeOptions()
Definition: System.h:1147
ProjectOptions & operator-=(Option opt)
Definition: System.h:1050
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:998
The abstract parent of all Subsystem "Guts" implementation classes.
Definition: SubsystemGuts.h:42
bool isOptionSet(Option opt) const
Definition: System.h:1036
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:1083
This option says we expect the state to be close to a solution already and restricts projection to mo...
Definition: System.h:958
RealizeOptions & operator-=(Option opt)
Definition: System.h:1166
void addEventHandler(ScheduledEventHandler *handler)
Add a ScheduledEventHandler to this System, which takes over ownership of the event handler object...
Definition: System.h:930
ProjectResults & setAnyChangeMade(bool changeMade)
Definition: System.h:1110
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:1108
RealizeOptions & operator&=(RealizeOptions opts)
Definition: System.h:1163
Use the stricter infinity (max absolute value) norm rather than the default RMS norm to determine whe...
Definition: System.h:965
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:1029
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:1070
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:1025
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:1157
void clearOption(Option opt)
Definition: System.h:1158
bool hasGuts() const
Return true if this System handle is not empty.
Definition: System.h:885
ProjectOptions()
Default constructor sets options to their default values.
Definition: System.h:977
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:909
Real getProjectionLimit() const
Return the maximum norm we're allowed to attempt to correct.
Definition: System.h:1034
Real getNormOnEntrance() const
Definition: System.h:1101
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:953
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:1006
Real getNormOnExit() const
Definition: System.h:1102
ProjectOptions & clearOption(Option opt)
Remove a given option from the set.
Definition: System.h:1022
RealizeOptions(Option opt)
Definition: System.h:1150
RealizeOptions & operator|=(Option opt)
Definition: System.h:1165
ProjectOptions & operator|=(Option opt)
Definition: System.h:1049
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:1116
void setOption(Option opt)
Definition: System.h:1159
Options for the handleEvent() method.
Definition: Event.h:265
Projection converged but was unable to achieve the required accuracy.
Definition: System.h:1078
This is a class to represent unique IDs for events in a type-safe way.