IterativeLevelSetSolver2.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_ITERATIVE_LEVEL_SET_SOLVER2_HPP
12 #define CUBBYFLOW_ITERATIVE_LEVEL_SET_SOLVER2_HPP
13 
15 
16 namespace CubbyFlow
17 {
30 {
31  public:
33  IterativeLevelSetSolver2() = default;
34 
37 
40 
42  ~IterativeLevelSetSolver2() override = default;
43 
46  delete;
47 
50  delete;
51 
59  void Reinitialize(const ScalarGrid2& inputSDF, double maxDistance,
60  ScalarGrid2* outputSDF) override;
61 
70  void Extrapolate(const ScalarGrid2& input, const ScalarField2& sdf,
71  double maxDistance, ScalarGrid2* output) override;
72 
82  void Extrapolate(const CollocatedVectorGrid2& input,
83  const ScalarField2& sdf, double maxDistance,
84  CollocatedVectorGrid2* output) override;
85 
95  void Extrapolate(const FaceCenteredGrid2& input, const ScalarField2& sdf,
96  double maxDistance, FaceCenteredGrid2* output) override;
97 
99  [[nodiscard]] double GetMaxCFL() const;
100 
107  void SetMaxCFL(double newMaxCfl);
108 
109  protected:
111  virtual void GetDerivatives(ConstArrayView2<double> grid,
112  const Vector2D& gridSpacing, size_t i, size_t j,
113  std::array<double, 2>* dx,
114  std::array<double, 2>* dy) const = 0;
115 
116  private:
117  void Extrapolate(const ConstArrayView2<double>& input,
118  const ConstArrayView2<double>& sdf,
119  const Vector2D& gridSpacing, double maxDistance,
120  ArrayView2<double> output);
121 
122  [[nodiscard]] static unsigned int DistanceToNumberOfIterations(
123  double distance, double dtau);
124 
125  [[nodiscard]] static double Sign(const ConstArrayView2<double>& sdf,
126  const Vector2D& gridSpacing, size_t i,
127  size_t j);
128 
129  [[nodiscard]] double PseudoTimeStep(const ConstArrayView2<double>& sdf,
130  const Vector2D& gridSpacing) const;
131 
132  double m_maxCFL = 0.5;
133 };
134 
135 using IterativeLevelSetSolver2Ptr = std::shared_ptr<IterativeLevelSetSolver2>;
136 } // namespace CubbyFlow
137 
138 #endif
IterativeLevelSetSolver2 & operator=(const IterativeLevelSetSolver2 &)=delete
Deleted copy assignment operator.
std::shared_ptr< IterativeLevelSetSolver2 > IterativeLevelSetSolver2Ptr
Definition: IterativeLevelSetSolver2.hpp:135
void Extrapolate(const ScalarGrid2 &input, const ScalarField2 &sdf, double maxDistance, ScalarGrid2 *output) override
void Reinitialize(const ScalarGrid2 &inputSDF, double maxDistance, ScalarGrid2 *outputSDF) override
Abstract base class for N-D scalar grid structure.
Definition: ScalarGrid.hpp:24
Abstract base class for N-D scalar field.
Definition: ScalarField.hpp:24
Abstract base class for 2-D PDE-based iterative level set solver.
Definition: IterativeLevelSetSolver2.hpp:29
double GetMaxCFL() const
Returns the maximum CFL limit.
void SetMaxCFL(double newMaxCfl)
Sets the maximum CFL limit.
IterativeLevelSetSolver2()=default
Default constructor.
Definition: Matrix.hpp:27
Definition: pybind11Utils.hpp:20
N-D face-centered (a.k.a MAC or staggered) grid.
Definition: FaceCenteredGrid.hpp:31
Abstract base class for 2-D level set solver.
Definition: LevelSetSolver2.hpp:23
virtual void GetDerivatives(ConstArrayView2< double > grid, const Vector2D &gridSpacing, size_t i, size_t j, std::array< double, 2 > *dx, std::array< double, 2 > *dy) const =0
Computes the derivatives for given grid point.
Generic N-dimensional array class interface.
Definition: Array.hpp:32
~IterativeLevelSetSolver2() override=default
Default virtual destructor.
Abstract base class for N-D collocated vector grid structure.
Definition: CollocatedVectorGrid.hpp:22