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