Jet  v1.3.3
grid_backward_euler_diffusion_solver2.h
Go to the documentation of this file.
1 // Copyright (c) 2018 Doyub Kim
2 //
3 // I am making my contributions/submissions to this project solely in my
4 // personal capacity and am not conveying any rights to any intellectual
5 // property of any third parties.
6 
7 #ifndef INCLUDE_JET_GRID_BACKWARD_EULER_DIFFUSION_SOLVER2_H_
8 #define INCLUDE_JET_GRID_BACKWARD_EULER_DIFFUSION_SOLVER2_H_
9 
13 #include <limits>
14 #include <memory>
15 
16 namespace jet {
17 
30  public:
31  enum BoundaryType {
33  Neumann
34  };
35 
38  BoundaryType boundaryType = Neumann);
39 
50  void solve(
51  const ScalarGrid2& source,
52  double diffusionCoefficient,
53  double timeIntervalInSeconds,
54  ScalarGrid2* dest,
55  const ScalarField2& boundarySdf
57  const ScalarField2& fluidSdf
58  = ConstantScalarField2(-kMaxD)) override;
59 
70  void solve(
71  const CollocatedVectorGrid2& source,
72  double diffusionCoefficient,
73  double timeIntervalInSeconds,
75  const ScalarField2& boundarySdf
77  const ScalarField2& fluidSdf
78  = ConstantScalarField2(-kMaxD)) override;
79 
90  void solve(
91  const FaceCenteredGrid2& source,
92  double diffusionCoefficient,
93  double timeIntervalInSeconds,
94  FaceCenteredGrid2* dest,
95  const ScalarField2& boundarySdf
97  const ScalarField2& fluidSdf
98  = ConstantScalarField2(-kMaxD)) override;
99 
102 
103  private:
104  BoundaryType _boundaryType;
105  FdmLinearSystem2 _system;
106  FdmLinearSystemSolver2Ptr _systemSolver;
107  Array2<char> _markers;
108 
109  void buildMarkers(
110  const Size2& size,
111  const std::function<Vector2D(size_t, size_t)>& pos,
112  const ScalarField2& boundarySdf,
113  const ScalarField2& fluidSdf);
114 
115  void buildMatrix(
116  const Size2& size,
117  const Vector2D& c);
118 
119  void buildVectors(
121  const Vector2D& c);
122 
123  void buildVectors(
125  const Vector2D& c,
126  size_t component);
127 };
128 
130 typedef std::shared_ptr<GridBackwardEulerDiffusionSolver2>
132 
133 } // namespace jet
134 
135 #endif // INCLUDE_JET_GRID_BACKWARD_EULER_DIFFUSION_SOLVER2_H_
jet::GridDiffusionSolver2
Abstract base class for 2-D grid-based diffusion equation solver.
Definition: grid_diffusion_solver2.h:29
jet::FdmLinearSystem2
Linear system (Ax=b) for 2-D finite differencing.
Definition: fdm_linear_system2.h:36
jet::FdmLinearSystemSolver2Ptr
std::shared_ptr< FdmLinearSystemSolver2 > FdmLinearSystemSolver2Ptr
Shared pointer type for the FdmLinearSystemSolver2.
Definition: fdm_linear_system_solver2.h:31
jet::Vector2D
Vector2< double > Vector2D
Double-type 2D vector.
Definition: vector2.h:340
jet::GridBackwardEulerDiffusionSolver2::solve
void solve(const CollocatedVectorGrid2 &source, double diffusionCoefficient, double timeIntervalInSeconds, CollocatedVectorGrid2 *dest, const ScalarField2 &boundarySdf=ConstantScalarField2(kMaxD), const ScalarField2 &fluidSdf=ConstantScalarField2(-kMaxD)) override
grid_diffusion_solver2.h
jet::ScalarField2
Abstract base class for 2-D scalar field.
Definition: scalar_field2.h:18
jet::GridBackwardEulerDiffusionSolver2::solve
void solve(const FaceCenteredGrid2 &source, double diffusionCoefficient, double timeIntervalInSeconds, FaceCenteredGrid2 *dest, const ScalarField2 &boundarySdf=ConstantScalarField2(kMaxD), const ScalarField2 &fluidSdf=ConstantScalarField2(-kMaxD)) override
constant_scalar_field2.h
jet::FaceCenteredGrid2
2-D face-centered (a.k.a MAC or staggered) grid.
Definition: face_centered_grid2.h:26
jet::Array< T, 2 >
2-D array class.
Definition: array2.h:42
jet::GridBackwardEulerDiffusionSolver2::BoundaryType
BoundaryType
Definition: grid_backward_euler_diffusion_solver2.h:31
jet
Definition: advection_solver2.h:18
jet::ConstArrayAccessor< T, 2 >
2-D read-only array accessor class.
Definition: array_accessor2.h:261
jet::ScalarGrid2
Abstract base class for 2-D scalar grid structure.
Definition: scalar_grid2.h:21
jet::GridBackwardEulerDiffusionSolver2::Neumann
@ Neumann
Definition: grid_backward_euler_diffusion_solver2.h:33
jet::ConstantScalarField2
2-D constant scalar field.
Definition: constant_scalar_field2.h:15
jet::Vector< T, 2 >
2-D vector class.
Definition: vector2.h:24
jet::CollocatedVectorGrid2
Abstract base class for 2-D collocated vector grid structure.
Definition: collocated_vector_grid2.h:18
jet::GridBackwardEulerDiffusionSolver2::setLinearSystemSolver
void setLinearSystemSolver(const FdmLinearSystemSolver2Ptr &solver)
Sets the linear system solver for this diffusion solver.
jet::GridBackwardEulerDiffusionSolver2Ptr
std::shared_ptr< GridBackwardEulerDiffusionSolver2 > GridBackwardEulerDiffusionSolver2Ptr
Shared pointer type for the GridBackwardEulerDiffusionSolver2.
Definition: grid_backward_euler_diffusion_solver2.h:131
jet::kMaxD
constexpr double kMaxD
Max double.
Definition: constants.h:88
jet::Size2
2-D size class.
Definition: size2.h:19
jet::GridBackwardEulerDiffusionSolver2::GridBackwardEulerDiffusionSolver2
GridBackwardEulerDiffusionSolver2(BoundaryType boundaryType=Neumann)
Constructs the solver with given boundary type.
jet::GridBackwardEulerDiffusionSolver2
2-D grid-based backward Euler diffusion solver.
Definition: grid_backward_euler_diffusion_solver2.h:29
jet::GridBackwardEulerDiffusionSolver2::solve
void solve(const ScalarGrid2 &source, double diffusionCoefficient, double timeIntervalInSeconds, ScalarGrid2 *dest, const ScalarField2 &boundarySdf=ConstantScalarField2(kMaxD), const ScalarField2 &fluidSdf=ConstantScalarField2(-kMaxD)) override
fdm_linear_system_solver2.h
jet::GridBackwardEulerDiffusionSolver2::Dirichlet
@ Dirichlet
Definition: grid_backward_euler_diffusion_solver2.h:32