Dear, Barry and Jed,

Thanks for your replies.

We understand your doubts, so let me to put our question into context. In CFD it is standard practice to solve non-linear equations of conservation for steady flows by means of a inexact Newton method. The original Jacobian matrix is modified by adding terms on the diagonal which are proportional to the Courant number and to the lumped mass matrix. This allows us to obtain two things, "relax" the solution update and increase the diagonal dominance of the matrix itself.

The latter is key when simple preconditioners are adopted, in our case point Jacobi or SOR. Indeed, if the original matrix was to be used, the GMRES method would converge only on very regular meshes and only when adopting ILU preconditioners with a very high level of fill-in. As result a higher number of non-linear iterations is traded with a simpler linear system to be solved.

While exploring the SNES+MF capabilities we found out that we could successfully solve the linear system only with ILU(200) or so. Of course we do not want to touch the function used to evaluate the residual, which determines the final solution. However we think that a suitable modification of the function that Petsc differences to compute the matrix vector product would allow us to obtain a behavior similar to the inexact Newton method.

Best regards,
Dario


On 01/03/2014 12:32 PM, Song Gao wrote:


---------- Forwarded message ----------
From: *Jed Brown* <[email protected] <mailto:[email protected]>>
Date: Thu, Jan 2, 2014 at 10:20 AM
Subject: Re: [petsc-users] SNESSetFunction and MatMFFDSetFunction
To: Song Gao <[email protected] <mailto:[email protected]>>, Barry Smith <[email protected] <mailto:[email protected]>>
Cc: petsc-users <[email protected] <mailto:[email protected]>>


Song Gao <[email protected] <mailto:[email protected]>> writes:

> Thanks, Barry.
>
> I mean 2) providing a function that I want PETSc to difference to evaluate
> the matrix vector product.
>
> I want to make a slight modification of the matrix after PETSc evaluate the
> matrix vector product.

Performing a matrix-vector product is not supposed to modify the matrix.
It's unlikely that you really want this.


On Wed, Jan 1, 2014 at 3:01 PM, Barry Smith <[email protected] <mailto:[email protected]>> wrote:


    On Jan 1, 2014, at 11:09 AM, Song Gao <[email protected]
    <mailto:[email protected]>> wrote:

    > Dear all,
    >
    > Happy new year!
    >
    > I'm using the matrix-free method to solve NS equations. I call
    the SNESSetFunction to set the RHS function. I think SNES also
    uses that RHS function to evaluate the matrix vector product.

       Yes, PETSc differences this function to evaluate the matrix
    vector product.

    >
    > But I want to set one function to evaluate the residual, and
    another different function to evaluate the matrix vector product.

       Are you providing a function that

        1) actually evaluates the matrix vector product or are you

        2) providing a function that you want PETSc to difference to
    evaluate the matrix vector product?

    > How can I do that? Does MatMFFDSetFunction do this job?

        For 2) yes, but if the function you provide is different than
    the function provided with SNESSetFunction then the matrix-vector
    product obtained from differencing it will not be “correct”
    Jacobian for the SNESSetFunction() you are providing so I don’t
    see why you would do it.

       For 1) you should use MatCreateShell() and
    MatShellSetOperation(mat,MATOP_MULT, ….) and then pass that matrix
    to SNESSetJacobian(), then PETSc will use that “matrix” to do its
    matrix-vector products.

       Barry



    >
    > Any suggestion is appreciated. Thank you.
    >
    >
    > Song



Reply via email to