Loading...
Searching...
No Matches
LevelSetLiquidSolver2.hpp
Go to the documentation of this file.
1// This code is based on Jet framework.
2// Copyright (c) 2018 Doyub Kim
3// CubbyFlow is voxel-based fluid simulation engine for computer games.
4// Copyright (c) 2020 CubbyFlow Team
5// Core Part: Chris Ohk, Junwoo Hwang, Jihong Sin, Seungwoo Yoo
6// AI Part: Dongheon Cho, Minseo Kim
7// We are making my contributions/submissions to this project solely in our
8// personal capacity and are not conveying any rights to any intellectual
9// property of any third parties.
10
11#ifndef CUBBYFLOW_LEVEL_SET_LIQUID_SOLVER2_HPP
12#define CUBBYFLOW_LEVEL_SET_LIQUID_SOLVER2_HPP
13
16
17namespace CubbyFlow
18{
31{
32 public:
33 class Builder;
34
37
40 const Vector2D& gridSpacing,
41 const Vector2D& gridOrigin);
42
45
48
51
54
57
60
63
66
68 void SetMinReinitializeDistance(double distance);
69
83
92
95
98 void OnBeginAdvanceTimeStep(double timeIntervalInSeconds) override;
99
101 void OnEndAdvanceTimeStep(double timeIntervalInSeconds) override;
102
104 void ComputeAdvection(double timeIntervalInSeconds) override;
105
114
115 private:
116 void Reinitialize(double currentCFL);
117
118 void ExtrapolateVelocityToAir(double currentCFL);
119
120 void AddVolume(double volDiff);
121
122 size_t m_signedDistanceFieldId;
123 LevelSetSolver2Ptr m_levelSetSolver;
124 double m_minReinitializeDistance = 10.0;
125 bool m_isGlobalCompensationEnabled = false;
126 double m_lastKnownVolume = 0.0;
127};
128
131
145} // namespace CubbyFlow
146
147#endif
Abstract base class for grid-based 2-D fluid solver.
Definition GridFluidSolver2.hpp:36
Base class for grid-based fluid solver builder.
Definition GridFluidSolver2.hpp:316
Front-end to create LevelSetLiquidSolver2 objects step by step.
Definition LevelSetLiquidSolver2.hpp:137
LevelSetLiquidSolver2Ptr MakeShared() const
Builds shared pointer of LevelSetLiquidSolver2 instance.
LevelSetLiquidSolver2 Build() const
Builds LevelSetLiquidSolver2.
Level set based 2-D liquid solver.
Definition LevelSetLiquidSolver2.hpp:31
LevelSetLiquidSolver2(LevelSetLiquidSolver2 &&) noexcept=delete
Deleted move constructor.
void SetLevelSetSolver(const LevelSetSolver2Ptr &newSolver)
Sets the level set solver.
void OnEndAdvanceTimeStep(double timeIntervalInSeconds) override
Called at the end of the time-step.
LevelSetSolver2Ptr GetLevelSetSolver() const
Returns the level set solver.
void SetMinReinitializeDistance(double distance)
Sets minimum reinitialization distance.
static Builder GetBuilder()
Returns builder fox LevelSetLiquidSolver2.
double ComputeVolume() const
Returns liquid volume measured by smeared Heaviside function.
LevelSetLiquidSolver2(const Vector2UZ &resolution, const Vector2D &gridSpacing, const Vector2D &gridOrigin)
Constructs solver with initial grid size.
void OnBeginAdvanceTimeStep(double timeIntervalInSeconds) override
Called at the beginning of the time-step.
LevelSetLiquidSolver2()
Default constructor.
LevelSetLiquidSolver2(const LevelSetLiquidSolver2 &)=delete
Deleted copy constructor.
ScalarField2Ptr GetFluidSDF() const override
Returns fluid region as a signed-distance field.
void SetIsGlobalCompensationEnabled(bool isEnabled)
Enables (or disables) global compensation feature flag.
void ComputeAdvection(double timeIntervalInSeconds) override
Customizes advection step.
ScalarGrid2Ptr GetSignedDistanceField() const
Returns signed-distance field.
Definition Matrix.hpp:30
Definition pybind11Utils.hpp:21
std::shared_ptr< ScalarField2 > ScalarField2Ptr
Shared pointer for the ScalarField2 type.
Definition ScalarField.hpp:67
Matrix< T, Rows, 1 > Vector
Definition Matrix.hpp:738
std::shared_ptr< LevelSetLiquidSolver2 > LevelSetLiquidSolver2Ptr
Shared pointer type for the LevelSetLiquidSolver2.
Definition LevelSetLiquidSolver2.hpp:130
std::shared_ptr< ScalarGrid2 > ScalarGrid2Ptr
Shared pointer for the ScalarGrid2 type.
Definition ScalarGrid.hpp:266
std::shared_ptr< LevelSetSolver2 > LevelSetSolver2Ptr
Shared pointer type for the LevelSetSolver2.
Definition LevelSetSolver2.hpp:93