From 0ecc5f4a52530de0ce260d38c4522a5fd0b56543 Mon Sep 17 00:00:00 2001 From: Henrik Finsberg Date: Fri, 1 Nov 2024 20:07:06 +0100 Subject: [PATCH] Early exit --- src/cardiac_geometries/geometry.py | 90 +++++++++++++++--------------- 1 file changed, 46 insertions(+), 44 deletions(-) diff --git a/src/cardiac_geometries/geometry.py b/src/cardiac_geometries/geometry.py index 44dfc41..07697a6 100644 --- a/src/cardiac_geometries/geometry.py +++ b/src/cardiac_geometries/geometry.py @@ -33,16 +33,16 @@ def save(self, path: str | Path) -> None: self.mesh.comm.barrier() adios4dolfinx.write_mesh(mesh=self.mesh, filename=path) - # if Version(np.__version__) <= Version("2.11") or Version(adios2.__version__) >= Version( - # "2.10.2" - # ): - # # This is broken in adios < 2.10.2 for numpy >= 2.11 - # adios4dolfinx.write_attributes( - # comm=self.mesh.comm, - # filename=path, - # name="markers", - # attributes={k: np.array(v, dtype=np.uint8) for k, v in self.markers.items()}, - # ) + if Version(np.__version__) <= Version("2.11") or Version(adios2.__version__) >= Version( + "2.10.2" + ): + # This is broken in adios < 2.10.2 for numpy >= 2.11 + adios4dolfinx.write_attributes( + comm=self.mesh.comm, + filename=path, + name="markers", + attributes={k: np.array(v, dtype=np.uint8) for k, v in self.markers.items()}, + ) if self.cfun is not None: adios4dolfinx.write_meshtags( @@ -58,41 +58,43 @@ def save(self, path: str | Path) -> None: filename=path, meshtag_name="Facet tags", ) - if self.efun is not None: - adios4dolfinx.write_meshtags( - meshtags=self.efun, - mesh=self.mesh, - filename=path, - meshtag_name="Edge tags", - ) - if self.vfun is not None: - adios4dolfinx.write_meshtags( - meshtags=self.vfun, - mesh=self.mesh, - filename=path, - meshtag_name="Vertex tags", - ) - - if self.f0 is not None: - el = self.f0.ufl_element() - arr = utils.element2array(el) - # if Version(np.__version__) <= Version("2.11") or Version(adios2.__version__) >= Version( - # "2.10.2" - # ): - # # This is broken in adios for numpy >= 2.11 - # adios4dolfinx.write_attributes( - # comm=self.mesh.comm, - # filename=path, - # name="function_space", - # attributes={k: arr for k in ("f0", "s0", "n0")}, - # ) - adios4dolfinx.write_function(u=self.f0, filename=path, name="f0") - if self.s0 is not None: - adios4dolfinx.write_function(u=self.s0, filename=path, name="s0") - if self.n0 is not None: - adios4dolfinx.write_function(u=self.n0, filename=path, name="n0") + # if self.efun is not None: + # adios4dolfinx.write_meshtags( + # meshtags=self.efun, + # mesh=self.mesh, + # filename=path, + # meshtag_name="Edge tags", + # ) + # if self.vfun is not None: + # adios4dolfinx.write_meshtags( + # meshtags=self.vfun, + # mesh=self.mesh, + # filename=path, + # meshtag_name="Vertex tags", + # ) - self.mesh.comm.barrier() + # exit() + # if self.f0 is not None: + # el = self.f0.ufl_element() + # arr = utils.element2array(el) + # if Version(np.__version__) <= Version("2.11") + # or Version(adios2.__version__) >= Version( + # "2.10.2" + # ): + # # This is broken in adios for numpy >= 2.11 + # adios4dolfinx.write_attributes( + # comm=self.mesh.comm, + # filename=path, + # name="function_space", + # attributes={k: arr for k in ("f0", "s0", "n0")}, + # ) + # adios4dolfinx.write_function(u=self.f0, filename=path, name="f0") + # if self.s0 is not None: + # adios4dolfinx.write_function(u=self.s0, filename=path, name="s0") + # if self.n0 is not None: + # adios4dolfinx.write_function(u=self.n0, filename=path, name="n0") + + # self.mesh.comm.barrier() @classmethod def from_file(cls, comm: MPI.Intracomm, path: str | Path) -> "Geometry":