PTEMS  0.1.0-dev+git.81fd0e4
PolyTopic Element Method Solver
ptems::NonlinearSolver< T > Class Template Reference

Nonlinear solver using (damped) Newton. More...

#include <ptems/solvers/nonlinearsolver.hpp>

Public Types

typedef T value_type
 The type of the nonlinear system. More...
 
typedef remove_complex_t< value_typereal_type
 The underlying real-valued type (either value_type or the underlying type of std::complex) More...
 

Public Member Functions

 NonlinearSolver (const DampingParameters< real_type > &dampingParams)
 Creates a damped Newton nonlinear solver. More...
 
 NonlinearSolver ()
 Creates an un-damped Newton solver. More...
 
template<typename Solver , typename Residual , std::size_t DIM, std::size_t N>
DiscreteFunction< DIM, value_type, N, N > SolveWithStatus (Solver solve, Residual residual, DiscreteFunction< DIM, value_type, N, N > initialGuess, double &tolerance, std::size_t &iterations)
 Solve the nonlinear system \(F(u) = 0\), where \(F(u)\) is the residual, and returns, via reference arguments, the actual number of iterations and achieved residual tolerance. More...
 
template<typename Solver , typename Residual , std::size_t DIM, std::size_t N>
DiscreteFunction< DIM, value_type, N, N > SolveWithStatus (Solver solve, Residual residual, const DiscreteFunction< DIM, value_type, N, N > &initialGuess, std::size_t &iterations)
 Solve the nonlinear system \(F(u) = 0\), where \(F(u)\) is the residual, and returns, via reference arguments, the actual number of iterations. More...
 
template<typename Solver , typename Residual , std::size_t DIM, std::size_t N>
DiscreteFunction< DIM, value_type, N, N > Solve (Solver solve, Residual residual, DiscreteFunction< DIM, value_type, N, N > initialGuess, double tolerance=1e-8, std::size_t maxItns=100)
 Solve the nonlinear system \(F(u) = 0\), where \(F(u)\) is the residual. More...
 
template<typename Solver , typename Residual , std::size_t DIM, std::size_t N>
DiscreteFunction< DIM, value_type, N, N > Solve (Solver solve, Residual residual, const DiscreteFunction< DIM, value_type, N, N > &initialGuess, std::size_t maxItns)
 Solve the nonlinear system \(F(u) = 0\), where \(F(u)\) is the residual. More...
 

Detailed Description

template<typename T>
class ptems::NonlinearSolver< T >

Nonlinear solver using (damped) Newton.

Todo:
This is for damped Newton only, should try to generalise!
Template Parameters
TThe type of the nonlinear system

Member Typedef Documentation

◆ real_type

template<typename T >
typedef remove_complex_t<value_type> ptems::NonlinearSolver< T >::real_type

The underlying real-valued type (either value_type or the underlying type of std::complex)

◆ value_type

template<typename T >
typedef T ptems::NonlinearSolver< T >::value_type

The type of the nonlinear system.

Constructor & Destructor Documentation

◆ NonlinearSolver() [1/2]

template<typename T >
ptems::NonlinearSolver< T >::NonlinearSolver ( const DampingParameters< real_type > &  dampingParams)
inline

Creates a damped Newton nonlinear solver.

Parameters
dampingParamsThe damping parameters for the damped Newton solver

◆ NonlinearSolver() [2/2]

template<typename T >
ptems::NonlinearSolver< T >::NonlinearSolver ( )
inline

Creates an un-damped Newton solver.

Member Function Documentation

◆ Solve() [1/2]

template<typename T >
template<typename Solver , typename Residual , std::size_t DIM, std::size_t N>
DiscreteFunction<DIM, value_type, N, N> ptems::NonlinearSolver< T >::Solve ( Solver  solve,
Residual  residual,
const DiscreteFunction< DIM, value_type, N, N > &  initialGuess,
std::size_t  maxItns 
)
inline

Solve the nonlinear system \(F(u) = 0\), where \(F(u)\) is the residual.

Uses default tolerance of 1e-8.

Exceptions
std::invalid_argumentIf tolerance is non-positive
Template Parameters
SolverType of the function to solve \(F'(u)v = F(u)\), where \(F'(u)v\) is the Frechet derivative of F in the direction \(v\) at \(u\).
ResidualType of the residual ( \(F\)) function
DIMThe dimension of the underlying domain
NThe number of variables in the underlying finite element space
Parameters
solveFunction to solve \(F'(u)v = F(u)\), where \(F'(u)v\) is the Frechet derivative of F in the direction \(v\) at \(u\). Should take form DiscreteFunction<DIM, value_type, N>(const DiscreteFunction<DIM, value_type, N>&, const std::vector<value_type>&) where the first argument is the function \(u\) and the second is the right hand side (residual \(F(u)\) evaluated at \(u\)), and should return the update \(v\).
residualFunction to compute the residual \(u\). Should have the form void(const DiscreteFunction<DIM, value_type, N>&, std::vector<value_type>&) where the first argument is the function \(u\) and the second is the residual vector \(F(u)\) to update - note this vector must be returned the same size as passed.
initialGuessThe initial guess for the Newton solver
maxItnsMaximum number of Newton iterations to compute the solution.
Returns
The solution to the nonlinear solve

◆ Solve() [2/2]

template<typename T >
template<typename Solver , typename Residual , std::size_t DIM, std::size_t N>
DiscreteFunction<DIM, value_type, N, N> ptems::NonlinearSolver< T >::Solve ( Solver  solve,
Residual  residual,
DiscreteFunction< DIM, value_type, N, N >  initialGuess,
double  tolerance = 1e-8,
std::size_t  maxItns = 100 
)
inline

Solve the nonlinear system \(F(u) = 0\), where \(F(u)\) is the residual.

Exceptions
std::invalid_argumentIf tolerance is non-positive
Template Parameters
SolverType of the function to solve \(F'(u)v = F(u)\), where \(F'(u)v\) is the Frechet derivative of F in the direction \(v\) at \(u\).
ResidualType of the residual ( \(F\)) function
DIMThe dimension of the underlying domain
NThe number of variables in the underlying finite element space
Parameters
solveFunction to solve \(F'(u)v = F(u)\), where \(F'(u)v\) is the Frechet derivative of F in the direction \(v\) at \(u\). Should take form DiscreteFunction<DIM, value_type, N>(const DiscreteFunction<DIM, value_type, N>&, const std::vector<value_type>&) where the first argument is the function \(u\) and the second is the right hand side (residual \(F(u)\) evaluated at \(u\)), and should return the update \(v\).
residualFunction to compute the residual \(u\). Should have the form void(const DiscreteFunction<DIM, value_type, N>&, std::vector<value_type>&) where the first argument is the function \(u\) and the second is the residual vector \(F(u)\) to update - note this vector must be returned the same size as passed.
initialGuessThe initial guess for the Newton solver
toleranceTolerance to acheive in the Newton solver. (default=1e-8)
maxItnsMaximum number of Newton iterations to compute the solution. (default = 100)
Returns
The solution to the nonlinear solve

◆ SolveWithStatus() [1/2]

template<typename T >
template<typename Solver , typename Residual , std::size_t DIM, std::size_t N>
DiscreteFunction<DIM, value_type, N, N> ptems::NonlinearSolver< T >::SolveWithStatus ( Solver  solve,
Residual  residual,
const DiscreteFunction< DIM, value_type, N, N > &  initialGuess,
std::size_t iterations 
)
inline

Solve the nonlinear system \(F(u) = 0\), where \(F(u)\) is the residual, and returns, via reference arguments, the actual number of iterations.

Uses default tolerance of 1e-8.

Template Parameters
SolverType of the function to solve \(F'(u)v = F(u)\), where \(F'(u)v\) is the Frechet derivative of F in the direction \(v\) at \(u\).
ResidualType of the residual ( \(F\)) function
DIMThe dimension of the underlying domain
NThe number of variables in the underlying finite element space
Parameters
solveFunction to solve \(F'(u)v = F(u)\), where \(F'(u)v\) is the Frechet derivative of F in the direction \(v\) at \(u\). Should take form DiscreteFunction<DIM, value_type, N>(const DiscreteFunction<DIM, value_type, N>&, const std::vector<value_type>&) where the first argument is the function \(u\) and the second is the right hand side (residual \(F(u)\) evaluated at \(u\)), and should return the update \(v\).
residualFunction to compute the residual \(u\). Should have the form void(const DiscreteFunction<DIM, value_type, N>&, std::vector<value_type>&) where the first argument is the function \(u\) and the second is the residual vector \(F(u)\) to update - note this vector must be returned the same size as passed.
initialGuessThe initial guess for the Newton solver
iterationsMaximum number of Newton iterations to compute the solution. Updated at exit with the number of actual iterations performed
Returns
The solution to the nonlinear solve

◆ SolveWithStatus() [2/2]

template<typename T >
template<typename Solver , typename Residual , std::size_t DIM, std::size_t N>
DiscreteFunction<DIM, value_type, N, N> ptems::NonlinearSolver< T >::SolveWithStatus ( Solver  solve,
Residual  residual,
DiscreteFunction< DIM, value_type, N, N >  initialGuess,
double &  tolerance,
std::size_t iterations 
)
inline

Solve the nonlinear system \(F(u) = 0\), where \(F(u)\) is the residual, and returns, via reference arguments, the actual number of iterations and achieved residual tolerance.

Exceptions
std::invalid_argumentIf tolerance is non-positive
Template Parameters
SolverType of the function to solve \(F'(u)v = F(u)\), where \(F'(u)v\) is the Frechet derivative of F in the direction \(v\) at \(u\).
ResidualType of the residual ( \(F\)) function
DIMThe dimension of the underlying domain
NThe number of variables in the underlying finite element space
Parameters
solveFunction to solve \(F'(u)v = F(u)\), where \(F'(u)v\) is the Frechet derivative of F in the direction \(v\) at \(u\). Should take form DiscreteFunction<DIM, value_type, N>(const DiscreteFunction<DIM, value_type, N>&, const std::vector<value_type>&) where the first argument is the function \(u\) and the second is the right hand side (residual \(F(u)\) evaluated at \(u\)), and should return the update \(v\).
residualFunction to compute the residual \(u\). Should have the form void(const DiscreteFunction<DIM, value_type, N>&, std::vector<value_type>&) where the first argument is the function \(u\) and the second is the residual vector \(F(u)\) to update - note this vector must be returned the same size as passed.
initialGuessThe initial guess for the Newton solver
toleranceTolerance to acheive in the Newton solver. Updated at exit with the achieved tolerance
iterationsMaximum number of Newton iterations to compute the solution. Updated at exit with the number of actual iterations performed
Returns
The solution to the nonlinear solve

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