You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am currently working on combining hp (de-)refinement, however, during testing I noticed that when modifying the element order, a subsequent fespace update for the 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()
# Start of p refinement
fespace.SetElementOrder(3, 1)
fespace.Update(False)
# End of p refinement
mesh.GeneralRefinement(mfem.intArray([0]), 1, 0) # h refine element 0
fespace.Update()
derefined = mesh.DerefineByError(mfem.Vector([0, 0, 0, 0, 1, 1, 1]), 0.5, 0, 1)
fespace.Update()
The code above uses PyMFEM, yet the issue stems from mfem. In this code, I create a simple mesh, h refine it once, then reset the element order of element 3 to 1 as a p refinement with no effect, h refine and then h derefine. When commenting out the p refinement part, the derefinement works as intended. Otherwise, I get the following error during the fespace.Update():
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? Is there a potential workaround for this?
Thank you in advance for your time and effort!
The text was updated successfully, but these errors were encountered:
Hello @tradeqvest, thanks for your interest in hp-(de)refinement. In the current state of the MFEM master branch, hp-refinement should work for H1 spaces in serial (the parallel extension is a work in progress, see PR 4038). As far as I know, derefinement is not supported with variable-order spaces, even in serial. I think it works for h-derefinement (constant order), but even that is not tested in any example, miniapp, or unit test.
The error you posted is a failed verification that the last mesh operation was an h-refinement. My guess is that the last operation was NONE, in the case of p-refinement. In other words, this error says that derefinement is not supported when the last mesh operation was not an h-refinement.
Supporting derefinement in variable-order spaces may require significant development effort in the MFEM library, so there is likely no workaround or easy solution. We should add this capability in MFEM in the future (no definite plans currently).
Hello,
I am currently working on combining hp (de-)refinement, however, during testing I noticed that when modifying the element order, a subsequent fespace update for the h derefinement was not possible anymore.
The code above uses PyMFEM, yet the issue stems from mfem. In this code, I create a simple mesh, h refine it once, then reset the element order of element 3 to 1 as a p refinement with no effect, h refine and then h derefine. When commenting out the p refinement part, the derefinement works as intended. Otherwise, I get the following error during the fespace.Update():
Do you have any insights on this? Is there a potential workaround for this?
Thank you in advance for your time and effort!
The text was updated successfully, but these errors were encountered: