GridBackwardEulerDiffusionSolver3.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: GridBackwardEulerDiffusionSolver3.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: 3-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_SOLVER3_H
10 #define CUBBYFLOW_GRID_BACKWARD_EULER_DIFFUSION_SOLVER3_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 ScalarGrid3& source,
52  double diffusionCoefficient,
53  double timeIntervalInSeconds,
54  ScalarGrid3* dest,
55  const ScalarField3& boundarySDF = ConstantScalarField3(std::numeric_limits<double>::max()),
56  const ScalarField3& fluidSDF = ConstantScalarField3(-std::numeric_limits<double>::max())) override;
57 
68  void Solve(
69  const CollocatedVectorGrid3& source,
70  double diffusionCoefficient,
71  double timeIntervalInSeconds,
73  const ScalarField3& boundarySDF = ConstantScalarField3(std::numeric_limits<double>::max()),
74  const ScalarField3& fluidSDF = ConstantScalarField3(-std::numeric_limits<double>::max())) override;
75 
86  void Solve(
87  const FaceCenteredGrid3& source,
88  double diffusionCoefficient,
89  double timeIntervalInSeconds,
90  FaceCenteredGrid3* dest,
91  const ScalarField3& boundarySDF = ConstantScalarField3(std::numeric_limits<double>::max()),
92  const ScalarField3& fluidSDF = ConstantScalarField3(-std::numeric_limits<double>::max())) override;
93 
96 
97  private:
98  BoundaryType m_boundaryType;
99  FDMLinearSystem3 m_system;
100  FDMLinearSystemSolver3Ptr m_systemSolver;
101  Array3<char> m_markers;
102 
103  void BuildMarkers(
104  const Size3& size,
105  const std::function<Vector3D(size_t, size_t, size_t)>& pos,
106  const ScalarField3& boundarySDF,
107  const ScalarField3& fluidSDF);
108 
109  void BuildMatrix(
110  const Size3& size,
111  const Vector3D& c);
112 
113  void BuildVectors(
115  const Vector3D& c);
116 
117  void BuildVectors(
119  const Vector3D& c,
120  size_t component);
121  };
122 
124  using GridBackwardEulerDiffusionSolver3Ptr = std::shared_ptr<GridBackwardEulerDiffusionSolver3>;
125 }
126 
127 #endif
3-D vector class.
Definition: Vector3.h:26
Abstract base class for 3-D collocated vector grid structure.
Definition: CollocatedVectorGrid3.h:19
void Solve(const ScalarGrid3 &source, double diffusionCoefficient, double timeIntervalInSeconds, ScalarGrid3 *dest, const ScalarField3 &boundarySDF=ConstantScalarField3(std::numeric_limits< double >::max()), const ScalarField3 &fluidSDF=ConstantScalarField3(-std::numeric_limits< double >::max())) override
3-D grid-based backward Euler diffusion solver.
Definition: GridBackwardEulerDiffusionSolver3.h:28
3-D read-only array accessor class.
Definition: ArrayAccessor3.h:269
std::shared_ptr< FDMLinearSystemSolver3 > FDMLinearSystemSolver3Ptr
Shared pointer type for the FDMLinearSystemSolver3.
Definition: FDMLinearSystemSolver3.h:33
3-D face-centered (a.k.a MAC or staggered) grid.
Definition: FaceCenteredGrid3.h:25
3-D point class.
Definition: Point3.h:26
Abstract base class for 3-D grid-based diffusion equation solver.
Definition: GridDiffusionSolver3.h:28
Definition: pybind11Utils.h:24
3-D constant scalar field.
Definition: ConstantScalarField3.h:17
std::shared_ptr< GridBackwardEulerDiffusionSolver3 > GridBackwardEulerDiffusionSolver3Ptr
Shared pointer type for the GridBackwardEulerDiffusionSolver3.
Definition: GridBackwardEulerDiffusionSolver3.h:124
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
void SetLinearSystemSolver(const FDMLinearSystemSolver3Ptr &solver)
Sets the linear system solver for this diffusion solver.
3-D array class.
Definition: Array3.h:45
GridBackwardEulerDiffusionSolver3(BoundaryType boundaryType=BoundaryType::Neumann)
Constructs the solver with given boundary type.
Linear system (Ax=b) for 3-D finite differencing.
Definition: FDMLinearSystem3.h:42
BoundaryType
Definition: GridBackwardEulerDiffusionSolver3.h:31
Vector3< double > Vector3D
Double-type 3D vector.
Definition: Vector3.h:353