Skip to content

BUG: Creating a mesh from a previous mesh's dmplex in parallel will diverge solve #4004

Open
@StefanoFochesatto

Description

@StefanoFochesatto

Describe the bug
For some context (because the example below looks pretty ridiculous without it), I've been trying to bring the SBR, mark and refine functionality from PETSc into firedrake (basically .refine_marked_elements() without --netgen). I ran into this issue where, in parallel, when a mesh is initialized from a dmplex object belonging to another firedrake mesh, calling solve() on the new mesh will diverge.

Steps to Reproduce
Run the following MFE in parallel

from firedrake import *

mesh = UnitSquareMesh(20, 20)

for i in range(2):

    V = FunctionSpace(mesh, "CG", 1)

    x, y = SpatialCoordinate(mesh)
    gbdry = Function(V).interpolate(Constant(0))

    # boundary ids
    bdry_ids = (1, 2, 3, 4)
    bcs = DirichletBC(V, gbdry, bdry_ids)

    # Define Weak Form
    f = Function(V).interpolate(Constant(1))
    u = TrialFunction(V)
    v = TestFunction(V)
    a = (inner(grad(u), grad(v))) * dx
    L = f*v*dx
    uu = Function(V)

    solve(a == L, uu, bcs=bcs, solver_parameters={"ksp_type": "preonly",
                                                "pc_type": "lu"})

    dm = mesh.topology_dm

    #----------------------fix-----------------------------------
    # dm.removeLabel("pyop2_core")
    # dm.removeLabel("pyop2_owned")
    # dm.removeLabel("pyop2_ghost")
    # ^ Koki Sagiyama suggested and it works
    # ----------------------fix-----------------------------------

    mesh = Mesh(dm)

Error message
On the second solve I get


^^^long traceback pointing to the solve command

  File "/home/stefano/FiredrakeAdapt/firedrake-dec24/src/firedrake/firedrake/solving_utils.py", line 124, in check_snes_convergence
    raise ConvergenceError(r"""Nonlinear solve failed to converge after %d nonlinear iterations.
    raise ConvergenceError(r"""Nonlinear solve failed to converge after %d nonlinear iterations.
firedrake.exceptions.ConvergenceError: Nonlinear solve failed to converge after 0 nonlinear iterations.
Reason:
   DIVERGED_LINEAR_SOLVE
firedrake.exceptions.ConvergenceError: Nonlinear solve failed to converge after 0 nonlinear iterations.
Reason:
   DIVERGED_LINEAR_SOLVE
application called MPI_Abort(PYOP2_COMM_WORLD, 1) - process 0
    raise ConvergenceError(r"""Nonlinear solve failed to converge after %d nonlinear iterations.
    raise ConvergenceError(r"""Nonlinear solve failed to converge after %d nonlinear iterations.
firedrake.exceptions.ConvergenceError: Nonlinear solve failed to converge after 0 nonlinear iterations.
Reason:
   DIVERGED_LINEAR_SOLVEapplication called MPI_Abort(PYOP2_COMM_WORLD, 1) - process 3
firedrake.exceptions.ConvergenceError: Nonlinear solve failed to converge after 0 nonlinear iterations.
Reason:
   DIVERGED_LINEAR_SOLVE
application called MPI_Abort(PYOP2_COMM_WORLD, 1) - process 1

application called MPI_Abort(PYOP2_COMM_WORLD, 1) - process 2

fixes
Koki's suggested fix from slack seemed to work and can be commented back into the MFE so that it succeeds.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions