HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GAS_ParticleForces.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: GAS_ParticleForces.h ( GAS Library, C++)
7  *
8  * COMMENTS: This node is intended to produce the force model
9  * for dealing with small grains that are represented
10  * by instanced spheres.
11  *
12  */
13 
14 #ifndef __GAS_ParticleForces__
15 #define __GAS_ParticleForces__
16 
17 #include "GAS_API.h"
18 #include "GAS_SubSolver.h"
19 #include "GAS_Utils.h"
20 
22 #include <UT/UT_HashGrid.h>
23 
24 #include <vector>
25 
26 class GU_Detail;
27 class GAS_GrainObject;
28 class GAS_GrainSphere;
29 
31 {
32 public:
33  GET_DATA_FUNC_S(GAS_NAME_GEOMETRY, GeometryName);
34  GET_DATA_FUNC_B("dopressure", DoPressure);
35  GET_DATA_FUNC_B("computev", ComputeVelocity);
36  GET_DATA_FUNC_B("docollision", DoCollisions);
37  GET_DATA_FUNC_B("usesdfvelocity", UseSDFVelocity);
38  GET_DATA_FUNC_B("usegeovelocity", UseGEOVelocity);
39 
40  // Model and Material params
41  GET_DATA_FUNC_F("poissonratio", PoissonRatio);
42  GET_DATA_FUNC_F("elasticrepulsion", ElasticRepulsion);
43  GET_DATA_FUNC_F("repulsionstrength", RepulsionStrength);
44  GET_DATA_FUNC_F("viscousdampening", ViscousDampening);
45  GET_DATA_FUNC_F("dampeningstrength", DampeningStrength);
46  GET_DATA_FUNC_F("contactresistance", ContactResistance);
47  GET_DATA_FUNC_F("contactdampening", ContactDampening);
48  GET_DATA_FUNC_F("rollingfriction", RollingFriction);
49  GET_DATA_FUNC_F("objrollingfriction", ObjRollingFriction);
50  GET_DATA_FUNC_F("objimpulseduration", ObjImpulseDuration );
51  GET_DATA_FUNC_F("objtranslationimpulsefactor", ObjTranslationImpulseFactor );
52  GET_DATA_FUNC_F("objrollingimpulsefactor", ObjRollingImpulseFactor );
53  GET_DATA_FUNC_F("minbounce", MinBounce );
54 
55  bool shouldMultiThread() { return true; }
56 
57 protected:
58  explicit GAS_ParticleForces(const SIM_DataFactory *factory);
59  virtual ~GAS_ParticleForces();
60 
61  /// Computes a pressure force for the given particle field
62  /// and either adjusts the velocity directly, or just
63  /// adds to the force variable.
64  virtual bool solveGasSubclass(SIM_Engine &engine,
65  SIM_Object *obj,
66  SIM_Time time,
67  SIM_Time timestep);
68 
69  virtual bool postSolveGasSubclass(SIM_Engine &engine,
70  SIM_Object *obj,
71  SIM_Time time,
72  SIM_Time timestep);
73 
74 protected:
75 
76  void calcForces(SIM_Engine &engine, SIM_Object *obj, GU_Detail *gdp,
77  const UT_Array<GAS_GrainObject> &grains,
78  SIM_Time time,
79  SIM_Time timestep);
80 
81  void updateContactDisplacement(SIM_Object *obj, GU_Detail *gdp,
82  const UT_Array<GAS_GrainObject> &grains,
83  SIM_Time timestep);
84 
85  /// Compute the repulsive force between two particles.
86  /// p is the point of impact, nml the normalized normal of the impact
87  /// and relvel the relative velocity at the point of impact.
88 
89  UT_Vector3 computeRepulsiveForce(const UT_Vector3 &p,
90  fpreal overlap,
91  const UT_Vector3 &nml,
92  const UT_Vector3 &relvel,
94  fpreal beta, fpreal kr,
95  fpreal alpha, fpreal kd,
96  fpreal nu, fpreal bounce,
97  fpreal mu_s,fpreal mu_d,
98  fpreal dt ) const;
99 
100  UT_Vector3 computeRepulsiveForcePP(const UT_Vector3 &p,
101  fpreal overlap,
102  const UT_Vector3 &nml,
103  const UT_Vector3 &relvel,
104  fpreal R, fpreal pmass,
105  fpreal beta, fpreal kr,
106  fpreal alpha, fpreal kd,
107  fpreal nu, fpreal gamma,
108  fpreal bounce,
109  fpreal mu_s,fpreal mu_d,
110  fpreal kc,
111  SIM_Time timestep,
112  UT_Vector3 &shearD ) const;
113 
114  UT_Vector3 computeRepulsiveTorque(const UT_Vector3 &z,
115  const UT_Vector3 &c1,
116  const UT_Vector3 &force,
117  const UT_Vector3 &nml,
118  const UT_Vector3 &angvel,
119  fpreal pscale, fpreal pmass,
120  fpreal mu_r ) const;
121 
122  UT_Vector3 getContactDisplacement(
123  GA_Offset ptoff,
124  const GA_ROHandleI &cg_gah,
125  const GA_ROHandleI &csj_gah,
126  const GA_ROHandleI &csk_gah,
127  const GA_ROHandleF &cd_gah,
128  int cs1, int cg2, int cs2 ) const;
129 
130  void setContactDisplacement(
131  GA_Offset ptoff,
132  const GA_RWHandleI &cg_gah,
133  const GA_RWHandleI &csj_gah,
134  const GA_RWHandleI &csk_gah,
135  const GA_RWHandleF &cd_gah,
136  std::vector<int> cg,
137  std::vector<int> csj,
138  std::vector<int> csk,
139  std::vector<UT_Vector3> sd
140  ) const;
141 
142  int adjustContactDisplacement( SIM_Object *obj,
143  GU_Detail *gdp,
144  const UT_Array<GAS_GrainObject> &grains,
145  SIM_Time timestep );
146 
147  void resizeContactGrainAttributes( GU_Detail *gdp,
148  int initialsize,
149  int finalsize) const;
150 
151  void applyStiction( UT_Vector3 &totalforce,
152  UT_Vector3 &totaltorque,
153  const UT_Vector3 v1,
154  const UT_Vector3 w1,
155  const UT_Vector3 c1,
156  const UT_Vector3 N,
157  fpreal pscale, fpreal pmass,
158  fpreal kv, fpreal kw,
159  fpreal dt );
160 
161 
162  void createGrainObjects(SIM_Object *obj, GU_Detail *gdp, UT_Array<GAS_GrainObject> &grains);
163 
165 
166 private:
167  static const SIM_DopDescription *getDopDescription();
168 
172  "Gas Particle Forces",
173  getDopDescription());
174 };
175 
176 #endif
#define DECLARE_STANDARD_GETCASTTOTYPE()
Definition: SIM_DataUtils.h:45
#define GAS_NAME_GEOMETRY
Definition: GAS_Utils.h:28
#define GAS_API
Definition: GAS_API.h:10
GLdouble GLdouble GLdouble z
Definition: glcorearb.h:847
virtual bool solveGasSubclass(SIM_Engine &engine, SIM_Object *obj, SIM_Time time, SIM_Time timestep)=0
3D Vector class.
#define DECLARE_DATAFACTORY(DataClass, SuperClass, Description, DopParms)
Definition: SIM_DataUtils.h:58
GA_Size GA_Offset
Definition: GA_Types.h:617
GLfloat GLfloat GLfloat alpha
Definition: glcorearb.h:111
GA_API const UT_StringHolder mass
double fpreal
Definition: SYS_Types.h:263
#define GET_DATA_FUNC_B(DataName, FuncName)
#define GET_DATA_FUNC_F(DataName, FuncName)
GLfloat GLfloat v1
Definition: glcorearb.h:816
GA_API const UT_StringHolder pscale
GA_API const UT_StringHolder N
virtual bool postSolveGasSubclass(SIM_Engine &engine, SIM_Object *obj, SIM_Time time, SIM_Time timestep)
#define GET_DATA_FUNC_S(DataName, FuncName)