From 711e3b37febedfe66e812d43a30f286f5893a278 Mon Sep 17 00:00:00 2001 From: Mohamed Ali Date: Sat, 4 Jan 2025 17:27:19 +0100 Subject: [PATCH 1/4] Preserve default mesh name after Netgen mesh creation to avoid checkpointing errors --- firedrake/mesh.py | 1 + 1 file changed, 1 insertion(+) diff --git a/firedrake/mesh.py b/firedrake/mesh.py index 7c99b47972..594a89adac 100644 --- a/firedrake/mesh.py +++ b/firedrake/mesh.py @@ -3094,6 +3094,7 @@ def Mesh(meshfile, **kwargs): if netgen and isinstance(meshfile, netgen.libngpy._meshing.Mesh): netgen_firedrake_mesh.createFromTopology(topology, name=plex.getName(), comm=user_comm) mesh = netgen_firedrake_mesh.firedrakeMesh + mesh.name = name mesh._tolerance = tolerance return mesh From da7e2bf776d680a69a5b6ab88157e1e19b8e63e9 Mon Sep 17 00:00:00 2001 From: Mohamed Ali Date: Wed, 15 Jan 2025 13:28:32 +0100 Subject: [PATCH 2/4] Update: Preserve default mesh name for Netgen meshes during initialization --- firedrake/mesh.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/firedrake/mesh.py b/firedrake/mesh.py index 594a89adac..d35b0ef92f 100644 --- a/firedrake/mesh.py +++ b/firedrake/mesh.py @@ -3064,6 +3064,7 @@ def Mesh(meshfile, **kwargs): netgen_flags = kwargs.get("netgen_flags", {"quad": False, "transform": None, "purify_to_tets": False}) netgen_firedrake_mesh = FiredrakeMesh(meshfile, netgen_flags, user_comm) plex = netgen_firedrake_mesh.meshMap.petscPlex + plex.setName(name) else: basename, ext = os.path.splitext(meshfile) if ext.lower() in ['.e', '.exo']: @@ -3090,11 +3091,11 @@ def Mesh(meshfile, **kwargs): distribution_name=kwargs.get("distribution_name"), permutation_name=kwargs.get("permutation_name"), comm=user_comm) - mesh = make_mesh_from_mesh_topology(topology, name) if netgen and isinstance(meshfile, netgen.libngpy._meshing.Mesh): - netgen_firedrake_mesh.createFromTopology(topology, name=plex.getName(), comm=user_comm) + netgen_firedrake_mesh.createFromTopology(topology, name=name, comm=user_comm) mesh = netgen_firedrake_mesh.firedrakeMesh - mesh.name = name + else: + mesh = make_mesh_from_mesh_topology(topology, name) mesh._tolerance = tolerance return mesh From 80a0f804b54f84d2f247ca7d390bd41c00137980 Mon Sep 17 00:00:00 2001 From: Mohamed Ali Date: Wed, 15 Jan 2025 13:56:39 +0100 Subject: [PATCH 3/4] Get the Name using plex.getName --- firedrake/mesh.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/firedrake/mesh.py b/firedrake/mesh.py index d35b0ef92f..07a9a73b4e 100644 --- a/firedrake/mesh.py +++ b/firedrake/mesh.py @@ -3092,7 +3092,7 @@ def Mesh(meshfile, **kwargs): permutation_name=kwargs.get("permutation_name"), comm=user_comm) if netgen and isinstance(meshfile, netgen.libngpy._meshing.Mesh): - netgen_firedrake_mesh.createFromTopology(topology, name=name, comm=user_comm) + netgen_firedrake_mesh.createFromTopology(topology, name=plex.getName(), comm=user_comm) mesh = netgen_firedrake_mesh.firedrakeMesh else: mesh = make_mesh_from_mesh_topology(topology, name) From 132eb70639f4073aecc816f074f0abd69abdf49c Mon Sep 17 00:00:00 2001 From: Mohamed Ali Date: Wed, 15 Jan 2025 15:05:53 +0100 Subject: [PATCH 4/4] Ensure consistent handling of mesh and topology names for Netgen and non-Netgen meshes --- firedrake/mesh.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/firedrake/mesh.py b/firedrake/mesh.py index 07a9a73b4e..3cf2a4ea2e 100644 --- a/firedrake/mesh.py +++ b/firedrake/mesh.py @@ -3064,7 +3064,7 @@ def Mesh(meshfile, **kwargs): netgen_flags = kwargs.get("netgen_flags", {"quad": False, "transform": None, "purify_to_tets": False}) netgen_firedrake_mesh = FiredrakeMesh(meshfile, netgen_flags, user_comm) plex = netgen_firedrake_mesh.meshMap.petscPlex - plex.setName(name) + plex.setName(_generate_default_mesh_topology_name(name)) else: basename, ext = os.path.splitext(meshfile) if ext.lower() in ['.e', '.exo']: @@ -3092,7 +3092,7 @@ def Mesh(meshfile, **kwargs): permutation_name=kwargs.get("permutation_name"), comm=user_comm) if netgen and isinstance(meshfile, netgen.libngpy._meshing.Mesh): - netgen_firedrake_mesh.createFromTopology(topology, name=plex.getName(), comm=user_comm) + netgen_firedrake_mesh.createFromTopology(topology, name=name, comm=user_comm) mesh = netgen_firedrake_mesh.firedrakeMesh else: mesh = make_mesh_from_mesh_topology(topology, name)