/**
* Wrapper around the nonlinear solver from the NOX
- * packge (https://docs.trilinos.org/dev/packages/nox/doc/html/index.html),
+ * package (https://docs.trilinos.org/dev/packages/nox/doc/html/index.html),
* targeting deal.II data structures.
*
* The following code shows the steps how to use this class:
* // create nonlinear solver
* TrilinosWrappers::NOXSolver<VectorType> solver(additional_data);
*
- * // set user functions to compute residual,
- * // set up Jacobian, and to apply the inverse of
- * // Jacobian; note that there are more functions that
- * // can be set
+ * // Set user functions to compute residual, to set up the Jacobian, and to
+ * // apply the inverse of the Jacobian.
+ * // Note that there are more functions that can be set.
* solver.residual = [](const auto &src, auto &dst) {...};
* solver.setup_jacobian = [](const auto &src) {...};
* solver.solve_with_jacobian =
* [](const auto &src, auto &dst, const auto) {...};
*
- * // solver nonlinear system with solution containing the intial guess and
+ * // solver nonlinear system with solution containing the initial guess and
* // the final solution
* solver.solve(solution);
* @endcode
/**
* Absolute l2 tolerance of the residual to be reached.
*
- * @note Solver terminates successfully if either the absolut or
+ * @note Solver terminates successfully if either the absolute or
* the relative tolerance has been reached.
*/
double abs_tol;
/**
* Relative l2 tolerance of the residual to be reached.
*
- * @note Solver terminates successfully if either the absolut or
+ * @note Solver terminates successfully if either the absolute or
* the relative tolerance has been reached.
*/
double rel_tol;
/**
* Max number of linear iterations after which the preconditioner
- * should be updated. This is only used if a lambda is attached to
- * solve_with_jacobian_and_track_n_linear_iterations.
+ * should be updated. This is only used if
+ * solve_with_jacobian_and_track_n_linear_iterations has been given
+ * a target (i.e., it is not empty).
*/
unsigned int threshold_n_linear_iterations;
*
* @note This function is optional and is used in the case of certain
* configurations. For instance, this function is required if the
- * polynomial line search (@p NOX::LineSearch::Polynomial) is
- * chosen, whereas for the full step case (@p NOX::LineSearch::FullStep)
+ * polynomial line search (`NOX::LineSearch::Polynomial`) is
+ * chosen, whereas for the full step case (`NOX::LineSearch::FullStep`)
* it won't be called.
*
* @note This function should return 0 in the case of success.
/**
* A user function that applies the inverse of the Jacobian to
* @p x and writes the result in @p x. The parameter @p tolerance
- * species the error reduction if a interative solver is used.
+ * specifies the error reduction if an iterative solver is used.
*
* @note This function is optional and is used in the case of certain
* configurations.
* of linear iterations is exceeded.
*
* @note This function is optional. If no function is attached, this
- * means implicitly a return value of false.
+ * means implicitly a return value of `false`.
*/
std::function<bool()> update_preconditioner_predicate;
#include <deal.II/base/config.h>
-#include <deal.II/trilinos/nox.h>
-
#ifdef DEAL_II_TRILINOS_WITH_NOX
+# include <deal.II/trilinos/nox.h>
+
# include <NOX_Abstract_Group.H>
# include <NOX_Abstract_Vector.H>
# include <NOX_Solver_Factory.H>
}
/**
- * Initialize every element of this vector with gamma.
+ * Initialize every element of this vector with @p gamma .
*/
NOX::Abstract::Vector &
init(double gamma) override
}
/**
- * Put element-wise absolute values of source vector y into this vector.
+ * Put element-wise absolute values of source vector @p y into this vector.
*/
NOX::Abstract::Vector &
abs(const NOX::Abstract::Vector &y) override
}
/**
- * Copy source vector y into this vector.
+ * Copy source vector @p y into this vector.
*/
NOX::Abstract::Vector &
operator=(const NOX::Abstract::Vector &y) override
}
/**
- * Put element-wise reciprocal of source vector y into this vector.
+ * Put element-wise reciprocal of source vector @p y into this vector.
*/
NOX::Abstract::Vector &
reciprocal(const NOX::Abstract::Vector &y) override
}
/**
- * Scale each element of this vector by gamma.
+ * Scale each element of this vector by @p gamma .
*/
NOX::Abstract::Vector &
scale(double gamma) override
}
/**
- * Scale this vector element-by-element by the vector a.
+ * Scale this vector element-by-element by the vector @p a.
*/
NOX::Abstract::Vector &
scale(const NOX::Abstract::Vector &a) override
}
/**
- * Compute x = (alpha * a) + (gamma * x) where x is this vector.
+ * Compute `x = (alpha * a) + (gamma * x)` where `x` is this vector.
*/
NOX::Abstract::Vector &
update(double alpha,
}
/**
- * Compute x = (alpha * a) + (beta * b) + (gamma * x) where x is this
- * vector.
+ * Compute `x = (alpha * a) + (beta * b) + (gamma * x)` where `x` is
+ * this vector.
*/
NOX::Abstract::Vector &
update(double alpha,
}
/**
- * Return the vector's weighted 2-Norm.
+ * Return the vector's weighted 2-norm.
*/
double
norm(const NOX::Abstract::Vector &weights) const override
}
/**
- * Set the solution vector `x` to @y.
+ * Set the solution vector `x` to @p y.
*/
void
setX(const NOX::Abstract::Vector &y) override
}
/**
- * Return true if the residual vector `F` is valid.
+ * Return `true` if the residual vector `F` is valid.
*/
bool
isF() const override
}
/**
- * Return true if the Jacobian is valid.
+ * Return `true` if the Jacobian is valid.
*/
bool
isJacobian() const override
}
/**
- * Return an `RCP` to solution vector.
+ * Return a reference counting pointer to solution vector.
*/
Teuchos::RCP<const NOX::Abstract::Vector>
getXPtr() const override
}
/**
- * Return an RCP to the residual `F(x)`.
+ * Return a reference counting pointer to the residual `F(x)`.
*/
Teuchos::RCP<const NOX::Abstract::Vector>
getFPtr() const override
}
/**
- * Return an `RCP` to gradient.
+ * Return a reference counting pointer to gradient.
*/
Teuchos::RCP<const NOX::Abstract::Vector>
getGradientPtr() const override
}
/**
- * Return an `RCP` to the Newton descent direction.
+ * Return a reference counting pointer to the Newton descent direction.
*/
Teuchos::RCP<const NOX::Abstract::Vector>
getNewtonPtr() const override
/**
* Create a new Group of the same derived type as this one by
- * cloning this one, and return a reference counting
- * pointer to the new group.
+ * cloning this one, and return a reference counting pointer to
+ * the new group.
*/
Teuchos::RCP<NOX::Abstract::Group>
clone(NOX::CopyType copy_type) const override
}
/**
- * Applies the Jacobian to the given input vector and assigns
+ * Applies the Jacobian to the given @p input vector and assigns
* the output to the @p result.
*/
NOX::Abstract::Group::ReturnType
private:
/**
- * Reset state.
+ * Reset the state of this object.
*/
void
reset()
is_valid_j = false;
}
- // internal vector for the current solution
+ /**
+ * An internal vector for the current solution.
+ */
Vector<VectorType> x;
- // internal vector for the residual
+ /**
+ * An internal vector for the residual.
+ */
Vector<VectorType> f;
- // internal vector for the solution gradient
+ /**
+ * An internal vector for the solution gradient.
+ */
Vector<VectorType> gradient;
- // internal vector for the newton step
+ /**
+ * An internal vector for the newton step.
+ */
Vector<VectorType> newton;
- // helper function to compute residual
+ /**
+ * A helper function to compute residual.
+ */
std::function<int(const VectorType &x, VectorType &f)> residual;
- // helper function to setup Jacobian
+ /**
+ * A helper function to setup Jacobian.
+ */
std::function<int(const VectorType &x)> setup_jacobian;
- // helper function to apply Jacobian
+ /**
+ * A helper function to apply Jacobian.
+ */
std::function<int(const VectorType &x, VectorType &v)> apply_jacobian;
- // helper function to solve jacobian
+ /**
+ * A helper function to solve Jacobian.
+ */
std::function<
int(const VectorType &f, VectorType &x, const double tolerance)>
solve_with_jacobian;
- // internal state (is residual computed?)
+ /**
+ * A flag that indicates if the has residual been computed.
+ */
bool is_valid_f;
- // internal state (is Jacobian computed?)
+ /**
+ * A flag that indicates if the Jacobian has been computed.
+ */
bool is_valid_j;
};
#include <deal.II/base/config.h>
-#include <deal.II/lac/block_vector.h>
-#include <deal.II/lac/la_parallel_block_vector.h>
-#include <deal.II/lac/la_parallel_vector.h>
-#include <deal.II/lac/la_vector.h>
-#include <deal.II/lac/petsc_block_vector.h>
-#include <deal.II/lac/petsc_vector.h>
-#include <deal.II/lac/trilinos_parallel_block_vector.h>
-#include <deal.II/lac/trilinos_vector.h>
-#include <deal.II/lac/vector_memory.h>
-
-#include <deal.II/trilinos/nox.templates.h>
-
#ifdef DEAL_II_TRILINOS_WITH_NOX
+# include <deal.II/lac/block_vector.h>
+# include <deal.II/lac/la_parallel_block_vector.h>
+# include <deal.II/lac/la_parallel_vector.h>
+# include <deal.II/lac/la_vector.h>
+# include <deal.II/lac/petsc_block_vector.h>
+# include <deal.II/lac/petsc_vector.h>
+# include <deal.II/lac/trilinos_parallel_block_vector.h>
+# include <deal.II/lac/trilinos_vector.h>
+# include <deal.II/lac/vector_memory.h>
+
+# include <deal.II/trilinos/nox.templates.h>
+
DEAL_II_NAMESPACE_OPEN
namespace TrilinosWrappers