21 const std::string &file)
30 PetscFunctionBeginUser;
34 ierr = PetscFinalized(&finalized); CHKERRV(ierr);
35 if (finalized)
return;
37 ierr =
amgx.finalize(); CHKERRV(ierr);
43 PetscFunctionBeginUser;
47 ierr =
amgx.finalize(); CHKERRQ(ierr);
50 PetscFunctionReturn(0);
56 PetscFunctionBeginUser;
65 config =
"solversAmgXOptions-tmp.info";
66 std::fstream file(
config.c_str(), std::ios::out);
69 ierr =
amgx.initialize(PETSC_COMM_WORLD,
"dDDI",
config); CHKERRQ(ierr);
72 if (
config ==
"solversAmgXOptions-tmp.info") std::remove(
config.c_str());
74 PetscFunctionReturn(0);
80 PetscFunctionBeginUser;
84 ierr =
amgx.setA(A); CHKERRQ(ierr);
86 PetscFunctionReturn(0);
92 PetscFunctionBeginUser;
96 ierr =
amgx.solve(
x, b); CHKERRQ(ierr);
98 PetscFunctionReturn(0);
104 PetscFunctionBeginUser;
108 ierr =
amgx.getIters(iters); CHKERRQ(ierr);
110 PetscFunctionReturn(0);
116 PetscFunctionBeginUser;
122 ierr =
amgx.getIters(iter); CHKERRQ(ierr);
123 ierr =
amgx.getResidual(iter, res); CHKERRQ(ierr);
125 PetscFunctionReturn(0);
virtual PetscErrorCode setMatrix(const Mat &A)
Set the coefficient matrix of the linear system.
virtual ~LinSolverAmgX()
Default destructor.
LinSolverAmgX(const std::string &solverName, const std::string &file)
Constructor.
virtual PetscErrorCode solve(Vec &x, Vec &b)
Solve the linear system.
virtual PetscErrorCode destroy()
Manually destroy the data in the current instance.
virtual PetscErrorCode init()
Private initialization function.
virtual PetscErrorCode getIters(PetscInt &iters)
Get the number of iterations of the solver.
AmgXSolver amgx
the underlying AmgX wrapper solver.
virtual PetscErrorCode getResidual(PetscReal &res)
Get the final residual of the solver.
The abstract (base) class for different iterative solvers.
std::string config
Path of the solver configuration file to read.
virtual PetscErrorCode destroy()
Manually destroy the data in the current instance.
std::string type
Type of the linear solver.
A toolbox for building flow solvers.