Advanced Multi-Physics (AMP)
On-Line Documentation
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
AMP::Solver::PetscSNESSolver Class Reference

#include <PetscSNESSolver.h>

Inheritance diagram for AMP::Solver::PetscSNESSolver:
Inheritance graph
[legend]

Public Types

typedef std::shared_ptr< AMP::Solver::SolverStrategyshared_ptr
 
enum class  SolverStatus {
  ConvergedOnAbsTol , ConvergedOnRelTol , ConvergedUserCondition , MaxIterations ,
  DivergedLineSearch , DivergedStepSize , DivergedFunctionCount , DivergedOnNan ,
  DivergedNestedSolver , DivergedOther
}
 

Public Member Functions

void apply (std::shared_ptr< const AMP::LinearAlgebra::Vector > f, std::shared_ptr< AMP::LinearAlgebra::Vector > u) override
 
AMP::Scalar getAbsoluteTolerance () const
 
int getBoundsCheckComponent (void)
 
bool getConverged (void) const
 
SolverStatus getConvergenceStatus (void) const
 
std::string getConvergenceStatusString (void) const
 
int getDebugPrintInfoLevel (void)
 
AMP::Utilities::ExecutionSpace getExecutionSpace () const
 
std::shared_ptr< AMP::LinearAlgebra::VectorgetFunctionScaling ()
 
virtual AMP::Scalar getInitialResidual (void) const
 
virtual const std::vector< int > & getIterationHistory (void)
 
virtual int getIterations (void) const
 
std::shared_ptr< PetscKrylovSolvergetKrylovSolver (void)
 
std::function< int(std::shared_ptr< AMP::LinearAlgebra::Vector >, std::shared_ptr< AMP::LinearAlgebra::Vector >, bool &)> getLineSearchPreCheckAdaptor ()
 
int getMaxIterations (void) const
 
std::shared_ptr< SolverStrategygetNestedSolver (void) override
 
int getNumberOfLineSearchPreCheckAttempts (void)
 
virtual std::shared_ptr< AMP::Operator::OperatorgetOperator (void)
 
AMP::Scalar getRelativeTolerance () const
 
virtual AMP::Scalar getResidualNorm (void) const
 
std::shared_ptr< AMP::LinearAlgebra::VectorgetScratchVector (void)
 
SNES getSNESSolver (void)
 
std::shared_ptr< AMP::LinearAlgebra::VectorgetSolution (void)
 
std::shared_ptr< AMP::LinearAlgebra::VectorgetSolutionScaling ()
 
int getTotalNumberOfIterations (void)
 
int getTotalNumberOfLinearIterations (void) const
 
bool getUsesJacobian (void)
 
virtual void initialize (std::shared_ptr< const SolverStrategyParameters > parameters)
 
 PetscSNESSolver ()
 
 PetscSNESSolver (std::shared_ptr< SolverStrategyParameters > parameters)
 
virtual void print (std::ostream &)
 
void printConvergenceStatus (SolverStrategy::SolverStatus status, std::ostream &os=AMP::pout) const override
 
virtual void printStatistics (std::ostream &os=AMP::pout)
 
virtual void registerOperator (std::shared_ptr< AMP::Operator::Operator > op)
 
virtual void registerWriter (std::shared_ptr< AMP::IO::Writer > writer)
 Registers a writer with the solver.
 
void reset (std::shared_ptr< AMP::Solver::SolverStrategyParameters >) override
 pointer to line search function
 
virtual void reset (std::shared_ptr< SolverStrategyParameters > parameters)
 
virtual void resetOperator (std::shared_ptr< const AMP::Operator::OperatorParameters > parameters)
 
virtual void residual (std::shared_ptr< const AMP::LinearAlgebra::Vector > f, std::shared_ptr< const AMP::LinearAlgebra::Vector > u, std::shared_ptr< AMP::LinearAlgebra::Vector > r)
 
virtual void setAbsoluteTolerance (AMP::Scalar abs_tol)
 
void setComponentScalings (std::shared_ptr< AMP::LinearAlgebra::Vector > s, std::shared_ptr< AMP::LinearAlgebra::Vector > f)
 for multiphysics problems it may be necessary to scale the solution
 
virtual void setDebugPrintInfoLevel (int print_level)
 
void setExecutionSpace (AMP::Utilities::ExecutionSpace space)
 
void setInitialGuess (std::shared_ptr< AMP::LinearAlgebra::Vector > initialGuess) override
 
void setIsNestedSolver (bool is_nested)
 Tell a solver that it is nested inside some outer solver.
 
void setLineSearchPreCheck (std::function< int(std::shared_ptr< AMP::LinearAlgebra::Vector >, std::shared_ptr< AMP::LinearAlgebra::Vector >, bool &)> lineSearchPreCheckPtr)
 set the pointer to the user function that does the line search pre-check if provided
 
virtual void setMaxIterations (const int max_iterations)
 
virtual void setNestedSolver (std::shared_ptr< SolverStrategy > solver)
 
virtual void setRelativeTolerance (AMP::Scalar rel_tol)
 
virtual void setZeroInitialGuess (bool use_zero_guess)
 
std::string type () const override
 Return the name of the solver.
 
virtual ~PetscSNESSolver ()
 

Static Public Member Functions

static std::unique_ptr< SolverStrategycreateSolver (std::shared_ptr< SolverStrategyParameters > solverStrategyParameters)
 static create routine that is used by SolverFactory
 
static std::string statusToString (SolverStatus status)
 

Protected Member Functions

virtual bool checkStoppingCriteria (AMP::Scalar res_norm, bool check_iters=true)
 
void getBaseFromInput (std::shared_ptr< AMP::Database > db)
 

Protected Attributes

bool d_bComputeResidual = false
 
bool d_bIsNestedSolver = false
 
bool d_bUseZeroInitialGuess = true
 
SolverStatus d_ConvergenceStatus = SolverStatus::DivergedOther
 
AMP::Scalar d_dAbsoluteTolerance = 1.0e-14
 
std::shared_ptr< AMP::Databased_db = nullptr
 
AMP::Scalar d_dInitialResidual
 
AMP::Scalar d_dRelativeTolerance = 1.0e-09
 
AMP::Scalar d_dResidualNorm
 
AMP::Utilities::ExecutionSpace d_exec_space = AMP::Utilities::ExecutionSpace::unspecified
 execution space for the solver
 
std::shared_ptr< AMP::Databased_global_db = nullptr
 
int d_iDebugPrintInfoLevel = 0
 
int d_iMaxIterations = 0
 
int d_iNumberIterations = 0
 
int d_iObjectId
 
std::vector< intd_iterationHistory
 keeps track of iteration statistics over solver lifetime
 
AMP::Utilities::MemoryType d_memory_location = AMP::Utilities::MemoryType::none
 memory storage address space
 
std::shared_ptr< AMP::LinearAlgebra::Vectord_pFunctionScaling
 
std::shared_ptr< AMP::Solver::SolverStrategyd_pNestedSolver = nullptr
 nested solver used by this solver
 
std::shared_ptr< AMP::Operator::Operatord_pOperator = nullptr
 
std::shared_ptr< AMP::LinearAlgebra::Vectord_pSolutionScaling
 
std::string d_sName
 
std::shared_ptr< AMP::IO::Writerd_writer = nullptr
 

Static Protected Attributes

static int d_iInstanceId
 

Private Member Functions

void createPetscObjects (std::shared_ptr< const SolverStrategyParameters > params)
 
std::shared_ptr< SolverStrategycreatePreconditioner (std::shared_ptr< AMP::Database > pc_solver_db)
 
int defaultLineSearchPreCheck (std::shared_ptr< AMP::LinearAlgebra::Vector > x, std::shared_ptr< AMP::LinearAlgebra::Vector > y, bool &changed_y)
 
void destroyPetscObjects (void)
 
void getFromInput (std::shared_ptr< const AMP::Database > db)
 
void initializePetscObjects (void)
 
void preApply (std::shared_ptr< const AMP::LinearAlgebra::Vector > v)
 
void resetPetscObjects (std::shared_ptr< AMP::Solver::SolverStrategyParameters > params)
 
void setConvergenceStatus (void)
 

Static Private Member Functions

static PetscErrorCode apply (SNES snes, Vec x, Vec f, void *ctx)
 
static PetscErrorCode applyPreconditioner (PC pc, Vec xin, Vec xout)
 
static bool isVectorValid (std::shared_ptr< AMP::Operator::Operator > &op, AMP::LinearAlgebra::Vector::shared_ptr &v, const AMP_MPI &comm)
 
static PetscErrorCode KSPPostSolve_SNESEW (KSP ksp, Vec b, Vec x, SNES snes)
 
static PetscErrorCode KSPPreSolve_SNESEW (KSP ksp, Vec b, Vec x, SNES snes)
 
static PetscErrorCode mffdCheckBounds (void *checkctx, Vec U, Vec a, PetscScalar *h)
 
static PetscErrorCode setJacobian (SNES, Vec x, Mat A, Mat, void *ctx)
 
static PetscErrorCode setupPreconditioner (PC pc)
 
static PetscErrorCode wrapperLineSearchPreCheck (SNESLineSearch snes, Vec x, Vec y, PetscBool *changed_y, void *ctx)
 

Private Attributes

bool d_bDestroyCachedVecs = false
 
bool d_bEnableLineSearchPreCheck = false
 
bool d_bEnableMFFDBoundsCheck = false
 
bool d_bPetscInterfaceInitialized = false
 
bool d_bPrintLinearResiduals = false
 
bool d_bPrintNonlinearResiduals = false
 
bool d_bUsesJacobian = false
 
AMP_MPI d_comm
 
double d_dConstantForcingTerm = PETSC_DEFAULT
 int is for passing choice to PETSc
 
double d_dEWChoice2Alpha = PETSC_DEFAULT
 
double d_dEWChoice2Gamma = PETSC_DEFAULT
 
double d_dEWSafeguardDisableThreshold = PETSC_DEFAULT
 
double d_dEWSafeguardExponent = PETSC_DEFAULT
 
double d_dInitialForcingTerm = PETSC_DEFAULT
 
double d_dMaximumForcingTerm = PETSC_DEFAULT
 
double d_dMFFDFunctionDifferencingError = PETSC_DEFAULT
 
double d_dStepTolerance = PETSC_DEFAULT
 
int d_iForcingTermFlag
 string is for input
 
std::vector< intd_iLinearIterationHistory
 keeps track of linear iteration statistics over solver lifetime
 
int d_iMaximumFunctionEvals = PETSC_DEFAULT
 
int d_iNumberOfLineSearchPreCheckAttempts = 0
 
Mat d_Jacobian = nullptr
 
std::function< int(std::shared_ptr< AMP::LinearAlgebra::Vector >, std::shared_ptr< AMP::LinearAlgebra::Vector >, bool &)> d_lineSearchPreCheckPtr
 
int d_operatorComponentToEnableBoundsCheck = 0
 
std::shared_ptr< PetscMonitord_PetscMonitor = nullptr
 
std::shared_ptr< PetscKrylovSolverd_pKrylovSolver = nullptr
 
std::shared_ptr< AMP::LinearAlgebra::Vectord_pResidualVector = nullptr
 
std::shared_ptr< AMP::LinearAlgebra::Vectord_pScratchVector = nullptr
 
std::shared_ptr< AMP::LinearAlgebra::Vectord_pSolutionVector = nullptr
 
std::string d_sForcingTermStrategy = "CONSTANT"
 
std::string d_sMFFDDifferencingStrategy = MATMFFD_WP
 
SNESConvergedReason d_SNES_completion_code
 
std::string d_SNESAppendOptionsPrefix = ""
 
SNES d_SNESSolver = nullptr
 

Detailed Description

The PETScSNESSolver is a wrapper to the PETSc SNES solver which provides an implementation of the inexact Newton method.

Definition at line 53 of file PetscSNESSolver.h.

Member Typedef Documentation

◆ shared_ptr

Definition at line 30 of file SolverStrategy.h.

Member Enumeration Documentation

◆ SolverStatus

Enumerator
ConvergedOnAbsTol 
ConvergedOnRelTol 
ConvergedUserCondition 
MaxIterations 
DivergedLineSearch 
DivergedStepSize 
DivergedFunctionCount 
DivergedOnNan 
DivergedNestedSolver 
DivergedOther 

Definition at line 62 of file SolverStrategy.h.

Constructor & Destructor Documentation

◆ PetscSNESSolver() [1/2]

AMP::Solver::PetscSNESSolver::PetscSNESSolver ( )

default constructor, sets default values for member variables

◆ PetscSNESSolver() [2/2]

AMP::Solver::PetscSNESSolver::PetscSNESSolver ( std::shared_ptr< SolverStrategyParameters parameters)
explicit

main constructor

Parameters
[in]parametersThe parameters object contains a database objects containing the following fields:
  1. type: string, name: SNESOptions, default value: "",
  2. type: bool, name: usesJacobian, default value: false, acceptable values (true, false)
  3. name: MFFDDifferencingStrategy, type:string , default value: MATMFFD_WP, acceptable values ()
  4. name: MFFDFunctionDifferencingError, type: double, default value: PETSC_DEFAULT, acceptable values ()
  5. name: maximumFunctionEvals, type: integer, default value: none acceptable values ()
  6. name: absoluteTolerance, type: double, default value: none acceptable values ()
  7. name: relativeTolerance, type: double, default value: none acceptable values ()
  8. name: stepTolerance, type: double, default value: none acceptable values ()
  9. name: enableLineSearchPreCheck, type: bool, default value: FALSE acceptable values ()
  10. name: numberOfLineSearchPreCheckAttempts, type: integer, default value: 5 acceptable values (non negative integer values)
  11. name: enableMFFDBoundsCheck, type: bool, default value: FALSE acceptable values ()
  12. name: operatorComponentToEnableBoundsCheck, type: integer, default value: none acceptable values ()

◆ ~PetscSNESSolver()

virtual AMP::Solver::PetscSNESSolver::~PetscSNESSolver ( )
virtual

Default destructor.

Member Function Documentation

◆ apply() [1/2]

static PetscErrorCode AMP::Solver::PetscSNESSolver::apply ( SNES  snes,
Vec  x,
Vec  f,
void ctx 
)
staticprivate

◆ apply() [2/2]

void AMP::Solver::PetscSNESSolver::apply ( std::shared_ptr< const AMP::LinearAlgebra::Vector f,
std::shared_ptr< AMP::LinearAlgebra::Vector u 
)
overridevirtual

Solve the system \(Au = 0\).

Parameters
[in]f: shared pointer to right hand side vector
[out]u: shared pointer to approximate computed solution

Implements AMP::Solver::SolverStrategy.

◆ applyPreconditioner()

static PetscErrorCode AMP::Solver::PetscSNESSolver::applyPreconditioner ( PC  pc,
Vec  xin,
Vec  xout 
)
staticprivate

◆ checkStoppingCriteria()

virtual bool AMP::Solver::SolverStrategy::checkStoppingCriteria ( AMP::Scalar  res_norm,
bool  check_iters = true 
)
protectedvirtualinherited

◆ createPetscObjects()

void AMP::Solver::PetscSNESSolver::createPetscObjects ( std::shared_ptr< const SolverStrategyParameters params)
private

◆ createPreconditioner()

std::shared_ptr< SolverStrategy > AMP::Solver::PetscSNESSolver::createPreconditioner ( std::shared_ptr< AMP::Database pc_solver_db)
private

◆ createSolver()

static std::unique_ptr< SolverStrategy > AMP::Solver::PetscSNESSolver::createSolver ( std::shared_ptr< SolverStrategyParameters solverStrategyParameters)
inlinestatic

static create routine that is used by SolverFactory

Definition at line 113 of file PetscSNESSolver.h.

◆ defaultLineSearchPreCheck()

int AMP::Solver::PetscSNESSolver::defaultLineSearchPreCheck ( std::shared_ptr< AMP::LinearAlgebra::Vector x,
std::shared_ptr< AMP::LinearAlgebra::Vector y,
bool changed_y 
)
private

◆ destroyPetscObjects()

void AMP::Solver::PetscSNESSolver::destroyPetscObjects ( void  )
private

◆ getAbsoluteTolerance()

AMP::Scalar AMP::Solver::SolverStrategy::getAbsoluteTolerance ( ) const
inlineinherited

◆ getBaseFromInput()

void AMP::Solver::SolverStrategy::getBaseFromInput ( std::shared_ptr< AMP::Database db)
protectedinherited

◆ getBoundsCheckComponent()

int AMP::Solver::PetscSNESSolver::getBoundsCheckComponent ( void  )
inline

Return an integer value for the component for which bounds checking is enabled.

Definition at line 174 of file PetscSNESSolver.h.

References d_operatorComponentToEnableBoundsCheck.

◆ getConverged()

bool AMP::Solver::SolverStrategy::getConverged ( void  ) const
inlineinherited

◆ getConvergenceStatus()

SolverStatus AMP::Solver::SolverStrategy::getConvergenceStatus ( void  ) const
inlineinherited

◆ getConvergenceStatusString()

std::string AMP::Solver::SolverStrategy::getConvergenceStatusString ( void  ) const
inlineinherited

◆ getDebugPrintInfoLevel()

int AMP::Solver::SolverStrategy::getDebugPrintInfoLevel ( void  )
inlineinherited

Get level of diagnostic information printed during iterations.

Definition at line 137 of file SolverStrategy.h.

References AMP::Solver::SolverStrategy::d_iDebugPrintInfoLevel.

◆ getExecutionSpace()

AMP::Utilities::ExecutionSpace AMP::Solver::SolverStrategy::getExecutionSpace ( ) const
inlineinherited

Definition at line 269 of file SolverStrategy.h.

References AMP::Solver::SolverStrategy::d_exec_space.

◆ getFromInput()

void AMP::Solver::PetscSNESSolver::getFromInput ( std::shared_ptr< const AMP::Database db)
private

◆ getFunctionScaling()

std::shared_ptr< AMP::LinearAlgebra::Vector > AMP::Solver::SolverStrategy::getFunctionScaling ( )
inlineinherited

Definition at line 267 of file SolverStrategy.h.

References AMP::Solver::SolverStrategy::d_pFunctionScaling.

◆ getInitialResidual()

virtual AMP::Scalar AMP::Solver::SolverStrategy::getInitialResidual ( void  ) const
inlinevirtualinherited

Definition at line 241 of file SolverStrategy.h.

References AMP::Solver::SolverStrategy::d_dInitialResidual.

◆ getIterationHistory()

virtual const std::vector< int > & AMP::Solver::SolverStrategy::getIterationHistory ( void  )
inlinevirtualinherited

Definition at line 243 of file SolverStrategy.h.

References AMP::Solver::SolverStrategy::d_iterationHistory.

◆ getIterations()

virtual int AMP::Solver::SolverStrategy::getIterations ( void  ) const
inlinevirtualinherited

Return the number of iterations taken by the solver to converge.

Definition at line 142 of file SolverStrategy.h.

References AMP::Solver::SolverStrategy::d_iNumberIterations.

◆ getKrylovSolver()

std::shared_ptr< PetscKrylovSolver > AMP::Solver::PetscSNESSolver::getKrylovSolver ( void  )
inline

Returns a shared pointer to the PetscKrylovSolver used internally for the linear solves

Definition at line 146 of file PetscSNESSolver.h.

References d_pKrylovSolver.

Referenced by getNestedSolver().

◆ getLineSearchPreCheckAdaptor()

std::function< int(std::shared_ptr< AMP::LinearAlgebra::Vector >, std::shared_ptr< AMP::LinearAlgebra::Vector >, bool &)> AMP::Solver::PetscSNESSolver::getLineSearchPreCheckAdaptor ( )
inline

Definition at line 185 of file PetscSNESSolver.h.

References AMP_ASSERT, and d_lineSearchPreCheckPtr.

◆ getMaxIterations()

int AMP::Solver::SolverStrategy::getMaxIterations ( void  ) const
inlineinherited

Definition at line 218 of file SolverStrategy.h.

References AMP::Solver::SolverStrategy::d_iMaxIterations.

◆ getNestedSolver()

std::shared_ptr< SolverStrategy > AMP::Solver::PetscSNESSolver::getNestedSolver ( void  )
inlineoverridevirtual

Return a nested solver (eg preconditioner) if it exists. By default return a nullptr

Reimplemented from AMP::Solver::SolverStrategy.

Definition at line 148 of file PetscSNESSolver.h.

References getKrylovSolver().

◆ getNumberOfLineSearchPreCheckAttempts()

int AMP::Solver::PetscSNESSolver::getNumberOfLineSearchPreCheckAttempts ( void  )
inline

Return the number of line search precheck attempts that were made for the current step

Definition at line 166 of file PetscSNESSolver.h.

References d_iNumberOfLineSearchPreCheckAttempts.

◆ getOperator()

virtual std::shared_ptr< AMP::Operator::Operator > AMP::Solver::SolverStrategy::getOperator ( void  )
virtualinherited

Return a shared pointer to the operator registered with the solver.

◆ getRelativeTolerance()

AMP::Scalar AMP::Solver::SolverStrategy::getRelativeTolerance ( ) const
inlineinherited

◆ getResidualNorm()

virtual AMP::Scalar AMP::Solver::SolverStrategy::getResidualNorm ( void  ) const
inlinevirtualinherited

Definition at line 239 of file SolverStrategy.h.

References AMP::Solver::SolverStrategy::d_dResidualNorm.

◆ getScratchVector()

std::shared_ptr< AMP::LinearAlgebra::Vector > AMP::Solver::PetscSNESSolver::getScratchVector ( void  )
inline

Return a shared pointer to the scratch vector used internally.

Definition at line 158 of file PetscSNESSolver.h.

References d_pScratchVector.

◆ getSNESSolver()

SNES AMP::Solver::PetscSNESSolver::getSNESSolver ( void  )
inline

return the PETSc SNES solver object

Definition at line 135 of file PetscSNESSolver.h.

References d_SNESSolver.

◆ getSolution()

std::shared_ptr< AMP::LinearAlgebra::Vector > AMP::Solver::PetscSNESSolver::getSolution ( void  )
inline

Return a shared pointer to the solution vector

Definition at line 153 of file PetscSNESSolver.h.

References d_pSolutionVector.

◆ getSolutionScaling()

std::shared_ptr< AMP::LinearAlgebra::Vector > AMP::Solver::SolverStrategy::getSolutionScaling ( )
inlineinherited

Definition at line 266 of file SolverStrategy.h.

References AMP::Solver::SolverStrategy::d_pSolutionScaling.

◆ getTotalNumberOfIterations()

int AMP::Solver::SolverStrategy::getTotalNumberOfIterations ( void  )
inherited

◆ getTotalNumberOfLinearIterations()

int AMP::Solver::PetscSNESSolver::getTotalNumberOfLinearIterations ( void  ) const

