From 925ff7cbce80ce3ec04b9b98fa8e90124e84460c Mon Sep 17 00:00:00 2001 From: Umberto Zerbinati Date: Tue, 21 Nov 2023 02:54:22 +0000 Subject: [PATCH] Added support for 3D adaptivity Signed-off-by: Umberto Zerbinati --- ngsPETSc/utils/firedrake.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/ngsPETSc/utils/firedrake.py b/ngsPETSc/utils/firedrake.py index 07e8d58..c4805a2 100644 --- a/ngsPETSc/utils/firedrake.py +++ b/ngsPETSc/utils/firedrake.py @@ -52,8 +52,28 @@ def refineMarkedElements(self, mark): self.netgen_mesh.Refine(adaptive=True) return fd.Mesh(self.netgen_mesh) return fd.Mesh(netgen.libngpy._meshing.Mesh(2)) + + elif self.geometric_dimension() == 3: + with mark.dat.vec as marked: + marked0 = marked + getIdx = self._cell_numbering.getOffset + if self.sfBCInv is not None: + getIdx = lambda x: x + _, marked0 = self.topology_dm.distributeField(self.sfBCInv, + self._cell_numbering, + marked) + if self.comm.Get_rank() == 0: + mark = marked0.getArray() + for i, el in enumerate(self.netgen_mesh.Elements3D()): + if mark[getIdx(i)]: + el.refine = True + else: + el.refine = False + self.netgen_mesh.Refine(adaptive=True) + return fd.Mesh(self.netgen_mesh) + return fd.Mesh(netgen.libngpy._meshing.Mesh(3)) else: - raise NotImplementedError("No implementation for dimension other than 2.") + raise NotImplementedError("No implementation for dimension other than 2 and 3.") def curveField(self, order): '''