Force.h

Go to the documentation of this file.
00001 #ifndef SimTK_SIMBODY_FORCE_H_
00002 #define SimTK_SIMBODY_FORCE_H_
00003 /* -------------------------------------------------------------------------- *
00004  *                      SimTK Core: SimTK Simbody(tm)                         *
00005  * -------------------------------------------------------------------------- *
00006  * This is part of the SimTK Core biosimulation toolkit originating from      *
00007  * Simbios, the NIH National Center for Physics-Based Simulation of           *
00008  * Biological Structures at Stanford, funded under the NIH Roadmap for        *
00009  * Medical Research, grant U54 GM072970. See https://simtk.org.               *
00010  *                                                                            *
00011  * Portions copyright (c) 2008 Stanford University and the Authors.           *
00012  * Authors: Peter Eastman                                                     *
00013  * Contributors:                                                              *
00014  *                                                                            *
00015  * Permission is hereby granted, free of charge, to any person obtaining a    *
00016  * copy of this software and associated documentation files (the "Software"), *
00017  * to deal in the Software without restriction, including without limitation  *
00018  * the rights to use, copy, modify, merge, publish, distribute, sublicense,   *
00019  * and/or sell copies of the Software, and to permit persons to whom the      *
00020  * Software is furnished to do so, subject to the following conditions:       *
00021  *                                                                            *
00022  * The above copyright notice and this permission notice shall be included in *
00023  * all copies or substantial portions of the Software.                        *
00024  *                                                                            *
00025  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR *
00026  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,   *
00027  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL    *
00028  * THE AUTHORS, CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,    *
00029  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR      *
00030  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE  *
00031  * USE OR OTHER DEALINGS IN THE SOFTWARE.                                     *
00032  * -------------------------------------------------------------------------- */
00033 
00034 #include "SimTKcommon.h"
00035 #include "simbody/internal/common.h"
00036 #include "simbody/internal/GeneralForceSubsystem.h"
00037 
00038 namespace SimTK {
00039 
00040 class SimbodyMatterSubsystem;
00041 class GeneralForceSubsystem;
00042 class MobilizedBody;
00043 class Force;
00044 class ForceImpl;
00045 
00046 // We only want the template instantiation to occur once. This symbol is defined in the SimTK core
00047 // compilation unit that defines the Force class but should not be defined any other time.
00048 #ifndef SimTK_SIMBODY_DEFINING_FORCE
00049     extern template class PIMPLHandle<Force, ForceImpl, true>;
00050 #endif
00051 
00057 class SimTK_SIMBODY_EXPORT Force : public PIMPLHandle<Force, ForceImpl, true> {
00058 public:
00059     Force() { }
00060     explicit Force(ForceImpl* r) : HandleBase(r) { }
00061 
00063     ForceIndex getForceIndex() const;
00064     
00065     class TwoPointLinearSpring;
00066     class TwoPointLinearDamper;
00067     class TwoPointConstantForce;
00068     class MobilityLinearSpring;
00069     class MobilityLinearDamper;
00070     class MobilityConstantForce;
00071     class ConstantForce;
00072     class ConstantTorque;
00073     class GlobalDamper;
00074     class UniformGravity;
00075     class Custom;
00076     
00077     class TwoPointLinearSpringImpl;
00078     class TwoPointLinearDamperImpl;
00079     class TwoPointConstantForceImpl;
00080     class MobilityLinearSpringImpl;
00081     class MobilityLinearDamperImpl;
00082     class MobilityConstantForceImpl;
00083     class ConstantForceImpl;
00084     class ConstantTorqueImpl;
00085     class GlobalDamperImpl;
00086     class UniformGravityImpl;
00087     class CustomImpl;
00088 };
00089 
00101 class SimTK_SIMBODY_EXPORT Force::TwoPointLinearSpring : public Force {
00102 public:
00114     TwoPointLinearSpring(GeneralForceSubsystem& forces, const MobilizedBody& body1, const Vec3& station1, const MobilizedBody& body2, const Vec3& station2, Real k, Real x0);
00115     SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(TwoPointLinearSpring, TwoPointLinearSpringImpl, Force);
00116 };
00117 
00130 class SimTK_SIMBODY_EXPORT Force::TwoPointLinearDamper: public Force {
00131 public:
00142     TwoPointLinearDamper(GeneralForceSubsystem& forces, const MobilizedBody& body1, const Vec3& station1, const MobilizedBody& body2, const Vec3& station2, Real damping);
00143     SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(TwoPointLinearDamper, TwoPointLinearDamperImpl, Force);
00144 };
00145 
00157 class SimTK_SIMBODY_EXPORT Force::TwoPointConstantForce: public Force {
00158 public:
00169     TwoPointConstantForce(GeneralForceSubsystem& forces, const MobilizedBody& body1, const Vec3& station1, const MobilizedBody& body2, const Vec3& station2, Real force);
00170     SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(TwoPointConstantForce, TwoPointConstantForceImpl, Force);
00171 };
00172 
00184 class SimTK_SIMBODY_EXPORT Force::MobilityLinearSpring : public Force {
00185 public:
00195     MobilityLinearSpring(GeneralForceSubsystem& forces, const MobilizedBody& body, int coordinate, Real k, Real q0);
00196     SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(MobilityLinearSpring, MobilityLinearSpringImpl, Force);
00197 };
00198 
00209 class SimTK_SIMBODY_EXPORT Force::MobilityLinearDamper : public Force {
00210 public:
00219     MobilityLinearDamper(GeneralForceSubsystem& forces, const MobilizedBody& body, int coordinate, Real damping);
00220     SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(MobilityLinearDamper, MobilityLinearDamperImpl, Force);
00221 };
00222 
00233 class SimTK_SIMBODY_EXPORT Force::MobilityConstantForce : public Force {
00234 public:
00243     MobilityConstantForce(GeneralForceSubsystem& forces, const MobilizedBody& body, int coordinate, Real force);
00244     SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(MobilityConstantForce, MobilityConstantForceImpl, Force);
00245 };
00246 
00254 class SimTK_SIMBODY_EXPORT Force::ConstantForce: public Force {
00255 public:
00256     ConstantForce(GeneralForceSubsystem& forces, const MobilizedBody& body, const Vec3& station, const Vec3& force);
00257     SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(ConstantForce, ConstantForceImpl, Force);
00258 };
00259 
00267 class SimTK_SIMBODY_EXPORT Force::ConstantTorque: public Force {
00268 public:
00269     ConstantTorque(GeneralForceSubsystem& forces, const MobilizedBody& body, const Vec3& torque);
00270     SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(ConstantTorque, ConstantTorqueImpl, Force);
00271 };
00272 
00287 class SimTK_SIMBODY_EXPORT Force::GlobalDamper : public Force {
00288 public:
00289     GlobalDamper(GeneralForceSubsystem& forces, const SimbodyMatterSubsystem& matter, Real damping);
00290     SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(GlobalDamper, GlobalDamperImpl, Force);
00291 };
00292 
00299 class SimTK_SIMBODY_EXPORT Force::UniformGravity : public Force {
00300 public:
00301     UniformGravity(GeneralForceSubsystem& forces, const SimbodyMatterSubsystem& matter, const Vec3& g, Real zeroHeight=0);
00302     Vec3 getGravity() const;
00303     void setGravity(const Vec3& g);
00304     Real getZeroHeight() const;
00305     void setZeroHeight(Real height);
00306     SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(UniformGravity, UniformGravityImpl, Force);
00307 };
00308 
00338 class SimTK_SIMBODY_EXPORT Force::Custom : public Force {
00339 public:
00340     class Implementation;
00349     Custom(GeneralForceSubsystem& forces, Implementation* implementation);
00350     SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(Custom, CustomImpl, Force);
00351 protected:
00352     const Implementation& getImplementation() const;
00353     Implementation& updImplementation();
00354 };
00355 
00356 class SimTK_SIMBODY_EXPORT Force::Custom::Implementation {
00357 public:
00358     virtual ~Implementation() { }
00370     virtual void calcForce(const State& state, Vector_<SpatialVec>& bodyForces, Vector_<Vec3>& particleForces, Vector& mobilityForces) const = 0;
00376     virtual Real calcPotentialEnergy(const State& state) const = 0;
00382     virtual bool dependsOnlyOnPositions() const {
00383         return false;
00384     }
00389     virtual void realizeTopology(State& state) const {
00390     }
00391     virtual void realizeModel(State& state) const {
00392     }
00393     virtual void realizeInstance(const State& state) const {
00394     }
00395     virtual void realizeTime(const State& state) const {
00396     }
00397     virtual void realizePosition(const State& state) const {
00398     }
00399     virtual void realizeVelocity(const State& state) const {
00400     }
00401     virtual void realizeDynamics(const State& state) const {
00402     }
00403     virtual void realizeAcceleration(const State& state) const {
00404     }
00405     virtual void realizeReport(const State& state) const {
00406     }
00408 };
00409 
00410 } // namespace SimTK
00411 
00412 #endif // SimTK_SIMBODY_FORCE_H_

Generated on Fri Sep 26 07:44:10 2008 for SimTKcore by  doxygen 1.5.6