OpenCAEPoro  v0.5.0
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 // faspcpr header files
29 #if WITH_FASPCPR
30 extern "C" {
31 #include "faspcpr.h"
32 #include "faspcpr_functs.h"
33 }
34 #endif
35 
36 // fasp4blkoil header files
37 #if WITH_FASP4BLKOIL
38 extern "C" {
39 #include "fasp4blkoil.h"
40 #include "fasp4blkoil_functs.h"
41 }
42 #endif
43 
44 // fasp4cuda header files
45 // Note: It should not inside extern "C" {} !
46 #if WITH_FASP4CUDA
47 #include "fasp4cuda.h"
48 #include "fasp4cuda_functs.h"
49 #endif
50 
51 // OpenCAEPoro header files
52 #include "LinearSolver.hpp"
53 
54 using namespace std;
55 
56 // Standard preconditioner types
57 #define PC_NULL 60
58 #define PC_FASP1 61
59 #define PC_FASP2 62
60 #define PC_FASP3 63
61 #define PC_FASP4 64
62 #define PC_FASP5 65
63 #define PC_DIAG 68
64 #define PC_BILU 69
65 
66 // Sharing-setup preconditioner types
67 #define PC_FASP1_SHARE 71
68 #define PC_FASP4_SHARE 74
69 #define RESET_CONST 35
70 
72 class FaspSolver : public LinearSolver
73 {
74 public:
76  void SetupParam(const string& dir, const string& file) override;
77 
79  USI GetNumIters() const override { return itParam.maxit; }
80 
81 public:
82  string solveDir;
83  string solveFile;
84  input_param inParam;
85  ITS_param itParam;
86  AMG_param amgParam;
87  ILU_param iluParam;
88  SWZ_param swzParam;
89 };
90 
93 {
94  friend class LinearSystem;
95 
96 private:
98  void Allocate(const vector<USI>& rowCapacity,
99  const OCP_USI& maxDim,
100  const USI& blockDim) override;
101 
103  void InitParam() override;
104 
106  void AssembleMat(const vector<vector<USI>>& colId,
107  const vector<vector<OCP_DBL>>& val,
108  const OCP_USI& dim,
109  const USI& blockDim,
110  vector<OCP_DBL>& rhs,
111  vector<OCP_DBL>& u) override;
112 
114  OCP_INT Solve() override;
115 
116 private:
117  dCSRmat A;
118  dvector b;
119  dvector x;
120 };
121 
124 {
125  friend class LinearSystem;
126 
127 private:
129  void Allocate(const vector<USI>& rowCapacity,
130  const OCP_USI& maxDim,
131  const USI& blockDim) override;
132 
134  void InitParam() override;
135 
137  void AssembleMat(const vector<vector<USI>>& colId,
138  const vector<vector<OCP_DBL>>& val,
139  const OCP_USI& dim,
140  const USI& blockDim,
141  vector<OCP_DBL>& rhs,
142  vector<OCP_DBL>& u) override;
143 
145  OCP_INT Solve() override;
146 
148  void Decoupling(dBSRmat* Absr,
149  dvector* b,
150  dBSRmat* Asc,
151  dvector* fsc,
152  ivector* order,
153  double* Dmatvec,
154  int decouple_type);
155 
156 private:
157  dBSRmat A;
158  dvector b;
159  dvector x;
160 
161  dBSRmat Asc;
162  dvector fsc;
163  ivector order;
164 
165  vector<OCP_DBL> Dmat;
166 };
167 
168 #endif // __FASPSOLVER_HEADER__
169 
170 /*----------------------------------------------------------------------------*/
171 /* Brief Change History of This File */
172 /*----------------------------------------------------------------------------*/
173 /* Author Date Actions */
174 /*----------------------------------------------------------------------------*/
175 /* Shizhe Li Nov/22/2021 Create file */
176 /* Chensong Zhang Jan/08/2022 Update Doxygen */
177 /* Chensong Zhang Jan/19/2022 Set FASP4BLKOIL as optional */
178 /* Li Zhao Apr/04/2022 Set FASP4CUDA as optional */
179 /*----------------------------------------------------------------------------*/
LinearSolver class declaration.
unsigned int USI
Generic unsigned integer.
Definition: OCPConst.hpp:23
unsigned int OCP_USI
Long unsigned integer.
Definition: OCPConst.hpp:25
int OCP_INT
Long integer.
Definition: OCPConst.hpp:26
Basic FASP solver class.
Definition: FaspSolver.hpp:73
AMG_param amgParam
Parameters for AMG method.
Definition: FaspSolver.hpp:86
input_param inParam
Parameters from input files.
Definition: FaspSolver.hpp:84
ILU_param iluParam
Parameters for ILU method.
Definition: FaspSolver.hpp:87
string solveFile
Relative path of fasp file.
Definition: FaspSolver.hpp:83
SWZ_param swzParam
Parameters for Schwarz method.
Definition: FaspSolver.hpp:88
string solveDir
Current work dir.
Definition: FaspSolver.hpp:82
ITS_param itParam
Parameters for iterative method.
Definition: FaspSolver.hpp:85
USI GetNumIters() const override
Get number of iterations used by iterative solver.
Definition: FaspSolver.hpp:79
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:93
Vector solvers in BSR format from FASP.
Definition: FaspSolver.hpp:124