18 rowCapacity.resize(maxDim);
21 diagPtr.resize(maxDim);
22 diagVal.resize(maxDim * blockSize);
23 b.resize(maxDim * blockDim);
24 u.resize(maxDim * blockDim);
29 for (
OCP_USI n = 0; n < maxDim; n++) {
30 colId[n].reserve(rowCapacity[n]);
31 val[n].reserve(rowCapacity[n] * blockSize);
37 for (
OCP_USI n = 0; n < maxDim; n++) {
38 rowCapacity[n] = colnum;
39 colId[n].reserve(colnum);
40 val[n].reserve(colnum * blockSize);
46 for (
OCP_USI i = 0; i < maxDim; i++) {
51 fill(diagVal.begin(), diagVal.end(), 0.0);
52 fill(b.begin(), b.end(), 0.0);
60 for (
OCP_USI i = 0; i < nrow; i++) {
67 string FileA = solveDir + fileA;
68 string Fileb = solveDir + fileb;
73 if (!outA.is_open()) cout <<
"Can not open " << FileA << endl;
76 outA << blockDim << endl;
80 for (
OCP_USI i = 0; i < dim; i++) {
81 outA << rowId << endl;
82 rowId += colId[i].size();
84 outA << rowId << endl;
87 for (
OCP_USI i = 0; i < dim; i++) {
88 rowSize = colId[i].size();
89 for (
USI j = 0; j < rowSize; j++) {
90 outA << colId[i][j] + 1 << endl;
94 for (
OCP_USI i = 0; i < dim; i++) {
95 rowSize = val[i].size();
96 for (
USI j = 0; j < rowSize; j++) {
97 outA << val[i][j] << endl;
104 ofstream outb(Fileb);
105 if (!outb.is_open()) cout <<
"Can not open " << Fileb << endl;
107 for (
OCP_USI i = 0; i < nRow; i++) {
108 outb << b[i] << endl;
114 string FileU = solveDir + fileU;
115 ofstream outu(FileU);
116 if (!outu.is_open()) cout <<
"Can not open " << FileU << endl;
119 for (
OCP_USI i = 0; i < nrow; i++) outu << u[i] << endl;
126 for (
OCP_USI n = 0; n < dim; n++) {
127 for (
auto v : val[n]) {
135 for (
OCP_USI n = 0; n < len; n++) {
136 if (!isfinite(b[n])) {
145 for (
OCP_USI n = 0; n < len; n++) {
146 if (!isfinite(u[n])) {
171 LS->
Allocate(rowCapacity, maxDim, blockDim);
Linear solver class declaration.
const USI VECTORFASP
Use vector linear solver in Fasp.
unsigned int USI
Generic unsigned integer.
unsigned int OCP_USI
Long unsigned integer.
const USI SCALARFASP
Use scalar linear solver in Fasp.
#define OCP_ABORT(msg)
Abort if critical error happens.
virtual void Allocate(const vector< USI > &rowCapacity, const OCP_USI &maxDim, const USI &blockDim)=0
Allocate maximum memory for linear solvers.
virtual void SetupParam(const string &dir, const string &file)=0
Read the params for linear solvers from an input file.
void OutputLinearSystem(const string &fileA, const string &fileb) const
Output the mat and rhs to fileA and fileb. // TODO: output to some obj?
void AllocateColMem()
Allocate memory for each matrix row with max possible number of columns.
void AllocateRowMem(const OCP_USI &dimMax, const USI &nb)
Allocate memory for linear system with max possible number of rows.
void ClearData()
Clear the internal matrix data for scalar-value problems.
void AssembleRhs(const vector< OCP_DBL > &rhs)
Assign Rhs — used for FIM now.
void CheckEquation() const
Check whether NAN or INF occurs in equations, used in debug mode.
void SetupLinearSolver(const USI &i, const string &dir, const string &file)
Setup LinearSolver.
void OutputSolution(const string &filename) const
Output the solution to a disk file name.
void CheckSolution() const
Check whether NAN or INF occurs in solutions, used in debug mode.
Scalar solvers in CSR format from FASP.
Vector solvers in BSR format from FASP.