tao-2.1-p0 2012-07-24


Sets the function to compute the Jacobian (and its inverse) of the constraint function with respect to the state variables. Used only for pde-constrained optimization.


#include "taosolver.h" 
PetscErrorCode TaoSetJacobianStateRoutine(TaoSolver tao, Mat J, Mat Jpre, Mat Jinv, PetscErrorCode (*func)(TaoSolver, Vec, Mat*, Mat *, Mat *, MatStructure *, void*), void *ctx)
Logically collective on TaoSolver

Input Parameters

tao - the TaoSolver context
J - Matrix used for the jacobian
Jpre - Matrix that will be used operated on by PETSc preconditioner, can be same as J. Only used if Jinv is PETSC_NULL
Jinv - [optional] Matrix used to apply the inverse of the state jacobian. Use PETSC_NULL to default to PETSc KSP solvers to apply the inverse.
jac - Jacobian evaluation routine
ctx - [optional] user-defined context for private data for the Jacobian evaluation routine (may be PETSC_NULL)

Calling sequence of jac

   jac (TaoSolver tao,Vec x,Mat *J,Mat *Jpre,MatStructure *flag,void *ctx);

tao - the TaoSolver context
x - input vector
J - Jacobian matrix
Jpre - preconditioner matrix, usually the same as J
Jinv - inverse of J
flag - flag indicating information about the preconditioner matrix structure (see below)
ctx - [optional] user-defined Jacobian context


Because of the structure of the jacobian matrix, It may be more efficient for a pde-constrained application to provide its own Jinv matrix.

The function jac() takes Mat * as the matrix arguments rather than Mat. This allows the Jacobian evaluation routine to replace A and/or B with a completely new new maitrix structure (not just different matrix elements) when appropriate, for instance, if the nonzero structure is changing throughout the global iterations.

The flag can be used to eliminate unnecessary work in the preconditioner during the repeated solution of linear systems of the same size. The available options are

     Jpre is identical during successive linear solves.
     This option is intended for folks who are using
     different Amat and Pmat matrices and want to reuse the
     same preconditioner matrix.  For example, this option
     saves work by not recomputing incomplete factorization
     for ILU/ICC preconditioners.
     Jpre has the same nonzero structure during
     successive linear solves. 
     Jpre does not have the same nonzero structure.


If you specify SAME_NONZERO_PATTERN, the software believes your assertion and does not check the structure of the matrix. If you erroneously claim that the structure is the same when it actually is not, the new preconditioner will not function correctly. Thus, use this optimization feature carefully!

If in doubt about whether your preconditioner matrix has changed structure or not, use the flag DIFFERENT_NONZERO_PATTERN.

See Also

: TaoComputeJacobianState(), TaoSetJacobianDesignRoutine(), TaoSetStateDesignIS()

TAO Solver Index
Table of Contents