00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __GAS_ParticleForces__
00023 #define __GAS_ParticleForces__
00024
00025 #include "GAS_API.h"
00026 #include "GAS_SubSolver.h"
00027 #include "GAS_Utils.h"
00028
00029 #include <UT/UT_ThreadedAlgorithm.h>
00030 #include <UT/UT_HashGrid.h>
00031
00032 #include <GEO/GEO_AttributeHandle.h>
00033
00034 class GU_Detail;
00035 class UT_FloatArray;
00036 class GAS_GrainObject;
00037 class GAS_GrainSphere;
00038
00039 class GAS_API GAS_ParticleForces : public GAS_SubSolver
00040 {
00041 public:
00042 GET_DATA_FUNC_S(GAS_NAME_GEOMETRY, GeometryName);
00043 GET_DATA_FUNC_B("dopressure", DoPressure);
00044 GET_DATA_FUNC_B("computev", ComputeVelocity);
00045 GET_DATA_FUNC_B("docollision", DoCollisions);
00046 GET_DATA_FUNC_B("usesdfvelocity", UseSDFVelocity);
00047 GET_DATA_FUNC_B("usegeovelocity", UseGEOVelocity);
00048
00049
00050 GET_DATA_FUNC_F("poissonratio", PoissonRatio);
00051 GET_DATA_FUNC_F("elasticrepulsion", ElasticRepulsion);
00052 GET_DATA_FUNC_F("repulsionstrength", RepulsionStrength);
00053 GET_DATA_FUNC_F("viscousdampening", ViscousDampening);
00054 GET_DATA_FUNC_F("dampeningstrength", DampeningStrength);
00055 GET_DATA_FUNC_F("contactresistance", ContactResistance);
00056 GET_DATA_FUNC_F("contactdampening", ContactDampening);
00057 GET_DATA_FUNC_F("rollingfriction", RollingFriction);
00058 GET_DATA_FUNC_F("objrollingfriction", ObjRollingFriction);
00059 GET_DATA_FUNC_F("objimpulseduration", ObjImpulseDuration );
00060 GET_DATA_FUNC_F("objtranslationimpulsefactor", ObjTranslationImpulseFactor );
00061 GET_DATA_FUNC_F("objrollingimpulsefactor", ObjRollingImpulseFactor );
00062
00063 bool shouldMultiThread() { return true; }
00064
00065 protected:
00066 explicit GAS_ParticleForces(const SIM_DataFactory *factory);
00067 virtual ~GAS_ParticleForces();
00068
00069
00070
00071
00072 virtual bool solveGasSubclass(SIM_Engine &engine,
00073 SIM_Object *obj,
00074 SIM_Time time,
00075 SIM_Time timestep);
00076
00077 virtual bool postSolveGasSubclass(SIM_Engine &engine,
00078 SIM_Object *obj,
00079 SIM_Time time,
00080 SIM_Time timestep);
00081
00082 protected:
00083
00084 void calcForces(SIM_Object *obj, GU_Detail *gdp,
00085 const UT_RefArray<GAS_GrainObject> &grains,
00086 SIM_Time timestep);
00087
00088 void updateContactDisplacement(SIM_Object *obj, GU_Detail *gdp,
00089 const UT_RefArray<GAS_GrainObject> &grains,
00090 SIM_Time timestep);
00091
00092
00093
00094
00095
00096 UT_Vector3 computeRepulsiveForce(const UT_Vector3 &p,
00097 fpreal overlap,
00098 const UT_Vector3 &nml,
00099 const UT_Vector3 &relvel,
00100 fpreal R, fpreal mass,
00101 fpreal beta, fpreal kr,
00102 fpreal alpha, fpreal kd,
00103 fpreal nu,
00104 fpreal mu_s,fpreal mu_d,
00105 fpreal dt ) const;
00106
00107 UT_Vector3 computeRepulsiveForcePP(const UT_Vector3 &p,
00108 fpreal overlap,
00109 const UT_Vector3 &nml,
00110 const UT_Vector3 &relvel,
00111 fpreal R, fpreal pmass,
00112 fpreal beta, fpreal kr,
00113 fpreal alpha, fpreal kd,
00114 fpreal nu, fpreal gamma,
00115 fpreal mu_s,fpreal mu_d,
00116 fpreal kc,
00117 SIM_Time timestep,
00118 UT_Vector3 &shearD ) const;
00119
00120 UT_Vector3 computeRepulsiveTorque(const UT_Vector3 &z,
00121 const UT_Vector3 &c1,
00122 const UT_Vector3 &force,
00123 const UT_Vector3 &nml,
00124 const UT_Vector3 &angvel,
00125 fpreal mu_r, fpreal pmass,
00126 SIM_Time timestep) const;
00127
00128 UT_Vector3 computeRepulsiveTorquePP(const UT_Vector3 &z,
00129 const UT_Vector3 &c1,
00130 const UT_Vector3 &force,
00131 const UT_Vector3 &nml,
00132 const UT_Vector3 &angvel,
00133 fpreal pscale, fpreal pmass,
00134 fpreal mu_r,
00135 fpreal dt) const;
00136
00137 UT_Vector3 getContactDisplacement( GEO_AttributeHandle &cg_gah,
00138 GEO_AttributeHandle &csj_gah,
00139 GEO_AttributeHandle &csk_gah,
00140 GEO_AttributeHandle &cd_gah,
00141 int cs1, int cg2, int cs2 ) const;
00142
00143 void setContactDisplacement( GEO_AttributeHandle &cg_gah,
00144 GEO_AttributeHandle &csj_gah,
00145 GEO_AttributeHandle &csk_gah,
00146 GEO_AttributeHandle &cd_gah,
00147 vector<int> cg,
00148 vector<int> csj,
00149 vector<int> csk,
00150 vector<UT_Vector3> sd ) const;
00151
00152 int adjustContactDisplacement( SIM_Object *obj,
00153 GU_Detail *gdp,
00154 const UT_RefArray<GAS_GrainObject> &grains,
00155 SIM_Time timestep );
00156
00157 void resizeContactGrainAttributes( GU_Detail *gdp,
00158 int initialsize,
00159 int finalsize) const;
00160
00161 void applyStiction( UT_Vector3 &totalforce,
00162 UT_Vector3 &totaltorque,
00163 const UT_Vector3 v1,
00164 const UT_Vector3 w1,
00165 const UT_Vector3 c1,
00166 const UT_Vector3 N,
00167 fpreal pscale, fpreal pmass,
00168 fpreal kv, fpreal kw,
00169 fpreal dt );
00170
00171 THREADED_METHOD2(GAS_ParticleForces, shouldMultiThread(), applyForces,
00172 GU_Detail *, gdp, SIM_Time, timestep)
00173 void applyForcesPartial(GU_Detail *gdp, SIM_Time timestep,
00174 const UT_JobInfo &info);
00175
00176 THREADED_METHOD1(GAS_ParticleForces, shouldMultiThread(), clearForces,
00177 GU_Detail *, gdp)
00178 void clearForcesPartial(GU_Detail *gdp,
00179 const UT_JobInfo &info);
00180
00181 void createGrainObjects(SIM_Object *obj, GU_Detail *gdp, UT_RefArray<GAS_GrainObject> &grains);
00182
00183 UT_HashGrid<const GAS_GrainSphere *> *buildHashGrid(const UT_RefArray<GAS_GrainObject> &grains);
00184
00185 private:
00186 static const SIM_DopDescription *getDopDescription();
00187
00188 DECLARE_STANDARD_GETCASTTOTYPE();
00189 DECLARE_DATAFACTORY(GAS_ParticleForces,
00190 GAS_SubSolver,
00191 "Gas Particle Forces",
00192 getDopDescription());
00193 };
00194
00195 #endif