15 #include "../config/config.hpp" 24 #ifdef MFEM_USE_SUITESPARSE 116 MPI_Comm comm = MPI_COMM_NULL;
174 bool final=
false)
const;
293 {
return dot_prod_type == 0 ? MPI_COMM_NULL : comm; }
321 const double damping=1.0);
334 const double damping=1.0);
359 const double damping;
363 bool use_abs_diag =
false;
369 const bool allow_updates;
390 int order,
double max_eig_estimate);
396 int order,
double max_eig_estimate);
408 int order, MPI_Comm comm = MPI_COMM_NULL,
409 int power_iterations = 10,
410 double power_tolerance = 1e-8);
416 int order, MPI_Comm comm = MPI_COMM_NULL,
417 int power_iterations = 10,
418 double power_tolerance = 1e-8);
422 int order,
int power_iterations = 10,
423 double power_tolerance = 1e-8);
429 int order,
int power_iterations = 10,
430 double power_tolerance = 1e-8);
448 double max_eig_estimate;
455 mutable Vector helperVector;
482 void SLI(
const Operator &A,
const Vector &
b, Vector &x,
483 int print_iter = 0,
int max_num_iter = 1000,
484 double RTOLERANCE = 1e-12,
double ATOLERANCE = 1e-24);
487 void SLI(
const Operator &A, Solver &B,
const Vector &
b, Vector &x,
488 int print_iter = 0,
int max_num_iter = 1000,
489 double RTOLERANCE = 1e-12,
double ATOLERANCE = 1e-24);
514 void CG(
const Operator &A,
const Vector &
b, Vector &x,
515 int print_iter = 0,
int max_num_iter = 1000,
516 double RTOLERANCE = 1e-12,
double ATOLERANCE = 1e-24);
519 void PCG(
const Operator &A, Solver &B,
const Vector &
b, Vector &x,
520 int print_iter = 0,
int max_num_iter = 1000,
521 double RTOLERANCE = 1e-12,
double ATOLERANCE = 1e-24);
562 int GMRES(
const Operator &A, Vector &x,
const Vector &
b, Solver &M,
563 int &max_iter,
int m,
double &tol,
double atol,
int printit);
566 void GMRES(
const Operator &A, Solver &B,
const Vector &
b, Vector &x,
567 int print_iter = 0,
int max_num_iter = 1000,
int m = 50,
568 double rtol = 1e-12,
double atol = 1e-24);
593 int BiCGSTAB(
const Operator &A, Vector &x,
const Vector &
b, Solver &M,
594 int &max_iter,
double &tol,
double atol,
int printit);
597 void BiCGSTAB(
const Operator &A, Solver &B,
const Vector &
b, Vector &x,
598 int print_iter = 0,
int max_num_iter = 1000,
599 double rtol = 1e-12,
double atol = 1e-24);
628 void MINRES(
const Operator &A,
const Vector &
b, Vector &x,
int print_it = 0,
629 int max_it = 1000,
double rtol = 1e-12,
double atol = 1e-24);
632 void MINRES(
const Operator &A, Solver &B,
const Vector &
b, Vector &x,
633 int print_it = 0,
int max_it = 1000,
634 double rtol = 1e-12,
double atol = 1e-24);
670 const double fnorm)
const;
677 const double fnorm)
const;
718 const double rtol0 = 0.5,
719 const double rtol_max = 0.9,
720 const double alpha = 0.5 * (1.0 + sqrt(5.0)),
721 const double gamma = 1.0);
734 for (
int i = 0; i <
skArray.Size(); i++)
746 for (
int i = 0; i <
m; i++)
779 { MFEM_WARNING(
"L-BFGS won't use the given preconditioner."); }
781 { MFEM_WARNING(
"L-BFGS won't use the given solver."); }
791 int aGMRES(
const Operator &A, Vector &x,
const Vector &
b,
792 const Operator &M,
int &max_iter,
793 int m_max,
int m_min,
int m_step,
double cf,
794 double &tol,
double &atol,
int printit);
830 { MFEM_ABORT(
"The objective gradient is not implemented."); }
868 { MFEM_ABORT(
"Not meaningful for this solver."); }
870 { MFEM_ABORT(
"Not meaningful for this solver."); }
1046 bool final)
override;
1050 #ifdef MFEM_USE_SUITESPARSE 1122 #endif // MFEM_USE_SUITESPARSE 1131 std::unique_ptr<DenseMatrixInverse[]> block_solvers;
1149 bool ownA,
bool ownS0,
bool ownS1)
1150 :
Solver(A_->
NumRows()), A(A_, ownA), S0(S0_, ownS0), S1(S1_, ownS1) { }
1169 const bool parallel;
1171 mutable int global_size;
1200 Solver *solver =
nullptr;
1204 void Orthogonalize(
const Vector &v,
Vector &v_ortho)
const;
1219 void Mult(
const Vector &x,
Vector &y,
bool transpose)
const;
1222 bool op_is_symmetric =
true,
bool own_aux_map =
false);
1229 #endif // MFEM_USE_MPI 1233 #endif // MFEM_SOLVERS const Array< int > * ess_dofs_list
Not owned.
MINRESSolver(MPI_Comm comm_)
GMRESSolver(MPI_Comm comm_)
Conjugate gradient method.
HypreSmoother & GetSmoother()
void MultTranspose(const Vector &x, Vector &y) const
Action of the transpose operator: y=A^t(x). The default behavior in class Operator is to generate an ...
double Info[UMFPACK_INFO]
Chebyshev accelerated smoothing with given vector, no matrix necessary.
Array< Vector * > ykArray
void SetPositiveDiagonal(bool pos_diag=true)
Replace diagonal entries with their absolute values.
const Operator * GetC() const
virtual void SetOperator(const Operator &op)
Also calls SetOperator for the preconditioner if there is one.
double GetInitialNorm() const
Returns the initial residual norm from the last call to Mult().
void SetHistorySize(int dim)
virtual void SetOperator(const Operator &op)
Also calls SetOperator for the preconditioner if there is one.
void SetSize(int s)
Resize the vector to size s.
bool summary
A summary of the solver process will be reported after the last iteration to mfem::out.
void Mult(const Table &A, const Table &B, Table &C)
C = A * B (as boolean matrices)
void Mult(const Vector &x, Vector &y) const
Operator application: y=A(x).
virtual void ProcessNewState(const Vector &x) const
This method can be overloaded in derived classes to perform computations that need knowledge of the n...
virtual void Mult(const Vector &b, Vector &x) const
Solve the nonlinear system with right-hand side b.
bool first_and_last
Information about the first and last iteration will be printed to mfem::out.
virtual void Mult(const Vector &b, Vector &x) const
Operator application: y=A(x).
const Vector * GetBoundsVec_Hi() const
OperatorJacobiSmoother(const double damping=1.0)
Default constructor: the diagonal will be computed by subsequent calls to SetOperator() using the Ope...
Pointer to an Operator of a specified type.
virtual void Mult(const Vector &b, Vector &x) const
Operator application: y=A(x).
~OperatorChebyshevSmoother()
T * GetData()
Returns the data.
virtual void Mult(const Vector &b, Vector &x) const
Operator application: y=A(x).
virtual void Mult(const Vector &b, Vector &x) const
Operator application: y=A(x).
void InitializeStorageVectors()
virtual void Mult(const Vector &b, Vector &x) const
Operator application: y=A(x).
Direct sparse solver using KLU.
bool errors
If a fatal problem has been detected the failure will be reported to mfem::err.
int NumRows() const
Get the number of rows (size of output) of the Operator. Synonym with Height().
virtual void Mult(const Vector &x, Vector &y) const =0
Operator application: y=A(x).
virtual void SetSolver(Solver &solver)
Set the linear solver for inverting the Jacobian.
virtual void Mult(const Vector &b, Vector &x) const
Operator application: y=A(x).
void SetOperator(const Operator &op)
UMFPackSolver(SparseMatrix &A, bool use_long_ints_=false)
Factorize the given SparseMatrix using the defaults. For larger matrices, if the solver fails...
Reordering
The reordering method used by the BlockILU factorization.
void Mult(const Vector &b, Vector &x) const
Solve the system LUx = b, where L and U are the block ILU factors.
virtual void Mult(const Vector &x, Vector &y) const
Operator application: y=A(x).
virtual ~IterativeSolverMonitor()
ResidualBCMonitor(const Array< int > &ess_dofs_list_)
int print_level
(DEPRECATED) Legacy print level definition, which is left for compatibility with custom iterative sol...
virtual void SetOperator(const Operator &op)
Set/update the solver for the given operator.
PrintLevel()=default
Initializes the print level to suppress.
virtual double CalcObjective(const Vector &x) const =0
Objective F(x). In parallel, the result should be reduced over tasks.
SLISolver(MPI_Comm comm_)
void add(const Vector &v1, const Vector &v2, Vector &v)
virtual ~OptimizationSolver()
void Monitor(int it, double norm, const Vector &r, const Vector &x, bool final=false) const
double GetFinalNorm() const
Returns the final residual norm after termination of the solver during the last call to Mult()...
virtual void SetOperator(const Operator &op)
Set the Operator that is the OrthoSolver is to invert (approximately).
virtual void Mult(const Vector &x, Vector &y) const
Operator application: y=A(x).
int BiCGSTAB(const Operator &A, Vector &x, const Vector &b, Solver &M, int &max_iter, double &tol, double atol, int printit)
BiCGSTAB method. (tolerances are squared)
const Vector * GetInequalityVec_Lo() const
virtual void SetOperator(const Operator &op) override
Also calls SetOperator for the preconditioner if there is one.
double Norm(const Vector &x) const
Direct sparse solver using UMFPACK.
const class IterativeSolver * iter_solver
The last IterativeSolver to which this monitor was attached.
virtual void SetPreconditioner(Solver &pr)
This should be called before SetOperator.
virtual void SetPrintLevel(int print_lvl)
Legacy method to set the level of verbosity of the solver output.
virtual void MultTranspose(const Vector &b, Vector &x) const
Action of the transpose operator: y=A^t(x). The default behavior in class Operator is to generate an ...
int GetNumConstraints() const
double solve(double l, const Vector &xt, Vector &x, int &nclip) const
Solve QP at fixed lambda.
void MINRES(const Operator &A, const Vector &b, Vector &x, int print_it, int max_it, double rtol, double atol)
MINRES method without preconditioner. (tolerances are squared)
Jacobi smoothing for a given bilinear form (no matrix necessary).
int GetNumIterations() const
Returns the number of iterations taken during the last call to Mult()
~OperatorJacobiSmoother()
virtual void CalcObjectiveGrad(const Vector &x, Vector &grad) const
The result grad is expected to enter with the correct size.
void SetMaxIter(int max_it)
OperatorChebyshevSmoother(const Operator &oper_, const Vector &d, const Array< int > &ess_tdof_list, int order, double max_eig_estimate)
void SetLinearConstraint(const Vector &w_, double a_)
void median(const Vector &lo, const Vector &hi)
v = median(v,lo,hi) entrywise. Implementation assumes lo <= hi.
DirectSubBlockSolver(const SparseMatrix &A, const SparseMatrix &block_dof)
void SetKDim(int dim)
Set the number of iteration to perform between restarts, default is 50.
Newton's method for solving F(x)=b for a given operator F.
void print_iteration(int it, double r, double l) const
void CG(const Operator &A, const Vector &b, Vector &x, int print_iter, int max_num_iter, double RTOLERANCE, double ATOLERANCE)
Conjugate gradient method. (tolerances are squared)
PrintLevel & Iterations()
void Setup(const Vector &diag)
virtual void MultTranspose(const Vector &x, Vector &y) const
Action of the transpose operator: y=A^t(x). The default behavior in class Operator is to generate an ...
Parallel smoothers in hypre.
void PCG(const Operator &A, Solver &B, const Vector &b, Vector &x, int print_iter, int max_num_iter, double RTOLERANCE, double ATOLERANCE)
Preconditioned conjugate gradient method. (tolerances are squared)
virtual void SetOperator(const Operator &op)
Set/update the solver for the given operator.
virtual void SetOperator(const Operator &op)
Also calls SetOperator for the preconditioner if there is one.
const Vector * GetInequalityVec_Hi() const
Array< Vector * > skArray
PrintLevel & FirstAndLast()
void SetIterativeSolver(const IterativeSolver &solver)
This method is invoked by IterativeSolver::SetMonitor, informing the monitor which IterativeSolver is...
virtual void SetOperator(const Operator &op)
Set/update the solver for the given operator.
BlockILU(int block_size_, Reordering reordering_=Reordering::MINIMUM_DISCARDED_FILL, int k_fill_=0)
void SetPrintLevel(int print_lvl)
Set the print level field in the Control data member.
void MultTranspose(const Vector &x, Vector &y) const
Action of the transpose operator: y=A^t(x). The default behavior in class Operator is to generate an ...
Stationary linear iteration: x <- x + B (b - A x)
void SetInequalityConstraint(const Vector &dl, const Vector &dh)
void SetEqualityConstraint(const Vector &c)
Abstract base class for an iterative solver monitor.
const Vector * GetBoundsVec_Lo() const
virtual void SetPreconditioner(Solver &pr)
This should be called before SetOperator.
void SetOperator(const Operator &op_)
Set/update the solver for the given operator.
ProductSolver(Operator *A_, Solver *S0_, Solver *S1_, bool ownA, bool ownS0, bool ownS1)
virtual void Mult(const Vector &b, Vector &x) const
Solve the nonlinear system with right-hand side b.
void SetAbsTol(double atol)
PrintLevel print_options
Output behavior for the iterative solver.
void SetRelTol(double rtol)
double Control[UMFPACK_CONTROL]
Monitor that checks whether the residual is zero at a given set of dofs.
Abstract base class for iterative solver.
UMFPackSolver(bool use_long_ints_=false)
For larger matrices, if the solver fails, set the parameter use_long_ints_ = true.
virtual void MultTranspose(const Vector &b, Vector &x) const
Action of the transpose operator: y=A^t(x). The default behavior in class Operator is to generate an ...
void DeleteStorageVectors()
void SetAdaptiveLinRtol(const int type=2, const double rtol0=0.5, const double rtol_max=0.9, const double alpha=0.5 *(1.0+sqrt(5.0)), const double gamma=1.0)
Enable adaptive linear solver relative tolerance algorithm.
bool GetConverged() const
Returns true if the last call to Mult() converged successfully.
int max_iter
Limit for the number of iterations the solver is allowed to do.
LBFGSSolver(MPI_Comm comm_)
virtual void Mult(const Vector &b, Vector &x) const
Operator application: y=A(x).
virtual void SetSolver(Solver &solver)
Set the linear solver for inverting the Jacobian.
void AdaptiveLinRtolPostSolve(const Vector &x, const Vector &b, const int it, const double fnorm) const
Method for the adaptive linear solver rtol invoked after the linear solve.
static int GuessLegacyPrintLevel(PrintLevel)
Use some heuristics to guess a legacy print level corresponding to the given PrintLevel.
FGMRESSolver(MPI_Comm comm_)
virtual void SetOptimizationProblem(const OptimizationProblem &prob)
void SetMonitor(IterativeSolverMonitor &m)
Set the iterative solver monitor.
Abstract solver for OptimizationProblems.
Solver wrapper which orthogonalizes the input and output vector.
double rel_tol
Relative tolerance.
OptimizationProblem(int insize, const Operator *C_, const Operator *D_)
In parallel, insize is the number of the local true dofs.
void SetSolutionBounds(const Vector &xl, const Vector &xh)
virtual void Mult(const Vector &xt, Vector &x) const
OpType * As() const
Return the Operator pointer statically cast to a specified OpType. Similar to the method Get()...
AuxSpaceSmoother(const HypreParMatrix &op, HypreParMatrix *aux_map, bool op_is_symmetric=true, bool own_aux_map=false)
virtual void Mult(const Vector &xt, Vector &x) const =0
Operator application: y=A(x).
BiCGSTABSolver(MPI_Comm comm_)
void SetOperator(const Operator &op)
Recompute the diagonal using the method AssembleDiagonal of the given new Operator, op.
SLBQPOptimizer(MPI_Comm comm_)
const Vector * GetEqualityVec() const
PrintLevel FromLegacyPrintLevel(int)
Convert a legacy print level integer to a PrintLevel object.
virtual void SetOperator(const Operator &op)
Also calls SetOperator for the preconditioner if there is one.
double Dot(const Vector &x, const Vector &y) const
MPI_Comm GetComm() const
Return the associated MPI communicator, or MPI_COMM_NULL if no communicator is set.
virtual void SetOperator(const Operator &op)
Also calls SetOperator for the preconditioner if there is one.
void SetSolver(Solver &s)
Set the solver used by the OrthoSolver.
void Mult(const Vector &b, Vector &x) const
Perform the action of the OrthoSolver: P * solver * P where P is the projection to the subspace of ve...
void MonitorResidual(int it, double norm, const Vector &r, bool final) override
Monitor the residual vector r.
virtual void SetPreconditioner(Solver &pr)
This should be called before SetOperator.
virtual void MonitorSolution(int it, double norm, const Vector &x, bool final)
Monitor the solution vector x.
virtual void SetPreconditioner(Solver &pr)
This should be called before SetOperator.
KLUSolver(SparseMatrix &A)
int aGMRES(const Operator &A, Vector &x, const Vector &b, const Operator &M, int &max_iter, int m_max, int m_min, int m_step, double cf, double &tol, double &atol, int printit)
bool warnings
If a non-fatal problem has been detected some context-specific information will be reported to mfem::...
bool iterations
Detailed information about each iteration will be reported to mfem::out.
OptimizationSolver(MPI_Comm comm_)
virtual void SetOperator(const Operator &op)
Set/update the solver for the given operator.
const OptimizationProblem * problem
virtual void Mult(const Vector &b, Vector &x) const
Operator application: y=A(x).
virtual double ComputeScalingFactor(const Vector &x, const Vector &b) const
This method can be overloaded in derived classes to implement line search algorithms.
Wrapper for hypre's ParCSR matrix class.
Block diagonal solver for A, each block is inverted by direct solver.
void SetBounds(const Vector &lo_, const Vector &hi_)
virtual void Mult(const Vector &x, Vector &y) const
Operator application: y=A(x).
virtual void MultTranspose(const Vector &x, Vector &y) const
Action of the transpose operator: y=A^t(x). The default behavior in class Operator is to generate an ...
void AdaptiveLinRtolPreSolve(const Vector &x, const int it, const double fnorm) const
Method for the adaptive linear solver rtol invoked before the linear solve.
Rank 3 tensor (array of matrices)
virtual void SetOptimizationProblem(const OptimizationProblem &prob)
NewtonSolver(MPI_Comm comm_)
void Mult(const Vector &x, Vector &y) const
Operator application: y=A(x).
const Operator * GetD() const
IterativeSolverMonitor * monitor
virtual void MonitorResidual(int it, double norm, const Vector &r, bool final)
Monitor the residual vector r.
int width
Dimension of the input / number of columns in the matrix.
virtual void SetOperator(const Operator &op)
Also calls SetOperator for the preconditioner if there is one.
Settings for the output behavior of the IterativeSolver.
const Operator * C
Not owned, some can remain unused (NULL).
double abs_tol
Absolute tolerance.
void SLI(const Operator &A, const Vector &b, Vector &x, int print_iter, int max_num_iter, double RTOLERANCE, double ATOLERANCE)
Stationary linear iteration. (tolerances are squared)
int GMRES(const Operator &A, Vector &x, const Vector &b, Solver &M, int &max_iter, int m, double &tol, double atol, int printit)
GMRES method. (tolerances are squared)
virtual void SetOperator(const Operator &op)
Also calls SetOperator for the preconditioner if there is one.
virtual void SetOperator(const Operator &op)
Factorize the given Operator op which must be a SparseMatrix.
double GetFinalRelNorm() const
Returns the final residual norm after termination of the solver during the last call to Mult()...