[petsc-users] Using PETSc Data Types with Existing F90 Functions

Smith, Barry F. bsmith at mcs.anl.gov
Fri Jan 4 18:59:32 CST 2019


   VecGetArrayF90()? Then a loop over the entries?

> On Jan 4, 2019, at 3:23 PM, Kevin Mattalo via petsc-users <petsc-users at mcs.anl.gov> wrote:
> 
> Hello,
> 
> I am currently implementing an implicit discretization of a high-order
> DG method that uses a pseudo-transient continuation globalization
> procedure combined with an inexact Newton method. I am using GMRES for
> the linear solves with a preconditioner constructed from the exact
> analytic Jacobian.
> 
> In order to verify my Jacobian (mostly the linearization of the flux
> functions since I have already verified the linearization of the local
> volume terms) I was trying to implement the finite difference
> approximation (SNESComputeJacobianDefault()). However, since all of my
> functions for calculating the residual use intrinsic F90 arrays for
> the MPI and the actual computations, I was wondering if there is a way
> to extract the values from the PETSc data types (Vec, Mat etc.) and to
> input the extracted values into the F90 arrays to use in my F90
> functions. The reason I need to do this is because I am assuming the
> ComputeJacobianDefault() function perturbs the argument x (the current
> point) which is a Vec datatype. Therefore, in order to find the
> residual using my existing functions (which don't use PETSc data
> types) I have to copy the values in x into my existing F90 arrays in
> order to use my existing functions. I tried simply equating the
> vectors but I believe that only copied the address and not the actual
> values within the vector.
> 
> Thanks,
> 
> Kevin



More information about the petsc-users mailing list