#include <AbstractNonlinearAssembler.hpp>
Public Member Functions | |
PetscErrorCode | AssembleResidual (const Vec currentGuess, Vec residualVector) |
PetscErrorCode | AssembleJacobian (const Vec currentGuess, Mat *pGlobalJacobian) |
AbstractNonlinearAssembler (unsigned numQuadPoints=2) | |
void | SetUseAnalyticalJacobian (bool useAnalyticalJacobian) |
virtual Vec | Solve (Vec initialGuess, bool useAnalyticalJacobian=false) |
void | SetNonlinearSolver (AbstractNonlinearSolver *pNonlinearSolver) |
Vec | CreateConstantInitialGuess (double value) |
bool | VerifyJacobian (double tol=1e-4, bool print=false) |
Protected Member Functions | |
void | ApplyDirichletConditions (Vec currentGuess, bool applyToMatrix) |
PetscErrorCode | AssembleJacobianNumerically (const Vec currentGuess, Mat *pJacobian) |
virtual void | AssembleSystem (bool assembleVector, bool assembleMatrix, Vec currentGuess=NULL, double currentTime=0.0) |
bool | ProblemIsNonlinear () |
void | InitialiseForSolve (Vec initialGuess) |
Vec | StaticSolve (Vec currentSolutionOrGuess=NULL, double currentTime=0.0, bool assembleMatrix=true) |
Protected Attributes | |
AbstractNonlinearSolver * | mpSolver |
bool | mWeAllocatedSolverMemory |
bool | mUseAnalyticalJacobian |
Private Types | |
typedef AbstractStaticAssembler < ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM, true, CONCRETE > | BaseClassType |
Private Attributes | |
Vec | mInitialGuess |
Definition at line 81 of file AbstractNonlinearAssembler.hpp.
AbstractNonlinearAssembler< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM, CONCRETE >::AbstractNonlinearAssembler | ( | unsigned | numQuadPoints = 2 |
) | [inline] |
Constructors just call the base class versions.
Definition at line 319 of file AbstractNonlinearAssembler.hpp.
void AbstractNonlinearAssembler< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM, CONCRETE >::ApplyDirichletConditions | ( | Vec | currentGuess, | |
bool | applyToMatrix | |||
) | [inline, protected, virtual] |
Apply Dirichlet boundary conditions to either the residual or jacobian.
Implements AbstractAssembler< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM >.
Definition at line 95 of file AbstractNonlinearAssembler.hpp.
PetscErrorCode AbstractNonlinearAssembler< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM, CONCRETE >::AssembleResidual | ( | const Vec | currentGuess, | |
Vec | residualVector | |||
) | [inline] |
Compute the residual vector given the current solution guess.
currentGuess | The solution guess for the current iteration. | |
residualVector | We fill this with the residual vector. |
Definition at line 122 of file AbstractNonlinearAssembler.hpp.
PetscErrorCode AbstractNonlinearAssembler< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM, CONCRETE >::AssembleJacobian | ( | const Vec | currentGuess, | |
Mat * | pGlobalJacobian | |||
) | [inline] |
Compute the Jacobian matrix given a current guess at the solution. Choose whether to use a numerical or analytical method based on a flag provided by the user (in Solve()).
currentGuess | The solution guess for the current iteration. | |
pGlobalJacobian | Pointer to object to fill with the jacobian matrix. |
Definition at line 146 of file AbstractNonlinearAssembler.hpp.
Referenced by AbstractNonlinearAssembler< ELEMENT_DIM, SPACE_DIM, 1, SimpleNonlinearEllipticAssembler< ELEMENT_DIM, SPACE_DIM > >::VerifyJacobian().
PetscErrorCode AbstractNonlinearAssembler< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM, CONCRETE >::AssembleJacobianNumerically | ( | const Vec | currentGuess, | |
Mat * | pJacobian | |||
) | [inline, protected] |
Computes the Jacobian numerically i.e. an approximation, using numerical partial derivatives.
currentGuess | Independent variable, u in f(u), for example | |
pJacobian | A pointer to the Jacobian matrix |
Definition at line 173 of file AbstractNonlinearAssembler.hpp.
Referenced by AbstractNonlinearAssembler< ELEMENT_DIM, SPACE_DIM, 1, SimpleNonlinearEllipticAssembler< ELEMENT_DIM, SPACE_DIM > >::AssembleJacobian().
virtual void AbstractNonlinearAssembler< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM, CONCRETE >::AssembleSystem | ( | bool | assembleVector, | |
bool | assembleMatrix, | |||
Vec | currentSolutionOrGuess = NULL , |
|||
double | currentTime = 0.0 | |||
) | [inline, protected, virtual] |
AssembleSystem - the major method for all assemblers
Assemble the linear system for a linear PDE, or the residual or Jacobian for nonlinear PDEs. Loops over each element (and each each surface element if there are non-zero Neumann boundary conditions), calls AssembleOnElement() and adds the contribution to the linear system.
Takes in current solution and time if necessary but only used if the problem is a dynamic one. This method uses PROBLEM_DIM and can assemble linear systems for any number of unknown variables.
Called by Solve() Calls AssembleOnElement()
assembleVector | Whether to assemble the RHS vector of the linear system (i.e. the residual vector for nonlinear problems). | |
assembleMatrix | Whether to assemble the LHS matrix of the linear system (i.e. the jacobian matrix for nonlinear problems). | |
currentSolutionOrGuess | The current solution in a linear dynamic problem, or the current guess in a nonlinear problem. Should be NULL for linear static problems. | |
currentTime | The current time for dynamic problems. Not used in static problems. |
Reimplemented from AbstractStaticAssembler< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM, true, CONCRETE >.
Definition at line 258 of file AbstractNonlinearAssembler.hpp.
Referenced by AbstractNonlinearAssembler< ELEMENT_DIM, SPACE_DIM, 1, SimpleNonlinearEllipticAssembler< ELEMENT_DIM, SPACE_DIM > >::AssembleJacobian(), and AbstractNonlinearAssembler< ELEMENT_DIM, SPACE_DIM, 1, SimpleNonlinearEllipticAssembler< ELEMENT_DIM, SPACE_DIM > >::AssembleResidual().
bool AbstractNonlinearAssembler< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM, CONCRETE >::ProblemIsNonlinear | ( | ) | [inline, protected, virtual] |
Whether grad_u should be calculated
Implements AbstractAssembler< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM >.
Definition at line 266 of file AbstractNonlinearAssembler.hpp.
void AbstractNonlinearAssembler< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM, CONCRETE >::InitialiseForSolve | ( | Vec | initialGuess | ) | [inline, protected, virtual] |
No separate initialisation is needed in the nonlinear case; PrepareForSolve does everything. We just check the size of the initial guess.
Implements AbstractAssembler< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM >.
Definition at line 275 of file AbstractNonlinearAssembler.hpp.
Referenced by AbstractNonlinearAssembler< ELEMENT_DIM, SPACE_DIM, 1, SimpleNonlinearEllipticAssembler< ELEMENT_DIM, SPACE_DIM > >::Solve().
Vec AbstractNonlinearAssembler< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM, CONCRETE >::StaticSolve | ( | Vec | currentSolutionOrGuess = NULL , |
|
double | currentTime = 0.0 , |
|||
bool | assembleMatrix = true | |||
) | [inline, protected, virtual] |
Perform the work of a single solve, but without any initialisation.
currentSolutionOrGuess | either the current solution (dynamic problem) or initial guess (static problem). MUST be provided. | |
currentTime | for a dynamic problem, the current time |
Implements AbstractAssembler< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM >.
Definition at line 298 of file AbstractNonlinearAssembler.hpp.
Referenced by AbstractNonlinearAssembler< ELEMENT_DIM, SPACE_DIM, 1, SimpleNonlinearEllipticAssembler< ELEMENT_DIM, SPACE_DIM > >::Solve().
void AbstractNonlinearAssembler< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM, CONCRETE >::SetUseAnalyticalJacobian | ( | bool | useAnalyticalJacobian | ) | [inline] |
Set whether to use an analytical jacobian. This is provided for use when solving dynamic nonlinear problems; when solving static problems there is an argument to the Solve method which specifies this property, and overrides any user call to this method.
If this method is not called the default is false i.e. numerical jacobian.
Definition at line 346 of file AbstractNonlinearAssembler.hpp.
Referenced by AbstractNonlinearAssembler< ELEMENT_DIM, SPACE_DIM, 1, SimpleNonlinearEllipticAssembler< ELEMENT_DIM, SPACE_DIM > >::Solve().
virtual Vec AbstractNonlinearAssembler< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM, CONCRETE >::Solve | ( | Vec | initialGuess, | |
bool | useAnalyticalJacobian = false | |||
) | [inline, virtual] |
Assemble and solve the system for a nonlinear elliptic PDE.
initialGuess | An initial guess for the iterative solver | |
useAnalyticalJacobian | Set to true to use an analytically calculated jacobian matrix rather than a numerically approximated one. |
Definition at line 359 of file AbstractNonlinearAssembler.hpp.
void AbstractNonlinearAssembler< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM, CONCRETE >::SetNonlinearSolver | ( | AbstractNonlinearSolver * | pNonlinearSolver | ) | [inline] |
SetNonlinearSolver - by default a SimplePetscNonlinearSolver is created and used in this class, this method can be called to use a different AbstractNonlinearSolver
Definition at line 375 of file AbstractNonlinearAssembler.hpp.
Vec AbstractNonlinearAssembler< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM, CONCRETE >::CreateConstantInitialGuess | ( | double | value | ) | [inline] |
A helpful method for creating an initial guess vector
Definition at line 388 of file AbstractNonlinearAssembler.hpp.
bool AbstractNonlinearAssembler< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM, CONCRETE >::VerifyJacobian | ( | double | tol = 1e-4 , |
|
bool | print = false | |||
) | [inline] |
VerifyJacobian
A helper method for use when writing concrete assemblers. Once the user has calculated (on paper) the weak form and the form of the ComputeMatrixTerm method, they can check whether the analytic Jacobian matches the numerical Jacobian (which only calls ComputeVectorTerm and ComputeVectorSurfaceTerm) to verify the correctness of the code.
tol | A tolerance which defaults to 1e-5 | |
Whether to print the different matrix J_numerical-J_analytical |
Definition at line 411 of file AbstractNonlinearAssembler.hpp.