proteus.NonlinearSolvers module

A hierarchy of classes for nonlinear algebraic system solvers.

Inheritance diagram of proteus.NonlinearSolvers

class proteus.NonlinearSolvers.NonlinearEquation(dim=0, dim_proc=None)[source]

Bases: object

The base class for nonlinear equations.

getResidual(r)[source]

Evaluate the residual r = F(u)

getJacobian(usePicard=False)[source]
resetNonlinearFunctionStatistics()[source]
proteus.NonlinearSolvers.resolveNorm(spec, F)[source]

Return the norm function selected by spec for the nonlinear equation F.

spec is a callable taking the owned entries of a vector (e.g. l2Norm), or one of the finite element norms of a nodal vector x, which the model F must provide:

‘L2’ ||x||_{L^2} = sqrt(x^T M_C x), M_C the consistent mass matrix (F.femL2Norm) ‘L2_lumped’ sqrt(x^T M_L x), M_L the lumped mass matrix (F.femL2Norm(x, lumped=True))

The finite element norms take the full local vector (owned and ghost entries), since M_C x at an owned row needs the ghost values; they are marked with full_vector = True.

class proteus.NonlinearSolvers.NonlinearSolver(F, J=None, du=None, rtol_r=0.0001, atol_r=1e-16, rtol_du=0.0001, atol_du=1e-16, maxIts=100, norm=<function l2Norm>, convergenceTest='r', computeRates=True, printInfo=True, unorm=None, tol_du=0.33)[source]

Bases: object

The base class for nonlinear solvers.

Convergence tests (convergenceTest):

‘r’ ||r_k|| < rtol_r ||r_0|| + atol_r (norm) ‘u’ s ||du_k|| < tol_du, s = rho/(1-rho) from the observed contraction rho (unorm) ‘du’ ||du_k|| < rtol_du ||u_k|| + atol_du: the last increment relative to the

current iterate (unorm). unorm=’L2’ with atol_du = 0 gives the criterion ||p^{k+1}-p^k||_{L2} < tol ||p^{k+1}||_{L2}

‘r_and_du’ both ‘r’ and ‘du’ (the increment test alone does not control the residual,

i.e. the discrete mass balance)

‘its’, ‘rits’ fixed iteration counts (with ‘rits’ also stopping on ‘r’)

norm(u)[source]
unorm(u)[source]
fullNewtonOff()[source]
fullNewtonOn()[source]
fullResidualOff()[source]
fullResidualOn()[source]
computeResidual(u, r, b)[source]
solveInitialize(u, r, b)[source]
computeConvergenceRates()[source]
converged(r)[source]
failed()[source]
computeAverages()[source]
info()[source]
class proteus.NonlinearSolvers.Newton(linearSolver, F, J=None, du=None, par_du=None, rtol_r=0.0001, atol_r=1e-16, rtol_du=0.0001, atol_du=1e-16, maxIts=100, norm=<function l2Norm>, convergenceTest='r', computeRates=True, printInfo=True, fullNewton=True, directSolver=False, EWtol=True, maxLSits=100, unorm=None)[source]

Bases: NonlinearSolver

A simple iterative solver that is Newton’s method if you give it the right Jacobian

lschemeRetry(hybrid, u, r, b, par_u, par_r)[source]

Hybrid Newton/L-scheme step test, called after the Newton update u -= du and r = F(u).

Trigger ‘residual’: the Newton step did not reduce ||r|| (where a line search would start). Trigger ‘theta’: also when Deuflhard’s affine-covariant contraction estimate Theta_k = ||J_k^{-1} F(u_{k+1})|| / ||du_k|| exceeds hybrid[‘theta_max’] (Theta ~ h_k/2 in the Newton-Kantorovich ball test; one extra back-solve with the current factorization). On a trigger the Newton step is undone and replaced by hybrid[‘its’] L-scheme iterations (F.setLScheme), after which Newton resumes. Returns True if the line search is to be skipped.

setLinearSolverTolerance(r)[source]

This function dynamically sets the relative tolerance of the linear solver associated with the non-linear iteration. Set useEistenstatWalker=True in a simulation’s numerics file to ensure that this function is used.

Parameters:

r (vector) – non-linear residual vector

Notes

The size of the relative reduction assigned to the linear solver depends on two factors: (i) how far the non-linear solver is from satifying its residual reductions and (ii) how large the drop in the latest non-linear residual was.

If the non-linear solver is both far from its residual reduction targets and the latest non-linear residual showed a big drop, then expect the algorithm to assign a large relative reduction to the linear solver.

As the non-linear residual reduction targets get closer, or the non-linear solver stagnates, the linear solver will be assigned a smaller relative reduction up to a minimum of 0.001.

solve(u, r=None, b=None, par_u=None, par_r=None, linear=False)[source]

Solves the non-linear system \(F(u) = b\).

Parameters:
class proteus.NonlinearSolvers.AddedMassNewton(linearSolver, F, J=None, du=None, par_du=None, rtol_r=0.0001, atol_r=1e-16, rtol_du=0.0001, atol_du=1e-16, maxIts=100, norm=<function l2Norm>, convergenceTest='r', computeRates=True, printInfo=True, fullNewton=True, directSolver=False, EWtol=True, maxLSits=100, unorm=None)[source]

Bases: Newton

solve(u, r=None, b=None, par_u=None, par_r=None)[source]

Solves the non-linear system \(F(u) = b\).

Parameters:
class proteus.NonlinearSolvers.MoveMeshMonitorNewton(linearSolver, F, J=None, du=None, par_du=None, rtol_r=0.0001, atol_r=1e-16, rtol_du=0.0001, atol_du=1e-16, maxIts=100, norm=<function l2Norm>, convergenceTest='r', computeRates=True, printInfo=True, fullNewton=True, directSolver=False, EWtol=True, maxLSits=100, unorm=None)[source]

Bases: Newton

solve(u, r=None, b=None, par_u=None, par_r=None)[source]

Solves the non-linear system \(F(u) = b\).

Parameters:
class proteus.NonlinearSolvers.TwoStageNewton(linearSolver, F, J=None, du=None, par_du=None, rtol_r=0.0001, atol_r=1e-16, rtol_du=0.0001, atol_du=1e-16, maxIts=100, norm=<function l2Norm>, convergenceTest='r', computeRates=True, printInfo=True, fullNewton=True, directSolver=False, EWtol=True, maxLSits=100, unorm=None)[source]

Bases: Newton

Solves a 2 Stage problem via Newton’s solve

solve(u, r=None, b=None, par_u=None, par_r=None)[source]

Solves a 2 Stage problem via Newton’s solve

class proteus.NonlinearSolvers.ExplicitLumpedMassMatrixShallowWaterEquationsSolver(linearSolver, F, J=None, du=None, par_du=None, rtol_r=0.0001, atol_r=1e-16, rtol_du=0.0001, atol_du=1e-16, maxIts=100, norm=<function l2Norm>, convergenceTest='r', computeRates=True, printInfo=True, fullNewton=True, directSolver=False, EWtol=True, maxLSits=100, unorm=None)[source]

Bases: Newton

This is a fake solver meant to be used with optimized code A simple iterative solver that is Newton’s method if you give it the right Jacobian

solve(u, r=None, b=None, par_u=None, par_r=None)[source]

Solves the non-linear system \(F(u) = b\).

Parameters:
class proteus.NonlinearSolvers.ExplicitConsistentMassMatrixShallowWaterEquationsSolver(linearSolver, F, J=None, du=None, par_du=None, rtol_r=0.0001, atol_r=1e-16, rtol_du=0.0001, atol_du=1e-16, maxIts=100, norm=<function l2Norm>, convergenceTest='r', computeRates=True, printInfo=True, fullNewton=True, directSolver=False, EWtol=True, maxLSits=100, unorm=None)[source]

Bases: Newton

This is a fake solver meant to be used with optimized code A simple iterative solver that is Newton’s method if you give it the right Jacobian

solve(u, r=None, b=None, par_u=None, par_r=None)[source]

Solves the non-linear system \(F(u) = b\).

Parameters:
class proteus.NonlinearSolvers.ExplicitLumpedMassMatrix(linearSolver, F, J=None, du=None, par_du=None, rtol_r=0.0001, atol_r=1e-16, rtol_du=0.0001, atol_du=1e-16, maxIts=100, norm=<function l2Norm>, convergenceTest='r', computeRates=True, printInfo=True, fullNewton=True, directSolver=False, EWtol=True, maxLSits=100, unorm=None)[source]

Bases: Newton

This is a fake solver meant to be used with optimized code A simple iterative solver that is Newton’s method if you give it the right Jacobian

solve(u, r=None, b=None, par_u=None, par_r=None)[source]

Solves the non-linear system \(F(u) = b\).

Parameters:
no_solve(u, r=None, b=None, par_u=None, par_r=None)[source]
class proteus.NonlinearSolvers.ExplicitLumpedMassMatrixForRichards(linearSolver, F, J=None, du=None, par_du=None, rtol_r=0.0001, atol_r=1e-16, rtol_du=0.0001, atol_du=1e-16, maxIts=100, norm=<function l2Norm>, convergenceTest='r', computeRates=True, printInfo=True, fullNewton=True, directSolver=False, EWtol=True, maxLSits=100, unorm=None)[source]

