OpenCAEPoro  0.2.0 Sep/22/2022
A simulator for multicomponent porous media flow
FaspSolver.hpp
Go to the documentation of this file.
1 
12 #ifndef __FASPSOLVER_HEADER__
13 #define __FASPSOLVER_HEADER__
14 
15 // Standard header files
16 #include <fstream>
17 #include <iostream>
18 #include <string>
19 #include <vector>
20 
21 // faspsolver header files
22 extern "C" {
23 #include "fasp.h"
24 #include "fasp_block.h"
25 #include "fasp_functs.h"
26 }
27 
28 // fasp4blkoil header files
29 #if WITH_FASP4BLKOIL
30 extern "C" {
31 #include "fasp4blkoil.h"
32 #include "fasp4blkoil_functs.h"
33 }
34 #endif
35 
36 // fasp4cuda header files
37 // Note: It should not inside extern "C" {} !
38 #if WITH_FASP4CUDA
39 #include "fasp4cuda.h"
40 #include "fasp4cuda_functs.h"
41 #endif
42 
43 // OpenCAEPoro header files
44 #include "LinearSolver.hpp"
45 
46 using namespace std;
47 
48 // Standard preconditioner types
49 #define PC_NULL 60
50 #define PC_FASP1 61
51 #define PC_FASP2 62
52 #define PC_FASP3 63
53 #define PC_FASP4 64
54 #define PC_FASP5 65
55 #define PC_DIAG 68
56 #define PC_BILU 69
57 
58 // Sharing-setup preconditioner types
59 #define PC_FASP1_SHARE 71
60 #define PC_FASP4_SHARE 74
61 #define RESET_CONST 35
62 
64 class FaspSolver : public LinearSolver
65 {
66 public:
68  void SetupParam(const string& dir, const string& file) override;
69 
71  USI GetNumIters() const override { return itParam.maxit; }
72 
73 public:
74  string solveDir;
75  string solveFile;
76  input_param inParam;
77  ITS_param itParam;
78  AMG_param amgParam;
79  ILU_param iluParam;
80  SWZ_param swzParam;
81 };
82 
85 {
86  friend class LinearSystem;
87 
88 private:
90  void Allocate(const vector<USI>& rowCapacity,
91  const OCP_USI& maxDim,
92  const USI& blockDim) override;
93 
95  void InitParam() override;
96 
98  void AssembleMat(const vector<vector<USI>>& colId,
99  const vector<vector<OCP_DBL>>& val,
100  const OCP_USI& dim,
101  const USI& blockDim,
102  vector<OCP_DBL>& rhs,
103  vector<OCP_DBL>& u) override;
104 
106  OCP_INT Solve() override;
107 
108 private:
109  dCSRmat A;
110  dvector b;
111  dvector x;
112 };
113 
116 {
117  friend class LinearSystem;
118 
119 private:
121  void Allocate(const vector<USI>& rowCapacity,
122  const OCP_USI& maxDim,
123  const USI& blockDim) override;
124 
126  void InitParam() override;
127 
129  void AssembleMat(const vector<vector<USI>>& colId,
130  const vector<vector<OCP_DBL>>& val,
131  const OCP_USI& dim,
132  const USI& blockDim,
133  vector<OCP_DBL>& rhs,
134  vector<OCP_DBL>& u) override;
135 
137  OCP_INT Solve() override;
138 
140  void Decoupling(dBSRmat* Absr,
141  dvector* b,
142  dBSRmat* Asc,
143  dvector* fsc,
144  ivector* order,
145  double* Dmatvec,
146  int decouple_type);
147 
148 private:
149  dBSRmat A;
150  dvector b;
151  dvector x;
152 
153  dBSRmat Asc;
154  dvector fsc;
155  ivector order;
156 
157  vector<OCP_DBL> Dmat;
158 };
159 
160 #endif // __FASPSOLVER_HEADER__
161 
162 /*----------------------------------------------------------------------------*/
163 /* Brief Change History of This File */
164 /*----------------------------------------------------------------------------*/
165 /* Author Date Actions */
166 /*----------------------------------------------------------------------------*/
167 /* Shizhe Li Nov/22/2021 Create file */
168 /* Chensong Zhang Jan/08/2022 Update Doxygen */
169 /* Chensong Zhang Jan/19/2022 Set FASP4BLKOIL as optional */
170 /* Li Zhao Apr/04/2022 Set FASP4CUDA as optional */
171 /*----------------------------------------------------------------------------*/
LinearSolver class declaration.
unsigned int USI
Generic unsigned integer.
Definition: OCPConst.hpp:22
unsigned int OCP_USI
Long unsigned integer.
Definition: OCPConst.hpp:24
int OCP_INT
Long integer.
Definition: OCPConst.hpp:25
Basic FASP solver class.
Definition: FaspSolver.hpp:65
AMG_param amgParam
Parameters for AMG method.
Definition: FaspSolver.hpp:78
input_param inParam
Parameters from input files.
Definition: FaspSolver.hpp:76
ILU_param iluParam
Parameters for ILU method.
Definition: FaspSolver.hpp:79
string solveFile
Relative path of fasp file.
Definition: FaspSolver.hpp:75
SWZ_param swzParam
Parameters for Schwarz method.
Definition: FaspSolver.hpp:80
string solveDir
Current work dir.
Definition: FaspSolver.hpp:74
ITS_param itParam
Parameters for iterative method.
Definition: FaspSolver.hpp:77
USI GetNumIters() const override
Get number of iterations used by iterative solver.
Definition: FaspSolver.hpp:71
Virtual base class for linear solvers.
Linear solvers for discrete systems.
OCP_INT Solve()
Solve the Linear System.
Scalar solvers in CSR format from FASP.
Definition: FaspSolver.hpp:85
Vector solvers in BSR format from FASP.
Definition: FaspSolver.hpp:116