Simbody  3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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 {return new ParticleConSurfaceSystemGuts(*this);}
73 
75  // Implementation of continuous DynamicSystem virtuals //
77 
78  /*virtual*/int realizeTopologyImpl(State&) const;
79  /*virtual*/int realizeModelImpl(State&) const;
80  /*virtual*/int realizeInstanceImpl(const State&) const;
81  /*virtual*/int realizePositionImpl(const State&) const;
82  /*virtual*/int realizeVelocityImpl(const State&) const;
83  /*virtual*/int realizeDynamicsImpl(const State&) const;
84  /*virtual*/int realizeAccelerationImpl(const State&) const;
85 
86  // qdot==u here so these are just copies
87  /*virtual*/void multiplyByNImpl(const State& state, const Vector& u,
88  Vector& dq) const {dq=u;}
89  /*virtual*/void multiplyByNTransposeImpl(const State& state, const Vector& fq,
90  Vector& fu) const {fu=fq;}
91  /*virtual*/void multiplyByNPInvImpl(const State& state, const Vector& dq,
92  Vector& u) const {u=dq;}
93  /*virtual*/void multiplyByNPInvTransposeImpl(const State& state, const Vector& fu,
94  Vector& fq) const {fq=fu;}
95 
96  // No prescribed motion.
97  /*virtual*/bool prescribeQImpl(State&) const {return false;}
98  /*virtual*/bool prescribeUImpl(State&) const {return false;}
99 
100  // No constraints.
101  /*virtual*/void projectQImpl(State&, Vector& qErrEst,
102  const ProjectOptions& options, ProjectResults& results) const;
103  /*virtual*/void projectUImpl(State&, Vector& uErrEst,
104  const ProjectOptions& options, ProjectResults& results) const;
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_*/
Vector & updQ(SubsystemIndex)
ParticleConSurfaceSystemGuts * cloneImpl() const
Definition: ParticleConSurfaceSystem.h:72
int realizeInstanceImpl(const State &) const
const System & getSystem() const
int realizePositionImpl(const State &) const
bool prescribeQImpl(State &) const
Definition: ParticleConSurfaceSystem.h:97
void multiplyByNPInvImpl(const State &state, const Vector &dq, Vector &u) const
Definition: ParticleConSurfaceSystem.h:91
Unique integer type for Subsystem-local uDotErr indexing.
SubsystemIndex getMySubsystemIndex() const
Return the SubsystemIndex within the containing System.
Definition: SubsystemGuts.h:493
Definition: ParticleConSurfaceSystem.h:111
Unique integer type for Subsystem-local u indexing.
This is the top-level SimTK namespace into which all SimTK names are placed to avoid collision with o...
Definition: Assembler.h:37
int realizeModelImpl(State &) const
Unique integer type for Subsystem-local uErr indexing.
Unique integer type for Subsystem-local qErr indexing.
bool prescribeUImpl(State &) const
Definition: ParticleConSurfaceSystem.h:98
Definition: ParticleConSurfaceSystem.h:44
This file defines the BicubicSurface class, and the BicubicFunction class that uses it to create a tw...
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:577
void adoptSystemGuts(System::Guts *g)
Put new unowned Guts into this *empty* handle and take over ownership.
Guts & updSystemGuts()
Obtain a writable reference to the System::Guts object to which this handle refers.
Definition: System.h:876
This object is intended to contain all state information for a SimTK::System, except topological info...
Definition: State.h:276
void multiplyByNImpl(const State &state, const Vector &u, Vector &dq) const
Definition: ParticleConSurfaceSystem.h:87
Results for advanced users of project() methods.
Definition: System.h:1067
Vector & updU(SubsystemIndex)
Options for the advanced project() methods.
Definition: System.h:950
Includes internal headers providing declarations for the basic SimTK Core classes, including Simmatrix.
void setDefaultTimeAndState(Real t, const Vector &q, const Vector &u)
Definition: ParticleConSurfaceSystem.h:132
void setHasTimeAdvancedEvents(bool)
This determines whether this System wants to be notified whenever time advances irreversibly.
void multiplyByNPInvTransposeImpl(const State &state, const Vector &fu, Vector &fq) const
Definition: ParticleConSurfaceSystem.h:93
SubsystemIndex getSubsysIndex() const
Definition: ParticleConSurfaceSystem.h:68
void projectQImpl(State &, Vector &qErrEst, const ProjectOptions &options, ProjectResults &results) const
const Guts & getSystemGuts() const
Obtain a const reference to the System::Guts object to which this handle refers.
Definition: System.h:872
ParticleConSurfaceSystem(const ContactGeometryImpl &geom)
Definition: ParticleConSurfaceSystem.h:113
Real & updTime()
You can call these as long as System stage >= Model, but the stage will be backed up if necessary to ...
Unique integer type for Subsystem-local q indexing.
void projectUImpl(State &, Vector &uErrEst, const ProjectOptions &options, ProjectResults &results) const
int realizeAccelerationImpl(const State &) const
This is the declaration for the System::Guts class, the abstract object to which a System handle poin...
Definition: SystemGuts.h:71
ParticleConSurfaceSystemGuts & updGuts()
Definition: ParticleConSurfaceSystem.h:127
ParticleConSurfaceSystemGuts(const ContactGeometryImpl &geom)
Definition: ParticleConSurfaceSystem.h:61
const ParticleConSurfaceSystem & getParticleConSurfaceSystem() const
Definition: ParticleConSurfaceSystem.h:144
This unique integer type is for selecting discrete variables.
void multiplyByNTransposeImpl(const State &state, const Vector &fq, Vector &fu) const
Definition: ParticleConSurfaceSystem.h:89
This is the base class that serves as the parent of all SimTK System objects; most commonly Simbody's...
Definition: System.h:97
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:910
int realizeTopologyImpl(State &) const
Defines the ContactGeometry class and its API-visible local subclasses for individual contact shapes...
Guts(const String &name="<NONAME>", const String &version="0.0.0")
int realizeDynamicsImpl(const State &) const
Unique integer type for Subsystem-local, per-stage event indexing.
State & updDefaultState()
Don't use this; make a copy of the default state instead and modify your copy.
const ParticleConSurfaceSystemGuts & getGuts() const
Definition: ParticleConSurfaceSystem.h:122
int realizeVelocityImpl(const State &) const