Simbody  3.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Force.h
Go to the documentation of this file.
1 #ifndef SimTK_SIMBODY_FORCE_H_
2 #define SimTK_SIMBODY_FORCE_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) 2008-13 Stanford University and the Authors. *
13  * Authors: Peter Eastman, 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"
30 
31 namespace SimTK {
32 
33 class SimbodyMatterSubsystem;
34 class GeneralForceSubsystem;
35 class MobilizedBody;
36 class Force;
37 class ForceImpl;
38 
39 // We only want the template instantiation to occur once. This symbol is defined
40 // in the SimTK core compilation unit that defines the Force class but should
41 // not be defined any other time.
42 #ifndef SimTK_SIMBODY_DEFINING_FORCE
43  extern template class PIMPLHandle<Force, ForceImpl, true>;
44 #endif
45 
51 public:
62  void disable(State&) const;
66  void enable(State&) const;
70  bool isDisabled(const State&) const;
76  void setDisabledByDefault(bool shouldBeDisabled);
80  bool isDisabledByDefault() const;
128  void calcForceContribution(const State& state,
129  Vector_<SpatialVec>& bodyForces,
130  Vector_<Vec3>& particleForces,
131  Vector& mobilityForces) const;
143  Real calcPotentialEnergyContribution(const State& state) const;
152  Force() {}
156  operator ForceIndex() const {return getForceIndex();}
160  const GeneralForceSubsystem& getForceSubsystem() const;
164  ForceIndex getForceIndex() const;
167  class TwoPointLinearSpring;
168  class TwoPointLinearDamper;
169  class TwoPointConstantForce;
170  class MobilityLinearSpring;
171  class MobilityLinearDamper;
172  class MobilityConstantForce;
173  class MobilityLinearStop;
174  class MobilityDiscreteForce;
175  class DiscreteForces;
176  class LinearBushing;
177  class ConstantForce;
178  class ConstantTorque;
179  class GlobalDamper;
180  class Thermostat;
181  class UniformGravity;
182  class Gravity;
183  class Custom;
184 
185  class TwoPointLinearSpringImpl;
186  class TwoPointLinearDamperImpl;
187  class TwoPointConstantForceImpl;
188  class MobilityLinearSpringImpl;
189  class MobilityLinearDamperImpl;
190  class MobilityConstantForceImpl;
191  class MobilityLinearStopImpl;
192  class MobilityDiscreteForceImpl;
193  class DiscreteForcesImpl;
194  class LinearBushingImpl;
195  class ConstantForceImpl;
196  class ConstantTorqueImpl;
197  class GlobalDamperImpl;
198  class ThermostatImpl;
199  class UniformGravityImpl;
200  class GravityImpl;
201  class CustomImpl;
202 
203 protected:
206  explicit Force(ForceImpl* r) : HandleBase(r) { }
207 };
208 
209 
222 public:
234  TwoPointLinearSpring(GeneralForceSubsystem& forces, const MobilizedBody& body1, const Vec3& station1, const MobilizedBody& body2, const Vec3& station2, Real k, Real x0);
235 
238 
240 };
241 
255 public:
266  TwoPointLinearDamper(GeneralForceSubsystem& forces, const MobilizedBody& body1, const Vec3& station1, const MobilizedBody& body2, const Vec3& station2, Real damping);
267 
270 
272 };
273 
286 public:
297  TwoPointConstantForce(GeneralForceSubsystem& forces, const MobilizedBody& body1, const Vec3& station1, const MobilizedBody& body2, const Vec3& station2, Real force);
298 
301 
303 };
304 
305 
314 public:
315  ConstantForce(GeneralForceSubsystem& forces, const MobilizedBody& body, const Vec3& station, const Vec3& force);
316 
319 
321 };
322 
331 public:
332  ConstantTorque(GeneralForceSubsystem& forces, const MobilizedBody& body, const Vec3& torque);
333 
336 
338 };
339 
355 public:
356  GlobalDamper(GeneralForceSubsystem& forces, const SimbodyMatterSubsystem& matter, Real damping);
357 
360 
362 };
363 
375 public:
377  const SimbodyMatterSubsystem& matter,
378  const Vec3& g, Real zeroHeight=0);
379 
382 
383  Vec3 getGravity() const;
384  void setGravity(const Vec3& g);
385  Real getZeroHeight() const;
386  void setZeroHeight(Real height);
388 };
389 
390 } // namespace SimTK
391 
392 #endif // SimTK_SIMBODY_FORCE_H_