Skip to content

Commit

Permalink
Early exit
Browse files Browse the repository at this point in the history
  • Loading branch information
finsberg committed Nov 1, 2024
1 parent 2c137a9 commit 0ecc5f4
Showing 1 changed file with 46 additions and 44 deletions.
90 changes: 46 additions & 44 deletions src/cardiac_geometries/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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":
Expand Down

0 comments on commit 0ecc5f4

Please sign in to comment.