[petsc-users] Custom matrix coloring for finite difference Jacobian

Barry Smith bsmith at petsc.dev
Thu Sep 25 18:28:31 CDT 2025


  Is this something you are still interested in having?

> On Sep 11, 2025, at 7:25 PM, Eirik Jaccheri Høydalsvik via petsc-users <petsc-users at mcs.anl.gov> wrote:
> 
> Hi,
> 
> I have made a two-phase flow code which computes motion of two phases in one dimension, where the phases are allowed to intermix. This code relies on a finite difference Jacobian computed using the standard coloring I get from the DMDA object:
> 
>    da = PETSc.DMDA().create(
>         dim=(N_vertical,),
>         dof=3,
>         stencil_width=1,
>     )
> 
> I now want to add a variable for the interphase height L_z in addition to a velocity u_v, giving the velocity of the vapor flowing in to the interface. The interface will move throughout the grid, meaning that these two variables will not be coupled to a fixed set of grid cells, but will be coupled to different sets of three grid cells throughout the simulation.
> 
> Questions:
> 
> 1. Is it possible to create a custom coloring to efficiently compute the finite difference Jacobian including the interphase height and vapor velocity?
> 
> 2. How do I revert to computing the full finite difference Jacobian with the purpose of testing if the interphase model works?
> 
> Best regards,
> Eirik Jaccheri Høydalsvik
> Sintef ER and NTNU EPT

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20250925/41a1ca4f/attachment.html>


More information about the petsc-users mailing list