Simbody 3.7
Loading...
Searching...
No Matches
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
41namespace SimTK {
42
43class 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
60public:
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;
105private:
106 const ContactGeometryImpl& geom;
107}; // class ParticleConSurfaceSystemGuts
108
109
110
112public:
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) {
134 updDefaultState().updU(guts.subsysIndex) = u;
135 updDefaultState().updQ(guts.subsysIndex) = q;
136 updDefaultState().updTime() = t;
137 }
138
139
140}; // class ParticleConSurfaceSystem
141
142
147
148
149} // namespace SimTK
150
151#endif /*SimTK_SIMBODY_PARTICLECONSURFACESYSTEM_H_*/
This file defines the BicubicSurface class, and the BicubicFunction class that uses it to create a tw...
Defines the ContactGeometry class and its API-visible local subclasses for individual contact shapes.
Includes internal headers providing declarations for the basic SimTK Core classes,...
This is a concrete Subsystem that is part of every System. It provides a variety of services for the ...
Definition System.h:910
This unique integer type is for selecting discrete variables.
Unique integer type for Subsystem-local, per-stage event indexing.
Definition ParticleConSurfaceSystem.h:44
void projectUImpl(State &, Vector &uErrEst, const ProjectOptions &options, ProjectResults &results) const override
ParticleConSurfaceSystemGuts * cloneImpl() const override
Definition ParticleConSurfaceSystem.h:72
int realizeTopologyImpl(State &) const override
void multiplyByNPInvTransposeImpl(const State &state, const Vector &fu, Vector &fq) const override
Definition ParticleConSurfaceSystem.h:93
SubsystemIndex getSubsysIndex() const
Definition ParticleConSurfaceSystem.h:68
void multiplyByNTransposeImpl(const State &state, const Vector &fq, Vector &fu) const override
Definition ParticleConSurfaceSystem.h:89
void multiplyByNImpl(const State &state, const Vector &u, Vector &dq) const override
Definition ParticleConSurfaceSystem.h:87
int realizeVelocityImpl(const State &) const override
int realizePositionImpl(const State &) const override
void multiplyByNPInvImpl(const State &state, const Vector &dq, Vector &u) const override
Definition ParticleConSurfaceSystem.h:91
ParticleConSurfaceSystemGuts(const ContactGeometryImpl &geom)
Definition ParticleConSurfaceSystem.h:61
int realizeAccelerationImpl(const State &) const override
bool prescribeQImpl(State &) const override
Definition ParticleConSurfaceSystem.h:97
int realizeModelImpl(State &) const override
int realizeInstanceImpl(const State &) const override
int realizeDynamicsImpl(const State &) const override
void projectQImpl(State &, Vector &qErrEst, const ProjectOptions &options, ProjectResults &results) const override
bool prescribeUImpl(State &) const override
Definition ParticleConSurfaceSystem.h:98
const ParticleConSurfaceSystem & getParticleConSurfaceSystem() const
Definition ParticleConSurfaceSystem.h:144
Definition ParticleConSurfaceSystem.h:111
ParticleConSurfaceSystem(const ContactGeometryImpl &geom)
Definition ParticleConSurfaceSystem.h:113
void setDefaultTimeAndState(Real t, const Vector &q, const Vector &u)
Definition ParticleConSurfaceSystem.h:132
const ParticleConSurfaceSystemGuts & getGuts() const
Definition ParticleConSurfaceSystem.h:122
ParticleConSurfaceSystemGuts & updGuts()
Definition ParticleConSurfaceSystem.h:127
Options for the advanced project() methods.
Definition System.h:950
Results for advanced users of project() methods.
Definition System.h:1067
Unique integer type for Subsystem-local qErr indexing.
Unique integer type for Subsystem-local q indexing.
This object is intended to contain all state information for a SimTK::System, except topological info...
Definition State.h:280
Vector & updQ(SubsystemIndex)
Real & updTime()
You can call these as long as System stage >= Model, but the stage will be backed up if necessary to ...
Vector & updU(SubsystemIndex)
Provide a unique integer type for identifying Subsystems.
SubsystemIndex getMySubsystemIndex() const
Return the SubsystemIndex within the containing System.
Definition SubsystemGuts.h:495
This is the declaration for the System::Guts class, the abstract object to which a System handle poin...
Definition SystemGuts.h:71
Guts(const String &name="<NONAME>", const String &version="0.0.0")
const System & getSystem() const
This is the base class that serves as the parent of all SimTK System objects; most commonly Simbody's...
Definition System.h:97
const Guts & getSystemGuts() const
Obtain a const reference to the System::Guts object to which this handle refers.
Definition System.h:872
void adoptSystemGuts(System::Guts *g)
Put new unowned Guts into this empty handle and take over ownership.
State & updDefaultState()
Don't use this; make a copy of the default state instead and modify your copy.
void setHasTimeAdvancedEvents(bool)
This determines whether this System wants to be notified whenever time advances irreversibly.
Guts & updSystemGuts()
Obtain a writable reference to the System::Guts object to which this handle refers.
Definition System.h:876
Unique integer type for Subsystem-local uDotErr indexing.
Unique integer type for Subsystem-local uErr indexing.
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
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