SemiLagrangian2.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_SEMI_LAGRANGIAN2_HPP
12 #define CUBBYFLOW_SEMI_LAGRANGIAN2_HPP
13 
15 
16 namespace CubbyFlow
17 {
30 {
31  public:
33  SemiLagrangian2() = default;
34 
36  SemiLagrangian2(const SemiLagrangian2&) = default;
37 
39  SemiLagrangian2(SemiLagrangian2&&) noexcept = default;
40 
42  ~SemiLagrangian2() override = default;
43 
45  SemiLagrangian2& operator=(const SemiLagrangian2&) = default;
46 
48  SemiLagrangian2& operator=(SemiLagrangian2&&) noexcept = default;
49 
69  void Advect(const ScalarGrid2& input, const VectorField2& flow, double dt,
70  ScalarGrid2* output,
71  const ScalarField2& boundarySDF = ConstantScalarField2(
72  std::numeric_limits<double>::max())) final;
73 
93  void Advect(const CollocatedVectorGrid2& input, const VectorField2& flow,
94  double dt, CollocatedVectorGrid2* output,
95  const ScalarField2& boundarySDF = ConstantScalarField2(
96  std::numeric_limits<double>::max())) final;
97 
117  void Advect(const FaceCenteredGrid2& input, const VectorField2& flow,
118  double dt, FaceCenteredGrid2* output,
119  const ScalarField2& boundarySDF = ConstantScalarField2(
120  std::numeric_limits<double>::max())) final;
121 
122  protected:
132  [[nodiscard]] virtual std::function<double(const Vector2D&)>
133  GetScalarSamplerFunc(const ScalarGrid2& input) const;
134 
144  [[nodiscard]] virtual std::function<Vector2D(const Vector2D&)>
145  GetVectorSamplerFunc(const CollocatedVectorGrid2& input) const;
146 
156  [[nodiscard]] virtual std::function<Vector2D(const Vector2D&)>
157  GetVectorSamplerFunc(const FaceCenteredGrid2& input) const;
158 
159  private:
160  [[nodiscard]] Vector2D BackTrace(const VectorField2& flow, double dt,
161  double h, const Vector2D& startPt,
162  const ScalarField2& boundarySDF) const;
163 };
164 
165 using SemiLagrangian2Ptr = std::shared_ptr<SemiLagrangian2>;
166 } // namespace CubbyFlow
167 
168 #endif
std::shared_ptr< SemiLagrangian2 > SemiLagrangian2Ptr
Definition: SemiLagrangian2.hpp:165
Implementation of 2-D semi-Lagrangian advection solver.
Definition: SemiLagrangian2.hpp:29
SemiLagrangian2()=default
Default constructor.
void Advect(const ScalarGrid2 &input, const VectorField2 &flow, double dt, ScalarGrid2 *output, const ScalarField2 &boundarySDF=ConstantScalarField2(std::numeric_limits< double >::max())) final
Computes semi-Lagrangian for given scalar grid.
Abstract base class for N-D scalar grid structure.
Definition: ScalarGrid.hpp:24
~SemiLagrangian2() override=default
Virtual default destructor.
Abstract base class for N-D scalar field.
Definition: ScalarField.hpp:24
virtual std::function< double(const Vector2D &)> GetScalarSamplerFunc(const ScalarGrid2 &input) const
Returns spatial interpolation function object for given scalar grid.
Definition: Matrix.hpp:27
Definition: pybind11Utils.hpp:20
virtual std::function< Vector2D(const Vector2D &)> GetVectorSamplerFunc(const CollocatedVectorGrid2 &input) const
Returns spatial interpolation function object for given collocated vector grid.
N-D face-centered (a.k.a MAC or staggered) grid.
Definition: FaceCenteredGrid.hpp:31
SemiLagrangian2 & operator=(const SemiLagrangian2 &)=default
Default copy assignment operator.
Abstract based class for 2-D grid-based advection solver.
Definition: AdvectionSolver2.hpp:28
Abstract base class for N-D vector field.
Definition: VectorField.hpp:42
Abstract base class for N-D collocated vector grid structure.
Definition: CollocatedVectorGrid.hpp:22
ConstantScalarField< 2 > ConstantScalarField2
2-D ConstantScalarField type.
Definition: ConstantScalarField.hpp:43