Simbody  3.4 (development)
Force.h
Go to the documentation of this file.
00001 #ifndef SimTK_SIMBODY_FORCE_H_
00002 #define SimTK_SIMBODY_FORCE_H_
00003 
00004 /* -------------------------------------------------------------------------- *
00005  *                               Simbody(tm)                                  *
00006  * -------------------------------------------------------------------------- *
00007  * This is part of the SimTK biosimulation toolkit originating from           *
00008  * Simbios, the NIH National Center for Physics-Based Simulation of           *
00009  * Biological Structures at Stanford, funded under the NIH Roadmap for        *
00010  * Medical Research, grant U54 GM072970. See https://simtk.org/home/simbody.  *
00011  *                                                                            *
00012  * Portions copyright (c) 2008-13 Stanford University and the Authors.        *
00013  * Authors: Peter Eastman, Michael Sherman                                    *
00014  * Contributors:                                                              *
00015  *                                                                            *
00016  * Licensed under the Apache License, Version 2.0 (the "License"); you may    *
00017  * not use this file except in compliance with the License. You may obtain a  *
00018  * copy of the License at http://www.apache.org/licenses/LICENSE-2.0.         *
00019  *                                                                            *
00020  * Unless required by applicable law or agreed to in writing, software        *
00021  * distributed under the License is distributed on an "AS IS" BASIS,          *
00022  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   *
00023  * See the License for the specific language governing permissions and        *
00024  * limitations under the License.                                             *
00025  * -------------------------------------------------------------------------- */
00026 
00027 #include "SimTKcommon.h"
00028 #include "simbody/internal/common.h"
00029 #include "simbody/internal/GeneralForceSubsystem.h"
00030 
00031 namespace SimTK {
00032 
00033 class SimbodyMatterSubsystem;
00034 class GeneralForceSubsystem;
00035 class MobilizedBody;
00036 class Force;
00037 class ForceImpl;
00038 
00039 // We only want the template instantiation to occur once. This symbol is defined
00040 // in the SimTK core compilation unit that defines the Force class but should 
00041 // not be defined any other time.
00042 #ifndef SimTK_SIMBODY_DEFINING_FORCE
00043     extern template class PIMPLHandle<Force, ForceImpl, true>;
00044 #endif
00045 
00050 class SimTK_SIMBODY_EXPORT Force : public PIMPLHandle<Force, ForceImpl, true> {
00051 public:
00062     void disable(State&) const;
00066     void enable(State&) const;
00070     bool isDisabled(const State&) const;
00076     void setDisabledByDefault(bool shouldBeDisabled);
00080     bool isDisabledByDefault() const;
00128     void calcForceContribution(const State&          state,
00129                                Vector_<SpatialVec>&  bodyForces,
00130                                Vector_<Vec3>&        particleForces,
00131                                Vector&               mobilityForces) const;
00143     Real calcPotentialEnergyContribution(const State& state) const;
00152     Force() {}
00156     operator ForceIndex() const {return getForceIndex();}
00160     const GeneralForceSubsystem& getForceSubsystem() const;
00164     ForceIndex getForceIndex() const;
00167     class TwoPointLinearSpring;
00168     class TwoPointLinearDamper;
00169     class TwoPointConstantForce;
00170     class MobilityLinearSpring;
00171     class MobilityLinearDamper;
00172     class MobilityConstantForce;
00173     class MobilityLinearStop;
00174     class MobilityDiscreteForce;
00175     class DiscreteForces;
00176     class LinearBushing;
00177     class ConstantForce;
00178     class ConstantTorque;
00179     class GlobalDamper;
00180     class Thermostat;
00181     class UniformGravity;
00182     class Gravity;
00183     class Custom;
00184     
00185     class TwoPointLinearSpringImpl;
00186     class TwoPointLinearDamperImpl;
00187     class TwoPointConstantForceImpl;
00188     class MobilityLinearSpringImpl;
00189     class MobilityLinearDamperImpl;
00190     class MobilityConstantForceImpl;
00191     class MobilityLinearStopImpl;
00192     class MobilityDiscreteForceImpl;
00193     class DiscreteForcesImpl;
00194     class LinearBushingImpl;
00195     class ConstantForceImpl;
00196     class ConstantTorqueImpl;
00197     class GlobalDamperImpl;
00198     class ThermostatImpl;
00199     class UniformGravityImpl;
00200     class GravityImpl;
00201     class CustomImpl;
00202 
00203 protected:
00206     explicit Force(ForceImpl* r) : HandleBase(r) { }
00207 };
00208 
00209 
00221 class SimTK_SIMBODY_EXPORT Force::TwoPointLinearSpring : public Force {
00222 public:
00234     TwoPointLinearSpring(GeneralForceSubsystem& forces, const MobilizedBody& body1, const Vec3& station1, const MobilizedBody& body2, const Vec3& station2, Real k, Real x0);
00235     
00237     TwoPointLinearSpring() {}
00238 
00239     SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(TwoPointLinearSpring, TwoPointLinearSpringImpl, Force);
00240 };
00241 
00254 class SimTK_SIMBODY_EXPORT Force::TwoPointLinearDamper: public Force {
00255 public:
00266     TwoPointLinearDamper(GeneralForceSubsystem& forces, const MobilizedBody& body1, const Vec3& station1, const MobilizedBody& body2, const Vec3& station2, Real damping);
00267     
00269     TwoPointLinearDamper() {}
00270 
00271     SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(TwoPointLinearDamper, TwoPointLinearDamperImpl, Force);
00272 };
00273 
00285 class SimTK_SIMBODY_EXPORT Force::TwoPointConstantForce: public Force {
00286 public:
00297     TwoPointConstantForce(GeneralForceSubsystem& forces, const MobilizedBody& body1, const Vec3& station1, const MobilizedBody& body2, const Vec3& station2, Real force);
00298     
00300     TwoPointConstantForce() {}
00301 
00302     SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(TwoPointConstantForce, TwoPointConstantForceImpl, Force);
00303 };
00304 
00305 
00313 class SimTK_SIMBODY_EXPORT Force::ConstantForce: public Force {
00314 public:
00315     ConstantForce(GeneralForceSubsystem& forces, const MobilizedBody& body, const Vec3& station, const Vec3& force);
00316     
00318     ConstantForce() {}
00319 
00320     SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(ConstantForce, ConstantForceImpl, Force);
00321 };
00322 
00330 class SimTK_SIMBODY_EXPORT Force::ConstantTorque: public Force {
00331 public:
00332     ConstantTorque(GeneralForceSubsystem& forces, const MobilizedBody& body, const Vec3& torque);
00333     
00335     ConstantTorque() {}
00336 
00337     SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(ConstantTorque, ConstantTorqueImpl, Force);
00338 };
00339 
00354 class SimTK_SIMBODY_EXPORT Force::GlobalDamper : public Force {
00355 public:
00356     GlobalDamper(GeneralForceSubsystem& forces, const SimbodyMatterSubsystem& matter, Real damping);
00357     
00359     GlobalDamper() {}
00360 
00361     SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(GlobalDamper, GlobalDamperImpl, Force);
00362 };
00363 
00374 class SimTK_SIMBODY_EXPORT Force::UniformGravity : public Force {
00375 public:
00376     UniformGravity(GeneralForceSubsystem& forces, 
00377                    const SimbodyMatterSubsystem& matter, 
00378                    const Vec3& g, Real zeroHeight=0);
00379     
00381     UniformGravity() {}
00382 
00383     Vec3 getGravity() const;
00384     void setGravity(const Vec3& g);
00385     Real getZeroHeight() const;
00386     void setZeroHeight(Real height);
00387     SimTK_INSERT_DERIVED_HANDLE_DECLARATIONS(UniformGravity, UniformGravityImpl, Force);
00388 };
00389 
00390 } // namespace SimTK
00391 
00392 #endif // SimTK_SIMBODY_FORCE_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines