PETSc solver options in PRJ file ignored – falls back to gmres with bjacobi

Hello everyone,

I am running a simulation with OpenGeoSys-6 (built from source, latest master) using a custom UCG (underground coal gasification) process. I have partitioned my mesh into 4 subdomains and run with MPI (mpiexec -n 4). In my PRJ file, I defined a linear solver with PETSc options to use LU with MUMPS, as follows:

<nonlinear_solvers>
    <nonlinear_solver>
        <name>basic_newton</name>
        <type>Newton</type>
        <max_iter>10</max_iter>
        <recompute_jacobian>1</recompute_jacobian>
        <damping>0.7</damping>
        <linear_solver>general_linear_solver</linear_solver>
    </nonlinear_solver>
</nonlinear_solvers>

<linear_solvers>
    <linear_solver>
        <name>general_linear_solver</name>
        <petsc>
            <prefix>ucg_</prefix>
            <parameters>
                -ucg_mat_type aij
                -ucg_pc_type lu
                -ucg_pc_factor_mat_solver_type mumps
                -ucg_ksp_rtol 1e-12
                -ucg_ksp_atol 1e-12
            </parameters>
        </petsc>
    </linear_solver>
</linear_solvers>

I start the simulation with:

mpiexec -n 4 ~/projects/ogs-build/bin/ogs PJ_D.prj -m partitioned_final -o mpi_test_n4_debug

However, the log shows that the linear solver used is gmres with bjacobi preconditioner, and I also get warnings about unused options. Here are some relevant lines from the log:

Linear solver gmres with (null) preconditioner using PRECONDITIONED
...
Linear solver gmres with bjacobi preconditioner using PRECONDITIONED
...
WARNING! There are options you set that were not used!
Option left: name:-ucg_ksp_rtol value: 1e-12 source: code
Option left: name:-ucg_pc_type value: lu source: code
...

It appears that the PETSc options with the ucg_ prefix are completely ignored, and the solver falls back to default settings.

What I have tried:

  1. I removed the <prefix>ucg_</prefix> tag and changed the parameters to global PETSc options (e.g., -ksp_type preonly, -pc_type lu, etc.). After that, the linear solver did use LU with MUMPS (as confirmed by “Linear solver preonly with lu preconditioner using NONE”), but the nonlinear solver then diverged (Newton iterations blew up, time step kept reducing until failure). That is a separate issue, and I am still debugging.

  2. I also tried adding -ksp_initial_guess_nonzero false to the global options, but the nonlinear divergence persisted.

  3. Crucially, I tested the exact same PRJ file (with the ucg_ prefix in either original linear solver parameters or global options) in single-core (non-MPI) mode by simply running ogs PJ_D.prj -o (without mpiexec and without using partitioned mesh). In that case, the linear solver options were correctly recognized, and the simulation proceeded successfully without any PETSc errors. This suggests that the issue is specific to MPI + partitioned mesh runs.

My main question: Why are the options with the ucg_ prefix not recognized in MPI runs, while they work fine in serial? Is there a known problem with PETSc option handling in parallel OGS? Do I need to set a different prefix (e.g., ls_ or something else) when using MPI? Could it be that OGS creates the KSP object with a different prefix when running in parallel, or that the prefix is overridden by the partitioning process?

I would appreciate any advice on how to correctly specify PETSc solver options in the PRJ file for MPI runs so that they are actually applied. Additionally, if you have suggestions for handling the nonlinear divergence (after the linear solver is fixed), that would be a bonus, but my primary concern is the proper configuration of the linear solver in parallel.

System info:

  • OGS version: NO_VERSION (built from source, likely 6.x)

  • PETSc version: 3.24.0 (configured with MUMPS, METIS, ParMETIS)

  • OS: Ubuntu 22.04 (WSL2)

  • Compiler: GCC 11

Thank you in advance for your help!

Best regards,

Wu

Hello Wugao,

in the benchmark file Tests/Data/EllipticPETSc/cube_1e3.prj(in the source dir of OGS) the prefix is without the underscore at the end, i.e., ucg instead of ucg_.

The string within <parameters> tag is given to PETSc as it is.

However, OGS adds an underscore to the end of the prefix before it is given to PETSc. In your case ucg__ is finally passed to PETSc. I think this is the reason for the PETSc default behaviour.

Best regards,

Tom

Hi Thomas,

Thanks for your reply.

I have changed the prefix of “ucg_” to “ucg” as follows:

<linear_solvers>
<linear_solver>
<name>general_linear_solver</name>
<petsc>
<prefix>ucg</prefix>
<parameters>
-ucg_mat_type aij
-ucg_pc_type lu
-ucg_pc_factor_mat_solver_type mumps
-ucg_ksp_rtol 1e-12
-ucg_ksp_atol 1e-12
</parameters>
</petsc>
</linear_solver>
</linear_solvers>

But the log this time shows:

Linear solver gmres with lu preconditioner using PRECONDITIONED

I have attached the full log.

mpi_test_n4_debug.docx (67.7 KB)

Best regards,

Wu

Hi Wu,

could you please send the full log as a pure text file?

Best regards,

Tom

Hi Tom,

It seems that a .txt file is not allowed to upload. Please see the screenshot below.

image

Best regards,

Wu

Hi Tom,

The full log is uploaded as a zip file. Thank you.

mpi_test_n4_debug.zip (64.6 KB)

Best regards,

Wu

Hi Wu,

now it is possible to attach txt files (and also doc, docx and pdf) directly. Please note that you txt file you attached as zip file is a not a txt file (maybe a docx file?). Please reupload a proper txt file again.

Thanks,
Lars

Hi Lars and Tom,

Sorry for the mistake. I really appreciate your reply.

To show more information, I have modified the linear solver configuration as follows:

    <linear_solvers>

        <linear_solver>

            <name>general_linear_solver</name>                  

            <petsc>

                <prefix>ucg</prefix>

                <parameters>

                   -ucg_mat_type aij

                   -ucg_ksp_type gmres

                   -ucg_pc_type lu

                   -ucg_pc_factor_mat_solver_type mumps

                   -ucg_ksp_rtol 1e-8

                   -ucg_ksp_atol 1e-12

                   -ucg_ksp_monitor

                   -ucg_ksp_converged_reason

                </parameters>

            </petsc>

        </linear_solver>

    </linear_solvers>

The corresponding full log of 4-core computation as zip file is as follows (strangely, it’s still not allowed to upload the .txt file from my side):

mpi_test_n4_petsc.zip (20.4 KB)

In addition, the partial log of single-core computation, which runs successfully using the above linear solver configuration, is provided below:

serial_petsc.zip (2.8 KB)

Look forward to hearing from you, and thank you!

Best

Wu

The serial PETSc (1 MPI process) run and the PETSc using 4 MPI processes have both the same linear solver settings:

Linear solver gmres with lu preconditioner using PRECONDITIONED

But this are not the values you specified in the prj-file. OGS passes the PETSc options given in the <parameter> tag to PETSc library using function PetscOptionsInsertString. In the linked document it is stated:

in_str - string that contains options separated by blanks

Your string contains line breaks. I’m not sure if a line break is also a blank. Please format your option string without line break and try it again.

This is correct and exactly what you wanted.
The default solver is gmres. Solvers in petsc are always iterative solvers. With lu preconditioning it does 1 iteration. The LU preconditioning is done with the mumps solver. This is how it works in petsc, direct solvers are preconditioners. (This is also how you specified it.) You could also make the output more verbose to obtain more information.