HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GAS_SeedFluidParticles.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  *
7  * NAME: GAS_SeedFluidParticles.h ( GAS Library, C++)
8  *
9  * COMMENTS:
10  */
11 
12 #ifndef __GAS_SeedFluidParticles__
13 #define __GAS_SeedFluidParticles__
14 
15 #include <GAS/GAS_API.h>
16 
17 #include <GAS/GAS_SubSolver.h>
18 #include <GAS/GAS_Utils.h>
19 
20 #include <GU/GU_Detail.h>
21 
22 #include <GA/GA_PageHandle.h>
23 #include <GA/GA_PageIterator.h>
24 #include <GA/GA_SplittableRange.h>
25 
26 #include <SIM/SIM_GeometryCopy.h>
27 #include <SIM/SIM_IndexField.h>
29 #include <UT/UT_UniquePtr.h>
30 
32 
33 class GU_Detail;
34 class SIM_ScalarField;
35 class GU_PrimParticle;
36 
38 {
39 public:
40  GET_DATA_FUNC_S(GAS_NAME_GEOMETRY, GeometryName);
41 
42  GET_DATA_FUNC_S(GAS_NAME_SURFACE, SurfaceName);
43  GET_DATA_FUNC_S(GAS_NAME_SOURCE, SourceName);
44  GET_DATA_FUNC_S(GAS_NAME_COLLISION, CollisionName);
45  GET_DATA_FUNC_S(GAS_NAME_SINK, SinkName);
46 
47  GETSET_DATA_FUNCS_B("onlysourcing", OnlySourcing);
48 
49  GET_DATA_FUNC_S("newpointattrib", NewPointAttrib);
50  GET_DATA_FUNC_S("posinitialized", PosInitialized);
51 
52  GETSET_DATA_FUNCS_I("partpervoxel", ParticlesPerVoxel);
53  GETSET_DATA_FUNCS_F("birththreshold", BirthThreshold);
54  GETSET_DATA_FUNCS_F("deaththreshold", DeathThreshold);
55 
56  GETSET_DATA_FUNCS_B("donarrowband", DoNarrowband);
57  GETSET_DATA_FUNCS_F("narrowbandwidth", NarrowBandwidth);
58 
59  GETSET_DATA_FUNCS_F("domainbandwidth", DomainBandwidth);
60 
61  GETSET_DATA_FUNCS_B("oversamplebounds", OversampleBounds);
62  GETSET_DATA_FUNCS_F("oversampling", Oversampling);
63  GETSET_DATA_FUNCS_F("oversamplingbandwidth", OversamplingBandwidth);
64 
65  GETSET_DATA_FUNCS_B("dosourcescatter", DoSourceScatter);
66  GETSET_DATA_FUNCS_F("scatterdensity", ScatterDensity);
67 
69 
70  GETSET_DATA_FUNCS_I("slice", Slice);
71 
72 public:
73  explicit GAS_SeedFluidParticles(const SIM_DataFactory *factory);
74  ~GAS_SeedFluidParticles() override;
75 
76  bool solveGasSubclass(
77  SIM_Engine &engine,
78  SIM_Object *obj,
79  SIM_Time time,
80  SIM_Time timestep) override;
81 
82  // Stores all input parameters
84  {
85  ReseedingParms() = default;
86  ReseedingParms(ReseedingParms &&) = default;
87  ReseedingParms(const ReseedingParms &) = delete;
88 
89  GU_Detail *gdp = nullptr;
90 
91  openvdb::math::Transform::Ptr xform = nullptr;
92  openvdb::tools::PointIndexGrid::ConstPtr ptgrid = nullptr;
93 
94  const SIM_RawField *surface = nullptr;
95  const SIM_RawField *source = nullptr;
96  const SIM_RawField *collision = nullptr;
97  const SIM_RawField *sink = nullptr;
98  const SIM_RawField *domain = nullptr;
99 
100  bool onlysourcing = false;
101 
102  UT_String newpointattrib = "";
103  UT_String posinitialized = "";
104 
105  fpreal density = -1;
106  fpreal birththreshold = -1;
107  fpreal deaththreshold = -1;
108 
110 
111  bool donarrowband = false;
112  fpreal bandwidth = -1;
113 
114  fpreal domainbandwidth = 2;
115 
116  bool dooversample = false;
117  fpreal oversamplescale = -1;
118  fpreal oversamplebandwidth = -1;
119 
120  bool dosourcescatter = false;
121  fpreal scatterdensity = -1;
122 
123  fpreal seed = 0;
124 
125  const SIM_IndexField *slice = nullptr;
126  exint thisslice = -1;
127  };
128 
129  // Structure that stores points to be created and deleted in temporary
130  // buffers. Points can be added and deleted asynchornously.
132  {
133  public:
134  ReseedingWrangler(int numtiles);
135 
136  // remove copy constructor to make sure we don't make a copy
137  ReseedingWrangler(const ReseedingWrangler &) = delete;
138 
139  void addPoint(UT_Vector3F p, int tileid);
140  void addSourcedPoint(UT_Vector3F p, int tileid);
141  void delPoint(GA_Offset p, int tileid);
142 
143  void apply(const ReseedingParms &parms);
144 
145  private:
147  UT_Array<UT_UniquePtr<UT_Vector3Array>> new_sourced_points;
149  };
150 
153  parms.surface->shouldMultiThread(),
154  reseedParticles,
155  const ReseedingParms &,
156  parms,
158  wrangler)
159 
160  void reseedParticlesPartial(
161  const ReseedingParms &parms,
162  ReseedingWrangler &wrangler,
163  const UT_JobInfo &info) const;
164 
165 private:
166  static const SIM_DopDescription *getDopDescription();
167 
172  "Gas Seed Fluid Particles",
173  getDopDescription());
174 };
175 
176 #endif
#define DECLARE_STANDARD_GETCASTTOTYPE()
Definition: SIM_DataUtils.h:50
#define GAS_NAME_GEOMETRY
Definition: GAS_Utils.h:30
#define GETSET_DATA_FUNCS_B(DataName, FuncName)
GT_API const UT_StringHolder time
#define GAS_API
Definition: GAS_API.h:10
#define GAS_NAME_COLLISION
Definition: GAS_Utils.h:21
int64 exint
Definition: SYS_Types.h:125
virtual bool solveGasSubclass(SIM_Engine &engine, SIM_Object *obj, SIM_Time time, SIM_Time timestep)=0
This class holds a three dimensional scalar field.
#define GETSET_DATA_FUNCS_F(DataName, FuncName)
#define DECLARE_DATAFACTORY(DataClass, SuperClass, Description, DopParms)
Definition: SIM_DataUtils.h:63
GA_Size GA_Offset
Definition: GA_Types.h:641
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:803
#define GETSET_DATA_FUNCS_I(DataName, FuncName)
#define THREADED_METHOD2_CONST(CLASSNAME, DOMULTI, METHOD, PARMTYPE1, PARMNAME1, PARMTYPE2, PARMNAME2)
#define GAS_NAME_SINK
Definition: GAS_Utils.h:35
fpreal64 fpreal
Definition: SYS_Types.h:277
Space-partitioning acceleration structure for points. Partitions the points into voxels to accelerate...
#define SIM_NAME_SEED
Definition: SIM_Names.h:185
GA_API const UT_StringHolder pscale
This class holds a three dimensional scalar field.
#define GAS_NAME_SOURCE
Definition: GAS_Utils.h:36
#define GAS_NAME_SURFACE
Definition: GAS_Utils.h:38
#define GET_DATA_FUNC_S(DataName, FuncName)