cardiac-geometriesx 0.4.0__tar.gz → 0.4.2__tar.gz

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.

Files changed (24) hide show
  1. {cardiac_geometriesx-0.4.0/src/cardiac_geometriesx.egg-info → cardiac_geometriesx-0.4.2}/PKG-INFO +2 -1
  2. {cardiac_geometriesx-0.4.0 → cardiac_geometriesx-0.4.2}/pyproject.toml +3 -2
  3. {cardiac_geometriesx-0.4.0 → cardiac_geometriesx-0.4.2}/src/cardiac_geometries/fibers/lv_ellipsoid.py +21 -9
  4. {cardiac_geometriesx-0.4.0 → cardiac_geometriesx-0.4.2}/src/cardiac_geometries/fibers/slab.py +4 -1
  5. {cardiac_geometriesx-0.4.0 → cardiac_geometriesx-0.4.2}/src/cardiac_geometries/fibers/utils.py +7 -4
  6. {cardiac_geometriesx-0.4.0 → cardiac_geometriesx-0.4.2}/src/cardiac_geometries/utils.py +9 -4
  7. {cardiac_geometriesx-0.4.0 → cardiac_geometriesx-0.4.2/src/cardiac_geometriesx.egg-info}/PKG-INFO +2 -1
  8. {cardiac_geometriesx-0.4.0 → cardiac_geometriesx-0.4.2}/src/cardiac_geometriesx.egg-info/requires.txt +1 -0
  9. {cardiac_geometriesx-0.4.0 → cardiac_geometriesx-0.4.2}/tests/test_cli.py +1 -1
  10. {cardiac_geometriesx-0.4.0 → cardiac_geometriesx-0.4.2}/LICENSE +0 -0
  11. {cardiac_geometriesx-0.4.0 → cardiac_geometriesx-0.4.2}/README.md +0 -0
  12. {cardiac_geometriesx-0.4.0 → cardiac_geometriesx-0.4.2}/setup.cfg +0 -0
  13. {cardiac_geometriesx-0.4.0 → cardiac_geometriesx-0.4.2}/src/cardiac_geometries/__init__.py +0 -0
  14. {cardiac_geometriesx-0.4.0 → cardiac_geometriesx-0.4.2}/src/cardiac_geometries/cli.py +0 -0
  15. {cardiac_geometriesx-0.4.0 → cardiac_geometriesx-0.4.2}/src/cardiac_geometries/fibers/__init__.py +0 -0
  16. {cardiac_geometriesx-0.4.0 → cardiac_geometriesx-0.4.2}/src/cardiac_geometries/geometry.py +0 -0
  17. {cardiac_geometriesx-0.4.0 → cardiac_geometriesx-0.4.2}/src/cardiac_geometries/gui.py +0 -0
  18. {cardiac_geometriesx-0.4.0 → cardiac_geometriesx-0.4.2}/src/cardiac_geometries/mesh.py +0 -0
  19. {cardiac_geometriesx-0.4.0 → cardiac_geometriesx-0.4.2}/src/cardiac_geometriesx.egg-info/SOURCES.txt +0 -0
  20. {cardiac_geometriesx-0.4.0 → cardiac_geometriesx-0.4.2}/src/cardiac_geometriesx.egg-info/dependency_links.txt +0 -0
  21. {cardiac_geometriesx-0.4.0 → cardiac_geometriesx-0.4.2}/src/cardiac_geometriesx.egg-info/entry_points.txt +0 -0
  22. {cardiac_geometriesx-0.4.0 → cardiac_geometriesx-0.4.2}/src/cardiac_geometriesx.egg-info/not-zip-safe +0 -0
  23. {cardiac_geometriesx-0.4.0 → cardiac_geometriesx-0.4.2}/src/cardiac_geometriesx.egg-info/top_level.txt +0 -0
  24. {cardiac_geometriesx-0.4.0 → cardiac_geometriesx-0.4.2}/tests/test_save_load.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cardiac-geometriesx
3
- Version: 0.4.0
3
+ Version: 0.4.2
4
4
  Summary: A python library for cardiac geometries
5
5
  Author-email: Henrik Finsberg <henriknf@simula.no>
6
6
  License: MIT
@@ -17,6 +17,7 @@ Requires-Dist: structlog
17
17
  Requires-Dist: cardiac-geometries-core
18
18
  Requires-Dist: rich-click
19
19
  Requires-Dist: adios4dolfinx
20
+ Requires-Dist: scifem
20
21
  Provides-Extra: dev
21
22
  Requires-Dist: bump-my-version; extra == "dev"
22
23
  Requires-Dist: ipython; extra == "dev"
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "cardiac-geometriesx"
7
- version = "0.4.0"
7
+ version = "0.4.2"
8
8
  description = "A python library for cardiac geometries"
9
9
  authors = [{name = "Henrik Finsberg", email = "henriknf@simula.no"}]
10
10
  license = {text = "MIT"}
@@ -22,6 +22,7 @@ dependencies = [
22
22
  "cardiac-geometries-core",
23
23
  "rich-click",
24
24
  "adios4dolfinx",
25
+ "scifem",
25
26
  ]
26
27
 
27
28
  [project.readme]
@@ -173,7 +174,7 @@ tag = true
173
174
  sign_tags = false
174
175
  tag_name = "v{new_version}"
175
176
  tag_message = "Bump version: {current_version} → {new_version}"
176
- current_version = "0.4.0"
177
+ current_version = "0.4.2"
177
178
 
178
179
 
179
180
  [[tool.bumpversion.files]]
@@ -8,7 +8,12 @@ from . import utils
8
8
 
9
9
 
10
10
  def mu_theta(
11
- x: np.ndarray, y: np.ndarray, z: np.ndarray, long_axis: int = 0
11
+ x: np.ndarray,
12
+ y: np.ndarray,
13
+ z: np.ndarray,
14
+ rs: np.ndarray,
15
+ rl: np.ndarray,
16
+ long_axis: int = 0,
12
17
  ) -> tuple[np.ndarray, np.ndarray, list[int]]:
13
18
  """Get the angles mu and theta from the coordinates x, y, z
14
19
  given the long axis.
@@ -21,6 +26,10 @@ def mu_theta(
21
26
  The y-coordinates
22
27
  z : np.ndarray
23
28
  The z-coordinates
29
+ rs : np.ndarray
30
+ The short radius
31
+ rl : np.ndarray
32
+ The long radius
24
33
  long_axis : int, optional
25
34
  The long axis, by default 0 (x-axis)
26
35
 
@@ -35,18 +44,18 @@ def mu_theta(
35
44
  If the long axis is not 0, 1 or 2
36
45
  """
37
46
  if long_axis == 0:
38
- a = np.sqrt(y**2 + z**2)
39
- b = x
47
+ a = np.sqrt(y**2 + z**2) / rs
48
+ b = x / rl
40
49
  theta = np.pi - np.arctan2(z, -y)
41
50
  perm = [0, 1, 2]
42
51
  elif long_axis == 1:
43
- a = np.sqrt(x**2 + z**2)
44
- b = y
52
+ a = np.sqrt(x**2 + z**2) / rs
53
+ b = y / rl
45
54
  theta = np.pi - np.arctan2(z, -x)
46
55
  perm = [1, 0, 2]
47
56
  elif long_axis == 2:
48
- a = np.sqrt(x**2 + y**2)
49
- b = z
57
+ a = np.sqrt(x**2 + y**2) / rs
58
+ b = z / rl
50
59
  theta = np.pi - np.arctan2(x, -y)
51
60
  perm = [2, 1, 0]
52
61
  else:
