GridBackwardEulerDiffusionSolver3.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_GRID_BACKWARD_EULER_DIFFUSION_SOLVER3_HPP
12 #define CUBBYFLOW_GRID_BACKWARD_EULER_DIFFUSION_SOLVER3_HPP
13 
16 
17 namespace CubbyFlow
18 {
31 {
32  public:
33  enum class BoundaryType
34  {
35  Dirichlet,
36  Neumann
37  };
38 
41  BoundaryType boundaryType = BoundaryType::Neumann);
42 
45  const GridBackwardEulerDiffusionSolver3&) = delete;
46 
49  GridBackwardEulerDiffusionSolver3&&) noexcept = delete;
50 
52  ~GridBackwardEulerDiffusionSolver3() override = default;
53 
56  const GridBackwardEulerDiffusionSolver3&) = delete;
57 
60  GridBackwardEulerDiffusionSolver3&&) noexcept = delete;
61 
72  void Solve(const ScalarGrid3& source, double diffusionCoefficient,
73  double timeIntervalInSeconds, ScalarGrid3* dest,
74  const ScalarField3& boundarySDF =
75  ConstantScalarField3{ std::numeric_limits<double>::max() },
76  const ScalarField3& fluidSDF = ConstantScalarField3{
77  -std::numeric_limits<double>::max() }) override;
78 
89  void Solve(const CollocatedVectorGrid3& source, double diffusionCoefficient,
90  double timeIntervalInSeconds, CollocatedVectorGrid3* dest,
91  const ScalarField3& boundarySDF =
92  ConstantScalarField3{ std::numeric_limits<double>::max() },
93  const ScalarField3& fluidSDF = ConstantScalarField3{
94  -std::numeric_limits<double>::max() }) override;
95 
106  void Solve(const FaceCenteredGrid3& source, double diffusionCoefficient,
107  double timeIntervalInSeconds, FaceCenteredGrid3* dest,
108  const ScalarField3& boundarySDF =
109  ConstantScalarField3{ std::numeric_limits<double>::max() },
110  const ScalarField3& fluidSDF = ConstantScalarField3{
111  -std::numeric_limits<double>::max() }) override;
112 
115 
116  private:
117  void BuildMarkers(
118  const Vector3UZ& size,
119  const std::function<Vector3D(size_t, size_t, size_t)>& pos,
120  const ScalarField3& boundarySDF, const ScalarField3& fluidSDF);
121 
122  void BuildMatrix(const Vector3UZ& size, const Vector3D& c);
123 
124  void BuildVectors(const ConstArrayView3<double>& f, const Vector3D& c);
125 
126  void BuildVectors(const ConstArrayView3<Vector3D>& f, const Vector3D& c,
127  size_t component);
128 
129  BoundaryType m_boundaryType;
130  FDMLinearSystem3 m_system;
131  FDMLinearSystemSolver3Ptr m_systemSolver;
132  Array3<char> m_markers;
133 };
134 
137  std::shared_ptr<GridBackwardEulerDiffusionSolver3>;
138 } // namespace CubbyFlow
139 
140 #endif
~GridBackwardEulerDiffusionSolver3() override=default
Default virtual destructor.
3-D grid-based backward Euler diffusion solver.
Definition: GridBackwardEulerDiffusionSolver3.hpp:30
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
std::shared_ptr< FDMLinearSystemSolver3 > FDMLinearSystemSolver3Ptr
Shared pointer type for the FDMLinearSystemSolver3.
Definition: FDMLinearSystemSolver3.hpp:52
Abstract base class for N-D scalar grid structure.
Definition: ScalarGrid.hpp:24
Abstract base class for N-D scalar field.
Definition: ScalarField.hpp:24
Abstract base class for 3-D grid-based diffusion equation solver.
Definition: GridDiffusionSolver3.hpp:30
Definition: Matrix.hpp:27
Definition: pybind11Utils.hpp:20
Definition: Array-Impl.hpp:19
N-D face-centered (a.k.a MAC or staggered) grid.
Definition: FaceCenteredGrid.hpp:31
std::shared_ptr< GridBackwardEulerDiffusionSolver3 > GridBackwardEulerDiffusionSolver3Ptr
Shared pointer type for the GridBackwardEulerDiffusionSolver3.
Definition: GridBackwardEulerDiffusionSolver3.hpp:137
GridBackwardEulerDiffusionSolver3 & operator=(const GridBackwardEulerDiffusionSolver3 &)=delete
Deleted copy assignment operator.
Generic N-dimensional array class interface.
Definition: Array.hpp:32
void SetLinearSystemSolver(const FDMLinearSystemSolver3Ptr &solver)
Sets the linear system solver for this diffusion solver.
Abstract base class for N-D collocated vector grid structure.
Definition: CollocatedVectorGrid.hpp:22
N-D constant scalar field.
Definition: ConstantScalarField.hpp:20
GridBackwardEulerDiffusionSolver3(BoundaryType boundaryType=BoundaryType::Neumann)
Constructs the solver with given boundary type.
Linear system (Ax=b) for 3-D finite differencing.
Definition: FDMLinearSystem3.hpp:43
BoundaryType
Definition: GridBackwardEulerDiffusionSolver3.hpp:33
Vector3< double > Vector3D
Definition: Matrix.hpp:787