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 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!
The text was updated successfully, but these errors were encountered:
I don't think you can currently mix the adaptations in sequence like that; an h coarsening must be preceded by an h refinement step. That's what that assertion is requiring.
I do not know if that check is there simply because it was the expected usage pattern at the time it was written (predating p adaptation), or if there is a more fundamental reason why the coarsening operations depend on that being the case.
Thank you for your answer, however inserting an h refinement before a subsequent derefinement still leads to the error iff there has been a p adaption before:
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)
print(derefined)
fespace.Update()
This code snippet also leads to the error. The error itself only occurs on the last line when updating the fespace, so the mesh has been derefined already. My current workaround is to create a new fespace, then derefine, then set the old element orders again, which is suboptimal and brings about many other issues. Would be glad if there was another way.
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.
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:
Do you have any insights on this?
Thank you in advance for your time and effort!
The text was updated successfully, but these errors were encountered: