LevelSetLiquidSolver3.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: LevelSetLiquidSolver3.h
3 > Project Name: CubbyFlow
4 > Author: Dongmin Kim
5 > Purpose: Level set based 3-D liquid solver.
6 > Created Time: 2017/09/06
7 > Copyright (c) 2018, Dongmin Kim
8 *************************************************************************/
9 #ifndef CUBBYFLOW_LEVEL_SET_LIQUID_SOLVER3_H
10 #define CUBBYFLOW_LEVEL_SET_LIQUID_SOLVER3_H
11 
14 
15 namespace CubbyFlow
16 {
29  {
30  public:
31  class Builder;
32 
35 
38  const Size3& resolution,
39  const Vector3D& gridSpacing,
40  const Vector3D& gridOrigin);
41 
43  virtual ~LevelSetLiquidSolver3();
44 
47 
50 
52  void SetLevelSetSolver(const LevelSetSolver3Ptr& newSolver);
53 
55  void SetMinReinitializeDistance(double distance);
56 
69  void SetIsGlobalCompensationEnabled(bool isEnabled);
70 
78  double ComputeVolume() const;
79 
81  static Builder GetBuilder();
82 
83  protected:
85  void OnBeginAdvanceTimeStep(double timeIntervalInSeconds) override;
86 
88  void OnEndAdvanceTimeStep(double timeIntervalInSeconds) override;
89 
91  void ComputeAdvection(double timeIntervalInSeconds) override;
92 
100  ScalarField3Ptr GetFluidSDF() const override;
101 
102  private:
103  size_t m_signedDistanceFieldId;
104  LevelSetSolver3Ptr m_levelSetSolver;
105  double m_minReinitializeDistance = 10.0;
106  bool m_isGlobalCompensationEnabled = false;
107  double m_lastKnownVolume = 0.0;
108 
109  void Reinitialize(double currentCFL);
110 
111  void ExtrapolateVelocityToAir(double currentCFL);
112 
113  void AddVolume(double volDiff);
114  };
115 
117  using LevelSetLiquidSolver3Ptr = std::shared_ptr<LevelSetLiquidSolver3>;
118 
122  class LevelSetLiquidSolver3::Builder final : public GridFluidSolverBuilderBase3<LevelSetLiquidSolver3::Builder>
123  {
124  public:
127 
130  };
131 }
132 
133 #endif
3-D vector class.
Definition: Vector3.h:26
void OnBeginAdvanceTimeStep(double timeIntervalInSeconds) override
Called at the beginning of the time-step.
LevelSetLiquidSolver3()
Default constructor.
Front-end to create LevelSetLiquidSolver3 objects step by step.
Definition: LevelSetLiquidSolver3.h:122
void SetMinReinitializeDistance(double distance)
Sets minimum reinitialization distance.
ScalarGrid3Ptr GetSignedDistanceField() const
Returns signed-distance field.
virtual ~LevelSetLiquidSolver3()
Destructor.
std::shared_ptr< ScalarField3 > ScalarField3Ptr
Shared pointer for the ScalarField3 type.
Definition: ScalarField3.h:44
void SetLevelSetSolver(const LevelSetSolver3Ptr &newSolver)
Sets the level set solver.
void SetIsGlobalCompensationEnabled(bool isEnabled)
Enables (or disables) global compensation feature flag.
LevelSetLiquidSolver3 Build() const
Builds LevelSetLiquidSolver3.
3-D point class.
Definition: Point3.h:26
ScalarField3Ptr GetFluidSDF() const override
Returns fluid region as a signed-distance field.
std::shared_ptr< ScalarGrid3 > ScalarGrid3Ptr
Shared pointer for the ScalarGrid3 type.
Definition: ScalarGrid3.h:179
Base class for grid-based fluid solver builder.
Definition: GridFluidSolver3.h:303
std::shared_ptr< LevelSetLiquidSolver3 > LevelSetLiquidSolver3Ptr
Shared pointer type for the LevelSetLiquidSolver3.
Definition: LevelSetLiquidSolver3.h:117
Level set based 3-D liquid solver.
Definition: LevelSetLiquidSolver3.h:28
static Builder GetBuilder()
Returns builder fox LevelSetLiquidSolver3.
Definition: pybind11Utils.h:24
Abstract base class for grid-based 3-D fluid solver.
Definition: GridFluidSolver3.h:33
void OnEndAdvanceTimeStep(double timeIntervalInSeconds) override
Called at the end of the time-step.
LevelSetLiquidSolver3Ptr MakeShared() const
Builds shared pointer of LevelSetLiquidSolver3 instance.
std::shared_ptr< LevelSetSolver3 > LevelSetSolver3Ptr
Shared pointer type for the LevelSetSolver3.
Definition: LevelSetSolver3.h:88
double ComputeVolume() const
Returns liquid volume measured by smeared Heaviside function.
void ComputeAdvection(double timeIntervalInSeconds) override
Customizes advection step.
LevelSetSolver3Ptr GetLevelSetSolver() const
Returns the level set solver.