Bases: Newton

This is a fake solver meant to be used with optimized code A simple iterative solver that is Newton’s method if you give it the right Jacobian

solve(u, r=None, b=None, par_u=None, par_r=None)[source]

Solves the non-linear system \(F(u) = b\).

Parameters:
class proteus.NonlinearSolvers.ExplicitConsistentMassMatrixWithRedistancing(linearSolver, F, J=None, du=None, par_du=None, rtol_r=0.0001, atol_r=1e-16, rtol_du=0.0001, atol_du=1e-16, maxIts=100, norm=<function l2Norm>, convergenceTest='r', computeRates=True, printInfo=True, fullNewton=True, directSolver=False, EWtol=True, maxLSits=100, unorm=None)[source]

Bases: Newton

This is a fake solver meant to be used with optimized code A simple iterative solver that is Newton’s method if you give it the right Jacobian

solve(u, r=None, b=None, par_u=None, par_r=None)[source]

Solves the non-linear system \(F(u) = b\).

Parameters:
class proteus.NonlinearSolvers.ExplicitConsistentMassMatrixForVOF(linearSolver, F, J=None, du=None, par_du=None, rtol_r=0.0001, atol_r=1e-16, rtol_du=0.0001, atol_du=1e-16, maxIts=100, norm=<function l2Norm>, convergenceTest='r', computeRates=True, printInfo=True, fullNewton=True, directSolver=False, EWtol=True, maxLSits=100, unorm=None)[source]

Bases: Newton

This is a fake solver meant to be used with optimized code A simple iterative solver that is Newton’s method if you give it the right Jacobian

solve(u, r=None, b=None, par_u=None, par_r=None)[source]

Solves the non-linear system \(F(u) = b\).

Parameters:
class proteus.NonlinearSolvers.ExplicitConsistentMassMatrixForRichards(linearSolver, F, J=None, du=None, par_du=None, rtol_r=0.0001, atol_r=1e-16, rtol_du=0.0001, atol_du=1e-16, maxIts=100, norm=<function l2Norm>, convergenceTest='r', computeRates=True, printInfo=True, fullNewton=True, directSolver=False, EWtol=True, maxLSits=100, unorm=None)[source]

Bases: Newton

This is a fake solver meant to be used with optimized code A simple iterative solver that is Newton’s method if you give it the right Jacobian

solve(u, r=None, b=None, par_u=None, par_r=None)[source]

Solves the non-linear system \(F(u) = b\).

Parameters:
class proteus.NonlinearSolvers.NewtonWithL2ProjectionForMassCorrection(linearSolver, F, J=None, du=None, par_du=None, rtol_r=0.0001, atol_r=1e-16, rtol_du=0.0001, atol_du=1e-16, maxIts=100, norm=<function l2Norm>, convergenceTest='r', computeRates=True, printInfo=True, fullNewton=True, directSolver=False, EWtol=True, maxLSits=100, unorm=None)[source]

Bases: Newton

This is a fake solver meant to be used with optimized code A simple iterative solver that is Newton’s method if you give it the right Jacobian

solve(u, r=None, b=None, par_u=None, par_r=None)[source]

Solve F(u) = b

b – right hand side u – solution r – F(u) - b

class proteus.NonlinearSolvers.CLSVOFNewton(linearSolver, F, J=None, du=None, par_du=None, rtol_r=0.0001, atol_r=1e-16, rtol_du=0.0001, atol_du=1e-16, maxIts=100, norm=<function l2Norm>, convergenceTest='r', computeRates=True, printInfo=True, fullNewton=True, directSolver=False, EWtol=True, maxLSits=100, unorm=None)[source]

Bases: Newton

spinUpStep(u, r=None, b=None, par_u=None, par_r=None)[source]
getNormalReconstruction(u, r=None, b=None, par_u=None, par_r=None)[source]
project_disc_ICs(u, r=None, b=None, par_u=None, par_r=None)[source]
redistance_disc_ICs(u, r=None, b=None, par_u=None, par_r=None, max_num_iters=100)[source]
spinup_for_disc_ICs(u, r=None, b=None, par_u=None, par_r=None)[source]
solve(u, r=None, b=None, par_u=None, par_r=None)[source]

Solves the non-linear system \(F(u) = b\).