◆ getUsesJacobian()

bool AMP::Solver::PetscSNESSolver::getUsesJacobian ( void  )
inline

Returns boolean to indicate whether the solver expects a Jacobian matrix to be provided or not.

Definition at line 141 of file PetscSNESSolver.h.

References d_bUsesJacobian.

◆ initialize()

virtual void AMP::Solver::SolverStrategy::initialize ( std::shared_ptr< const SolverStrategyParameters parameters)
virtualinherited

◆ initializePetscObjects()

void AMP::Solver::PetscSNESSolver::initializePetscObjects ( void  )
private

◆ isVectorValid()

static bool AMP::Solver::PetscSNESSolver::isVectorValid ( std::shared_ptr< AMP::Operator::Operator > &  op,
AMP::LinearAlgebra::Vector::shared_ptr v,
const AMP_MPI comm 
)
staticprivate

◆ KSPPostSolve_SNESEW()

static PetscErrorCode AMP::Solver::PetscSNESSolver::KSPPostSolve_SNESEW ( KSP  ksp,
Vec  b,
Vec  x,
SNES  snes 
)
staticprivate

◆ KSPPreSolve_SNESEW()

static PetscErrorCode AMP::Solver::PetscSNESSolver::KSPPreSolve_SNESEW ( KSP  ksp,
Vec  b,
Vec  x,
SNES  snes 
)
staticprivate

◆ mffdCheckBounds()

static PetscErrorCode AMP::Solver::PetscSNESSolver::mffdCheckBounds ( void checkctx,
Vec  U,
Vec  a,
PetscScalar h 
)
staticprivate

◆ preApply()

void AMP::Solver::PetscSNESSolver::preApply ( std::shared_ptr< const AMP::LinearAlgebra::Vector v)
private

◆ print()

virtual void AMP::Solver::SolverStrategy::print ( std::ostream &  )
inlinevirtualinherited

Definition at line 237 of file SolverStrategy.h.

◆ printConvergenceStatus()

void AMP::Solver::PetscSNESSolver::printConvergenceStatus ( SolverStrategy::SolverStatus  status,
std::ostream &  os = AMP::pout 
) const
overridevirtual

Reimplemented from AMP::Solver::SolverStrategy.

◆ printStatistics()

virtual void AMP::Solver::SolverStrategy::printStatistics ( std::ostream &  os = AMP::pout)
inlinevirtualinherited

Reimplemented in AMP::Solver::NonlinearKrylovAccelerator< T >.

Definition at line 220 of file SolverStrategy.h.

◆ registerOperator()

virtual void AMP::Solver::SolverStrategy::registerOperator ( std::shared_ptr< AMP::Operator::Operator op)
virtualinherited

◆ registerWriter()

virtual void AMP::Solver::SolverStrategy::registerWriter ( std::shared_ptr< AMP::IO::Writer writer)
inlinevirtualinherited

Registers a writer with the solver.

This function will register a writer with the solver. The solver may then register any vector components it "owns" with the writer.

Parameters
writerThe writer to register

Definition at line 186 of file SolverStrategy.h.

References AMP::Solver::SolverStrategy::d_writer.

◆ reset() [1/2]

void AMP::Solver::PetscSNESSolver::reset ( std::shared_ptr< AMP::Solver::SolverStrategyParameters )
override

pointer to line search function

◆ reset() [2/2]

virtual void AMP::Solver::SolverStrategy::reset ( std::shared_ptr< SolverStrategyParameters parameters)
virtualinherited

◆ resetOperator()

virtual void AMP::Solver::SolverStrategy::resetOperator ( std::shared_ptr< const AMP::Operator::OperatorParameters parameters)
virtualinherited

Resets the operator registered with the solver with new parameters if necessary

Parameters
parametersOperatorParameters object that is NULL by default

Reimplemented in AMP::Solver::PetscKrylovSolver, AMP::Solver::BandedSolver, AMP::Solver::ColumnSolver, AMP::Solver::HypreSolver, AMP::Solver::CoupledFlow1DSolver, AMP::Solver::Flow1DSolver, AMP::Solver::PelletStackMechanicsSolver, AMP::Solver::TrilinosMLSolver, and AMP::Solver::TrilinosMueLuSolver.

◆ resetPetscObjects()

void AMP::Solver::PetscSNESSolver::resetPetscObjects ( std::shared_ptr< AMP::Solver::SolverStrategyParameters params)
private

◆ residual()

virtual void AMP::Solver::SolverStrategy::residual ( std::shared_ptr< const AMP::LinearAlgebra::Vector f,
std::shared_ptr< const AMP::LinearAlgebra::Vector u,
std::shared_ptr< AMP::LinearAlgebra::Vector r 
)
virtualinherited

◆ setAbsoluteTolerance()

virtual void AMP::Solver::SolverStrategy::setAbsoluteTolerance ( AMP::Scalar  abs_tol)
inlinevirtualinherited

◆ setComponentScalings()

void AMP::Solver::SolverStrategy::setComponentScalings ( std::shared_ptr< AMP::LinearAlgebra::Vector s,
std::shared_ptr< AMP::LinearAlgebra::Vector f 
)
inlineinherited

for multiphysics problems it may be necessary to scale the solution

Definition at line 259 of file SolverStrategy.h.

References AMP::Solver::SolverStrategy::d_pFunctionScaling, and AMP::Solver::SolverStrategy::d_pSolutionScaling.

◆ setConvergenceStatus()

void AMP::Solver::PetscSNESSolver::setConvergenceStatus ( void  )
private

◆ setDebugPrintInfoLevel()

virtual void AMP::Solver::SolverStrategy::setDebugPrintInfoLevel ( int  print_level)
inlinevirtualinherited

Specify level of diagnostic information printed during iterations.

Parameters
[in]print_levelinteger level value with permissible values 0 and higher. Setting to zero should provide minimial debugging information with higher values resulting in increasingly verbose information being printed out.

