Simbody  3.5
MultibodySystem.h
Go to the documentation of this file.
1 #ifndef SimTK_SIMBODY_MULTIBODY_SYSTEM_H_
2 #define SimTK_SIMBODY_MULTIBODY_SYSTEM_H_
3 
4 /* -------------------------------------------------------------------------- *
5  * Simbody(tm) *
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) 2005-12 Stanford University and the Authors. *
13  * Authors: 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 #include "SimTKcommon.h"
29 
30 #include <vector>
31 
32 namespace SimTK {
33 
34 class SimbodyMatterSubsystem;
35 class ForceSubsystem;
36 class DecorationSubsystem;
37 class GeneralContactSubsystem;
38 
39 
49 public:
52 
53  // Steals ownership of the source; returns subsystem ID number.
54  int addForceSubsystem(ForceSubsystem&);
55 
56  int setMatterSubsystem(SimbodyMatterSubsystem&);
57  const SimbodyMatterSubsystem& getMatterSubsystem() const;
58  SimbodyMatterSubsystem& updMatterSubsystem();
59  bool hasMatterSubsystem() const;
60 
61  int setDecorationSubsystem(DecorationSubsystem&);
62  const DecorationSubsystem& getDecorationSubsystem() const;
63  DecorationSubsystem& updDecorationSubsystem();
64  bool hasDecorationSubsystem() const;
65 
66  int setContactSubsystem(GeneralContactSubsystem&);
67  const GeneralContactSubsystem& getContactSubsystem() const;
68  GeneralContactSubsystem& updContactSubsystem();
69  bool hasContactSubsystem() const;
70 
71 
74  const Real calcPotentialEnergy(const State&) const;
77  const Real calcKineticEnergy(const State&) const;
80  Real calcEnergy(const State& s) const {
81  return calcPotentialEnergy(s)+calcKineticEnergy(s);
82  }
83 
84  // These methods are for use by our constituent subsystems to communicate
85  // with each other and with the MultibodySystem as a whole.
86 
87  // These cache entries belong to the global subsystem, which zeroes them at
88  // the start of the corresponding stage. They are filled in by the force
89  // subsystems when they are realized to each stage. Forces are cumulative
90  // from stage to stage, so the Dynamics stage includes everything. That may
91  // then be accessed by the matter subsystem in Acceleration stage to
92  // generate the accelerations.
93  const Vector_<SpatialVec>& getRigidBodyForces(const State&, Stage) const;
94  const Vector_<Vec3>& getParticleForces (const State&, Stage) const;
95  const Vector& getMobilityForces (const State&, Stage) const;
96 
97  // These routines are for use by force subsystems during Dynamics stage.
98  Vector_<SpatialVec>& updRigidBodyForces(const State&, Stage) const;
99  Vector_<Vec3>& updParticleForces (const State&, Stage) const;
100  Vector& updMobilityForces (const State&, Stage) const;
101 
102  // Private implementation.
104  class MultibodySystemRep& updRep();
105  const MultibodySystemRep& getRep() const;
106 protected:
107  explicit MultibodySystem(MultibodySystemRep*);
108 };
109 
110 
111 } // namespace SimTK
112 
113 #endif // SimTK_SIMBODY_MULTIBODY_SYSTEM_H_
This is the vector class intended to appear in user code for large, variable size column vectors...
Definition: BigMatrix.h:171
This is the top-level SimTK namespace into which all SimTK names are placed to avoid collision with o...
Definition: Assembler.h:37
This class is basically a glorified enumerated type, type-safe and range checked but permitting conve...
Definition: Stage.h:50
Every Simbody header and source file should include this header before any other Simbody header...
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:593
This object is intended to contain all state information for a SimTK::System, except topological info...
Definition: State.h:276
This class performs collision detection for use in contact modeling.
Definition: GeneralContactSubsystem.h:57
Includes internal headers providing declarations for the basic SimTK Core classes, including Simmatrix.
The job of the MultibodySystem class is to coordinate the activities of various subsystems which can ...
Definition: MultibodySystem.h:48
This is logically an abstract class, more specialized than "Subsystem" but not yet concrete...
Definition: ForceSubsystem.h:36
Real calcEnergy(const State &s) const
Calculate the total energy of the system.
Definition: MultibodySystem.h:80
#define SimTK_SIMBODY_EXPORT
Definition: Simbody/include/simbody/internal/common.h:72
This is the base class that serves as the parent of all SimTK System objects; most commonly Simbody&#39;s...
Definition: System.h:97
This subsystem contains the bodies ("matter") in the multibody system, the mobilizers (joints) that d...
Definition: SimbodyMatterSubsystem.h:133
#define SimTK_PIMPL_DOWNCAST(Derived, Parent)
Similar to the above but for private implementation abstract classes, that is, abstract class hierarc...
Definition: SimTKcommon/include/SimTKcommon/internal/common.h:580
This is the client-side handle class encapsulating the hidden implementation of the DecorationSubsyst...
Definition: DecorationSubsystem.h:54