cardiac-geometriesx 0.0.1__py3-none-any.whl → 0.0.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of cardiac-geometriesx might be problematic. Click here for more details.
- cardiac_geometries/mesh.py +5 -5
- cardiac_geometries/utils.py +37 -87
- {cardiac_geometriesx-0.0.1.dist-info → cardiac_geometriesx-0.0.3.dist-info}/METADATA +1 -3
- {cardiac_geometriesx-0.0.1.dist-info → cardiac_geometriesx-0.0.3.dist-info}/RECORD +7 -7
- {cardiac_geometriesx-0.0.1.dist-info → cardiac_geometriesx-0.0.3.dist-info}/WHEEL +0 -0
- {cardiac_geometriesx-0.0.1.dist-info → cardiac_geometriesx-0.0.3.dist-info}/entry_points.txt +0 -0
- {cardiac_geometriesx-0.0.1.dist-info → cardiac_geometriesx-0.0.3.dist-info}/top_level.txt +0 -0
cardiac_geometries/mesh.py
CHANGED
|
@@ -166,7 +166,7 @@ def biv_ellipsoid(
|
|
|
166
166
|
c_epi_rv=c_epi_rv,
|
|
167
167
|
)
|
|
168
168
|
comm.barrier()
|
|
169
|
-
geometry = utils.gmsh2dolfin(comm=comm, msh_file=mesh_name
|
|
169
|
+
geometry = utils.gmsh2dolfin(comm=comm, msh_file=mesh_name)
|
|
170
170
|
|
|
171
171
|
if comm.rank == 0:
|
|
172
172
|
with open(outdir / "markers.json", "w") as f:
|
|
@@ -367,7 +367,7 @@ def biv_ellipsoid_torso(
|
|
|
367
367
|
)
|
|
368
368
|
comm.barrier()
|
|
369
369
|
|
|
370
|
-
geometry = utils.gmsh2dolfin(comm=comm, msh_file=mesh_name
|
|
370
|
+
geometry = utils.gmsh2dolfin(comm=comm, msh_file=mesh_name)
|
|
371
371
|
|
|
372
372
|
if comm.rank == 0:
|
|
373
373
|
with open(outdir / "markers.json", "w") as f:
|
|
@@ -500,7 +500,7 @@ def lv_ellipsoid(
|
|
|
500
500
|
)
|
|
501
501
|
comm.barrier()
|
|
502
502
|
|
|
503
|
-
geometry = utils.gmsh2dolfin(comm=comm, msh_file=mesh_name
|
|
503
|
+
geometry = utils.gmsh2dolfin(comm=comm, msh_file=mesh_name)
|
|
504
504
|
|
|
505
505
|
# if aha:
|
|
506
506
|
# from .aha import lv_aha
|
|
@@ -618,7 +618,7 @@ def slab(
|
|
|
618
618
|
cgc.slab(mesh_name=mesh_name.as_posix(), lx=lx, ly=ly, lz=lz, dx=dx)
|
|
619
619
|
comm.barrier()
|
|
620
620
|
|
|
621
|
-
geometry = utils.gmsh2dolfin(comm=comm, msh_file=mesh_name
|
|
621
|
+
geometry = utils.gmsh2dolfin(comm=comm, msh_file=mesh_name)
|
|
622
622
|
|
|
623
623
|
if comm.rank == 0:
|
|
624
624
|
with open(outdir / "markers.json", "w") as f:
|
|
@@ -716,7 +716,7 @@ def slab_in_bath(
|
|
|
716
716
|
dx=dx,
|
|
717
717
|
)
|
|
718
718
|
|
|
719
|
-
geometry = utils.gmsh2dolfin(comm=comm, msh_file=mesh_name
|
|
719
|
+
geometry = utils.gmsh2dolfin(comm=comm, msh_file=mesh_name)
|
|
720
720
|
|
|
721
721
|
if comm.rank == 0:
|
|
722
722
|
with open(outdir / "markers.json", "w") as f:
|
cardiac_geometries/utils.py
CHANGED
|
@@ -8,7 +8,6 @@ from mpi4py import MPI
|
|
|
8
8
|
from structlog import get_logger
|
|
9
9
|
import basix
|
|
10
10
|
import dolfinx
|
|
11
|
-
import meshio
|
|
12
11
|
|
|
13
12
|
|
|
14
13
|
logger = get_logger()
|
|
@@ -68,106 +67,57 @@ class GMshGeometry(NamedTuple):
|
|
|
68
67
|
markers: dict[str, tuple[int, int]]
|
|
69
68
|
|
|
70
69
|
|
|
71
|
-
def create_mesh(mesh, cell_type):
|
|
72
|
-
# From http://jsdokken.com/converted_files/tutorial_pygmsh.html
|
|
73
|
-
cells = mesh.get_cells_type(cell_type)
|
|
74
|
-
if cells.size == 0:
|
|
75
|
-
return None
|
|
76
|
-
|
|
77
|
-
cells = mesh.get_cells_type(cell_type)
|
|
78
|
-
cell_data = mesh.get_cell_data("gmsh:physical", cell_type)
|
|
79
|
-
out_mesh = meshio.Mesh(
|
|
80
|
-
points=mesh.points,
|
|
81
|
-
cells={cell_type: cells},
|
|
82
|
-
cell_data={"name_to_read": [cell_data]},
|
|
83
|
-
)
|
|
84
|
-
return out_mesh
|
|
85
|
-
|
|
86
|
-
|
|
87
70
|
def read_ffun(mesh, filename: str | Path) -> dolfinx.mesh.MeshTags | None:
|
|
88
71
|
mesh.topology.create_connectivity(mesh.topology.dim - 1, mesh.topology.dim)
|
|
89
72
|
with dolfinx.io.XDMFFile(mesh.comm, filename, "r") as xdmf:
|
|
90
|
-
ffun = xdmf.read_meshtags(mesh, name="
|
|
91
|
-
|
|
73
|
+
ffun = xdmf.read_meshtags(mesh, name="Facet tags")
|
|
74
|
+
|
|
92
75
|
return ffun
|
|
93
76
|
|
|
94
77
|
|
|
95
78
|
def read_mesh(comm, filename: str | Path) -> tuple[dolfinx.mesh.Mesh, dolfinx.mesh.MeshTags | None]:
|
|
96
79
|
with dolfinx.io.XDMFFile(comm, filename, "r") as xdmf:
|
|
97
|
-
mesh = xdmf.read_mesh(name="
|
|
98
|
-
cfun = xdmf.read_meshtags(mesh, name="
|
|
80
|
+
mesh = xdmf.read_mesh(name="Mesh")
|
|
81
|
+
cfun = xdmf.read_meshtags(mesh, name="Cell tags")
|
|
99
82
|
return mesh, cfun
|
|
100
83
|
|
|
101
84
|
|
|
102
|
-
def gmsh2dolfin(comm: MPI.Intracomm, msh_file,
|
|
85
|
+
def gmsh2dolfin(comm: MPI.Intracomm, msh_file, rank: int = 0) -> GMshGeometry:
|
|
103
86
|
logger.debug(f"Convert file {msh_file} to dolfin")
|
|
104
87
|
outdir = Path(msh_file).parent
|
|
105
88
|
|
|
106
|
-
|
|
107
|
-
line_mesh_name = outdir / "line_mesh.xdmf"
|
|
108
|
-
triangle_mesh_name = outdir / "triangle_mesh.xdmf"
|
|
109
|
-
tetra_mesh_name = outdir / "mesh.xdmf"
|
|
110
|
-
|
|
111
|
-
if comm.rank == 0:
|
|
112
|
-
msh = meshio.gmsh.read(msh_file)
|
|
113
|
-
vertex_mesh = create_mesh(msh, "vertex")
|
|
114
|
-
line_mesh = create_mesh(msh, "line")
|
|
115
|
-
triangle_mesh = create_mesh(msh, "triangle")
|
|
116
|
-
tetra_mesh = create_mesh(msh, "tetra")
|
|
117
|
-
|
|
118
|
-
if vertex_mesh is not None:
|
|
119
|
-
meshio.write(vertex_mesh_name, vertex_mesh)
|
|
120
|
-
|
|
121
|
-
if line_mesh is not None:
|
|
122
|
-
meshio.write(line_mesh_name, line_mesh)
|
|
123
|
-
|
|
124
|
-
if triangle_mesh is not None:
|
|
125
|
-
meshio.write(triangle_mesh_name, triangle_mesh)
|
|
126
|
-
|
|
127
|
-
if tetra_mesh is not None:
|
|
128
|
-
meshio.write(
|
|
129
|
-
tetra_mesh_name,
|
|
130
|
-
tetra_mesh,
|
|
131
|
-
)
|
|
132
|
-
markers = msh.field_data
|
|
133
|
-
else:
|
|
134
|
-
markers = {}
|
|
135
|
-
# Broadcast markers
|
|
136
|
-
markers = comm.bcast(markers, root=0)
|
|
137
|
-
comm.barrier()
|
|
138
|
-
|
|
139
|
-
mesh, cfun = read_mesh(comm, tetra_mesh_name)
|
|
140
|
-
|
|
141
|
-
if triangle_mesh_name.is_file():
|
|
142
|
-
ffun = read_ffun(mesh, triangle_mesh_name)
|
|
143
|
-
else:
|
|
144
|
-
ffun = None
|
|
89
|
+
import gmsh
|
|
145
90
|
|
|
146
|
-
|
|
147
|
-
mesh.topology.create_connectivity(mesh.topology.dim - 2, mesh.topology.dim)
|
|
148
|
-
with dolfinx.io.XDMFFile(comm, line_mesh_name, "r") as xdmf:
|
|
149
|
-
efun = xdmf.read_meshtags(mesh, name="Grid")
|
|
150
|
-
else:
|
|
151
|
-
efun = None
|
|
91
|
+
# We could make this work in parallel in the future
|
|
152
92
|
|
|
153
|
-
if
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
93
|
+
if comm.rank == rank:
|
|
94
|
+
gmsh.initialize()
|
|
95
|
+
gmsh.model.add("Mesh from file")
|
|
96
|
+
gmsh.merge(str(msh_file))
|
|
97
|
+
mesh, ct, ft = dolfinx.io.gmshio.model_to_mesh(gmsh.model, comm, 0)
|
|
98
|
+
markers = {gmsh.model.getPhysicalName(*v): v for v in gmsh.model.getPhysicalGroups()}
|
|
99
|
+
gmsh.finalize()
|
|
157
100
|
else:
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
101
|
+
mesh, ct, ft = dolfinx.io.gmshio.model_to_mesh(gmsh.model, comm, 0)
|
|
102
|
+
markers = {}
|
|
103
|
+
mesh.name = "Mesh"
|
|
104
|
+
ct.name = "Cell tags"
|
|
105
|
+
ft.name = "Facet tags"
|
|
106
|
+
|
|
107
|
+
markers = comm.bcast(markers, root=rank)
|
|
108
|
+
|
|
109
|
+
# Save tags to xdmf
|
|
110
|
+
with dolfinx.io.XDMFFile(comm, outdir / "mesh.xdmf", "w") as xdmf:
|
|
111
|
+
xdmf.write_mesh(mesh)
|
|
112
|
+
mesh.topology.create_connectivity(2, 3)
|
|
113
|
+
xdmf.write_meshtags(
|
|
114
|
+
ct, mesh.geometry, geometry_xpath=f"/Xdmf/Domain/Grid[@Name='{mesh.name}']/Geometry"
|
|
115
|
+
)
|
|
116
|
+
xdmf.write_meshtags(
|
|
117
|
+
ft, mesh.geometry, geometry_xpath=f"/Xdmf/Domain/Grid[@Name='{mesh.name}']/Geometry"
|
|
118
|
+
)
|
|
119
|
+
|
|
120
|
+
vfun = None
|
|
121
|
+
efun = None
|
|
122
|
+
|
|
123
|
+
return GMshGeometry(mesh, ct, ft, efun, vfun, markers)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: cardiac-geometriesx
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.3
|
|
4
4
|
Summary: A python library for cardiac geometries
|
|
5
5
|
Author-email: Henrik Finsberg <henriknf@simula.no>
|
|
6
6
|
License: MIT
|
|
@@ -12,8 +12,6 @@ Classifier: Programming Language :: Python :: 3 :: Only
|
|
|
12
12
|
Requires-Python: >=3.8
|
|
13
13
|
Description-Content-Type: text/markdown
|
|
14
14
|
Requires-Dist: fenics-dolfinx >=0.8.0
|
|
15
|
-
Requires-Dist: meshio
|
|
16
|
-
Requires-Dist: h5py
|
|
17
15
|
Requires-Dist: structlog
|
|
18
16
|
Requires-Dist: cardiac-geometries-core
|
|
19
17
|
Requires-Dist: rich-click
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
cardiac_geometries/__init__.py,sha256=-I-0nXbVFRgfZ-mbXeC-OMg2jh7WnTch6_DkBbAGnGg,202
|
|
2
2
|
cardiac_geometries/cli.py,sha256=nOI56WV1fXstL3vxhux90qPnmZ69y1r-PGDYgFMgNeA,19324
|
|
3
3
|
cardiac_geometries/geometry.py,sha256=MYF9diZl9igayAuptSyOsHf7-3zJHFd8UgfWtXJgrHk,4849
|
|
4
|
-
cardiac_geometries/mesh.py,sha256=
|
|
5
|
-
cardiac_geometries/utils.py,sha256=
|
|
4
|
+
cardiac_geometries/mesh.py,sha256=tAB9A6J-C4do-pvwShr20s8iQzUm4YfYmXqzGRmYW8Q,25180
|
|
5
|
+
cardiac_geometries/utils.py,sha256=BXEpU6qYylE3y7rabBvTXGhNZYbiT177UjJ8assiuXE,3693
|
|
6
6
|
cardiac_geometries/fibers/__init__.py,sha256=p6d-3uql8pFailBcLPPGLfRDQs38wefnarS3aSQV0FE,151
|
|
7
7
|
cardiac_geometries/fibers/lv_ellipsoid.py,sha256=DWDUV0sGrsZH9O-EtN3veSkE96U6XuHko3WUW9Ce_uc,3695
|
|
8
8
|
cardiac_geometries/fibers/slab.py,sha256=sY9VXv-J1D2wSPTcB_6opRmGMLqUXb5ix7C3gJlSJOU,3867
|
|
9
9
|
cardiac_geometries/fibers/utils.py,sha256=iozqorgu2KcxbzR52b2Not2IyJ-DrPyqn2Ds-QX2QLE,2584
|
|
10
|
-
cardiac_geometriesx-0.0.
|
|
11
|
-
cardiac_geometriesx-0.0.
|
|
12
|
-
cardiac_geometriesx-0.0.
|
|
13
|
-
cardiac_geometriesx-0.0.
|
|
14
|
-
cardiac_geometriesx-0.0.
|
|
10
|
+
cardiac_geometriesx-0.0.3.dist-info/METADATA,sha256=5PZwkcOwkoz-4euqoXoRhUsEcS2UlgIagPk2sJRu8Zw,1395
|
|
11
|
+
cardiac_geometriesx-0.0.3.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
12
|
+
cardiac_geometriesx-0.0.3.dist-info/entry_points.txt,sha256=xOBnlc6W-H9oCDYLNz3kpki26OmpfYSoFSrmi_4V-Ec,52
|
|
13
|
+
cardiac_geometriesx-0.0.3.dist-info/top_level.txt,sha256=J0gQxkWR2my5Vf7Qt8buDY8ZOjYdVfIweVunCGXWKNE,19
|
|
14
|
+
cardiac_geometriesx-0.0.3.dist-info/RECORD,,
|
|
File without changes
|
{cardiac_geometriesx-0.0.1.dist-info → cardiac_geometriesx-0.0.3.dist-info}/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|