Definition at line 132 of file SolverStrategy.h.

References AMP::Solver::SolverStrategy::d_iDebugPrintInfoLevel.

◆ setExecutionSpace()

void AMP::Solver::SolverStrategy::setExecutionSpace ( AMP::Utilities::ExecutionSpace  space)
inlineinherited

Definition at line 270 of file SolverStrategy.h.

References AMP::Solver::SolverStrategy::d_exec_space.

◆ setInitialGuess()

void AMP::Solver::PetscSNESSolver::setInitialGuess ( std::shared_ptr< AMP::LinearAlgebra::Vector initialGuess)
overridevirtual

Initialize the solution vector by copying the initial guess vector

Parameters
[in]initialGuessshared pointer to the initial guess vector.

Reimplemented from AMP::Solver::SolverStrategy.

◆ setIsNestedSolver()

void AMP::Solver::SolverStrategy::setIsNestedSolver ( bool  is_nested)
inlineinherited

Tell a solver that it is nested inside some outer solver.

Definition at line 166 of file SolverStrategy.h.

References AMP::Solver::SolverStrategy::d_bIsNestedSolver.

◆ setJacobian()

static PetscErrorCode AMP::Solver::PetscSNESSolver::setJacobian ( SNES  ,
Vec  x,
Mat  A,
Mat  ,
void ctx 
)
staticprivate

◆ setLineSearchPreCheck()

void AMP::Solver::PetscSNESSolver::setLineSearchPreCheck ( std::function< int(std::shared_ptr< AMP::LinearAlgebra::Vector >, std::shared_ptr< AMP::LinearAlgebra::Vector >, bool &)>  lineSearchPreCheckPtr)

set the pointer to the user function that does the line search pre-check if provided

◆ setMaxIterations()

virtual void AMP::Solver::SolverStrategy::setMaxIterations ( const int  max_iterations)
inlinevirtualinherited

Definition at line 216 of file SolverStrategy.h.

References AMP::Solver::SolverStrategy::d_iMaxIterations.

◆ setNestedSolver()

virtual void AMP::Solver::SolverStrategy::setNestedSolver ( std::shared_ptr< SolverStrategy solver)
inlinevirtualinherited

Set a nested solver, eg, Krylov for Newton, preconditioner for Krylov etc. Null op in base class

Definition at line 159 of file SolverStrategy.h.

References AMP::Solver::SolverStrategy::d_pNestedSolver.

◆ setRelativeTolerance()

virtual void AMP::Solver::SolverStrategy::setRelativeTolerance ( AMP::Scalar  rel_tol)
inlinevirtualinherited

◆ setupPreconditioner()

static PetscErrorCode AMP::Solver::PetscSNESSolver::setupPreconditioner ( PC  pc)
staticprivate

◆ setZeroInitialGuess()

virtual void AMP::Solver::SolverStrategy::setZeroInitialGuess ( bool  use_zero_guess)
inlinevirtualinherited

Tells the solver to use an initial guess of zero and not try to copy an initial guess into the solution vector

Parameters
[in]use_zero_guessboolean to specify whether zero initial guess should be used or not.

Reimplemented in AMP::Solver::PetscKrylovSolver.

Definition at line 150 of file SolverStrategy.h.

References AMP::Solver::SolverStrategy::d_bUseZeroInitialGuess.

◆ statusToString()

static std::string AMP::Solver::SolverStrategy::statusToString ( SolverStatus  status)
inlinestaticinherited

◆ type()

std::string AMP::Solver::PetscSNESSolver::type ( ) const
inlineoverridevirtual

Return the name of the solver.

Implements AMP::Solver::SolverStrategy.

Definition at line 109 of file PetscSNESSolver.h.

◆ wrapperLineSearchPreCheck()

static PetscErrorCode AMP::Solver::PetscSNESSolver::wrapperLineSearchPreCheck ( SNESLineSearch  snes,
Vec  x,
Vec  y,
PetscBool changed_y,
void ctx 
)
staticprivate

Member Data Documentation

◆ d_bComputeResidual

bool AMP::Solver::SolverStrategy::d_bComputeResidual = false
protectedinherited

Definition at line 295 of file SolverStrategy.h.

◆ d_bDestroyCachedVecs

bool AMP::Solver::PetscSNESSolver::d_bDestroyCachedVecs = false
private

Definition at line 250 of file PetscSNESSolver.h.

◆ d_bEnableLineSearchPreCheck

bool AMP::Solver::PetscSNESSolver::d_bEnableLineSearchPreCheck = false
private

Definition at line 245 of file PetscSNESSolver.h.

◆ d_bEnableMFFDBoundsCheck

bool AMP::Solver::PetscSNESSolver::d_bEnableMFFDBoundsCheck = false
private

Definition at line 246 of file PetscSNESSolver.h.

◆ d_bIsNestedSolver

bool AMP::Solver::SolverStrategy::d_bIsNestedSolver = false
protectedinherited

Definition at line 294 of file SolverStrategy.h.

Referenced by AMP::Solver::SolverStrategy::setIsNestedSolver().

◆ d_bPetscInterfaceInitialized

bool AMP::Solver::PetscSNESSolver::d_bPetscInterfaceInitialized = false
private

Definition at line 249 of file PetscSNESSolver.h.

◆ d_bPrintLinearResiduals

bool AMP::Solver::PetscSNESSolver::d_bPrintLinearResiduals = false
private

Definition at line 248 of file PetscSNESSolver.h.

◆ d_bPrintNonlinearResiduals

bool AMP::Solver::PetscSNESSolver::d_bPrintNonlinearResiduals = false
private

Definition at line 247 of file PetscSNESSolver.h.

◆ d_bUsesJacobian

bool AMP::Solver::PetscSNESSolver::d_bUsesJacobian = false
private

