HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GAS_ExternalForces.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_ExternalForces.h ( GAS Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __GAS_ExternalForces__
12 #define __GAS_ExternalForces__
13 
14 #include "GAS_API.h"
15 
16 #include <SIM/SIM_VectorField.h>
17 #include "GAS_SubSolver.h"
18 #include "GAS_Utils.h"
19 
20 class SIM_ForceResolver;
21 
23 {
24 public:
25  GET_DATA_FUNC_S(GAS_NAME_SURFACE, SurfaceName);
26  GET_DATA_FUNC_S(GAS_NAME_DENSITY, DensityName);
27  GET_DATA_FUNC_S(GAS_NAME_VELOCITY, VelocityName);
28  GET_DATA_FUNC_S(GAS_NAME_GEOMETRY, GeometryName);
29  GET_DATA_FUNC_S(GAS_NAME_PTGROUP, PointGroupName);
30  GET_DATA_FUNC_S("forcenames", ForceNames);
31  GET_DATA_FUNC_B("scalebysurface", ScaleBySurface);
32  GET_DATA_FUNC_B("scalebydensity", ScaleByDensity);
33  GET_DATA_FUNC_I("scaletype", ScaleType);
34  GET_DATA_FUNC_B("computev", ComputeVelocity);
35  GET_DATA_FUNC_B("stabledrag", StableDrag);
36 
39 
40  // Different ways of scaling the forces. Needed so that forces
41  // can be scaled using density rather than mass in SPH simulations.
42  enum ScaleMethod {
45  NONE
46  };
47 
48 protected:
49  explicit GAS_ExternalForces(const SIM_DataFactory *factory);
50  virtual ~GAS_ExternalForces();
51 
52  /// Adds to the velocity field the effect of all forces at that point.
53  /// Unit density is currently assumed.
54  /// Only incorpreates the external simulation forces. Internal
55  /// gas forces are handled elsewher.
56  virtual bool solveGasSubclass(SIM_Engine &engine,
57  SIM_Object *obj,
58  SIM_Time time,
59  SIM_Time timestep);
60 
61 protected:
62  void applyForcesToField(SIM_Object *obj,
63  const SIM_ConstDataArray &forces,
64  SIM_VectorField *velocity,
65  const SIM_ScalarField *surface,
66  const SIM_ScalarField *density,
67  SIM_Time timestep);
68 
69  struct applyParms
70  {
75  SIM_RawField *vel[3];
79  };
80 
81  THREADED_METHOD2(GAS_ExternalForces, parms.velocity->getXField()->shouldMultiThread(),
82  applyForceResolversToField,
83  const applyParms &, parms,
84  const UT_ValArray<SIM_ForceResolver *> &, forceresolvers)
85  void applyForceResolversToFieldPartial(
86  const applyParms &parms,
87  const UT_ValArray<SIM_ForceResolver *> &forceresolvers,
88  const UT_JobInfo &info);
89 
90 
91  void applyForcesToGeo(SIM_Object *obj,
92  const SIM_ConstDataArray &forces,
93  GU_Detail *gdp,
94  const GA_PointGroup *ptgrp,
95  SIM_Time timestep);
96 
97  THREADED_METHOD5(GAS_ExternalForces, gdp->getNumPoints() > 2048,
98  applyForceResolversToGeo,
99  SIM_Object *, obj,
100  GU_Detail *, gdp,
101  const GA_PointGroup *, ptgrp,
103  const UT_ValArray<SIM_ForceResolver *> &, forceresolvers)
104  void applyForceResolversToGeoPartial(SIM_Object *obj,
105  GU_Detail *gdp,
106  const GA_PointGroup *ptgrp,
107  SIM_Time timestep,
108  const UT_ValArray<SIM_ForceResolver *> &forceresolvers,
109  const UT_JobInfo &info);
110 
112  parms.velocity->getXField()->shouldMultiThread(),
113  addBackField,
114  const applyParms &, parms,
115  int, axis);
116  void addBackFieldPartial(const applyParms &parms,
117  int axis,
118  const UT_JobInfo &info);
119 
120 private:
121  static const SIM_DopDescription *getDopDescription();
122 
126  "Gas External Forces",
127  getDopDescription());
128 };
129 
130 #endif
131 
#define DECLARE_STANDARD_GETCASTTOTYPE()
Definition: SIM_DataUtils.h:45
const GA_PointGroup * ptgrp
#define GAS_NAME_GEOMETRY
Definition: GAS_Utils.h:28
#define GAS_NAME_USETIMESTEP
Definition: GAS_Utils.h:37
#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 GAS_NAME_DENSITY
Definition: GAS_Utils.h:23
#define GAS_NAME_VELOCITY
Definition: GAS_Utils.h:40
#define DECLARE_DATAFACTORY(DataClass, SuperClass, Description, DopParms)
Definition: SIM_DataUtils.h:58
#define GET_DATA_FUNC_I(DataName, FuncName)
#define THREADED_METHOD2(CLASSNAME, DOMULTI, METHOD, PARMTYPE1, PARMNAME1, PARMTYPE2, PARMNAME2)
#define THREADED_METHOD5(CLASSNAME, DOMULTI, METHOD, PARMTYPE1, PARMNAME1, PARMTYPE2, PARMNAME2, PARMTYPE3, PARMNAME3, PARMTYPE4, PARMNAME4, PARMTYPE5, PARMNAME5)
typedef int
Definition: png.h:1175
#define GET_DATA_FUNC_B(DataName, FuncName)
#define GET_DATA_FUNC_F(DataName, FuncName)
This class holds a three dimensional scalar field.
#define GAS_NAME_TIMESCALE
Definition: GAS_Utils.h:38
#define GAS_NAME_PTGROUP
Definition: GAS_Utils.h:32
#define GAS_NAME_SURFACE
Definition: GAS_Utils.h:36
This class holds a three dimensional vector field.
#define GET_DATA_FUNC_S(DataName, FuncName)
const GA_PointGroup SIM_Time timestep