CudaPenalityContactForceField.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef SOFA_GPU_CUDA_CUDAPENALITYCONTACTFORCEFIELD_H
00026 #define SOFA_GPU_CUDA_CUDAPENALITYCONTACTFORCEFIELD_H
00027
00028 #include "CudaTypes.h"
00029 #include <sofa/component/forcefield/PenalityContactForceField.h>
00030 #include <sofa/gpu/cuda/CudaCollisionDetection.h>
00031
00032 namespace sofa
00033 {
00034
00035 namespace gpu
00036 {
00037
00038 namespace cuda
00039 {
00040
00041 }
00042
00043 }
00044
00045 namespace component
00046 {
00047
00048 namespace forcefield
00049 {
00050
00051 using sofa::gpu::cuda::CudaVec3fTypes;
00052
00053 template<>
00054 class PenalityContactForceField<CudaVec3fTypes> : public core::componentmodel::behavior::PairInteractionForceField<CudaVec3fTypes>
00055 {
00056 public:
00057 typedef CudaVec3fTypes DataTypes;
00058 typedef core::componentmodel::behavior::PairInteractionForceField<DataTypes> Inherit;
00059 typedef DataTypes DataTypes1;
00060 typedef DataTypes DataTypes2;
00061 typedef DataTypes::VecCoord VecCoord;
00062 typedef DataTypes::VecDeriv VecDeriv;
00063 typedef DataTypes::Coord Coord;
00064 typedef DataTypes::Deriv Deriv;
00065 typedef Coord::value_type Real;
00066 typedef core::componentmodel::behavior::MechanicalState<DataTypes> MechanicalState;
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082 sofa::gpu::cuda::CudaVector<sofa::defaulttype::Vec4f> contacts;
00083 sofa::gpu::cuda::CudaVector<float> pen;
00084
00085
00086
00087
00088
00089
00090 PenalityContactForceField(MechanicalState* object1, MechanicalState* object2)
00091 : Inherit(object1, object2)
00092 {
00093 }
00094
00095 PenalityContactForceField()
00096 {
00097 }
00098
00099 void clear(int reserve = 0);
00100
00101 void addContact(int m1, int m2, const Deriv& norm, Real dist, Real ks, Real mu_s = 0.0f, Real mu_v = 0.0f, int oldIndex = 0);
00102
00103 void setContacts(Real distance, Real ks, sofa::core::componentmodel::collision::GPUDetectionOutputVector* outputs, bool useDistance, defaulttype::Mat3x3f* normXForm = NULL);
00104
00105 virtual void addForce(VecDeriv& f1, VecDeriv& f2, const VecCoord& x1, const VecCoord& x2, const VecDeriv& v1, const VecDeriv& v2);
00106
00107 virtual void addDForce(VecDeriv& df1, VecDeriv& df2, const VecDeriv& dx1, const VecDeriv& dx2, double kFactor, double bFactor);
00108
00109 virtual double getPotentialEnergy(const VecCoord&, const VecCoord&);
00110
00111 void draw();
00112 };
00113
00114 }
00115
00116 }
00117
00118 }
00119
00120 #endif