Definition at line 244 of file PetscSNESSolver.h.

Referenced by getUsesJacobian().

◆ d_bUseZeroInitialGuess

bool AMP::Solver::SolverStrategy::d_bUseZeroInitialGuess = true
protectedinherited

◆ d_comm

AMP_MPI AMP::Solver::PetscSNESSolver::d_comm
private

Definition at line 283 of file PetscSNESSolver.h.

◆ d_ConvergenceStatus

SolverStatus AMP::Solver::SolverStrategy::d_ConvergenceStatus = SolverStatus::DivergedOther
protectedinherited

◆ d_dAbsoluteTolerance

AMP::Scalar AMP::Solver::SolverStrategy::d_dAbsoluteTolerance = 1.0e-14
protectedinherited

◆ d_db

std::shared_ptr<AMP::Database> AMP::Solver::SolverStrategy::d_db = nullptr
protectedinherited

Definition at line 304 of file SolverStrategy.h.

◆ d_dConstantForcingTerm

double AMP::Solver::PetscSNESSolver::d_dConstantForcingTerm = PETSC_DEFAULT
private

int is for passing choice to PETSc

Definition at line 270 of file PetscSNESSolver.h.

◆ d_dEWChoice2Alpha

double AMP::Solver::PetscSNESSolver::d_dEWChoice2Alpha = PETSC_DEFAULT
private

Definition at line 275 of file PetscSNESSolver.h.

◆ d_dEWChoice2Gamma

double AMP::Solver::PetscSNESSolver::d_dEWChoice2Gamma = PETSC_DEFAULT
private

Definition at line 276 of file PetscSNESSolver.h.

◆ d_dEWSafeguardDisableThreshold

double AMP::Solver::PetscSNESSolver::d_dEWSafeguardDisableThreshold = PETSC_DEFAULT
private

Definition at line 278 of file PetscSNESSolver.h.

◆ d_dEWSafeguardExponent

double AMP::Solver::PetscSNESSolver::d_dEWSafeguardExponent = PETSC_DEFAULT
private

Definition at line 277 of file PetscSNESSolver.h.

◆ d_dInitialForcingTerm

double AMP::Solver::PetscSNESSolver::d_dInitialForcingTerm = PETSC_DEFAULT
private

Definition at line 271 of file PetscSNESSolver.h.

◆ d_dInitialResidual

AMP::Scalar AMP::Solver::SolverStrategy::d_dInitialResidual
protectedinherited

Definition at line 285 of file SolverStrategy.h.

Referenced by AMP::Solver::SolverStrategy::getInitialResidual().

◆ d_dMaximumForcingTerm

double AMP::Solver::PetscSNESSolver::d_dMaximumForcingTerm = PETSC_DEFAULT
private

Definition at line 272 of file PetscSNESSolver.h.

◆ d_dMFFDFunctionDifferencingError

double AMP::Solver::PetscSNESSolver::d_dMFFDFunctionDifferencingError = PETSC_DEFAULT
private

Definition at line 264 of file PetscSNESSolver.h.

◆ d_dRelativeTolerance

AMP::Scalar AMP::Solver::SolverStrategy::d_dRelativeTolerance = 1.0e-09
protectedinherited

◆ d_dResidualNorm

AMP::Scalar AMP::Solver::SolverStrategy::d_dResidualNorm
protectedinherited

Definition at line 284 of file SolverStrategy.h.

Referenced by AMP::Solver::SolverStrategy::getResidualNorm().

◆ d_dStepTolerance

double AMP::Solver::PetscSNESSolver::d_dStepTolerance = PETSC_DEFAULT
private

Definition at line 256 of file PetscSNESSolver.h.

◆ d_exec_space

AMP::Utilities::ExecutionSpace AMP::Solver::SolverStrategy::d_exec_space = AMP::Utilities::ExecutionSpace::unspecified
protectedinherited

execution space for the solver

Definition at line 324 of file SolverStrategy.h.

Referenced by AMP::Solver::SolverStrategy::getExecutionSpace(), and AMP::Solver::SolverStrategy::setExecutionSpace().

◆ d_global_db

std::shared_ptr<AMP::Database> AMP::Solver::SolverStrategy::d_global_db = nullptr
protectedinherited

Pointer to global database This is temporary fix and eventually either d_global_db or d_db should go away This is introduced to allow for solver factories to access databases in the global database for the construction of nested solvers

Definition at line 311 of file SolverStrategy.h.

◆ d_iDebugPrintInfoLevel

int AMP::Solver::SolverStrategy::d_iDebugPrintInfoLevel = 0
protectedinherited

◆ d_iForcingTermFlag

int AMP::Solver::PetscSNESSolver::d_iForcingTermFlag
private

string is for input

Definition at line 268 of file PetscSNESSolver.h.

◆ d_iInstanceId

int AMP::Solver::SolverStrategy::d_iInstanceId
staticprotectedinherited

Definition at line 299 of file SolverStrategy.h.

◆ d_iLinearIterationHistory

std::vector<int> AMP::Solver::PetscSNESSolver::d_iLinearIterationHistory
private

keeps track of linear iteration statistics over solver lifetime

Definition at line 281 of file PetscSNESSolver.h.

◆ d_iMaximumFunctionEvals

int AMP::Solver::PetscSNESSolver::d_iMaximumFunctionEvals = PETSC_DEFAULT
private

Definition at line 252 of file PetscSNESSolver.h.

◆ d_iMaxIterations

int AMP::Solver::SolverStrategy::d_iMaxIterations = 0
protectedinherited

◆ d_iNumberIterations

int AMP::Solver::SolverStrategy::d_iNumberIterations = 0
protectedinherited

Definition at line 280 of file SolverStrategy.h.

Referenced by AMP::Solver::SolverStrategy::getIterations().

◆ d_iNumberOfLineSearchPreCheckAttempts

