Skip to content

h derefinement fails after p adaption #215

@tradeqvest

Description

@tradeqvest

Hello,

I am currently working on combining hp (de-)refinement, however, during testing I noticed that when modifying the element order, a subsequent h derefinement was not possible anymore.

import mfem.ser as mfem
def init_mesh_and_fespace():
    # create simple mesh consisting of 1 triangle
    mesh = mfem.Mesh(2, 3, 1, 0, 2)
    mesh.AddVertex(mfem.Vector([0.0, 0.0]))
    mesh.AddVertex(mfem.Vector([1.0, 0.0]))
    mesh.AddVertex(mfem.Vector([0.0, 1.0]))
    mesh.AddTriangle([0, 1, 2], 1)
    mesh.FinalizeTriMesh(1, 1, True)

    # create finite element space
    fec = mfem.H1_FECollection(1, 2)
    fespace = mfem.FiniteElementSpace(mesh, fec)

    return mesh, fespace


mesh, fespace = init_mesh_and_fespace()

mesh.GeneralRefinement(mfem.intArray([0]), 1, 0) # h refine element 0
fespace.Update()
mesh.GeneralRefinement(mfem.intArray([0]), 1, 0)  # h refine element 0
fespace.Update()
# Start of p refinement
fespace.SetElementOrder(3, 1)
fespace.Update(False)
# End of p refinement
derefined = mesh.DerefineByError(mfem.Vector([0, 0, 0, 0, 1, 1, 1]), 0.5, 0, 1)
fespace.Update()

In this code, I create a simple mesh, h refine it twice, then reset the element order of element 3 to 1 as a p refinement with no effect and h derefine. When commenting out the p refinement part, the derefinement works as intended. Otherwise, I get the following error:

RuntimeError: PyMFEM error (mfem::ErrorException): Verification failed: (GetLastOperation() == Mesh::REFINE) is false:
 --> 
 ... in function: const CoarseFineTransformations &mfem::Mesh::GetRefinementTransforms()

Do you have any insights on this?

Thank you in advance for your time and effort!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions