IterativeLevelSetSolver2.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: IterativeLevelSetSolver2.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: Abstract base class for 2-D PDE-based iterative level set solver.
6 > Created Time: 2017/08/30
7 > Copyright (c) 2018, Chan-Ho Chris Ohk
8 *************************************************************************/
9 #ifndef CUBBYFLOW_ITERATIVE_LEVEL_SET_SOLVER2_H
10 #define CUBBYFLOW_ITERATIVE_LEVEL_SET_SOLVER2_H
11 
13 
14 namespace CubbyFlow
15 {
28  {
29  public:
32 
34  virtual ~IterativeLevelSetSolver2();
35 
43  void Reinitialize(
44  const ScalarGrid2& inputSDF,
45  double maxDistance,
46  ScalarGrid2* outputSDF) override;
47 
56  void Extrapolate(
57  const ScalarGrid2& input,
58  const ScalarField2& sdf,
59  double maxDistance,
60  ScalarGrid2* output) override;
61 
71  void Extrapolate(
72  const CollocatedVectorGrid2& input,
73  const ScalarField2& sdf,
74  double maxDistance,
75  CollocatedVectorGrid2* output) override;
76 
86  void Extrapolate(
87  const FaceCenteredGrid2& input,
88  const ScalarField2& sdf,
89  double maxDistance,
90  FaceCenteredGrid2* output) override;
91 
93  double GetMaxCFL() const;
94 
101  void SetMaxCFL(double newMaxCfl);
102 
103  protected:
105  virtual void GetDerivatives(
107  const Vector2D& gridSpacing,
108  size_t i, size_t j,
109  std::array<double, 2>* dx, std::array<double, 2>* dy) const = 0;
110 
111  private:
112  double m_maxCFL = 0.5;
113 
114  void Extrapolate(
115  const ConstArrayAccessor2<double>& input,
116  const ConstArrayAccessor2<double>& sdf,
117  const Vector2D& gridSpacing,
118  double maxDistance,
119  ArrayAccessor2<double> output);
120 
121  static unsigned int DistanceToNumberOfIterations(double distance, double dtau);
122 
123  static double Sign(
124  const ConstArrayAccessor2<double>& sdf,
125  const Vector2D& gridSpacing,
126  size_t i, size_t j);
127 
128  double PseudoTimeStep(
130  const Vector2D& gridSpacing) const;
131  };
132 
133  using IterativeLevelSetSolver2Ptr = std::shared_ptr<IterativeLevelSetSolver2>;
134 }
135 
136 #endif
2-D read-only array accessor class.
Definition: ArrayAccessor2.h:261
std::shared_ptr< IterativeLevelSetSolver2 > IterativeLevelSetSolver2Ptr
Definition: IterativeLevelSetSolver2.h:133
void Extrapolate(const ScalarGrid2 &input, const ScalarField2 &sdf, double maxDistance, ScalarGrid2 *output) override
Abstract base class for 2-D scalar field.
Definition: ScalarField2.h:21
void Reinitialize(const ScalarGrid2 &inputSDF, double maxDistance, ScalarGrid2 *outputSDF) override
Abstract base class for 2-D collocated vector grid structure.
Definition: CollocatedVectorGrid2.h:19
IterativeLevelSetSolver2()
Default constructor.
Abstract base class for 2-D PDE-based iterative level set solver.
Definition: IterativeLevelSetSolver2.h:27
double GetMaxCFL() const
Returns the maximum CFL limit.
void SetMaxCFL(double newMaxCfl)
Sets the maximum CFL limit.
2-D array accessor class.
Definition: ArrayAccessor2.h:31
2-D face-centered (a.k.a MAC or staggered) grid.
Definition: FaceCenteredGrid2.h:25
Definition: pybind11Utils.h:24
virtual void GetDerivatives(ConstArrayAccessor2< 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.
Abstract base class for 2-D level set solver.
Definition: LevelSetSolver2.h:21
virtual ~IterativeLevelSetSolver2()
Default destructor.
2-D vector class.
Definition: Vector2.h:26
Abstract base class for 2-D scalar grid structure.
Definition: ScalarGrid2.h:21