SemiLagrangian2.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: SemiLagrangian2.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: Implementation of 2-D semi-Lagrangian advection solver.
6 > Created Time: 2017/08/07
7 > Copyright (c) 2018, Chan-Ho Chris Ohk
8 *************************************************************************/
9 #ifndef CUBBYFLOW_SEMI_LAGRANGIAN2_H
10 #define CUBBYFLOW_SEMI_LAGRANGIAN2_H
11 
13 
14 namespace CubbyFlow
15 {
28  {
29  public:
31 
32  virtual ~SemiLagrangian2();
33 
52  void Advect(
53  const ScalarGrid2& input,
54  const VectorField2& flow,
55  double dt,
56  ScalarGrid2* output,
57  const ScalarField2& boundarySDF = ConstantScalarField2(std::numeric_limits<double>::max())) final;
58 
77  void Advect(
78  const CollocatedVectorGrid2& input,
79  const VectorField2& flow,
80  double dt,
81  CollocatedVectorGrid2* output,
82  const ScalarField2& boundarySDF = ConstantScalarField2(std::numeric_limits<double>::max())) final;
83 
103  void Advect(
104  const FaceCenteredGrid2& input,
105  const VectorField2& flow,
106  double dt,
107  FaceCenteredGrid2* output,
108  const ScalarField2& boundarySDF = ConstantScalarField2(std::numeric_limits<double>::max())) final;
109 
110  protected:
119  virtual std::function<double(const Vector2D&)> GetScalarSamplerFunc(const ScalarGrid2& input) const;
120 
130  virtual std::function<Vector2D(const Vector2D&)> GetVectorSamplerFunc(const CollocatedVectorGrid2& input) const;
131 
141  virtual std::function<Vector2D(const Vector2D&)> GetVectorSamplerFunc(const FaceCenteredGrid2& input) const;
142 
143  private:
144  Vector2D BackTrace(
145  const VectorField2& flow,
146  double dt,
147  double h,
148  const Vector2D& pt0,
149  const ScalarField2& boundarySDF) const;
150  };
151 
152  using SemiLagrangian2Ptr = std::shared_ptr<SemiLagrangian2>;
153 }
154 
155 #endif
std::shared_ptr< SemiLagrangian2 > SemiLagrangian2Ptr
Definition: SemiLagrangian2.h:152
Implementation of 2-D semi-Lagrangian advection solver.
Definition: SemiLagrangian2.h:27
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 2-D scalar field.
Definition: ScalarField2.h:21
Abstract base class for 2-D collocated vector grid structure.
Definition: CollocatedVectorGrid2.h:19
virtual std::function< double(const Vector2D &)> GetScalarSamplerFunc(const ScalarGrid2 &input) const
Returns spatial interpolation function object for given scalar grid.
2-D face-centered (a.k.a MAC or staggered) grid.
Definition: FaceCenteredGrid2.h:25
Definition: pybind11Utils.h:24
virtual std::function< Vector2D(const Vector2D &)> GetVectorSamplerFunc(const CollocatedVectorGrid2 &input) const
Returns spatial interpolation function object for given collocated vector grid.
2-D constant scalar field.
Definition: ConstantScalarField2.h:17
2-D vector class.
Definition: Vector2.h:26
Abstract based class for 2-D grid-based advection solver.
Definition: AdvectionSolver2.h:26
Abstract base class for 2-D vector field.
Definition: VectorField2.h:21
Abstract base class for 2-D scalar grid structure.
Definition: ScalarGrid2.h:21