Parameters:
solveOldMethod(u, r=None, b=None, par_u=None, par_r=None)[source]
class proteus.NonlinearSolvers.POD_Newton(linearSolver, F, J=None, du=None, par_du=None, rtol_r=0.0001, atol_r=1e-16, rtol_du=0.0001, atol_du=1e-16, maxIts=100, norm=<function l2Norm>, convergenceTest='r', computeRates=True, printInfo=True, fullNewton=True, directSolver=False, EWtol=True, maxLSits=100, use_deim=False)[source]

Bases: Newton

Newton’s method on the reduced order system based on POD

deim_utils = <module 'proteus.deim_utils' from '/home/cekees/proteus-1.9.1-docs/proteus/deim_utils.py'>[source]
computeResidual(u, r, b)[source]

Use DEIM algorithm to compute residual if use_deim is turned on

Right now splits the evaluation into two ‘temporal’ (mass) and spatial piece

As first step for DEIM still does full evaluation

norm(u)[source]
solve(u, r=None, b=None, par_u=None, par_r=None)[source]

Solve F(u) = b

b – right hand side u – solution r – F(u) - b

class proteus.NonlinearSolvers.POD_DEIM_Newton(linearSolver, F, J=None, du=None, par_du=None, rtol_r=0.0001, atol_r=1e-16, rtol_du=0.0001, atol_du=1e-16, maxIts=100, norm=<function l2Norm>, convergenceTest='r', computeRates=True, printInfo=True, fullNewton=True, directSolver=False, EWtol=True, maxLSits=100, use_deim=True)[source]

Bases: Newton

Newton’s method on the reduced order system based on POD

norm(u)[source]
computeDEIMresiduals(u, rs, rt)[source]

wrapper for computing residuals separately for DEIM

solveInitialize(u, r, b)[source]

if using deim modifies base initialization by splitting up residual evaluation into separate pieces interpolated by deim (right now just does ‘mass’ and ‘space’)

NOT FINISHED

solve(u, r=None, b=None, par_u=None, par_r=None)[source]

Solve F(u) = b

b – right hand side u – solution r – F(u) - b

solveDEIM(u, r=None, b=None, par_u=None, par_r=None)[source]

Solve F(u) = b

b – right hand side u – solution r – F(u) - b

using DEIM Start with brute force just testing things

class proteus.NonlinearSolvers.NewtonNS(linearSolver, F, J=None, du=None, par_du=None, rtol_r=0.0001, atol_r=1e-16, rtol_du=0.0001, atol_du=1e-16, maxIts=100, norm=<function l2Norm>, convergenceTest='r', computeRates=True, printInfo=True, fullNewton=True, directSolver=False, EWtol=True, maxLSits=100)[source]

Bases: NonlinearSolver

A simple iterative solver that is Newton’s method if you give it the right Jacobian

setLinearSolverTolerance(r)[source]
converged(r)[source]
solve(u, r=None, b=None, par_u=None, par_r=None)[source]

Solve F(u) = b

b – right hand side u – solution r – F(u) - b

class proteus.NonlinearSolvers.SSPRKNewton(linearSolver, F, J=None, du=None, par_du=None, rtol_r=0.0001, atol_r=1e-16, rtol_du=0.0001, atol_du=1e-16, maxIts=100, norm=<function l2Norm>, convergenceTest='r', computeRates=True, printInfo=True, fullNewton=True, directSolver=False, EWtol=True, maxLSits=100)[source]

Bases: Newton

Version of Newton for SSPRK so doesn’t refactor unnecessarily

solve(u, r=None, b=None, par_u=None, par_r=None)[source]

Solve F(u) = b

b – right hand side u – solution r – F(u) - b

resetFactorization(needToRefactor=True)[source]
class proteus.NonlinearSolvers.PicardNewton(linearSolver, F, J=None, du=None, par_du=None, rtol_r=0.0001, atol_r=1e-16, rtol_du=0.0001, atol_du=1e-16, maxIts=100, norm=<function l2Norm>, convergenceTest='r', computeRates=True, printInfo=True, fullNewton=True, directSolver=False, EWtol=True, maxLSits=100)[source]

Bases: Newton

solve(u, r=None, b=None, par_u=None, par_r=None)[source]

Solve F(u) = b

b – right hand side u – solution r – F(u) - b

class proteus.NonlinearSolvers.NLJacobi(F, J, du, weight=0.8, rtol_r=0.0001, atol_r=1e-16, rtol_du=0.0001, atol_du=1e-16, maxIts=100, norm=<function l2Norm>, convergenceTest='r', computeRates=True, printInfo=True, fullNewton=True)[source]

Bases: NonlinearSolver

Nonlinear Jacobi iteration.

