FDMLinearSystem3.h
Go to the documentation of this file.
1 /*************************************************************************
2 > File Name: FDMLinearSystem3.h
3 > Project Name: CubbyFlow
4 > Author: Chan-Ho Chris Ohk
5 > Purpose: Linear system (Ax=b) for 3-D finite differencing.
6 > Created Time: 2017/08/12
7 > Copyright (c) 2018, Chan-Ho Chris Ohk
8 *************************************************************************/
9 #ifndef CUBBYFLOW_FDM_LINEAR_SYSTEM3_H
10 #define CUBBYFLOW_FDM_LINEAR_SYSTEM3_H
11 
12 #include <Core/Array/Array3.h>
13 #include <Core/Matrix/MatrixCSR.h>
14 #include <Core/Size/Size3.h>
15 #include <Core/Vector/VectorN.h>
16 
17 namespace CubbyFlow
18 {
21  {
23  double center = 0.0;
24 
26  double right = 0.0;
27 
29  double up = 0.0;
30 
32  double front = 0.0;
33  };
34 
37 
40 
43  {
46 
49 
52 
54  void Clear();
55 
57  void Resize(const Size3& size);
58  };
59 
62  {
65 
68 
71 
73  void Clear();
74  };
75 
77  struct FDMBLAS3
78  {
79  using ScalarType = double;
82 
84  static void Set(ScalarType s, VectorType* result);
85 
87  static void Set(const VectorType& v, VectorType* result);
88 
90  static void Set(ScalarType s, MatrixType* result);
91 
93  static void Set(const MatrixType& m, MatrixType* result);
94 
96  static double Dot(const VectorType& a, const VectorType& b);
97 
99  static void AXPlusY(double a, const VectorType& x, const VectorType& y, VectorType* result);
100 
102  static void MVM(const MatrixType& m, const VectorType& v, VectorType* result);
103 
105  static void Residual(const MatrixType& a, const VectorType& x, const VectorType& b, VectorType* result);
106 
108  static ScalarType L2Norm(const VectorType& v);
109 
111  static ScalarType LInfNorm(const VectorType& v);
112  };
113 
116  {
117  using ScalarType = double;
120 
122  static void Set(ScalarType s, VectorType* result);
123 
125  static void Set(const VectorType& v, VectorType* result);
126 
128  static void Set(ScalarType s, MatrixType* result);
129 
131  static void Set(const MatrixType& m, MatrixType* result);
132 
134  static double Dot(const VectorType& a, const VectorType& b);
135 
137  static void AXPlusY(double a, const VectorType& x, const VectorType& y, VectorType* result);
138 
140  static void MVM(const MatrixType& m, const VectorType& v, VectorType* result);
141 
143  static void Residual(const MatrixType& a, const VectorType& x, const VectorType& b, VectorType* result);
144 
146  static ScalarType L2Norm(const VectorType& v);
147 
149  static ScalarType LInfNorm(const VectorType& v);
150  };
151 }
152 
153 #endif
double ScalarType
Definition: FDMLinearSystem3.h:117
MatrixCSRD A
System matrix.
Definition: FDMLinearSystem3.h:64
VectorND x
Solution vector.
Definition: FDMLinearSystem3.h:67
MatrixCSR< double > MatrixCSRD
Double-type CSR matrix.
Definition: MatrixCSR.h:475
static ScalarType L2Norm(const VectorType &v)
Returns L2-norm of the given vector v.
double up
Off-diagonal element where column refers to (i, j+1, k) grid point.
Definition: FDMLinearSystem3.h:29
VectorN< double > VectorND
Double-type N-D vector.
Definition: VectorN.h:397
static ScalarType L2Norm(const VectorType &v)
Returns L2-norm of the given vector v.
Array3< FDMMatrixRow3 > FDMMatrix3
Matrix type for 3-D finite differencing.
Definition: FDMLinearSystem3.h:39
static void AXPlusY(double a, const VectorType &x, const VectorType &y, VectorType *result)
Performs ax + y operation where a is a matrix and x and y are vectors.
Array3< double > FDMVector3
Vector type for 3-D finite differencing.
Definition: FDMLinearSystem3.h:36
static void MVM(const MatrixType &m, const VectorType &v, VectorType *result)
Performs matrix-vector multiplication.
VectorND b
RHS vector.
Definition: FDMLinearSystem3.h:70
3-D point class.
Definition: Point3.h:26
BLAS operator wrapper for compressed 3-D finite differencing.
Definition: FDMLinearSystem3.h:115
static void Set(ScalarType s, VectorType *result)
Sets entire element of given vector result with scalar s.
static void Residual(const MatrixType &a, const VectorType &x, const VectorType &b, VectorType *result)
Computes residual vector (b - ax).
BLAS operator wrapper for 3-D finite differencing.
Definition: FDMLinearSystem3.h:77
Definition: pybind11Utils.h:24
void Clear()
Clears all the data.
FDMMatrix3 A
System matrix.
Definition: FDMLinearSystem3.h:45
static ScalarType LInfNorm(const VectorType &v)
Returns Linf-norm of the given vector v.
static double Dot(const VectorType &a, const VectorType &b)
Performs dot product with vector a and b.
static ScalarType LInfNorm(const VectorType &v)
Returns Linf-norm of the given vector v.
The row of FDMMatrix3 where row corresponds to (i, j, k) grid point.
Definition: FDMLinearSystem3.h:20
void Clear()
Clears all the data.
static void AXPlusY(double a, const VectorType &x, const VectorType &y, VectorType *result)
Performs ax + y operation where a is a matrix and x and y are vectors.
double center
Diagonal component of the matrix (row, row).
Definition: FDMLinearSystem3.h:23
double ScalarType
Definition: FDMLinearSystem3.h:79
double front
OFf-diagonal element where column refers to (i, j, k+1) grid point.
Definition: FDMLinearSystem3.h:32
3-D array class.
Definition: Array3.h:45
static void Residual(const MatrixType &a, const VectorType &x, const VectorType &b, VectorType *result)
Computes residual vector (b - ax).
static double Dot(const VectorType &a, const VectorType &b)
Performs dot product with vector a and b.
double right
Off-diagonal element where column refers to (i+1, j, k) grid point.
Definition: FDMLinearSystem3.h:26
FDMVector3 x
Solution vector.
Definition: FDMLinearSystem3.h:48
static void MVM(const MatrixType &m, const VectorType &v, VectorType *result)
Performs matrix-vector multiplication.
Compressed linear system (Ax=b) for 3-D finite differencing.
Definition: FDMLinearSystem3.h:61
FDMVector3 b
RHS vector.
Definition: FDMLinearSystem3.h:51
Linear system (Ax=b) for 3-D finite differencing.
Definition: FDMLinearSystem3.h:42
static void Set(ScalarType s, VectorType *result)
Sets entire element of given vector result with scalar s.
void Resize(const Size3 &size)
Resizes the arrays with given grid size.