Loading...
Searching...
No Matches
FDMLinearSystem2.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_SYSTEM2_HPP
12#define CUBBYFLOW_FDM_LINEAR_SYSTEM2_HPP
13
14#include <Core/Array/Array.hpp>
17
18namespace CubbyFlow
19{
22{
24 double center = 0.0;
25
27 double right = 0.0;
28
30 double up = 0.0;
31};
32
35
38
41{
43 void Clear();
44
46 void Resize(const Vector2UZ& size);
47
50
53
56};
57
73
76{
80
83
85 static void Set(const VectorType& v, VectorType* result);
86
89
91 static void Set(const MatrixType& m, MatrixType* result);
92
94 static double Dot(const VectorType& a, const VectorType& b);
95
98 static void AXPlusY(double a, const VectorType& x, const VectorType& y,
100
102 static void MVM(const MatrixType& m, const VectorType& v,
104
106 static void Residual(const MatrixType& a, const VectorType& x,
107 const VectorType& b, VectorType* result);
108
111
114};
115
118{
122
125
127 static void Set(const VectorType& v, VectorType* result);
128
131
133 static void Set(const MatrixType& m, MatrixType* result);
134
136 static double Dot(const VectorType& a, const VectorType& b);
137
140 static void AXPlusY(double a, const VectorType& x, const VectorType& y,
142
144 static void MVM(const MatrixType& m, const VectorType& v,
146
148 static void Residual(const MatrixType& a, const VectorType& x,
149 const VectorType& b, VectorType* result);
150
153
156};
157} // namespace CubbyFlow
158
159#endif
Definition Matrix.hpp:30
Definition pybind11Utils.hpp:21
Array2< FDMMatrixRow2 > FDMMatrix2
Matrix type for 2-D finite differencing.
Definition FDMLinearSystem2.hpp:37
VectorN< double > VectorND
Definition Matrix.hpp:832
MatrixCSR< double > MatrixCSRD
Double-type CSR matrix.
Definition MatrixCSR.hpp:448
Matrix< T, Rows, 1 > Vector
Definition Matrix.hpp:738
Array2< double > FDMVector2
Vector type for 2-D finite differencing.
Definition FDMLinearSystem2.hpp:34
BLAS operator wrapper for 2-D finite differencing.
Definition FDMLinearSystem2.hpp:76
static void MVM(const MatrixType &m, const VectorType &v, VectorType *result)
Performs matrix-vector multiplication.
static void Set(ScalarType s, VectorType *result)
Sets entire element of given vector result with scalar s.
static ScalarType L2Norm(const VectorType &v)
Returns L2-norm of the given vector v.
static void AXPlusY(double a, const VectorType &x, const VectorType &y, VectorType *result)
static ScalarType LInfNorm(const VectorType &v)
Returns Linf-norm of the given vector v.
static void Set(const VectorType &v, VectorType *result)
Copies entire element of given vector result with other vector v.
static void Set(ScalarType s, MatrixType *result)
Sets entire element of given matrix result with scalar s.
static double Dot(const VectorType &a, const VectorType &b)
Performs dot product with vector a and b.
static void Residual(const MatrixType &a, const VectorType &x, const VectorType &b, VectorType *result)
Computes residual vector (b - ax).
static void Set(const MatrixType &m, MatrixType *result)
Copies entire element of given matrix result with other matrix v.
BLAS operator wrapper for compressed 2-D finite differencing.
Definition FDMLinearSystem2.hpp:118
static void Residual(const MatrixType &a, const VectorType &x, const VectorType &b, VectorType *result)
Computes residual vector (b - ax).
static void Set(const VectorType &v, VectorType *result)
Copies entire element of given vector result with other vector v.
static void MVM(const MatrixType &m, const VectorType &v, VectorType *result)
Performs matrix-vector multiplication.
static void Set(const MatrixType &m, MatrixType *result)
Copies entire element of given matrix result with other matrix v.
static void Set(ScalarType s, VectorType *result)
Sets entire element of given vector result with scalar s.
static ScalarType L2Norm(const VectorType &v)
Returns L2-norm of the given vector v.
static void AXPlusY(double a, const VectorType &x, const VectorType &y, VectorType *result)
static double Dot(const VectorType &a, const VectorType &b)
Performs dot product with vector a and b.
static void Set(ScalarType s, MatrixType *result)
Sets entire element of given matrix result with scalar s.
static ScalarType LInfNorm(const VectorType &v)
Returns Linf-norm of the given vector v.
Compressed linear system (Ax=b) for 2-D finite differencing.
Definition FDMLinearSystem2.hpp:60
MatrixCSRD A
System matrix.
Definition FDMLinearSystem2.hpp:65
VectorND b
RHS vector.
Definition FDMLinearSystem2.hpp:71
void Clear()
Clears all the data.
VectorND x
Solution vector.
Definition FDMLinearSystem2.hpp:68
Linear system (Ax=b) for 2-D finite differencing.
Definition FDMLinearSystem2.hpp:41
void Resize(const Vector2UZ &size)
Resizes the arrays with given grid size.
FDMMatrix2 A
System matrix.
Definition FDMLinearSystem2.hpp:49
FDMVector2 x
Solution vector.
Definition FDMLinearSystem2.hpp:52
void Clear()
Clears all the data.
FDMVector2 b
RHS vector.
Definition FDMLinearSystem2.hpp:55
The row of FDMMatrix2 where row corresponds to (i, j) grid point.
Definition FDMLinearSystem2.hpp:22
double center
Diagonal component of the matrix (row, row).
Definition FDMLinearSystem2.hpp:24
double up
Off-diagonal element where column refers to (i, j+1) grid point.
Definition FDMLinearSystem2.hpp:30
double right
Off-diagonal element where column refers to (i+1, j) grid point.
Definition FDMLinearSystem2.hpp:27