HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GAS_Elasticity.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_Elasticity.h ( GAS Library, C++)
7  *
8  * COMMENTS: This node is intended to simulate elastic forces
9  * within a particle-based fluid using a simple
10  * spring setup. This is similar to the technique
11  * described in "Particle-based Viscoelastic Fluid
12  * Simultion" (see paper repository).
13  *
14  */
15 
16 #ifndef __GAS_Elasticity__
17 #define __GAS_Elasticity__
18 
19 #include "GAS_API.h"
20 
21 #include "GAS_SubSolver.h"
22 #include "GAS_Utils.h"
23 
24 #include <GA/GA_Handle.h>
25 #include <GA/GA_Types.h>
26 
27 #include <UT/UT_Map.h>
29 #include <UT/UT_ValArray.h>
30 
31 class GU_Detail;
32 class GAS_SPH;
33 class UT_String;
34 
36 {
37 public:
38  GET_DATA_FUNC_S(GAS_NAME_GEOMETRY, GeometryName);
39  GET_DATA_FUNC_F("elasticityconst", ElasticityConstant);
40  GET_DATA_FUNC_B("doelasticity", DoElasticity);
41  GET_DATA_FUNC_B("computev", ComputeVelocity);
42  GET_DATA_FUNC_B("useid", UseID);
43 
44  bool shouldMultiThread() { return true; }
45 
46 protected:
47  explicit GAS_Elasticity(const SIM_DataFactory *factory);
48  virtual ~GAS_Elasticity();
49 
50  /// Computes pairwise elastic forces between particles in the
51  /// given particle field and either adjusts the velocity
52  /// directly, or just adds to the force attribute.
53  virtual bool solveGasSubclass(SIM_Engine &engine,
54  SIM_Object *obj,
55  SIM_Time time,
56  SIM_Time timestep);
57 
58  THREADED_METHOD4(GAS_Elasticity, shouldMultiThread(), applySprings,
59  GU_Detail *, gdp,
60  const GAS_SPH &, sph,
61  fpreal, elasticityconst,
62  SIM_Time, timestep)
63  void applySpringsPartial(GU_Detail *gdp,
64  const GAS_SPH &sph,
65  fpreal elasticityconst, SIM_Time timestep,
66  const UT_JobInfo &info);
67 
68 private:
69  bool myUseID;
70 
71  /// This function reads spring length information from the
72  /// springlengths and springindices point attributes.
73  void getSprings(GA_Offset ptoff,
74  const GA_ROHandleR &lengthattrib,
75  const GA_ROHandleI &indexattrib,
76  UT_FloatArray &weightmap,
78  const UT_Map<int,int> &weighthash);
79 
80  /// Creates a float attribute of the given length to store
81  /// spring lengths.
82  void createLengthAttrib(GU_Detail *gdp, int size);
83 
84  /// Creates an int attribute of the given length to store
85  /// spring indices.
86  void createIndexAttrib(GU_Detail *gdp, int size);
87 
88  /// Grow these attributes to the given size.
89  void growLengthAttrib(GU_Detail *gdp,
90  int initialsize, int finalsize);
91  void growIndexAttrib(GU_Detail *gdp,
92  int initialsize, int finalsize);
93 
94  static const SIM_DopDescription *getDopDescription();
95 
99  "Gas Elasticity",
100  getDopDescription());
101 
102 };
103 
104 #endif
#define DECLARE_STANDARD_GETCASTTOTYPE()
Definition: SIM_DataUtils.h:45
GLsizei GLenum const void * indices
Definition: glcorearb.h:405
Unsorted map container.
Definition: UT_Map.h:83
#define GAS_NAME_GEOMETRY
Definition: GAS_Utils.h:28
GT_API const UT_StringHolder time
#define GAS_API
Definition: GAS_API.h:10
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
virtual bool solveGasSubclass(SIM_Engine &engine, SIM_Object *obj, SIM_Time time, SIM_Time timestep)=0
GLsizeiptr size
Definition: glcorearb.h:663
#define DECLARE_DATAFACTORY(DataClass, SuperClass, Description, DopParms)
Definition: SIM_DataUtils.h:58
GA_Size GA_Offset
Definition: GA_Types.h:617
bool shouldMultiThread()
#define THREADED_METHOD4(CLASSNAME, DOMULTI, METHOD, PARMTYPE1, PARMNAME1, PARMTYPE2, PARMNAME2, PARMTYPE3, PARMNAME3, PARMTYPE4, PARMNAME4)
double fpreal
Definition: SYS_Types.h:270
#define GET_DATA_FUNC_B(DataName, FuncName)
#define GET_DATA_FUNC_F(DataName, FuncName)
#define const
Definition: zconf.h:214
#define GET_DATA_FUNC_S(DataName, FuncName)