@@ -120,7 +129,7 @@ def compute_system(
120
129
  y = dof_coordinates[:, 1]
121
130
  z = dof_coordinates[:, 2]
122
131
 
123
- mu, theta, perm = mu_theta(x, y, z, long_axis=long_axis)
132
+ mu, theta, perm = mu_theta(x, y, z, rs, rl, long_axis=long_axis)
124
133
 
125
134
  e_t = np.array(
126
135
  [
@@ -159,7 +168,10 @@ def compute_system(
159
168
  s0 = utils.normalize(s0)
160
169
 
161
170
  Vv = space_from_string(
162
- space_string=f"{element.family_name}_{element.degree}", mesh=mesh, dim=mesh.geometry.dim
171
+ space_string=f"{element.family_name}_{element.degree}",
172
+ mesh=mesh,
173
+ dim=mesh.geometry.dim,
174
+ discontinuous=element.discontinuous,
163
175
  )
164
176
 
165
177
  fiber = dolfinx.fem.Function(Vv)
@@ -60,7 +60,10 @@ def compute_system(
60
60
  n0 = utils.normalize(n0)
61
61
 
62
62
  Vv = space_from_string(
63
- space_string=f"{element.family_name}_{element.degree}", mesh=mesh, dim=mesh.geometry.dim
63
+ space_string=f"{element.family_name}_{element.degree}",
64
+ mesh=mesh,
65
+ dim=mesh.geometry.dim,
66
+ discontinuous=element.discontinuous,
64
67
  )
65
68
 
66
69
  fiber = dolfinx.fem.Function(Vv)
@@ -20,21 +20,24 @@ class Microstructure(NamedTuple):
20
20
  def save_microstructure(
21
21
  mesh: dolfinx.mesh.Mesh, functions: Sequence[dolfinx.fem.Function], outdir: str | Path
22
22
  ) -> None:
23
- from ..utils import create_xdmf_pointcloud, element2array
23
+ from ..utils import element2array
24
24
 
25
25
  if len(functions) == 0:
26
26
  return
27
27
  # Save for paraview visualization
28
+
28
29
  if functions[0].function_space.ufl_element().family_name == "quadrature":
29
- create_xdmf_pointcloud(us=functions, filename=Path(outdir) / "microstructure-viz.xdmf")
30
+ from scifem.xdmf import create_pointcloud
31
+
32
+ create_pointcloud(functions=functions, filename=Path(outdir) / "microstructure-viz.xdmf")
30
33
  else:
31
34
  try:
32
35
  with dolfinx.io.VTXWriter(
33
36
  mesh.comm, Path(outdir) / "microstructure-viz.bp", functions, engine="BP4"
34
37
  ) as file:
35
38
  file.write(0.0)
36
- except RuntimeError:
37
- pass
39
+ except RuntimeError as ex:
40
+ print(f"Failed to write microstructure: {ex}")
38
41
 
39
42
  # Save with proper function space
40
43
  filename = Path(outdir) / "microstructure.bp"
@@ -270,7 +270,9 @@ def model_to_mesh(
270
270
  return GMshModel(mesh, ct, ft, et, vt)
271
271
 
272
272
 
273
- def parse_element(space_string: str, mesh: dolfinx.mesh.Mesh, dim: int) -> basix.ufl._ElementBase:
273
+ def parse_element(
274
+ space_string: str, mesh: dolfinx.mesh.Mesh, dim: int, discontinuous: bool = False
275
+ ) -> basix.ufl._ElementBase:
274
276
  """
275
277
  Parse a string representation of a basix element family
276
278
  """
@@ -283,8 +285,9 @@ def parse_element(space_string: str, mesh: dolfinx.mesh.Mesh, dim: int) -> basix
283
285
  else:
284
286
  kwargs["shape"] = (dim,)
285
287
 
288
+ # breakpoint()
286
289
  if family_str in ["Lagrange", "P", "CG"]:
287
- el = basix.ufl.element(family=basix.ElementFamily.P, discontinuous=False, **kwargs)
290
+ el = basix.ufl.element(family=basix.ElementFamily.P, discontinuous=discontinuous, **kwargs)
288
291
  elif family_str in ["Discontinuous Lagrange", "DG", "dP"]:
289
292
  el = basix.ufl.element(family=basix.ElementFamily.P, discontinuous=True, **kwargs)
290
293
 
@@ -298,7 +301,7 @@ def parse_element(space_string: str, mesh: dolfinx.mesh.Mesh, dim: int) -> basix
298
301
 
299
302
 
300
303
  def space_from_string(
301
- space_string: str, mesh: dolfinx.mesh.Mesh, dim: int
304
+ space_string: str, mesh: dolfinx.mesh.Mesh, dim: int, discontinuous: bool = False
302
305
  ) -> dolfinx.fem.functionspace:
303
306
  """
304
307
  Constructed a finite elements space from a string
@@ -313,8 +316,10 @@ def space_from_string(
313
316
  The mesh
314
317
  dim : int
315
318
  1 for scalar space, 3 for vector space.
319
+ discontinuous: bool
320
+ If true force element to be discontinuous, by default False
316
321
  """
317
- el = parse_element(space_string, mesh, dim)
322
+ el = parse_element(space_string, mesh, dim, discontinuous=discontinuous)
318
323
  return dolfinx.fem.functionspace(mesh, el)
319
324
 
320
325
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cardiac-geometriesx
3
- Version: 0.4.0
3
+ Version: 0.4.2
4
4
  Summary: A python library for cardiac geometries
5
5
  Author-email: Henrik Finsberg <henriknf@simula.no>
6
6
  License: MIT
@@ -17,6 +17,7 @@ Requires-Dist: structlog
17
17
  Requires-Dist: cardiac-geometries-core
18
18
  Requires-Dist: rich-click
19
19
  Requires-Dist: adios4dolfinx
20
+ Requires-Dist: scifem
20
21
  Provides-Extra: dev
21
22
  Requires-Dist: bump-my-version; extra == "dev"
22
23
  Requires-Dist: ipython; extra == "dev"
@@ -3,6 +3,7 @@ structlog
3
3
  cardiac-geometries-core
4
4
  rich-click
5
5
  adios4dolfinx
6
+ scifem
6
7
 
7
8
  [dev]
8
9
  bump-my-version
@@ -16,7 +16,7 @@ from cardiac_geometries import Geometry, cli
16
16
  ],
17
17
  ids=["slab", "lv_ellipsoid"],
18
18
  )
19
- @pytest.mark.parametrize("fiber_space", [None, "P_1", "P_2", "Quadrature_2"])
19
+ @pytest.mark.parametrize("fiber_space", [None, "P_1", "P_2", "Quadrature_2", "DG_1"])
20
20
  def test_script(fiber_space, script, tmp_path: Path):
21
21
  runner = CliRunner()
22
22