solve(u, r=None, b=None, par_u=None, par_r=None)[source]
class proteus.NonlinearSolvers.NLGaussSeidel(connectionList, F, J, du, weight=1.0, sym=False, rtol_r=0.0001, atol_r=1e-16, rtol_du=0.0001, atol_du=1e-16, maxIts=100, norm=<function l2Norm>, convergenceTest='r', computeRates=True, printInfo=True, fullNewton=True)[source]

Bases: NonlinearSolver

Nonlinear Gauss-Seidel.

solve(u, r=None, b=None, par_u=None, par_r=None)[source]
class proteus.NonlinearSolvers.NLStarILU(connectionList, F, J, du, weight=1.0, sym=False, rtol_r=0.0001, atol_r=1e-16, rtol_du=0.0001, atol_du=1e-16, maxIts=100, norm=<function l2Norm>, convergenceTest='r', computeRates=True, printInfo=True, fullNewton=True)[source]

Bases: NonlinearSolver

Nonlinear alternating Schwarz on node stars.

prepareSubdomains()[source]
solve(u, r=None, b=None, par_u=None, par_r=None)[source]
class proteus.NonlinearSolvers.FasTwoLevel(prolong, restrict, restrictSum, coarseF, preSmoother, postSmoother, coarseSolver, F, J=None, du=None, rtol_r=0.0001, atol_r=1e-16, rtol_du=0.0001, atol_du=1e-16, maxIts=100, norm=<function l2Norm>, convergenceTest='r', computeRates=True, printInfo=True)[source]

Bases: NonlinearSolver

A generic nonlinear two-level solver based on the full approximation scheme. (FAS).

fullNewtonOff()[source]
fullNewtonOn()[source]
fullResidualOff()[source]
fullResidualOn()[source]
solve(u, r=None, b=None, par_u=None, par_r=None)[source]
class proteus.NonlinearSolvers.FAS(prolongList, restrictList, restrictSumList, FList, preSmootherList, postSmootherList, coarseSolver, mgItsList=[], printInfo=True)[source]

Bases: object

A generic nonlinear multigrid W cycle using the Full Approximation Scheme (FAS).

solve(u, r=None, b=None, par_u=None, par_r=None)[source]
class proteus.NonlinearSolvers.MultilevelNonlinearSolver(fList, levelNonlinearSolverList, computeRates=False, printInfo=False)[source]

Bases: object

A generic multilevel solver.

solveMultilevel(uList, rList, bList=None, par_uList=None, par_rList=None)[source]
updateJacobian()[source]
info()[source]
class proteus.NonlinearSolvers.NLNI(fList=[], solverList=[], prolongList=[], restrictList=[], restrictSumList=[], maxIts=None, tolList=None, atol=None, computeRates=True, printInfo=True)[source]

Bases: MultilevelNonlinearSolver

Nonlinear nested iteration.

solve(u, r=None, b=None, par_u=None, par_r=None)[source]
solveMultilevel(uList, rList, bList=None, par_uList=None, par_rList=None)[source]
info()[source]
switchToResidualConvergence(solver, rtol)[source]
revertToFixedIteration(solver)[source]
proteus.NonlinearSolvers.multilevelNonlinearSolverChooser(nonlinearOperatorList, jacobianList, par_jacobianList, duList=None, par_duList=None, relativeToleranceList=None, absoluteTolerance=1e-08, multilevelNonlinearSolverType=<class 'proteus.NonlinearSolvers.NLNI'>, computeSolverRates=False, printSolverInfo=False, linearSolverList=None, linearDirectSolverFlag=False, solverFullNewtonFlag=True, maxSolverIts=500, solverConvergenceTest='r', levelNonlinearSolverType=<class 'proteus.NonlinearSolvers.Newton'>, levelSolverFullNewtonFlag=True, levelSolverConvergenceTest='r', computeLevelSolverRates=False, printLevelSolverInfo=False, relaxationFactor=None, connectionListList=None, smootherType='Jacobi', prolong_bcList=None, restrict_bcList=None, restrict_bcSumList=None, prolongList=None, restrictList=None, restrictionRowSumList=None, preSmooths=3, postSmooths=3, cycles=3, smootherConvergenceTest='its', computeSmootherRates=False, printSmootherInfo=False, smootherFullNewtonFlag=True, computeCoarseSolverRates=False, printCoarseSolverInfo=False, EWtol=True, maxLSits=100, parallelUsesFullOverlap=True, nonlinearSolverNorm=<function l2Norm>, nonlinearSolverUNorm=None, relativeToleranceDu=0.0001, absoluteToleranceDu=1e-16)[source]