12 #ifndef __LINEARSYSTEM_HEADER__
13 #define __LINEARSYSTEM_HEADER__
35 void AllocateRowMem(
const OCP_USI& dimMax,
const USI& nb);
37 void AllocateColMem(
const vector<USI>& bulk2bulk,
38 const vector<vector<OCP_USI>> well2bulk);
45 void CheckEquation()
const;
47 void CheckSolution()
const;
49 void OutputLinearSystem(
const string& fileA,
const string& fileb)
const;
51 void OutputSolution(
const string& filename)
const;
55 void SetupLinearSolver(
const USI& i,
const string& dir,
const string& file);
72 OCP_ASSERT(colId[n].size() == 0,
"Wrong Diag");
73 colId[n].push_back(n);
85 OCP_ASSERT(colId[bId].size() > 0,
"Wrong Diag");
86 colId[bId].push_back(eId);
87 val[bId].push_back(v);
95 void NewDiag(
const OCP_USI& n,
const vector<OCP_DBL>& v)
97 OCP_ASSERT(colId[n].size() == 0,
"Wrong Diag");
98 colId[n].push_back(n);
99 val[n].insert(val[n].begin(), v.begin(), v.end());
101 void AddDiag(
const OCP_USI& n,
const vector<OCP_DBL>& v)
103 OCP_ASSERT(colId[n].size() > 0,
"Wrong Diag");
104 for (
USI i = 0; i < blockSize; i++) {
108 void NewOffDiag(
const OCP_USI& bId,
const OCP_USI& eId,
const vector<OCP_DBL>& v)
110 OCP_ASSERT(colId[bId].size() > 0,
"Wrong Diag");
111 colId[bId].push_back(eId);
112 val[bId].insert(val[bId].end(), v.begin(), v.end());
117 for (
USI i = 0; i < blockDim; i++) {
118 b[n * blockDim + i] += v[i];
123 void AssembleRhsAccumulate(
const vector<OCP_DBL>& rhs);
125 void AssembleRhsCopy(
const vector<OCP_DBL>& rhs);
144 vector<USI> rowCapacity;
145 vector<vector<OCP_USI>> colId;
146 vector<vector<OCP_DBL>> val;
Operations about small dense mat.
Declaration of classes interfacing to the FASP solvers.
Definition of build-in datatypes and consts.
unsigned int USI
Generic unsigned integer.
double OCP_DBL
Double precision.
unsigned int OCP_USI
Long unsigned integer.
#define OCP_ASSERT(cond, msg)
Assert condition and log user messages in DEBUG mode.
Virtual base class for linear solvers.
Linear solvers for discrete systems.
USI GetNumIters()
Return the number of iterations.
void AddRhs(const OCP_USI &n, const vector< OCP_DBL > &v)
Add a value at b[n].
void AssembleMatLinearSolver()
Assemble Mat for Linear Solver.
void AddDiag(const OCP_USI &n, const OCP_DBL &v)
Add a value at diagonal value.
void NewDiag(const OCP_USI &n, const OCP_DBL &v)
Push back a diagonal val, which is always at the first location.
void AssignGuess(const OCP_USI &n, const OCP_DBL &v)
Assign an initial value at u[n].
void AddRhs(const OCP_USI &n, const OCP_DBL &v)
Add a value at b[n].
void NewOffDiag(const OCP_USI &bId, const OCP_USI &eId, const OCP_DBL &v)
Push back a off-diagonal value.
OCP_INT Solve()
Solve the Linear System.
OCP_USI AddDim(const OCP_USI &n)
Setup dimensions.
vector< OCP_DBL > & GetSolution()
Return the solution.