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