83 VecDestroy(& globSolVec);
84 VecDestroy(& globRhsVec);
94 KSPConvergedReason reason;
106 #ifdef __PARALLEL_MODE 109 MPI_Comm comm = PETSC_COMM_SELF;
111 KSPCreate(comm, & Lhs.
ksp);
122 #if PETSC_VERSION_MAJOR >= 3 && PETSC_VERSION_MINOR >= 5 130 #if PETSC_VERSION_MAJOR >= 3 && PETSC_VERSION_MINOR >= 5 146 KSPSetTolerances(Lhs.
ksp, PETSC_DEFAULT, PETSC_DEFAULT, PETSC_DEFAULT, PETSC_DEFAULT);
155 KSPSetFromOptions(Lhs.
ksp);
162 err = KSPSolve(Lhs.
ksp, b, x);
166 KSPGetConvergedReason(Lhs.
ksp, & reason);
167 KSPGetIterationNumber(Lhs.
ksp, & nite);
172 OOFEM_WARNING(
"Diverged! KSPConvergedReason: %d, number of iterations: %d\n", reason, nite);
177 OOFEM_LOG_INFO(
"PetscSolver: User time consumed by solution: %.2fs, KSPConvergedReason: %d, number of iterations: %d\n", timer.
getUtime(), reason, nite );
207 for (
int i = 0; i < cols; ++i ) {
208 VecCreateSeqWithArray(PETSC_COMM_SELF, rows, B.
givePointer() + rows * i, & globRhsVec);
209 VecDuplicate(globRhsVec, & globSolVec);
210 s = this->
petsc_solve(*Lhs, globRhsVec, globSolVec, newLhs);
217 VecGetArray(globSolVec, & ptr);
218 for (
int j = 0; j < rows; ++j ) {
219 Xptr [ j + rows * i ] = ptr [ j ];
221 VecRestoreArray(globSolVec, & ptr);
223 VecDestroy(& globSolVec);
224 VecDestroy(& globRhsVec);
int giveNumberOfColumns() const
Returns number of columns of receiver.
#define NM_Success
Numerical method exited with success.
problemScale giveProblemScale()
Returns scale in multiscale simulation.
Base class for all matrices stored in sparse format.
virtual int requiresUnknownsDictionaryUpdate()
Indicates if EngngModel requires Dofs dictionaries to be updated.
void createVecGlobal(Vec *answer) const
Creates a global vector that fits the instance of this matrix.
This base class is an abstraction for all numerical methods solving sparse linear system of equations...
const double * givePointer() const
Exposes the internal values of the matrix.
KSP ksp
Linear solver context.
unsigned long NM_Status
Mask defining NumMetod Status; which can be asked after finishing computation by Numerical Method...
#define NM_NoSuccess
Numerical method failed to solve problem.
#define OOFEM_LOG_INFO(...)
int scatterL2G(const FloatArray &src, Vec dest) const
Scatters and gathers vector in local form to global (parallel) one.
MPI_Comm giveParallelComm()
Returns the communication object of reciever.
Initializes the variable VERBOSE, in order to get a few intermediate messages on screen: beginning an...
Class representing vector of real numbers.
Implementation of matrix containing floating point numbers.
bool kspInit
Flag if context initialized.
void resize(int rows, int cols)
Checks size of receiver towards requested bounds.
PetscSolver(Domain *d, EngngModel *m)
Constructor.
REGISTER_SparseLinSolver(IMLSolver, ST_IML)
Class implementing single timer, providing wall clock and user time capabilities. ...
bool newValues
Flag if matrix has changed since last solve.
NM_Status petsc_solve(PetscSparseMtrx &A, Vec b, Vec x)
Solves the given linear system.
Abstract base class representing the "problem" under consideration.
int giveSize() const
Returns the size of receiver.
the oofem namespace is to define a context or scope in which all oofem names are defined.
int scatterG2L(Vec src, FloatArray &dest) const
Scatters global vector to natural one.
virtual NM_Status solve(SparseMtrx &A, FloatArray &b, FloatArray &x)
Solves the given sparse linear system of equations .
int giveNumberOfRows() const
Returns number of rows of receiver.
EngngModel * engngModel
Pointer to engineering model.
This class provides an sparse matrix interface to PETSc Matrices.
double getUtime()
Returns total user time elapsed in seconds.
#define OOFEM_WARNING(...)
void resize(int s)
Resizes receiver towards requested size.