Smith  0.1
Smith is an implicit thermal structural mechanics simulation code.
Public Member Functions | Public Attributes | List of all members
smith::NonlinearBlockSolver Class Reference

Nonlinear block solver backed by an EquationSolver forward solve and linear adjoint solves. More...

#include <nonlinear_block_solver.hpp>

Collaboration diagram for smith::NonlinearBlockSolver:
Collaboration graph
[legend]

Public Member Functions

 NonlinearBlockSolver (std::unique_ptr< EquationSolver > s, MPI_Comm comm, double abs_tol=1e-12, double rel_tol=1e-8, std::optional< NonlinearSolverOptions > retained_nonlinear_options=std::nullopt, std::optional< LinearSolverOptions > retained_linear_options=std::nullopt)
 Construct from a nonlinear equation solver. More...
 
ConvergenceStatus convergenceStatus (double tolerance_multiplier, const std::vector< mfem::Vector > &residuals, NonlinearConvergenceContext &context) const override
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
void primeConvergenceContext (const std::vector< mfem::Vector > &residuals, NonlinearConvergenceContext &context) const override
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
std::vector< FieldPtrsolve (const std::vector< FieldPtr > &u_guesses, std::function< std::vector< mfem::Vector >(const std::vector< FieldPtr > &)> residuals, std::function< std::vector< std::vector< MatrixPtr >>(const std::vector< FieldPtr > &)> jacobians) const override
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
std::vector< FieldPtrsolveAdjoint (const std::vector< DualPtr > &u_bars, std::vector< std::vector< MatrixPtr >> &jacobian_transposed) const override
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
void completeSetup (const std::vector< FieldPtr > &us) const
 Initialize the preconditioner in case of vector problems.
 
void setInnerToleranceMultiplier (double multiplier) override
 Set the inner tolerance multiplier.
 
std::shared_ptr< NonlinearBlockSolvercloneFresh () const
 Build a fresh solver instance from retained config.
 
ConvergenceStatus convergenceStatus (double tolerance_multiplier, const std::vector< mfem::Vector > &residuals) const
 Evaluate convergence for this solver's configured tolerance using solver-owned convergence state.
 
virtual ConvergenceStatus convergenceStatus (double tolerance_multiplier, const std::vector< mfem::Vector > &residuals, NonlinearConvergenceContext &context) const=0
 Evaluate convergence with externally owned convergence state.
 
- Public Member Functions inherited from smith::NonlinearBlockSolverBase
virtual ~NonlinearBlockSolverBase ()
 destructor
 
ConvergenceStatus convergenceStatus (double tolerance_multiplier, const std::vector< mfem::Vector > &residuals) const
 Evaluate convergence for this solver's configured tolerance using solver-owned convergence state.
 
bool checkConvergence (double tolerance_multiplier, const std::vector< mfem::Vector > &residuals) const
 Check whether the current residuals satisfy the convergence criterion.
 
virtual void resetConvergenceState () const
 Reset internal convergence tracking state (e.g. the stored initial residual norm used for relative tolerance). Call this at the start of each new solve sequence.
 
virtual void clearMemory () const
 Interface option to clear memory between solves to avoid high-water mark memory usage.
 

Public Attributes

std::unique_ptr< mfem::BlockOperator > block_jac_
 Need to hold an instance of a block operator to work with the mfem solver interface.
 
std::vector< std::vector< MatrixPtr > > matrix_of_jacs_
 
std::unique_ptr< EquationSolvernonlinear_solver_
 the nonlinear equation solver used for the forward pass
 
MPI_Comm comm_
 MPI communicator for parallel norm computation.
 
double abs_tol_
 absolute residual tolerance for convergence check
 
double rel_tol_
 relative residual tolerance for convergence check
 
double inner_tol_multiplier_ = 1.0
 multiplier for tolerances during inner solves
 
std::optional< NonlinearSolverOptionsretained_nonlinear_options_ = std::nullopt
 retained nonlinear config
 
std::optional< LinearSolverOptionsretained_linear_options_ = std::nullopt
 retained linear config
 

Additional Inherited Members

- Public Types inherited from smith::NonlinearBlockSolverBase
using FieldT = FiniteElementState
 using
 
using FieldPtr = std::shared_ptr< FieldT >
 using
 
using FieldD = FiniteElementDual
 using
 
using DualPtr = std::shared_ptr< FieldD >
 using
 
using MatrixPtr = std::unique_ptr< mfem::HypreParMatrix >
 using
 
- Protected Attributes inherited from smith::NonlinearBlockSolverBase
bool is_setup_ = false
 Records if this block solver has its preconditioner initialized.
 
NonlinearConvergenceContext convergence_context_ = {}
 Solver-owned convergence state for one solve.
 

Detailed Description

Nonlinear block solver backed by an EquationSolver forward solve and linear adjoint solves.

Definition at line 107 of file nonlinear_block_solver.hpp.

Constructor & Destructor Documentation

◆ NonlinearBlockSolver()

smith::NonlinearBlockSolver::NonlinearBlockSolver ( std::unique_ptr< EquationSolver s,
MPI_Comm  comm,
double  abs_tol = 1e-12,
double  rel_tol = 1e-8,
std::optional< NonlinearSolverOptions retained_nonlinear_options = std::nullopt,
std::optional< LinearSolverOptions retained_linear_options = std::nullopt 
)

Construct from a nonlinear equation solver.

Note
The caller is responsible for choosing inner vs outer tolerance when using this constructor directly. The builder function buildNonlinearBlockSolver applies a 0.6x inner-tolerance factor automatically.

Definition at line 44 of file nonlinear_block_solver.cpp.

Member Data Documentation

◆ matrix_of_jacs_

std::vector<std::vector<MatrixPtr> > smith::NonlinearBlockSolver::matrix_of_jacs_
mutable

Holding vectors of block matrices to that do not going out of scope before the mfem solver is done with using them in the block_jac_

Definition at line 149 of file nonlinear_block_solver.hpp.


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