Jet  v1.3.3
fdm_linear_system3.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_FDM_LINEAR_SYSTEM3_H_
8 #define INCLUDE_JET_FDM_LINEAR_SYSTEM3_H_
9 
10 #include <jet/array1.h>
11 #include <jet/array3.h>
12 #include <jet/matrix_csr.h>
13 #include <jet/vector_n.h>
14 
15 namespace jet {
16 
18 struct FdmMatrixRow3 {
20  double center = 0.0;
21 
23  double right = 0.0;
24 
26  double up = 0.0;
27 
29  double front = 0.0;
30 };
31 
34 
37 
42 
45 
48 
50  void clear();
51 
53  void resize(const Size3& size);
54 };
55 
60 
63 
66 
68  void clear();
69 };
70 
72 struct FdmBlas3 {
73  typedef double ScalarType;
76 
78  static void set(ScalarType s, VectorType* result);
79 
81  static void set(const VectorType& v, VectorType* result);
82 
84  static void set(ScalarType s, MatrixType* result);
85 
87  static void set(const MatrixType& m, MatrixType* result);
88 
90  static double dot(const VectorType& a, const VectorType& b);
91 
94  static void axpy(double a, const VectorType& x, const VectorType& y,
95  VectorType* result);
96 
98  static void mvm(const MatrixType& m, const VectorType& v,
99  VectorType* result);
100 
102  static void residual(const MatrixType& a, const VectorType& x,
103  const VectorType& b, VectorType* result);
104 
106  static ScalarType l2Norm(const VectorType& v);
107 
109  static ScalarType lInfNorm(const VectorType& v);
110 };
111 
114  typedef double ScalarType;
117 
119  static void set(ScalarType s, VectorType* result);
120 
122  static void set(const VectorType& v, VectorType* result);
123 
125  static void set(ScalarType s, MatrixType* result);
126 
128  static void set(const MatrixType& m, MatrixType* result);
129 
131  static double dot(const VectorType& a, const VectorType& b);
132 
135  static void axpy(double a, const VectorType& x, const VectorType& y,
136  VectorType* result);
137 
139  static void mvm(const MatrixType& m, const VectorType& v,
140  VectorType* result);
141 
143  static void residual(const MatrixType& a, const VectorType& x,
144  const VectorType& b, VectorType* result);
145 
147  static ScalarType l2Norm(const VectorType& v);
148 
150  static ScalarType lInfNorm(const VectorType& v);
151 };
152 
153 } // namespace jet
154 
155 #endif // INCLUDE_JET_FDM_LINEAR_SYSTEM3_H_
jet::FdmBlas3::set
static void set(const VectorType &v, VectorType *result)
Copies entire element of given vector result with other vector v.
jet::FdmMatrixRow3::up
double up
Off-diagonal element where column refers to (i, j+1, k) grid point.
Definition: fdm_linear_system3.h:26
jet::VectorN< double >
jet::FdmCompressedBlas3::set
static void set(const VectorType &v, VectorType *result)
Copies entire element of given vector result with other vector v.
jet::FdmBlas3::MatrixType
FdmMatrix3 MatrixType
Definition: fdm_linear_system3.h:75
jet::FdmCompressedBlas3::ScalarType
double ScalarType
Definition: fdm_linear_system3.h:114
jet::FdmCompressedBlas3::dot
static double dot(const VectorType &a, const VectorType &b)
Performs dot product with vector a and b.
jet::FdmBlas3::ScalarType
double ScalarType
Definition: fdm_linear_system3.h:73
jet::FdmMatrixRow3::center
double center
Diagonal component of the matrix (row, row).
Definition: fdm_linear_system3.h:20
jet::FdmCompressedBlas3::residual
static void residual(const MatrixType &a, const VectorType &x, const VectorType &b, VectorType *result)
Computes residual vector (b - ax).
jet::FdmMatrixRow3::front
double front
OFf-diagonal element where column refers to (i, j, k+1) grid point.
Definition: fdm_linear_system3.h:29
jet::MatrixCsr< double >
jet::FdmCompressedBlas3::l2Norm
static ScalarType l2Norm(const VectorType &v)
Returns L2-norm of the given vector v.
jet::FdmCompressedBlas3
BLAS operator wrapper for compressed 3-D finite differencing.
Definition: fdm_linear_system3.h:113
jet::FdmMatrix3
Array3< FdmMatrixRow3 > FdmMatrix3
Matrix type for 3-D finite differencing.
Definition: fdm_linear_system3.h:36
matrix_csr.h
jet
Definition: advection_solver2.h:18
jet::FdmCompressedBlas3::lInfNorm
static ScalarType lInfNorm(const VectorType &v)
Returns Linf-norm of the given vector v.
jet::FdmCompressedBlas3::mvm
static void mvm(const MatrixType &m, const VectorType &v, VectorType *result)
Performs matrix-vector multiplication.
jet::FdmCompressedBlas3::set
static void set(ScalarType s, VectorType *result)
Sets entire element of given vector result with scalar s.
jet::FdmBlas3::axpy
static void axpy(double a, const VectorType &x, const VectorType &y, VectorType *result)
jet::FdmBlas3::VectorType
FdmVector3 VectorType
Definition: fdm_linear_system3.h:74
jet::FdmBlas3::set
static void set(ScalarType s, VectorType *result)
Sets entire element of given vector result with scalar s.
jet::FdmBlas3::residual
static void residual(const MatrixType &a, const VectorType &x, const VectorType &b, VectorType *result)
Computes residual vector (b - ax).
jet::FdmCompressedLinearSystem3
Compressed linear system (Ax=b) for 3-D finite differencing.
Definition: fdm_linear_system3.h:57
jet::FdmLinearSystem3::x
FdmVector3 x
Solution vector.
Definition: fdm_linear_system3.h:44
jet::Size3
3-D size class.
Definition: size3.h:19
array3.h
jet::FdmBlas3::dot
static double dot(const VectorType &a, const VectorType &b)
Performs dot product with vector a and b.
jet::FdmCompressedBlas3::axpy
static void axpy(double a, const VectorType &x, const VectorType &y, VectorType *result)
jet::FdmLinearSystem3::A
FdmMatrix3 A
System matrix.
Definition: fdm_linear_system3.h:41
jet::FdmBlas3::lInfNorm
static ScalarType lInfNorm(const VectorType &v)
Returns Linf-norm of the given vector v.
jet::FdmLinearSystem3
Linear system (Ax=b) for 3-D finite differencing.
Definition: fdm_linear_system3.h:39
jet::FdmBlas3::set
static void set(const MatrixType &m, MatrixType *result)
Copies entire element of given matrix result with other matrix v.
jet::FdmBlas3::mvm
static void mvm(const MatrixType &m, const VectorType &v, VectorType *result)
Performs matrix-vector multiplication.
jet::FdmBlas3::set
static void set(ScalarType s, MatrixType *result)
Sets entire element of given matrix result with scalar s.
jet::FdmLinearSystem3::clear
void clear()
Clears all the data.
jet::FdmLinearSystem3::b
FdmVector3 b
RHS vector.
Definition: fdm_linear_system3.h:47
jet::FdmCompressedLinearSystem3::A
MatrixCsrD A
System matrix.
Definition: fdm_linear_system3.h:59
vector_n.h
jet::FdmCompressedBlas3::MatrixType
MatrixCsrD MatrixType
Definition: fdm_linear_system3.h:116
jet::FdmCompressedBlas3::set
static void set(const MatrixType &m, MatrixType *result)
Copies entire element of given matrix result with other matrix v.
jet::FdmVector3
Array3< double > FdmVector3
Vector type for 3-D finite differencing.
Definition: fdm_linear_system3.h:33
jet::FdmMatrixRow3
The row of FdmMatrix3 where row corresponds to (i, j, k) grid point.
Definition: fdm_linear_system3.h:18
jet::FdmMatrixRow3::right
double right
Off-diagonal element where colum refers to (i+1, j, k) grid point.
Definition: fdm_linear_system3.h:23
jet::FdmLinearSystem3::resize
void resize(const Size3 &size)
Resizes the arrays with given grid size.
jet::FdmCompressedBlas3::VectorType
VectorND VectorType
Definition: fdm_linear_system3.h:115
jet::Array< T, 3 >
3-D array class.
Definition: array3.h:43
jet::FdmCompressedLinearSystem3::b
VectorND b
RHS vector.
Definition: fdm_linear_system3.h:65
jet::FdmCompressedLinearSystem3::x
VectorND x
Solution vector.
Definition: fdm_linear_system3.h:62
jet::FdmCompressedBlas3::set
static void set(ScalarType s, MatrixType *result)
Sets entire element of given matrix result with scalar s.
array1.h
jet::FdmBlas3
BLAS operator wrapper for 3-D finite differencing.
Definition: fdm_linear_system3.h:72
jet::FdmCompressedLinearSystem3::clear
void clear()
Clears all the data.
jet::FdmBlas3::l2Norm
static ScalarType l2Norm(const VectorType &v)
Returns L2-norm of the given vector v.