Simbody  3.6
ParticleConSurfaceSystem.h
Go to the documentation of this file.
1 #ifndef SimTK_SIMBODY_PARTICLECONSURFACESYSTEM_H_
2 #define SimTK_SIMBODY_PARTICLECONSURFACESYSTEM_H_
3 
4 /* -------------------------------------------------------------------------- *
5  * Simbody(tm): SimTKmath *
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) 2012 Stanford University and the Authors. *
13  * Authors: Ian Stavness, Michael Sherman *
14  * Contributors: *
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 
36 #include "simmath/internal/BicubicSurface.h" // XXX compiler needed this
38 #include "SimTKcommon.h"
40 
41 namespace SimTK {
42 
43 class ParticleConSurfaceSystem;
46 
47  // TOPOLOGY STATE
48  SubsystemIndex subsysIndex;
49 
50  // TOPOLOGY CACHE
51 // mutable DiscreteVariableIndex massIndex, lengthIndex, gravityIndex;
52  DiscreteVariableIndex geodesicIndex, geometryIndex;
53  mutable QIndex q0;
54  mutable UIndex u0;
55  mutable QErrIndex qerr0;
56  mutable UErrIndex uerr0;
57  mutable UDotErrIndex udoterr0;
58  mutable EventTriggerByStageIndex event0;
59 
60 public:
61  ParticleConSurfaceSystemGuts(const ContactGeometryImpl& geom)
62  : Guts(), geom(geom) {
63  // Index types set themselves invalid on construction.
64  }
65 
67 
69  return subsysIndex;
70  }
71 
72  /*virtual*/ParticleConSurfaceSystemGuts* cloneImpl() const override {return new ParticleConSurfaceSystemGuts(*this);}
73 
75  // Implementation of continuous DynamicSystem virtuals //
77 
78  /*virtual*/int realizeTopologyImpl(State&) const override;
79  /*virtual*/int realizeModelImpl(State&) const override;
80  /*virtual*/int realizeInstanceImpl(const State&) const override;
81  /*virtual*/int realizePositionImpl(const State&) const override;
82  /*virtual*/int realizeVelocityImpl(const State&) const override;
83  /*virtual*/int realizeDynamicsImpl(const State&) const override;
84  /*virtual*/int realizeAccelerationImpl(const State&) const override;
85 
86  // qdot==u here so these are just copies
87  /*virtual*/void multiplyByNImpl(const State& state, const Vector& u,
88  Vector& dq) const override {dq=u;}
89  /*virtual*/void multiplyByNTransposeImpl(const State& state, const Vector& fq,
90  Vector& fu) const override {fu=fq;}
91  /*virtual*/void multiplyByNPInvImpl(const State& state, const Vector& dq,
92  Vector& u) const override {u=dq;}
93  /*virtual*/void multiplyByNPInvTransposeImpl(const State& state, const Vector& fu,
94  Vector& fq) const override {fq=fu;}
95 
96  // No prescribed motion.
97  /*virtual*/bool prescribeQImpl(State&) const override {return false;}
98  /*virtual*/bool prescribeUImpl(State&) const override {return false;}
99 
100  // No constraints.
101  /*virtual*/void projectQImpl(State&, Vector& qErrEst,
102  const ProjectOptions& options, ProjectResults& results) const override;
103  /*virtual*/void projectUImpl(State&, Vector& uErrEst,
104  const ProjectOptions& options, ProjectResults& results) const override;
105 private:
106  const ContactGeometryImpl& geom;
107 }; // class ParticleConSurfaceSystemGuts
108 
109 
110 
112 public:
113  ParticleConSurfaceSystem(const ContactGeometryImpl& geom) : System()
114  {
116  DefaultSystemSubsystem defsub(*this);
117  updGuts().subsysIndex = defsub.getMySubsystemIndex();
118 
120  }
121 
123  return SimTK_DYNAMIC_CAST_DEBUG<const ParticleConSurfaceSystemGuts&>
124  (getSystemGuts());
125  }
126 
128  return SimTK_DYNAMIC_CAST_DEBUG<ParticleConSurfaceSystemGuts&>
129  (updSystemGuts());
130  }
131 
132  void setDefaultTimeAndState(Real t, const Vector& q, const Vector& u) {
133  const ParticleConSurfaceSystemGuts& guts = getGuts();
134  updDefaultState().updU(guts.subsysIndex) = u;
135  updDefaultState().updQ(guts.subsysIndex) = q;
136  updDefaultState().updTime() = t;
137  }
138 
139 
140 }; // class ParticleConSurfaceSystem
141 
142 
143 inline const ParticleConSurfaceSystem& ParticleConSurfaceSystemGuts::
145  return static_cast<const ParticleConSurfaceSystem&>(getSystem());
146 }
147 
148 
149 } // namespace SimTK
150 
151 #endif /*SimTK_SIMBODY_PARTICLECONSURFACESYSTEM_H_*/
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
UErrIndex
QErrIndex
SimTK::ParticleConSurfaceSystemGuts::prescribeUImpl
bool prescribeUImpl(State &) const override
Definition: ParticleConSurfaceSystem.h:98
DiscreteVariableIndex
SimTK::ProjectResults
Results for advanced users of project() methods.
Definition: System.h:1067
UIndex
UDotErrIndex
SimTK::State::updU
Vector & updU(SubsystemIndex)
SimTK::ParticleConSurfaceSystemGuts
Definition: ParticleConSurfaceSystem.h:44
ContactGeometry.h
SimTK::State::updQ
Vector & updQ(SubsystemIndex)
SimTK::ParticleConSurfaceSystem::setDefaultTimeAndState
void setDefaultTimeAndState(Real t, const Vector &q, const Vector &u)
Definition: ParticleConSurfaceSystem.h:132
SimTK::ParticleConSurfaceSystemGuts::realizeAccelerationImpl
int realizeAccelerationImpl(const State &) const override
SimTK
This is a System that represents the dynamics of a particle moving along a smooth surface.
Definition: Assembler.h:37
SimTK::ParticleConSurfaceSystemGuts::multiplyByNPInvImpl
void multiplyByNPInvImpl(const State &state, const Vector &dq, Vector &u) const override
Definition: ParticleConSurfaceSystem.h:91
SimTK::ParticleConSurfaceSystemGuts::getSubsysIndex
SubsystemIndex getSubsysIndex() const
Definition: ParticleConSurfaceSystem.h:68
SimTK::ParticleConSurfaceSystem::ParticleConSurfaceSystem
ParticleConSurfaceSystem(const ContactGeometryImpl &geom)
Definition: ParticleConSurfaceSystem.h:113
SimTK::State::updTime
Real & updTime()
You can call these as long as System stage >= Model, but the stage will be backed up if necessary to ...
SimTK::ParticleConSurfaceSystemGuts::realizeTopologyImpl
int realizeTopologyImpl(State &) const override
SimTK::System::Guts::getSystem
const System & getSystem() const
SimTK::ParticleConSurfaceSystemGuts::projectQImpl
void projectQImpl(State &, Vector &qErrEst, const ProjectOptions &options, ProjectResults &results) const override
SimTK::System::setHasTimeAdvancedEvents
void setHasTimeAdvancedEvents(bool)
This determines whether this System wants to be notified whenever time advances irreversibly.
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
SimTKcommon.h
BicubicSurface.h
SimTK::System::adoptSystemGuts
void adoptSystemGuts(System::Guts *g)
Put new unowned Guts into this empty handle and take over ownership.
SimTK::ParticleConSurfaceSystemGuts::getParticleConSurfaceSystem
const ParticleConSurfaceSystem & getParticleConSurfaceSystem() const
Definition: ParticleConSurfaceSystem.h:144
SimTK::ParticleConSurfaceSystem::getGuts
const ParticleConSurfaceSystemGuts & getGuts() const
Definition: ParticleConSurfaceSystem.h:122
SimTK::ParticleConSurfaceSystemGuts::prescribeQImpl
bool prescribeQImpl(State &) const override
Definition: ParticleConSurfaceSystem.h:97
SimTK::ParticleConSurfaceSystemGuts::multiplyByNImpl
void multiplyByNImpl(const State &state, const Vector &u, Vector &dq) const override
Definition: ParticleConSurfaceSystem.h:87
QIndex
SimTK::ParticleConSurfaceSystemGuts::multiplyByNPInvTransposeImpl
void multiplyByNPInvTransposeImpl(const State &state, const Vector &fu, Vector &fq) const override
Definition: ParticleConSurfaceSystem.h:93
SimTK::ParticleConSurfaceSystemGuts::realizePositionImpl
int realizePositionImpl(const State &) const override
SimTK::ParticleConSurfaceSystemGuts::projectUImpl
void projectUImpl(State &, Vector &uErrEst, const ProjectOptions &options, ProjectResults &results) const override
EventTriggerByStageIndex
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::ParticleConSurfaceSystemGuts::ParticleConSurfaceSystemGuts
ParticleConSurfaceSystemGuts(const ContactGeometryImpl &geom)
Definition: ParticleConSurfaceSystem.h:61
SimTK::ProjectOptions
Options for the advanced project() methods.
Definition: System.h:950
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
SubsystemIndex
SimTK::ParticleConSurfaceSystemGuts::realizeInstanceImpl
int realizeInstanceImpl(const State &) const override
SimTK::Vector_< Real >
SimTK::ParticleConSurfaceSystem::updGuts
ParticleConSurfaceSystemGuts & updGuts()
Definition: ParticleConSurfaceSystem.h:127
SimTK::ParticleConSurfaceSystemGuts::multiplyByNTransposeImpl
void multiplyByNTransposeImpl(const State &state, const Vector &fq, Vector &fu) const override
Definition: ParticleConSurfaceSystem.h:89
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::ParticleConSurfaceSystemGuts::realizeModelImpl
int realizeModelImpl(State &) const override
SimTK::Subsystem::getMySubsystemIndex
SubsystemIndex getMySubsystemIndex() const
Return the SubsystemIndex within the containing System.
Definition: SubsystemGuts.h:495
SimTK::ParticleConSurfaceSystemGuts::realizeDynamicsImpl
int realizeDynamicsImpl(const State &) const override
SimTK::ParticleConSurfaceSystemGuts::realizeVelocityImpl
int realizeVelocityImpl(const State &) const override
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::updDefaultState
State & updDefaultState()
Don't use this; make a copy of the default state instead and modify your copy.
SystemGuts.h
SimTK::System::Guts::Guts
Guts(const String &name="<NONAME>", const String &version="0.0.0")
SimTK::ParticleConSurfaceSystem
Definition: ParticleConSurfaceSystem.h:111
SimTK::ParticleConSurfaceSystemGuts::cloneImpl
ParticleConSurfaceSystemGuts * cloneImpl() const override
Definition: ParticleConSurfaceSystem.h:72