Chaste Commit::1fd4e48e3990e67db148bc1bc4cf6991a0049d0c
SimplePetscNonlinearSolver Class Reference

#include <SimplePetscNonlinearSolver.hpp>

+ Inheritance diagram for SimplePetscNonlinearSolver:
+ Collaboration diagram for SimplePetscNonlinearSolver:

Public Member Functions

Vec Solve (PetscErrorCode(*pComputeResidual)(SNES, Vec, Vec, void *), PetscErrorCode(*pComputeJacobian)(SNES, Vec, Mat *, Mat *, MatStructure *, void *), Vec initialGuess, unsigned fill, void *pContext)
 
- Public Member Functions inherited from AbstractNonlinearSolver
virtual ~AbstractNonlinearSolver ()
 

Detailed Description

Concrete Simple Nonlinear PDE system solver.

Definition at line 46 of file SimplePetscNonlinearSolver.hpp.

Member Function Documentation

◆ Solve()

Vec SimplePetscNonlinearSolver::Solve ( PetscErrorCode(*)(SNES, Vec, Vec, void *)  pComputeResidual,
PetscErrorCode(*)(SNES, Vec, Mat *, Mat *, MatStructure *, void *)  pComputeJacobian,
Vec  initialGuess,
unsigned  fill,
void *  pContext 
)
virtual

Simple Nonlinear PDE system solver, uses the PETSc SNES Solver, which uses Newton's method.

Parameters
pComputeResidualpoints to the function which computes the residual, it must take arguments SNES (a PETSc nonlinear solver object), Vec (current guess - a vector of the correct size), Vec (a Vec of the correct size in which the residual is returned), void* (a pointer to anything you may need to refer to when calculating the residual)
pComputeJacobianpoints to the function which computes the Jacobian. Before PETSc 3.5 it took arguments SNES (a PETSc nonlinear solver * object), Vec, Mat* (a pointer to the Jacobian matrix), Mat* (a pointer to a preconditioner matrix), MatStructure* (points to the PETSc matrix type e.g. AIJ), void* (a pointer to anything you may need to refer to when calculating the residual). For PETSc 3.5+ this became SNES, Vec, Mat, Mat, void*.
initialGuessA PETSc Vec of the correct size, containing initial guesses for the nonlinear solver.
pContext[optional] A pointer to a class that may have to be used in the ComputeResidual and ComputeJacobian functions
fillthe expected maximum number of nonzeros in a row of the Jacobian matrix
Returns
Returns a PETSc Vec of the solution.

To be used in the form: Vec answer=solver->Solve(&ComputeResidual, &ComputeJacobian, initialGuess, NULL);

In the same file, but outside this class the functions ComputeResidual and ComputeJacobian must sit, using the input arguments specified above.

Concrete Simple Nonlinear PDE system solver.

Implements AbstractNonlinearSolver.

Definition at line 46 of file SimplePetscNonlinearSolver.cpp.

References CHASTE_PETSC_NULLPTR, PetscTools::Destroy(), EXCEPTION, PETSC_DESTROY_PARAM, and PetscTools::SetupMat().


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