Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
StefanoFochesatto opened this issue Jan 31, 2025 · 0 comments
Labels

Comments

@StefanoFochesatto
Copy link

StefanoFochesatto commented Jan 31, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant