19 rowCapacity.resize(maxDim);
22 b.resize(maxDim * blockDim);
23 u.resize(maxDim * blockDim);
27 const vector<vector<OCP_USI>> well2bulk)
30 const OCP_USI bulkNum = bulk2bulk.size();
31 for (
OCP_USI n = 0; n < bulkNum; n++) {
32 rowCapacity[n] = bulk2bulk[n];
36 const OCP_USI wellNum = well2bulk.size();
38 for (
auto& w : well2bulk) {
39 for (
auto& p : w) rowCapacity[p]++;
40 if (maxPerfNum < w.size()) {
41 maxPerfNum = w.size();
47 for (
OCP_USI w = bulkNum; w < bulkNum + wellNum; w++) {
48 rowCapacity[w] += (maxPerfNum + 1);
51 for (
OCP_USI n = 0; n < maxDim; n++) {
52 colId[n].reserve(rowCapacity[n]);
53 val[n].reserve(rowCapacity[n] * blockSize);
59 for (
OCP_USI i = 0; i < maxDim; i++) {
64 fill(b.begin(), b.end(), 0.0);
73 for (
OCP_USI i = 0; i < nrow; i++) {
80 Dcopy(dim * blockDim, &b[0], &rhs[0]);
85 string FileA = solveDir + fileA;
86 string Fileb = solveDir + fileb;
91 if (!outA.is_open()) cout <<
"Can not open " << FileA << endl;
94 outA << blockDim <<
"\n";
98 for (
OCP_USI i = 0; i < dim; i++) {
99 outA << rowId <<
"\n";
100 rowId += colId[i].size();
102 outA << rowId <<
"\n";
105 for (
OCP_USI i = 0; i < dim; i++) {
106 rowSize = colId[i].size();
107 for (
USI j = 0; j < rowSize; j++) {
108 outA << colId[i][j] + 1 <<
"\n";
112 for (
OCP_USI i = 0; i < dim; i++) {
113 rowSize = val[i].size();
114 for (
USI j = 0; j < rowSize; j++) {
115 outA << val[i][j] <<
"\n";
122 ofstream outb(Fileb);
123 if (!outb.is_open()) cout <<
"Can not open " << Fileb << endl;
125 for (
OCP_USI i = 0; i < nRow; i++) {
126 outb << b[i] <<
"\n";
132 string FileU = solveDir + fileU;
133 ofstream outu(FileU);
134 if (!outu.is_open()) cout <<
"Can not open " << FileU << endl;
137 for (
OCP_USI i = 0; i < nrow; i++) outu << u[i] <<
"\n";
144 for (
OCP_USI n = 0; n < dim; n++) {
145 for (
auto v : val[n]) {
153 for (
OCP_USI n = 0; n < len; n++) {
154 if (!isfinite(b[n])) {
163 for (
OCP_USI n = 0; n < len; n++) {
164 if (!isfinite(u[n])) {
190 LS->
Allocate(rowCapacity, maxDim, blockDim);
void Dcopy(const int &N, double *dst, const double *src)
Calculate the minimal eigenvalue for symmetric matrix with mkl lapack.
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(const vector< USI > &bulk2bulk, const vector< vector< OCP_USI >> well2bulk)
Allocate memory for linear system with max possible number of columns.
void AssembleRhsCopy(const vector< OCP_DBL > &rhs)
Assign Rhs by Copying.
void AssembleRhsAccumulate(const vector< OCP_DBL > &rhs)
Assign Rhs by Accumulating.
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 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.