[petsc-users] Nested FieldSplit Implementation for FE using Fortran

Barry Smith bsmith at petsc.dev
Sun Sep 21 15:28:35 CDT 2025


   The example you indicate that allows nesting field splits on the command line

-pc_fieldsplit_0_fields 0,1 -pc_fieldsplit_1_fields 2

works because the "fields" can be indicated by an offset that defines each field in the vector, where the fields are stored interlaced in the array.  For example doing

-fieldsplit_0_pc_type fieldsplit
-fieldsplit_0_pc_fieldsplit_block_size 2
-fieldsplit_0_pc_fieldsplit_0_fields 0
-fieldsplit_0_pc_fieldsplit_1_fields 1

will split the original first split into its own fieldsplit

See src/ksp/ksp/tutorials/ex42-mgschur_nestedfs.opts for such an example. You can ignore the -stokes_mg_levels_prefix, it appears because we are doing the nesting field split on each level of multigrid.

If the fields have a more complicated structure in the array used by the vector, for example, if some variables are cell-centered and some are vertex-centered, you cannot indicate a field by a single offset. Thus indicating the preconditioner purely from the options database is more difficult (or not possible?)

But if the inner fieldsplit involves fields that are stored in the simple interlaced pattern (even if the outer fields are not) you can do the same trick as above to define the inner split from the command line.

For the most general case where the outer splits are defined by two general IS and the inner splits of one (or both) of the outer splits are also defined by two general IS you actually have to write some code :-). Basically you tell the PC the outer split IS and then pull out of the PC the sub-PC for that split and provide it with its IS. See src/dm/impls/stag/tests/ex43.c which does exactly that. 

Feel free to contact us with questions etc.

Barry






> On Sep 15, 2025, at 10:45 AM, Lucia Barandiaran via petsc-users <petsc-users at mcs.anl.gov> wrote:
> 
> Dear PETSc community,
> 
> Our research group is employing the PETSc libraries within a Fortran-based finite element (FE) code to solve large-scale, coupled multi-physics problems. The systems of interest typically involve more than two primary fields, specifically displacements (U), water pressure (W), gas pressure (G), and temperature (T).
> 
> We have recently integrated the FieldSplit preconditioner into our solver pipeline and have achieved successful results on a 3D gas injection reservoir simulation model comprising approximately 130,000 nodes. The indices for each field variable were defined using ISCreateGeneral, and the splits were established via PCFieldSplitSetIS (one split per variable). The following command-line options were utilized effectively for this case:
> 
> -ksp_type gmres -ksp_gmres_modifiedgramschmidt \
> -pc_type fieldsplit -pc_fieldsplit_type schur \
> -pc_fieldsplit_schur_fact_type lower \
> -pc_fieldsplit_schur_precondition selfp \
> -fieldsplit_U_ksp_type preonly \
> -fieldsplit_U_pc_type hypre \
> -fieldsplit_U_pc_hypre_type boomeramg \
> -fieldsplit_U_pc_hypre_boomeramg_coarsen_type PMIS \
> -fieldsplit_U_pc_hypre_boomeramg_strong_threshold 0.6 \
> -fieldsplit_U_pc_hypre_boomeramg_max_levels 25  
> -fieldsplit_G_ksp_type preonly \
> -fieldsplit_G_pc_type hypre \
> -fieldsplit_G_pc_hypre_type boomeramg \
> -fieldsplit_G_pc_hypre_boomeramg_coarsen_type PMIS \
> -fieldsplit_G_pc_hypre_boomeramg_strong_threshold 0.6 \
> -fieldsplit_G_pc_hypre_boomeramg_max_levels 25   
> 
> Subsequently, we have also configured a case with three primary fields by combining W and G into a single monolithic P (pressure) variable, which was solved using a similar approach.
> 
> We are now interested in advancing our preconditioning strategy by implementing a nested (or recursive) Schur complement decomposition. Our objective is to define a hierarchical structure where, for instance, an outer Schur complement is first constructed, and then the primary split itself is solved using an inner Schur complement preconditioner.
> 
> We have encountered an example of this nested configuration in presentation slides for the PETSc example ex31 (e.g., from [1]), which outlines a command-line structure similar to:
> 
> -ksp_type fgmres -pc_type fieldsplit -pc_fieldsplit_type schur
> -pc_fieldsplit_0_fields 0,1 -pc_fieldsplit_1_fields 2
> -pc_fieldsplit_schur_factorization_type upper
> -fieldsplit_0_ksp_type fgmres -fieldsplit_0_pc_type fieldsplit
> -fieldsplit_0_pc_fieldsplit_type schur
> -fieldsplit_0_pc_fieldsplit_schur_factorization_type full
> -fieldsplit_0_fieldsplit_velocity_ksp_type preonly
> -fieldsplit_0_fieldsplit_velocity_pc_type lu
> -fieldsplit_0_fieldsplit_pressure_ksp_rtol 1e-10
> -fieldsplit_0_fieldsplit_pressure_pc_type jacobi
> -fieldsplit_temperature_ksp_type gmres
> -fieldsplit_temperature_pc_type lsc
> 
> We are currently seeking guidance on how to implement this nested FieldSplit functionality within our Fortran code. We were wondering if the source code for this specific ex31 example is publicly available, or if you could direct us to any other Fortran examples that demonstrate the implementation of a recursive Schur complement preconditioner.
> 
> Any advice, references, or code examples you could provide would be immensely valuable to our research.
> 
> Thank you very much for your time and assistance.
> 
> Sincerely,
> 
> Lucía Barandiarán
> 
> Scientific software developer  - Dracsys 
> 
> Collaborator at MECMAT group - Universitat Politècnica de Catalunya (UPC)
> 
> Reference:
> [1] Knepley, M. G. (2016). Advanced PETSc Preconditioning. Presentation. Retrieved from https://urldefense.us/v3/__https://cse.buffalo.edu/*knepley/presentations/PresMIT2016.pdf__;fg!!G_uCfscf7eWS!dXD6kmWC3csMp5SCWAsN98pB8hX8nC9aOzIImmwoHNypDcfaoyjWZ1zVSnNWMB-lmgFmxtNb3o1pN4MK6dogoko$  <https://urldefense.us/v3/__https://cse.buffalo.edu/*knepley/presentations/PresMIT2016.pdf__;fg!!G_uCfscf7eWS!cyBB84JdoI3gXz-X7IFeVHTUEuq5x6-N36gHKdnu1acRmIh47LSfDP3AqW10CDEpIUW2fWhiL5g7nsUDzIMbTGkWotRffgz__g$>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20250921/07f75d63/attachment.html>


More information about the petsc-users mailing list