OOFEM 3.0
Loading...
Searching...
No Matches
oofem::PetscSolver Class Reference

#include <petscsolver.h>

Inheritance diagram for oofem::PetscSolver:
Collaboration diagram for oofem::PetscSolver:

Public Member Functions

 PetscSolver (Domain *d, EngngModel *m)
virtual ~PetscSolver ()
ConvergedReason solve (SparseMtrx &A, FloatArray &b, FloatArray &x) override
ConvergedReason petsc_solve (PetscSparseMtrx &A, Vec b, Vec x)
const char * giveClassName () const override
LinSystSolverType giveLinSystSolverType () const override
SparseMtrxType giveRecommendedMatrix (bool symmetric) const override
Public Member Functions inherited from oofem::SparseLinearSystemNM
 SparseLinearSystemNM (Domain *d, EngngModel *m)
 Constructor.
virtual ~SparseLinearSystemNM ()
 Destructor.
std::string errorInfo (const char *func)
virtual ConvergedReason solve (SparseMtrx &A, FloatMatrix &B, FloatMatrix &X)
Public Member Functions inherited from oofem::NumericalMethod
 NumericalMethod (Domain *d, EngngModel *m)
virtual ~NumericalMethod ()
 Destructor.
EngngModelgiveEngngModel ()
virtual void initializeFrom (InputRecord &ir)
virtual void reinitialize ()
virtual void setDomain (Domain *d)
virtual void saveContext (DataStream &stream, ContextMode mode)
virtual void restoreContext (DataStream &stream, ContextMode mode)

Additional Inherited Members

Protected Attributes inherited from oofem::NumericalMethod
Domaindomain
 Pointer to domain.
EngngModelengngModel
 Pointer to engineering model.

Detailed Description

Implements the solution of linear system of equation in the form \(A\cdot x=b\) using solvers from PETSc library. Only works with the PETSc sparse matrix implementation.

Definition at line 52 of file petscsolver.h.

Constructor & Destructor Documentation

◆ PetscSolver()

oofem::PetscSolver::PetscSolver ( Domain * d,
EngngModel * m )

Constructor.

Parameters
dDomain which solver belongs to.
mEngineering model which solver belongs to.

Definition at line 51 of file petscsolver.C.

References oofem::SparseLinearSystemNM::SparseLinearSystemNM().

◆ ~PetscSolver()

oofem::PetscSolver::~PetscSolver ( )
virtual

Definition at line 53 of file petscsolver.C.

Member Function Documentation

◆ giveClassName()

const char * oofem::PetscSolver::giveClassName ( ) const
inlineoverridevirtual

Implements oofem::SparseLinearSystemNM.

Definition at line 75 of file petscsolver.h.

◆ giveLinSystSolverType()

LinSystSolverType oofem::PetscSolver::giveLinSystSolverType ( ) const
inlineoverridevirtual
Returns
LinSystSolverType value, corresponding to receiver.

Implements oofem::SparseLinearSystemNM.

Definition at line 76 of file petscsolver.h.

References oofem::ST_Petsc.

◆ giveRecommendedMatrix()

SparseMtrxType oofem::PetscSolver::giveRecommendedMatrix ( bool symmetric) const
inlineoverridevirtual

Returns the recommended sparse matrix type for this solver.

Implements oofem::SparseLinearSystemNM.

Definition at line 77 of file petscsolver.h.

References oofem::SMT_PetscMtrx.

◆ petsc_solve()

ConvergedReason oofem::PetscSolver::petsc_solve ( PetscSparseMtrx & A,
Vec b,
Vec x )

Solves the given linear system.

Parameters
ACoefficient matrix.
bRight hand side (PETSC Vec(tor)).
xSolution array(PETSC Vec(tor)).
Returns
ConvergedReason value.
Todo
I'm not 100% on the choice MatStructure. SAME_NONZERO_PATTERN should be safe.

Definition at line 91 of file petscsolver.C.

References oofem::CR_CONVERGED, oofem::CR_DIVERGED_ITS, oofem::NumericalMethod::engngModel, oofem::Timer::getUtime(), oofem::PetscSparseMtrx::giveMtrx(), oofem::PetscSparseMtrx::ksp, oofem::PetscSparseMtrx::kspInit, oofem::macroScale, oofem::PetscSparseMtrx::newValues, OOFEM_ERROR, OOFEM_LOG_INFO, OOFEM_WARNING, oofem::Timer::startTimer(), and oofem::Timer::stopTimer().

Referenced by solve().

◆ solve()

ConvergedReason oofem::PetscSolver::solve ( SparseMtrx & A,
FloatArray & b,
FloatArray & x )
overridevirtual

Solves the given sparse linear system of equations \( A\cdot x=b \).

Parameters
ACoefficient matrix.
bRight hand side.
xSolution array.
Returns
Status of the solver.

Implements oofem::SparseLinearSystemNM.

Definition at line 55 of file petscsolver.C.

References oofem::PetscSparseMtrx::createVecGlobal(), oofem::FloatArray::giveSize(), OOFEM_ERROR, petsc_solve(), oofem::FloatArray::resize(), oofem::PetscSparseMtrx::scatterG2L(), and oofem::PetscSparseMtrx::scatterL2G().


The documentation for this class was generated from the following files:

This page is part of the OOFEM-3.0 documentation. Copyright Copyright (C) 1994-2025 Borek Patzak Bořek Patzák
Project e-mail: oofem@fsv.cvut.cz
Generated at for OOFEM by doxygen 1.15.0 written by Dimitri van Heesch, © 1997-2011