GridBackwardEulerDiffusionSolver2.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: GridBackwardEulerDiffusionSolver2.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: 2-D grid-based backward Euler diffusion solver.
6 > Created Time: 2017/08/11
7 > Copyright (c) 2018, Chan-Ho Chris Ohk
8 *************************************************************************/
9 #ifndef CUBBYFLOW_GRID_BACKWARD_EULER_DIFFUSION_SOLVER2_H
10 #define CUBBYFLOW_GRID_BACKWARD_EULER_DIFFUSION_SOLVER2_H
11 
14 
15 namespace CubbyFlow
16 {
29  {
30  public:
31  enum class BoundaryType
32  {
33  Dirichlet,
34  Neumann
35  };
36 
39 
50  void Solve(
51  const ScalarGrid2& source,
52  double diffusionCoefficient,
53  double timeIntervalInSeconds,
54  ScalarGrid2* dest,
55  const ScalarField2& boundarySDF = ConstantScalarField2(std::numeric_limits<double>::max()),
56  const ScalarField2& fluidSDF = ConstantScalarField2(-std::numeric_limits<double>::max())) override;
57 
68  void Solve(
69  const CollocatedVectorGrid2& source,
70  double diffusionCoefficient,
71  double timeIntervalInSeconds,
73  const ScalarField2& boundarySDF = ConstantScalarField2(std::numeric_limits<double>::max()),
74  const ScalarField2& fluidSDF = ConstantScalarField2(-std::numeric_limits<double>::max())) override;
75 
86  void Solve(
87  const FaceCenteredGrid2& source,
88  double diffusionCoefficient,
89  double timeIntervalInSeconds,
90  FaceCenteredGrid2* dest,
91  const ScalarField2& boundarySDF = ConstantScalarField2(std::numeric_limits<double>::max()),
92  const ScalarField2& fluidSDF = ConstantScalarField2(-std::numeric_limits<double>::max())) override;
93 
96 
97  private:
98  BoundaryType m_boundaryType;
99  FDMLinearSystem2 m_system;
100  FDMLinearSystemSolver2Ptr m_systemSolver;
101  Array2<char> m_markers;
102 
103  void BuildMarkers(
104  const Size2& size,
105  const std::function<Vector2D(size_t, size_t)>& pos,
106  const ScalarField2& boundarySDF,
107  const ScalarField2& fluidSDF);
108 
109  void BuildMatrix(
110  const Size2& size,
111  const Vector2D& c);
112 
113  void BuildVectors(
115  const Vector2D& c);
116 
117  void BuildVectors(
119  const Vector2D& c,
120  size_t component);
121  };
122 
124  using GridBackwardEulerDiffusionSolver2Ptr = std::shared_ptr<GridBackwardEulerDiffusionSolver2>;
125 }
126 
127 #endif
2-D read-only array accessor class.
Definition: ArrayAccessor2.h:261
std::shared_ptr< FDMLinearSystemSolver2 > FDMLinearSystemSolver2Ptr
Shared pointer type for the FDMLinearSystemSolver2.
Definition: FDMLinearSystemSolver2.h:33
Linear system (Ax=b) for 2-D finite differencing.
Definition: FDMLinearSystem2.h:39
BoundaryType
Definition: GridBackwardEulerDiffusionSolver2.h:31
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
2-D point class.
Definition: Point2.h:25
GridBackwardEulerDiffusionSolver2(BoundaryType boundaryType=BoundaryType::Neumann)
Constructs the solver with given boundary type.
2-D face-centered (a.k.a MAC or staggered) grid.
Definition: FaceCenteredGrid2.h:25
Definition: pybind11Utils.h:24
Vector2< double > Vector2D
Double-type 2D vector.
Definition: Vector2.h:341
2-D grid-based backward Euler diffusion solver.
Definition: GridBackwardEulerDiffusionSolver2.h:28
2-D constant scalar field.
Definition: ConstantScalarField2.h:17
2-D vector class.
Definition: Vector2.h:26
2-D array class.
Definition: Array2.h:42
void SetLinearSystemSolver(const FDMLinearSystemSolver2Ptr &solver)
Sets the linear system solver for this diffusion solver.
std::shared_ptr< GridBackwardEulerDiffusionSolver2 > GridBackwardEulerDiffusionSolver2Ptr
Shared pointer type for the GridBackwardEulerDiffusionSolver2.
Definition: GridBackwardEulerDiffusionSolver2.h:124
void Solve(const ScalarGrid2 &source, double diffusionCoefficient, double timeIntervalInSeconds, ScalarGrid2 *dest, const ScalarField2 &boundarySDF=ConstantScalarField2(std::numeric_limits< double >::max()), const ScalarField2 &fluidSDF=ConstantScalarField2(-std::numeric_limits< double >::max())) override
Abstract base class for 2-D scalar grid structure.
Definition: ScalarGrid2.h:21
Abstract base class for 2-D grid-based diffusion equation solver.
Definition: GridDiffusionSolver2.h:28