HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GAS_AdjustElasticity.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_AdjustElasticity.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). The purpose of
13  * this particular node is to dynamically adjust the
14  * lengths of springs between fluid particles.
15  *
16  */
17 
18 #ifndef __GAS_AdjustElasticity__
19 #define __GAS_AdjustElasticity__
20 
21 #include "GAS_API.h"
22 
23 #include "GAS_SubSolver.h"
24 #include "GAS_Utils.h"
25 #include "GAS_SPH.h"
26 
27 class GU_Detail;
28 class GAS_SPH;
29 
31 
33 {
34 public:
35  GET_DATA_FUNC_S(GAS_NAME_GEOMETRY, GeometryName);
36  GET_DATA_FUNC_B("doelasticity", DoElasticity);
37  GET_DATA_FUNC_F("plasticityconst", PlasticityConstant);
38  GET_DATA_FUNC_F("yieldratio", YieldRatio);
39  GET_DATA_FUNC_B("clampsprings", ClampNumSprings);
40  GET_DATA_FUNC_I("maxsprings", MaxSprings);
41  GET_DATA_FUNC_B("useid", UseID);
42 
43  bool shouldMultiThread() { return true; }
44 
45 protected:
46  explicit GAS_AdjustElasticity(const SIM_DataFactory *factory);
47  ~GAS_AdjustElasticity() override;
48 
49  /// Adds and removes springs between particles as necessary,
50  /// and also dynamically adjusts the lengths of springs
51  /// between particles.
52  bool solveGasSubclass(SIM_Engine &engine,
53  SIM_Object *obj,
54  SIM_Time time,
55  SIM_Time timestep) override;
56 
57  THREADED_METHOD5(GAS_AdjustElasticity, shouldMultiThread(),
58  adjustSprings, GU_Detail *, gdp,
59  const GAS_SPH &, sph,
60  fpreal, yieldratio,
61  fpreal, plasticityconstant,
62  SIM_Time, timestep)
63  void adjustSpringsPartial(GU_Detail *gdp,
64  const GAS_SPH &sph,
65  fpreal yieldratio,
66  fpreal plasticity,
67  SIM_Time timestep,
68  const UT_JobInfo &info);
69 
70 private:
71  bool myUseID;
72 
73  /// A similar function to the one above, but this writes
74  /// the spring information in to attribute handles.
75  void setSprings(GA_Offset ptoff,
76  const GA_RWHandleR &lengthattrib,
77  const GA_RWHandleI &indexattrib,
78  const UT_FloatArray &lengthlist,
79  const UT_IntArray &idxlist,
80  fpreal h, int initiallength);
81 
82 
83  /// A similar function to the one above that reads the
84  /// information from attribute handles. We assume that
85  /// the point has already been set in the handle.
86  void getSprings(GA_Offset ptoff,
87  const GA_ROHandleR &lengthattrib,
88  const GA_ROHandleI &indexattrib,
89  UT_FloatArray &weightmap,
91  const UT_Map<int,int> &weighthash);
92 
93  /// Adjusts the size of the spring attributes, if necessary.
94  void resizeSpringAttributes(GU_Detail *gdp, GAS_SPH &sph);
95 
96  /// Queries the sph structure at each point to determine the
97  /// number of entries required in the spring attributes.
98  int getAttribSize(GU_Detail *gdp, GAS_SPH &sph);
99 
100  /// Creates a float attribute of the given length to store
101  /// spring lengths.
102  void createLengthAttrib(GU_Detail *gdp, int size);
103 
104  /// Creates an int attribute of the given length to store
105  /// spring indices.
106  void createIndexAttrib(GU_Detail *gdp, int size);
107 
108  /// Grow these attributes to the given size.
109  void growLengthAttrib(GU_Detail *gdp,
110  int initialsize, int finalsize);
111  void growIndexAttrib(GU_Detail *gdp,
112  int initialsize, int finalsize);
113 
114  /// Reduce the given point list to the given maximum size.
115  /// The points closest to the reference point will be kept.
116  void sortAndCullPoints(const GA_Detail &detail,
117  GA_Offset ptoff,
118  GAS_SPH::gas_PointList &ptlist,
119  int newmax) const;
120 
121  static const SIM_DopDescription *getDopDescription();
122 
126  "Gas Adjust Elasticity",
127  getDopDescription());
128 };
129 
130 #endif
#define DECLARE_STANDARD_GETCASTTOTYPE()
Definition: SIM_DataUtils.h:50
GLsizei GLenum const void * indices
Definition: glcorearb.h:406
Unsorted map container.
Definition: UT_Map.h:107
#define GAS_NAME_GEOMETRY
Definition: GAS_Utils.h:30
void
Definition: png.h:1083
GT_API const UT_StringHolder time
#define GAS_API
Definition: GAS_API.h:10
virtual bool solveGasSubclass(SIM_Engine &engine, SIM_Object *obj, SIM_Time time, SIM_Time timestep)=0
#define DECLARE_DATAFACTORY(DataClass, SuperClass, Description, DopParms)
Definition: SIM_DataUtils.h:63
GA_Size GA_Offset
Definition: GA_Types.h:641
#define GET_DATA_FUNC_I(DataName, FuncName)
#define THREADED_METHOD5(CLASSNAME, DOMULTI, METHOD, PARMTYPE1, PARMNAME1, PARMTYPE2, PARMNAME2, PARMTYPE3, PARMNAME3, PARMTYPE4, PARMNAME4, PARMTYPE5, PARMNAME5)
GLsizeiptr size
Definition: glcorearb.h:664
GLfloat GLfloat GLfloat GLfloat h
Definition: glcorearb.h:2002
fpreal64 fpreal
Definition: SYS_Types.h:277
#define GET_DATA_FUNC_B(DataName, FuncName)
#define GET_DATA_FUNC_F(DataName, FuncName)
Container class for all geometry.
Definition: GA_Detail.h:96
#define const
Definition: zconf.h:214
#define GET_DATA_FUNC_S(DataName, FuncName)