FDMLinearSystem3.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_FDM_LINEAR_SYSTEM3_HPP
12 #define CUBBYFLOW_FDM_LINEAR_SYSTEM3_HPP
13 
14 #include <Core/Array/Array.hpp>
15 #include <Core/Matrix/Matrix.hpp>
17 
18 namespace CubbyFlow
19 {
22 {
24  double center = 0.0;
25 
27  double right = 0.0;
28 
30  double up = 0.0;
31 
33  double front = 0.0;
34 };
35 
38 
41 
44 {
46  void Clear();
47 
49  void Resize(const Vector3UZ& size);
50 
53 
56 
59 };
60 
63 {
65  void Clear();
66 
69 
72 
75 };
76 
78 struct FDMBLAS3
79 {
80  using ScalarType = double;
83 
85  static void Set(ScalarType s, VectorType* result);
86 
88  static void Set(const VectorType& v, VectorType* result);
89 
91  static void Set(ScalarType s, MatrixType* result);
92 
94  static void Set(const MatrixType& m, MatrixType* result);
95 
97  static double Dot(const VectorType& a, const VectorType& b);
98 
101  static void AXPlusY(double a, const VectorType& x, const VectorType& y,
102  VectorType* result);
103 
105  static void MVM(const MatrixType& m, const VectorType& v,
106  VectorType* result);
107 
109  static void Residual(const MatrixType& a, const VectorType& x,
110  const VectorType& b, VectorType* result);
111 
113  [[nodiscard]] static ScalarType L2Norm(const VectorType& v);
114 
116  [[nodiscard]] static ScalarType LInfNorm(const VectorType& v);
117 };
118 
121 {
122  using ScalarType = double;
125 
127  static void Set(ScalarType s, VectorType* result);
128 
130  static void Set(const VectorType& v, VectorType* result);
131 
133  static void Set(ScalarType s, MatrixType* result);
134 
136  static void Set(const MatrixType& m, MatrixType* result);
137 
139  static double Dot(const VectorType& a, const VectorType& b);
140 
143  static void AXPlusY(double a, const VectorType& x, const VectorType& y,
144  VectorType* result);
145 
147  static void MVM(const MatrixType& m, const VectorType& v,
148  VectorType* result);
149 
151  static void Residual(const MatrixType& a, const VectorType& x,
152  const VectorType& b, VectorType* result);
153 
155  [[nodiscard]] static ScalarType L2Norm(const VectorType& v);
156 
158  [[nodiscard]] static ScalarType LInfNorm(const VectorType& v);
159 };
160 } // namespace CubbyFlow
161 
162 #endif
double ScalarType
Definition: FDMLinearSystem3.hpp:122
MatrixCSRD A
System matrix.
Definition: FDMLinearSystem3.hpp:68
VectorND x
Solution vector.
Definition: FDMLinearSystem3.hpp:71
double up
Off-diagonal element where column refers to (i, j+1, k) grid point.
Definition: FDMLinearSystem3.hpp:30
VectorN< double > VectorND
Definition: Matrix.hpp:832
Array3< FDMMatrixRow3 > FDMMatrix3
Matrix type for 3-D finite differencing.
Definition: FDMLinearSystem3.hpp:40
Array3< double > FDMVector3
Vector type for 3-D finite differencing.
Definition: FDMLinearSystem3.hpp:37
VectorND b
RHS vector.
Definition: FDMLinearSystem3.hpp:74
BLAS operator wrapper for compressed 3-D finite differencing.
Definition: FDMLinearSystem3.hpp:120
Definition: Matrix.hpp:27
BLAS operator wrapper for 3-D finite differencing.
Definition: FDMLinearSystem3.hpp:78
Definition: pybind11Utils.hpp:20
Definition: Array-Impl.hpp:19
FDMMatrix3 A
System matrix.
Definition: FDMLinearSystem3.hpp:52
The row of FDMMatrix3 where row corresponds to (i, j, k) grid point.
Definition: FDMLinearSystem3.hpp:21
double center
Diagonal component of the matrix (row, row).
Definition: FDMLinearSystem3.hpp:24
MatrixCSR< double > MatrixCSRD
Double-type CSR matrix.
Definition: MatrixCSR.hpp:448
double ScalarType
Definition: FDMLinearSystem3.hpp:80
double front
OFf-diagonal element where column refers to (i, j, k+1) grid point.
Definition: FDMLinearSystem3.hpp:33
double right
Off-diagonal element where column refers to (i+1, j, k) grid point.
Definition: FDMLinearSystem3.hpp:27
FDMVector3 x
Solution vector.
Definition: FDMLinearSystem3.hpp:55
Compressed linear system (Ax=b) for 3-D finite differencing.
Definition: FDMLinearSystem3.hpp:62
FDMVector3 b
RHS vector.
Definition: FDMLinearSystem3.hpp:58
Linear system (Ax=b) for 3-D finite differencing.
Definition: FDMLinearSystem3.hpp:43