Simbody  3.7
System.h
Go to the documentation of this file.
1 #ifndef SimTK_SimTKCOMMON_SYSTEM_H_
2 #define SimTK_SimTKCOMMON_SYSTEM_H_
3 
4 /* -------------------------------------------------------------------------- *
5  * Simbody(tm): SimTKcommon *
6  * -------------------------------------------------------------------------- *
7  * This is part of the SimTK biosimulation toolkit originating from *
8  * Simbios, the NIH National Center for Physics-Based Simulation of *
9  * Biological Structures at Stanford, funded under the NIH Roadmap for *
10  * Medical Research, grant U54 GM072970. See https://simtk.org/home/simbody. *
11  * *
12  * Portions copyright (c) 2006-13 Stanford University and the Authors. *
13  * Authors: Michael Sherman *
14  * Contributors: Peter Eastman *
15  * *
16  * Licensed under the Apache License, Version 2.0 (the "License"); you may *
17  * not use this file except in compliance with the License. You may obtain a *
18  * copy of the License at http://www.apache.org/licenses/LICENSE-2.0. *
19  * *
20  * Unless required by applicable law or agreed to in writing, software *
21  * distributed under the License is distributed on an "AS IS" BASIS, *
22  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
23  * See the License for the specific language governing permissions and *
24  * limitations under the License. *
25  * -------------------------------------------------------------------------- */
26 
27 #include "SimTKcommon/basics.h"
28 #include "SimTKcommon/Simmatrix.h"
32 
33 #include <cassert>
34 
35 namespace SimTK {
36 
37 class DecorativeGeometry;
38 class DefaultSystemSubsystem;
39 class ScheduledEventHandler;
40 class ScheduledEventReporter;
41 class TriggeredEventHandler;
42 class TriggeredEventReporter;
43 class RealizeOptions;
44 class RealizeResults;
45 class ProjectOptions;
46 class ProjectResults;
47 
48 //==============================================================================
49 // SYSTEM
50 //==============================================================================
98 public:
99 class Guts; // local; name is System::Guts
100 
101 
102 //------------------------------------------------------------------------------
126 
134 System& setUseUniformBackground(bool useUniformBackground);
135 
150 
159 
165 void setHasTimeAdvancedEvents(bool); // default=false
166 
184 //------------------------------------------------------------------------------
193 inline void addEventHandler(ScheduledEventHandler* handler);
196 inline void addEventHandler(TriggeredEventHandler* handler);
199 inline void addEventReporter(ScheduledEventReporter* handler) const;
202 inline void addEventReporter(TriggeredEventReporter* handler) const;
206 //------------------------------------------------------------------------------
235 const State& realizeTopology() const;
236 
251 const State& getDefaultState() const;
255 
274 void realizeModel(State& state) const;
275 
283 void realize(const State& state, Stage stage = Stage::HighestRuntime) const;
287 //------------------------------------------------------------------------------
368 void project(State& state, Real accuracy=-1) const;
369 
385 void projectQ(State& state, Real accuracy=-1) const;
386 
404 void projectU(State& state, Real accuracy=-1) const;
405 
441 void projectQ(State& state, Vector& qErrEst,
442  const ProjectOptions& options, ProjectResults& results) const;
443 
467 void projectU(State& state, Vector& uErrEst,
468  const ProjectOptions& options, ProjectResults& results) const;
469 
470 
488 void prescribe(State& state) const {
489  realize(state, Stage::Time);
490  prescribeQ(state);
491  realize(state, Stage::Position);
492  prescribeU(state);
493 }
494 
513 bool prescribeQ(State& state) const;
514 
530 bool prescribeU(State& state) const;
531 
537 void getFreeQIndex(const State& state, Array_<SystemQIndex>& freeQs) const;
538 
544 void getFreeUIndex(const State& state, Array_<SystemUIndex>& freeUs) const;
548 //------------------------------------------------------------------------------
587 void handleEvents(State& state,
588  Event::Cause cause,
589  const Array_<EventId>& eventIds,
590  const HandleEventsOptions& options,
591  HandleEventsResults& results) const;
592 
596 void reportEvents(const State& state,
597  Event::Cause cause,
598  const Array_<EventId>& eventIds) const;
599 
608 void calcEventTriggerInfo(const State& state,
609  Array_<EventTriggerInfo>& triggerInfo) const;
610 
617  Real& tNextEvent,
618  Array_<EventId>& eventIds,
619  bool includeCurrentTime) const;
620 
625  Real& tNextEvent,
626  Array_<EventId>& eventIds,
627  bool includeCurrentTime) const;
631 //------------------------------------------------------------------------------
660 void relax(State& state, Stage stage, Real accuracy=-1) const;
664 //------------------------------------------------------------------------------
685 void multiplyByN(const State& state, const Vector& u,
686  Vector& dq) const;
688 void multiplyByNTranspose(const State& state, const Vector& fq,
689  Vector& fu) const;
691 void multiplyByNPInv(const State& state, const Vector& dq,
692  Vector& u) const;
694 void multiplyByNPInvTranspose(const State& state, const Vector& fu,
695  Vector& fq) const;
699 //------------------------------------------------------------------------------
710 
711  // Realization
712 
717 
721 int getNumRealizeCalls() const;
722 
723  // Prescribed motion
724 
729 
730  // Projection
731 
739 int getNumQProjections() const;
743 
751 int getNumUProjections() const;
755 
756  // Event handling and reporting
757 
762 
766 
773 //------------------------------------------------------------------------------
780 System() : guts(0) { }
782 System(const System&);
788 
790 const String& getName() const;
792 const String& getVersion() const;
793 
797 
799 int getNumSubsystems() const;
810 
814 inline operator const Subsystem&() const; // implemented below
818 inline operator Subsystem&();
819 
825 
834 
841 
852 
862 
863 
866 bool isSameSystem(const System& otherSystem) const;
867 
868 
872 const Guts& getSystemGuts() const {assert(guts); return *guts;}
876 Guts& updSystemGuts() {assert(guts); return *guts;}
877 
882 
884 explicit System(System::Guts* g) : guts(g) { }
886 bool hasGuts() const {return guts!=0;}
887 
889 bool isOwnerHandle() const;
891 bool isEmptyHandle() const;
894 private:
895 friend class Guts;
896 // This is the only data member in this class. Also, any class derived from
897 // System must have *NO* data members at all (data goes in the Guts class).
898 Guts* guts;
899 };
900 
901 
911 public:
917  EventId createEventId(SubsystemIndex subsys, const State& state) const;
919  (SubsystemIndex subsys, const State& state,
920  const Array_<EventId>& allEvents,
921  Array_<EventId>& eventsForSubsystem) const;
922  // don't let doxygen see this private class
924  class Guts;
926 private:
927  const Guts& getGuts() const;
928  Guts& updGuts();
929 };
930 
932 { updDefaultSubsystem().addEventHandler(handler); }
934 { updDefaultSubsystem().addEventHandler(handler); }
939 
940 inline System::operator const Subsystem&() const {return getDefaultSubsystem();}
941 inline System::operator Subsystem&() {return updDefaultSubsystem();}
942 
943 
944 //==============================================================================
945 // PROJECT OPTIONS and PROJECT RESULTS
946 //==============================================================================
951 public:
952  enum Option {
954  None = 0x0000,
959  LocalOnly = 0x0001,
963  DontThrow = 0x0002,
966  UseInfinityNorm = 0x0004,
970  ForceProjection = 0x0008,
974  ForceFullNewton = 0x0010
975  };
976 
982  explicit ProjectOptions(Real accuracy)
983  { clear(); setRequiredAccuracy(accuracy); }
986  explicit ProjectOptions(Option opt)
987  { clear(); setOption(opt); }
988 
993  { optionSet=0; setAccuracyDefaults(); return *this; }
994 
1000  requiredAccuracy = accuracy > 0 ? accuracy
1002  return *this;
1003  }
1004 
1008  assert(0 < overshoot && overshoot <= 1);
1009  desiredOvershoot = overshoot;
1010  return *this;
1011  }
1012 
1016  assert(limit > 0);
1017  projectionLimit = limit;
1018  return *this;
1019  }
1020 
1024  { optionSet &= ~(unsigned)opt; return *this; }
1027  { optionSet |= (unsigned)opt; return *this; }
1028 
1030  Real getRequiredAccuracy() const {return requiredAccuracy;}
1033  Real getOvershootFactor() const {return desiredOvershoot;}
1035  Real getProjectionLimit() const {return projectionLimit;}
1036 
1037  bool isOptionSet(Option opt) const {return (optionSet&(unsigned)opt) != 0;}
1038 
1039  static Real getDefaultRequiredAccuracy() {return Real(1e-4);}
1040  static Real getDefaultOvershootFactor() {return Real(0.1);} //i.e., 1e-5
1041 
1042  // Set operators: not, or, and, set difference
1044  { optionSet |= opts.optionSet; return *this; }
1046  { optionSet &= opts.optionSet; return *this; }
1048  { optionSet &= ~opts.optionSet; return *this; }
1049 
1050  ProjectOptions& operator|=(Option opt) {setOption(opt); return *this;}
1051  ProjectOptions& operator-=(Option opt) {clearOption(opt); return *this;}
1052 
1053 private:
1054  Real requiredAccuracy;
1055  Real desiredOvershoot; // try for accuracy*overshoot
1056  Real projectionLimit; // abort if initial norm is worse than this
1057  unsigned optionSet;
1058 
1059  void setAccuracyDefaults() {
1060  requiredAccuracy = getDefaultRequiredAccuracy();
1061  desiredOvershoot = getDefaultOvershootFactor();
1062  projectionLimit = Infinity; // we'll try from however far away
1063  }
1064 };
1065 
1068 public:
1070 
1071  enum Status {
1073  Invalid = -1,
1084  FailedToConverge = 2
1085  };
1086 
1090  m_exitStatus = Invalid;
1091  m_anyChangeMade = m_projectionLimitExceeded = false;
1092  m_numIterations = 0;
1093  m_worstError = -1;
1094  m_normOnEntrance = m_normOnExit = NaN;
1095  return *this;
1096  }
1097  bool isValid() const {return m_exitStatus != Invalid;}
1098  Status getExitStatus() const {return m_exitStatus;}
1099 
1100  bool getAnyChangeMade() const {assert(isValid());return m_anyChangeMade;}
1101  int getNumIterations() const {assert(isValid());return m_numIterations;}
1102  Real getNormOnEntrance() const {assert(isValid());return m_normOnEntrance;}
1103  Real getNormOnExit() const {assert(isValid());return m_normOnExit;}
1105  { assert(isValid());return m_worstError; }
1107  { assert(isValid());return m_projectionLimitExceeded; }
1108 
1110  { m_exitStatus=status; return *this; }
1112  { m_anyChangeMade=changeMade; return *this; }
1114  { m_projectionLimitExceeded=limitExceeded; return *this; }
1115  ProjectResults& setNumIterations(int numIterations)
1116  { m_numIterations=numIterations; return *this; }
1118  { m_normOnEntrance=norm; m_worstError=worstError; return *this; }
1120  { m_normOnExit=norm; return *this; }
1121 private:
1122  Status m_exitStatus;
1123  bool m_anyChangeMade;
1124  bool m_projectionLimitExceeded;
1125  int m_numIterations;
1126  int m_worstError; // index of worst error on entrance
1127  Real m_normOnEntrance; // in selected rms or infinity norm
1128  Real m_normOnExit;
1129 };
1130 
1131 
1132 
1133 //==============================================================================
1134 // REALIZE OPTIONS and REALIZE RESULTS
1135 //==============================================================================
1138  unsigned int optionSet;
1139  explicit RealizeOptions(unsigned o) : optionSet(o) { }
1140 public:
1141 
1142  enum Option {
1143  None = 0x00,
1144  DontThrow = 0x01
1145  };
1146 
1147 
1148  RealizeOptions() : optionSet(0) { }
1149 
1150  // This is an implicit conversion
1151  RealizeOptions(Option opt) : optionSet((unsigned)opt) { }
1152 
1153  // Implicit conversion to bool when needed
1154  operator bool() const {return optionSet != 0;}
1155  bool isEmpty() const {return optionSet==0;}
1156 
1157  bool isOptionSet(Option opt) const {return (optionSet&(unsigned)opt) != 0;}
1158  void clear() {optionSet=0;}
1159  void clearOption(Option opt) {optionSet &= ~(unsigned)opt;}
1160  void setOption (Option opt) {optionSet |= (unsigned)opt;}
1161 
1162  // Set operators: or, and
1163  RealizeOptions& operator|=(RealizeOptions opts) {optionSet |= opts.optionSet; return *this;}
1164  RealizeOptions& operator&=(RealizeOptions opts) {optionSet &= opts.optionSet; return *this;}
1165 
1166  RealizeOptions& operator|=(Option opt) {setOption(opt); return *this;}
1167  RealizeOptions& operator-=(Option opt) {clearOption(opt); return *this;}
1168 };
1169 
1172 };
1173 
1174 
1175 
1176 
1177 } // namespace SimTK
1178 
1179 #endif // SimTK_SimTKCOMMON_SYSTEM_H_
SimTK::Stage::HighestRuntime
@ HighestRuntime
Definition: Stage.h:84
SimTK::System::addEventReporter
void addEventReporter(ScheduledEventReporter *handler) const
Add a ScheduledEventReporter to this System, which takes over ownership of the event reporter object.
Definition: System.h:935
SimTK::System::updSystemGuts
Guts & updSystemGuts()
Obtain a writable reference to the System::Guts object to which this handle refers.
Definition: System.h:876
SimTK::State
This object is intended to contain all state information for a SimTK::System, except topological info...
Definition: State.h:280
SimTK::System::addEventHandler
void addEventHandler(ScheduledEventHandler *handler)
Add a ScheduledEventHandler to this System, which takes over ownership of the event handler object.
Definition: System.h:931
SimTK::ProjectResults::getProjectionLimitExceeded
bool getProjectionLimitExceeded() const
Definition: System.h:1106
SimTK::RealizeOptions::operator|=
RealizeOptions & operator|=(RealizeOptions opts)
Definition: System.h:1163
SimTK::ProjectOptions::getDefaultOvershootFactor
static Real getDefaultOvershootFactor()
Definition: System.h:1040
SimTK::RealizeOptions::setOption
void setOption(Option opt)
Definition: System.h:1160
SimTK::ProjectOptions::LocalOnly
@ LocalOnly
This option says we expect the state to be close to a solution already and restricts projection to mo...
Definition: System.h:959
SimTK::System::getNumUErrorEstimateProjections
int getNumUErrorEstimateProjections() const
How many of the projectU() calls that did a constraint projection also projected an error estimate?
SimTK::ProjectOptions::setOption
ProjectOptions & setOption(Option opt)
Set a particular option.
Definition: System.h:1026
SimTK::System::multiplyByNTranspose
void multiplyByNTranspose(const State &state, const Vector &fq, Vector &fu) const
Calculate fu=~N*fq in O(n) time (very fast).
SimTK::System::prescribeU
bool prescribeU(State &state) const
This solver sets prescribed u's to their known values u=u(t,q) as a function of time and position var...
SimTK::DefaultSystemSubsystem::addEventHandler
void addEventHandler(TriggeredEventHandler *handler)
SimTK::System::getNumReportEventCalls
int getNumReportEventCalls() const
This is the total number of calls to reportEvents() regardless of the outcome.
SimTK::ProjectOptions::ForceProjection
@ ForceProjection
Normally a project() method will return immediately after evaluating the norm if it is already at or ...
Definition: System.h:970
SimTK::System::reportEvents
void reportEvents(const State &state, Event::Cause cause, const Array_< EventId > &eventIds) const
This method is similar to handleEvents(), but does not allow the State to be modified.
SimTK::Subsystem
A Subsystem is expected to be part of a larger System and to have interdependencies with other subsys...
Definition: Subsystem.h:55
SimTK::ProjectOptions::setProjectionLimit
ProjectOptions & setProjectionLimit(Real limit)
Project will fail immediately if the initial norm is greater than the projection limit,...
Definition: System.h:1015
SimTK::ProjectResults
Results for advanced users of project() methods.
Definition: System.h:1067
SimTK::System::isEmptyHandle
bool isEmptyHandle() const
Internal use only.
SimTK::ProjectResults::isValid
bool isValid() const
Definition: System.h:1097
SimTK::Event::Cause
These are all the possible causes for events.
Definition: Event.h:126
SimTK::ProjectResults::Status
Status
Definition: System.h:1071
SimTK::HandleEventsOptions
Options for the handleEvent() method.
Definition: Event.h:269
SimTK::System::projectQ
void projectQ(State &state, Vector &qErrEst, const ProjectOptions &options, ProjectResults &results) const
(Advanced) Project free q's so that position constraints are satisfied and remove the corresponding e...
SimTK::System::multiplyByNPInvTranspose
void multiplyByNPInvTranspose(const State &state, const Vector &fu, Vector &fq) const
Calculate fq=~pinv(N)*fu in O(n) time (very fast).
SimTK::System::getUseUniformBackground
bool getUseUniformBackground() const
Get the current setting of the "use uniform background" visualization hint.
SimTK::DefaultSystemSubsystem::addEventReporter
void addEventReporter(TriggeredEventReporter *handler) const
SimTK::System::projectU
void projectU(State &state, Vector &uErrEst, const ProjectOptions &options, ProjectResults &results) const
(Advanced) Project free u's so that velocity constraints are satisfied and remove the corresponding e...
SimTK::System::getNumHandleEventCalls
int getNumHandleEventCalls() const
This is the total number of calls to handleEvents() regardless of the outcome.
SimTK::DefaultSystemSubsystem::findSubsystemEventIds
void findSubsystemEventIds(SubsystemIndex subsys, const State &state, const Array_< EventId > &allEvents, Array_< EventId > &eventsForSubsystem) const
SimTK::ProjectOptions::UseInfinityNorm
@ UseInfinityNorm
Use the stricter infinity (max absolute value) norm rather than the default RMS norm to determine whe...
Definition: System.h:966
SimTK::System::getNumHandlerCallsThatChangedStage
int getNumHandlerCallsThatChangedStage(Stage) const
handleEvents() reports the lowest Stage it modified and we bump the counter for that Stage.
SimTK::System::projectQ
void projectQ(State &state, Real accuracy=-1) const
Set prescribed positions q=q(t) and attempt to satisfy position constraints by modifying the remainin...
SimTK::HandleEventsResults
Results returned by the handleEvent() method.
Definition: Event.h:345
SimTK::System::getUpDirection
CoordinateDirection getUpDirection() const
Get the current setting of the "up" direction hint.
SimTK::System::getFreeQIndex
void getFreeQIndex(const State &state, Array_< SystemQIndex > &freeQs) const
Return the indices of the q's in the given state that are free; that is, they are not affected by pre...
SimTK
This is a System that represents the dynamics of a particle moving along a smooth surface.
Definition: Assembler.h:37
SimTK::System::getName
const String & getName() const
Return the name assigned to this System (arbitrary).
Simmatrix.h
SimTK::ProjectResults::ProjectResults
ProjectResults()
Definition: System.h:1069
SimTK::NaN
const Real NaN
This is the IEEE "not a number" constant for this implementation of the default-precision Real type; ...
SimTK::ProjectOptions::operator|=
ProjectOptions & operator|=(Option opt)
Definition: System.h:1050
SimTK::System::getDefaultSubsystem
const DefaultSystemSubsystem & getDefaultSubsystem() const
Get read-only access to the default subsystem which is present in every system.
SimTK::System::isOwnerHandle
bool isOwnerHandle() const
Internal use only.
SimTK::System::getNumSubsystems
int getNumSubsystems() const
How may Subsystems are in here?
SimTK::ProjectResults::getWorstErrorOnEntrance
int getWorstErrorOnEntrance() const
Definition: System.h:1104
SimTK::System::setHasTimeAdvancedEvents
void setHasTimeAdvancedEvents(bool)
This determines whether this System wants to be notified whenever time advances irreversibly.
SimTK::RealizeOptions::isOptionSet
bool isOptionSet(Option opt) const
Definition: System.h:1157
SimTK::System::resetAllCountersToZero
void resetAllCountersToZero()
Zero out the statistics for this System.
SimTK::Subsystem::Guts
The abstract parent of all Subsystem implementation classes.
Definition: SubsystemGuts.h:47
SimTK::DefaultSystemSubsystem
This is a concrete Subsystem that is part of every System. It provides a variety of services for the ...
Definition: System.h:910
SimTK::ProjectResults::FailedToAchieveAccuracy
@ FailedToAchieveAccuracy
Projection converged but was unable to achieve the required accuracy.
Definition: System.h:1079
SimTK::System::getNumProjectQCalls
int getNumProjectQCalls() const
Return the total number of calls to projectQ(), regardless of whether the call did anything.
SimTK::ProjectOptions::getProjectionLimit
Real getProjectionLimit() const
Return the maximum norm we're allowed to attempt to correct.
Definition: System.h:1035
SimTK::ProjectResults::getNormOnExit
Real getNormOnExit() const
Definition: System.h:1103
SimTK::ProjectOptions::operator-=
ProjectOptions & operator-=(const ProjectOptions &opts)
Definition: System.h:1047
SimTK::System::System
System()
Default constructor creates an empty handle.
Definition: System.h:780
SimTK::ProjectResults::Invalid
@ Invalid
This object has not been filled in yet and holds no results.
Definition: System.h:1073
SimTK::ProjectResults::getExitStatus
Status getExitStatus() const
Definition: System.h:1098
SimTK::ProjectOptions::operator&=
ProjectOptions & operator&=(const ProjectOptions &opts)
Definition: System.h:1045
SimTK_SimTKCOMMON_EXPORT
#define SimTK_SimTKCOMMON_EXPORT
Definition: SimTKcommon/include/SimTKcommon/internal/common.h:224
SimTK::RealizeOptions
(NOT USED YET) Options for the advanced realize() methods.
Definition: System.h:1137
SimTK::System::getFreeUIndex
void getFreeUIndex(const State &state, Array_< SystemUIndex > &freeUs) const
Return the indices of the u's in the given state that are free; that is, they are not affected by pre...
SimTK::System::getDefaultState
const State & getDefaultState() const
This is available after realizeTopology(), and will throw an exception if realizeTopology() has not b...
SimTK::DefaultSystemSubsystem::addEventHandler
void addEventHandler(ScheduledEventHandler *handler)
SimTK::System::getNumPrescribeQCalls
int getNumPrescribeQCalls() const
Return the total number of calls to the System's prescribeQ() method.
SimTK::System::adoptSystemGuts
void adoptSystemGuts(System::Guts *g)
Put new unowned Guts into this empty handle and take over ownership.
SimTK::StageVersion
long long StageVersion
This is the type to use for Stage version numbers that get incremented whenever a state variable chan...
Definition: Stage.h:44
SimTK::RealizeOptions::Option
Option
Definition: System.h:1142
SimTK::System::getNumPrescribeUCalls
int getNumPrescribeUCalls() const
Return the total number of calls to the System's prescribeU() method.
SimTK::System::adoptSubsystem
SubsystemIndex adoptSubsystem(Subsystem &child)
Take over ownership of the supplied subsystem and install it into the next free subsystem slot.
SimTK::System::getNumRealizeCalls
int getNumRealizeCalls() const
Return the total number of calls to realizeTopology(), realizeModel(), or realize(),...
SimTK::ProjectResults::setNormOnEntrance
ProjectResults & setNormOnEntrance(Real norm, int worstError)
Definition: System.h:1117
SimTK::System::getNumQProjections
int getNumQProjections() const
How many of the successful projectQ() calls actually did a constraint projection, rather than returni...
SimTK::System::System
System(const System &)
Copy constructor (untested).
SimTK::System::realizeTopology
const State & realizeTopology() const
The following call must be made after any topological change has been made to this System,...
SimTK::System::getNumFailedProjectUCalls
int getNumFailedProjectUCalls() const
Return the total number of calls to projectU() that failed.
SimTK::System::prescribeQ
bool prescribeQ(State &state) const
This solver sets prescribed q's to their known values q=q(t) as a function of time (and possibly earl...
SimTK::ProjectOptions::getOvershootFactor
Real getOvershootFactor() const
Return the factor by which a project() method should try to do better than the required accuracy.
Definition: System.h:1033
SimTK::ProjectResults::getNormOnEntrance
Real getNormOnEntrance() const
Definition: System.h:1102
SimTK::ProjectOptions::ProjectOptions
ProjectOptions()
Default constructor sets options to their default values.
Definition: System.h:978
SimTK::ScheduledEventReporter
ScheduledEventReporter is a subclass of EventReporter for events that occur at a particular time that...
Definition: EventReporter.h:72
SimTK::System::realize
void realize(const State &state, Stage stage=Stage::HighestRuntime) const
Realize the given state to the indicated stage.
SimTK::ProjectOptions::operator-=
ProjectOptions & operator-=(Option opt)
Definition: System.h:1051
SimTK::ProjectOptions::clear
ProjectOptions & clear()
Restore this object to its default-constructed state (no options selected, default accuracy and overs...
Definition: System.h:992
SimTK::ProjectResults::setProjectionLimitExceeded
ProjectResults & setProjectionLimitExceeded(bool limitExceeded)
Definition: System.h:1113
SimTK::System::projectU
void projectU(State &state, Real accuracy=-1) const
Set prescribed velocities u=u(t,q) and attempt to satisfy velocity constraints by modifying the remai...
SimTK::ProjectResults::setNumIterations
ProjectResults & setNumIterations(int numIterations)
Definition: System.h:1115
SimTK::ProjectOptions::setOvershootFactor
ProjectOptions & setOvershootFactor(Real overshoot)
Project will attempt to reach accuracy*overshoot but settle for just accuracy.
Definition: System.h:1007
SimTK::System::getDefaultLengthScale
Real getDefaultLengthScale() const
Get the currently-set value for the default length scale, 1 length unit if it has never been set.
SimTK::ProjectOptions::ForceFullNewton
@ ForceFullNewton
A project() method is free to use an out-of-date Jacobian when solving the nonlinear system.
Definition: System.h:974
SimTK::System::setDefaultTimeScale
System & setDefaultTimeScale(Real tc)
(Advanced) This is a hint used for some default behaviors, such as determining an initial step size f...
SimTK::ProjectOptions::isOptionSet
bool isOptionSet(Option opt) const
Definition: System.h:1037
SimTK::TriggeredEventReporter
TriggeredEventReporter is a subclass of EventReporter for events that occur when some condition is sa...
Definition: EventReporter.h:96
SimTK::ProjectResults::getNumIterations
int getNumIterations() const
Definition: System.h:1101
SimTK::Stage
This class is basically a glorified enumerated type, type-safe and range checked but permitting conve...
Definition: Stage.h:66
SimTK::System::setDefaultLengthScale
System & setDefaultLengthScale(Real lc)
(Advanced) This is a hint that can be used to get a sense of what a "unit length" looks like for thi...
EventId
SimTK::System::~System
~System()
Destructor here will invoke the virtual destructor in the System::Guts class and thus clean up all un...
SimTK::RealizeOptions::RealizeOptions
RealizeOptions()
Definition: System.h:1148
SimTK::ProjectOptions::setRequiredAccuracy
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:999
SimTK::Stage::Position
@ Position
Spatial configuration available.
Definition: Stage.h:74
SimTK::System::multiplyByNPInv
void multiplyByNPInv(const State &state, const Vector &dq, Vector &u) const
Calculate u=pinv(N)*dq in O(n) time (very fast).
SimTK::ProjectResults::FailedToConverge
@ FailedToConverge
The Newton iterations were diverging.
Definition: System.h:1084
SimTK::ProjectOptions::Option
Option
Definition: System.h:952
SimTK::System::calcTimeOfNextScheduledEvent
void calcTimeOfNextScheduledEvent(const State &state, Real &tNextEvent, Array_< EventId > &eventIds, bool includeCurrentTime) const
This routine should be called to determine if and when there is an event scheduled to occur at a part...
Subsystem.h
SimTK::RealizeOptions::operator&=
RealizeOptions & operator&=(RealizeOptions opts)
Definition: System.h:1164
SimTK::ProjectOptions::clearOption
ProjectOptions & clearOption(Option opt)
Remove a given option from the set.
Definition: System.h:1023
SimTK::ProjectResults::setAnyChangeMade
ProjectResults & setAnyChangeMade(bool changeMade)
Definition: System.h:1111
SimTK::ProjectResults::getAnyChangeMade
bool getAnyChangeMade() const
Definition: System.h:1100
SimTK::System::multiplyByN
void multiplyByN(const State &state, const Vector &u, Vector &dq) const
Calculate dq=N*u in O(n) time (very fast).
SimTK::System::Guts
This is the declaration for the System::Guts class, the abstract object to which a System handle poin...
Definition: SystemGuts.h:71
SimTK::DefaultSystemSubsystem::addEventReporter
void addEventReporter(ScheduledEventReporter *handler) const
SimTK::System::invalidateSystemTopologyCache
void invalidateSystemTopologyCache() const
(Advanced) Mark the Topology stage of this system and all its subsystems "not realized....
SimTK::System::calcEventTriggerInfo
void calcEventTriggerInfo(const State &state, Array_< EventTriggerInfo > &triggerInfo) const
This routine provides the Integrator with information it needs about the individual event trigger fun...
SimTK::System::handleEvents
void handleEvents(State &state, Event::Cause cause, const Array_< EventId > &eventIds, const HandleEventsOptions &options, HandleEventsResults &results) const
This solver handles a set of events which a TimeStepper has denoted as having occurred at the given t...
SimTK::System::getDefaultTimeScale
Real getDefaultTimeScale() const
Get the currently-set value for the default time scale, 0.1 time units if it has never been set.
SimTK::System::System
System(System::Guts *g)
Constructor for internal use only.
Definition: System.h:884
SimTK::System::setUseUniformBackground
System & setUseUniformBackground(bool useUniformBackground)
This is a hint to visualization software that this System is best viewed against a uniform background...
SimTK::RealizeOptions::operator-=
RealizeOptions & operator-=(Option opt)
Definition: System.h:1167
SimTK::ProjectOptions::ProjectOptions
ProjectOptions(Option opt)
This constructor creates default options except one setting one non-default Option.
Definition: System.h:986
SimTK::System::setSystemTopologyCacheVersion
void setSystemTopologyCacheVersion(StageVersion topoVersion) const
(Really advanced) Set the current version number of this system's Topology cache information.
SimTK::System::getNumFailedProjectQCalls
int getNumFailedProjectQCalls() const
Return the total number of calls to projectQ() that failed.
SimTK::Stage::Time
@ Time
A new time has been realized.
Definition: Stage.h:73
SimTK::ProjectOptions::getRequiredAccuracy
Real getRequiredAccuracy() const
Return the current value for the required accuracy option.
Definition: System.h:1030
SimTK::TriggeredEventHandler
TriggeredEventHandler is a subclass of EventHandler for events that occur when some condition is sati...
Definition: EventHandler.h:109
SimTK::ProjectOptions
Options for the advanced project() methods.
Definition: System.h:950
SimTK::ProjectResults::clear
ProjectResults & clear()
Restore this object to its default-constructed state, with the return status set to Invalid.
Definition: System.h:1089
SimTK::Array_
The Array_<T> container class is a plug-compatible replacement for the C++ standard template library ...
Definition: Array.h:53
SimTK::RealizeOptions::clear
void clear()
Definition: System.h:1158
SimTK::RealizeOptions::clearOption
void clearOption(Option opt)
Definition: System.h:1159
SimTK::Real
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:606
SimTK::Infinity
const Real Infinity
This is the IEEE positive infinity constant for this implementation of the default-precision Real typ...
SimTK::System::hasTimeAdvancedEvents
bool hasTimeAdvancedEvents() const
Return the current value of the flag indicating whether this System wants an event generated whenever...
SubsystemIndex
SimTK::RealizeResults
(NOT USED YET) Results for advanced users of realize() methods.
Definition: System.h:1171
SimTK::System::calcDecorativeGeometryAndAppend
void calcDecorativeGeometryAndAppend(const State &, Stage, Array_< DecorativeGeometry > &) const
(Advanced) Generate all decorative geometry computable at a specific stage; this is useful for visual...
SimTK::ProjectOptions::operator|=
ProjectOptions & operator|=(const ProjectOptions &opts)
Definition: System.h:1043
SimTK::RealizeOptions::isEmpty
bool isEmpty() const
Definition: System.h:1155
SimTK::ProjectResults::setNormOnExit
ProjectResults & setNormOnExit(Real norm)
Definition: System.h:1119
SimTK::System::hasGuts
bool hasGuts() const
Return true if this System handle is not empty.
Definition: System.h:886
SimTK::Vector_< Real >
SimTK::System::getVersion
const String & getVersion() const
Return the version string assigned to this System (arbitrary).
SimTK::ProjectResults::Succeeded
@ Succeeded
The project() was successful either because no projection was necessary or projection was able to ach...
Definition: System.h:1076
basics.h
SimTK::DefaultSystemSubsystem::DefaultSystemSubsystem
DefaultSystemSubsystem(System &sys)
SimTK::RealizeOptions::DontThrow
@ DontThrow
Definition: System.h:1144
SimTK::String
SimTK::String is a plug-compatible std::string replacement (plus some additional functionality) inten...
Definition: String.h:62
SimTK::System
This is the base class that serves as the parent of all SimTK System objects; most commonly Simbody's...
Definition: System.h:97
SimTK::System::setUpDirection
System & setUpDirection(const CoordinateDirection &up)
This is a hint to other software as to which way this System's designer considers to be "up".
SimTK::RealizeOptions::None
@ None
Definition: System.h:1143
State.h
SimTK::System::updSubsystem
Subsystem & updSubsystem(SubsystemIndex)
Obtain writable access to a particular subsystem by its index.
SimTK::ProjectOptions::DontThrow
@ DontThrow
Normally failure to meet the accuracy requirements throws an exception.
Definition: System.h:963
SimTK::System::getSystemTopologyCacheVersion
StageVersion getSystemTopologyCacheVersion() const
(Advanced) Return the current version number of this system's Topology cache information.
SimTK::DefaultSystemSubsystem::createEventId
EventId createEventId(SubsystemIndex subsys, const State &state) const
SimTK::System::getSystemGuts
const Guts & getSystemGuts() const
Obtain a const reference to the System::Guts object to which this handle refers.
Definition: System.h:872
SimTK::System::getSubsystem
const Subsystem & getSubsystem(SubsystemIndex) const
Obtain read-only access to a particular subsystem by its index.
SimTK::RealizeOptions::operator|=
RealizeOptions & operator|=(Option opt)
Definition: System.h:1166
SimTK::System::relax
void relax(State &state, Stage stage, Real accuracy=-1) const
This optional method should modify fast variables at the given stage until they satisfy some relaxati...
SimTK::System::getNumQErrorEstimateProjections
int getNumQErrorEstimateProjections() const
How many of the projectQ() calls that did a constraint projection also projected an error estimate?
SimTK::System::prescribe
void prescribe(State &state) const
Set values for prescribed positions q and velocities u.
Definition: System.h:488
SimTK::System::project
void project(State &state, Real accuracy=-1) const
Apply prescribed motion and attempt to satisfy all position and velocity constraints by projecting th...
SimTK::System::calcTimeOfNextScheduledReport
void calcTimeOfNextScheduledReport(const State &state, Real &tNextEvent, Array_< EventId > &eventIds, bool includeCurrentTime) const
This routine is similar to calcTimeOfNextScheduledEvent(), but is used for "reporting events" which d...
SimTK::System::isSameSystem
bool isSameSystem(const System &otherSystem) const
There can be multiple handles referring to the same System::Guts object; they are considered to be th...
SimTK::ProjectResults::setExitStatus
ProjectResults & setExitStatus(Status status)
Definition: System.h:1109
SimTK::System::systemTopologyHasBeenRealized
bool systemTopologyHasBeenRealized() const
(Advanced) You can check whether realizeTopology() has been called since the last topological change ...
SimTK::System::operator=
System & operator=(const System &)
Copy assignment (untested).
SimTK::ProjectOptions::getDefaultRequiredAccuracy
static Real getDefaultRequiredAccuracy()
Definition: System.h:1039
SimTK::System::updDefaultState
State & updDefaultState()
Don't use this; make a copy of the default state instead and modify your copy.
SimTK::ProjectOptions::ProjectOptions
ProjectOptions(Real accuracy)
This constructor allows the default accuracy to be overridden while leaving all other options at thei...
Definition: System.h:982
SimTK::CoordinateDirection
A CoordinateDirection is a CoordinateAxis plus a direction indicating the positive or negative direct...
Definition: CoordinateAxis.h:244
SimTK::System::getNumRealizationsOfThisStage
int getNumRealizationsOfThisStage(Stage) const
Whenever the system was realized from Stage-1 to the indicated Stage, this counter is bumped.
SimTK::norm
float norm(const conjugate< float > &c)
Definition: conjugate.h:486
SimTK::ProjectOptions::None
@ None
Take all defaults.
Definition: System.h:954
SubsystemGuts.h
SimTK::System::getNumProjectUCalls
int getNumProjectUCalls() const
Return the total number of calls to projectU(), regardless of whether the call did anything.
SimTK::RealizeOptions::RealizeOptions
RealizeOptions(Option opt)
Definition: System.h:1151
SimTK::System::updDefaultSubsystem
DefaultSystemSubsystem & updDefaultSubsystem()
Get writable access to the default subsystem which is present in every system.
SimTK::System::getNumUProjections
int getNumUProjections() const
How many of the successful projectU() calls actually did a constraint projection, rather than returni...
SimTK::System::realizeModel
void realizeModel(State &state) const
Realize the model to be used for subsequent computations with the given state.
SimTK::ScheduledEventHandler
ScheduledEventHandler is a subclass of EventHandler for events that occur at a particular time that i...
Definition: EventHandler.h:84