int AMP::Solver::PetscSNESSolver::d_iNumberOfLineSearchPreCheckAttempts = 0
private

Definition at line 253 of file PetscSNESSolver.h.

Referenced by getNumberOfLineSearchPreCheckAttempts().

◆ d_iObjectId

int AMP::Solver::SolverStrategy::d_iObjectId
protectedinherited

Definition at line 297 of file SolverStrategy.h.

◆ d_iterationHistory

std::vector<int> AMP::Solver::SolverStrategy::d_iterationHistory
protectedinherited

keeps track of iteration statistics over solver lifetime

Definition at line 302 of file SolverStrategy.h.

Referenced by AMP::Solver::SolverStrategy::getIterationHistory().

◆ d_Jacobian

Mat AMP::Solver::PetscSNESSolver::d_Jacobian = nullptr
private

Definition at line 293 of file PetscSNESSolver.h.

◆ d_lineSearchPreCheckPtr

std::function<int( std::shared_ptr<AMP::LinearAlgebra::Vector>, std::shared_ptr<AMP::LinearAlgebra::Vector>, bool & )> AMP::Solver::PetscSNESSolver::d_lineSearchPreCheckPtr
private

Definition at line 242 of file PetscSNESSolver.h.

Referenced by getLineSearchPreCheckAdaptor().

◆ d_memory_location

AMP::Utilities::MemoryType AMP::Solver::SolverStrategy::d_memory_location = AMP::Utilities::MemoryType::none
protectedinherited

memory storage address space

Definition at line 327 of file SolverStrategy.h.

◆ d_operatorComponentToEnableBoundsCheck

int AMP::Solver::PetscSNESSolver::d_operatorComponentToEnableBoundsCheck = 0
private

Definition at line 254 of file PetscSNESSolver.h.

Referenced by getBoundsCheckComponent().

◆ d_PetscMonitor

std::shared_ptr<PetscMonitor> AMP::Solver::PetscSNESSolver::d_PetscMonitor = nullptr
private

Definition at line 289 of file PetscSNESSolver.h.

◆ d_pFunctionScaling

std::shared_ptr<AMP::LinearAlgebra::Vector> AMP::Solver::SolverStrategy::d_pFunctionScaling
protectedinherited

◆ d_pKrylovSolver

std::shared_ptr<PetscKrylovSolver> AMP::Solver::PetscSNESSolver::d_pKrylovSolver = nullptr
private

Definition at line 297 of file PetscSNESSolver.h.

Referenced by getKrylovSolver().

◆ d_pNestedSolver

std::shared_ptr<AMP::Solver::SolverStrategy> AMP::Solver::SolverStrategy::d_pNestedSolver = nullptr
protectedinherited

nested solver used by this solver

Definition at line 319 of file SolverStrategy.h.

Referenced by AMP::Solver::SolverStrategy::getNestedSolver(), and AMP::Solver::SolverStrategy::setNestedSolver().

◆ d_pOperator

std::shared_ptr<AMP::Operator::Operator> AMP::Solver::SolverStrategy::d_pOperator = nullptr
protectedinherited

Definition at line 316 of file SolverStrategy.h.

◆ d_pResidualVector

std::shared_ptr<AMP::LinearAlgebra::Vector> AMP::Solver::PetscSNESSolver::d_pResidualVector = nullptr
private

Definition at line 286 of file PetscSNESSolver.h.

◆ d_pScratchVector

std::shared_ptr<AMP::LinearAlgebra::Vector> AMP::Solver::PetscSNESSolver::d_pScratchVector = nullptr
private

Definition at line 287 of file PetscSNESSolver.h.

Referenced by getScratchVector().

◆ d_pSolutionScaling

std::shared_ptr<AMP::LinearAlgebra::Vector> AMP::Solver::SolverStrategy::d_pSolutionScaling
protectedinherited

◆ d_pSolutionVector

std::shared_ptr<AMP::LinearAlgebra::Vector> AMP::Solver::PetscSNESSolver::d_pSolutionVector = nullptr
private

Definition at line 285 of file PetscSNESSolver.h.

Referenced by getSolution().

◆ d_sForcingTermStrategy

std::string AMP::Solver::PetscSNESSolver::d_sForcingTermStrategy = "CONSTANT"
private

Definition at line 267 of file PetscSNESSolver.h.

◆ d_sMFFDDifferencingStrategy

std::string AMP::Solver::PetscSNESSolver::d_sMFFDDifferencingStrategy = MATMFFD_WP
private

Definition at line 259 of file PetscSNESSolver.h.

◆ d_sName

std::string AMP::Solver::SolverStrategy::d_sName
protectedinherited

Definition at line 278 of file SolverStrategy.h.

◆ d_SNES_completion_code

SNESConvergedReason AMP::Solver::PetscSNESSolver::d_SNES_completion_code
private

Definition at line 295 of file PetscSNESSolver.h.

◆ d_SNESAppendOptionsPrefix

std::string AMP::Solver::PetscSNESSolver::d_SNESAppendOptionsPrefix = ""
private

Definition at line 262 of file PetscSNESSolver.h.

◆ d_SNESSolver

SNES AMP::Solver::PetscSNESSolver::d_SNESSolver = nullptr
private

Definition at line 291 of file PetscSNESSolver.h.

Referenced by getSNESSolver().

◆ d_writer

std::shared_ptr<AMP::IO::Writer> AMP::Solver::SolverStrategy::d_writer = nullptr
protectedinherited

Definition at line 321 of file SolverStrategy.h.

Referenced by AMP::Solver::SolverStrategy::registerWriter().


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



Advanced Multi-Physics (AMP)
Oak Ridge National Laboratory
Idaho National Laboratory
Los Alamos National Laboratory
This page automatically produced from the
source code by doxygen
Last updated: Tue Mar 10 2026 13:06:45.
Comments on this page