cardiac-geometriesx 0.4.1__py3-none-any.whl → 0.4.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.

@@ -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
  [
@@ -25,6 +25,7 @@ def save_microstructure(
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
30
  from scifem.xdmf import create_pointcloud
30
31
 
@@ -35,8 +36,8 @@ def save_microstructure(
35
36
  mesh.comm, Path(outdir) / "microstructure-viz.bp", functions, engine="BP4"
36
37
  ) as file:
37
38
  file.write(0.0)
38
- except RuntimeError:
39
- pass
39
+ except RuntimeError as ex:
40
+ print(f"Failed to write microstructure: {ex}")
40
41
 
41
42
  # Save with proper function space
42
43
  filename = Path(outdir) / "microstructure.bp"
@@ -5,9 +5,11 @@ from pathlib import Path
5
5
 
6
6
  from mpi4py import MPI
7
7
 
8
+ import adios2
8
9
  import adios4dolfinx
9
10
  import dolfinx
10
11
  import numpy as np
12
+ from packaging.version import Version
11
13
 
12
14
  from . import utils
13
15
 
@@ -31,12 +33,16 @@ class Geometry:
31
33
  self.mesh.comm.barrier()
32
34
  adios4dolfinx.write_mesh(mesh=self.mesh, filename=path)
33
35
 
34
- adios4dolfinx.write_attributes(
35
- comm=self.mesh.comm,
36
- filename=path,
37
- name="markers",
38
- attributes={k: np.array(v, dtype=np.uint8) for k, v in self.markers.items()},
39
- )
36
+ if Version(np.__version__) <= Version("2.11") or Version(adios2.__version__) >= Version(
37
+ "2.10.2"
38
+ ):
39
+ # This is broken in adios < 2.10.2 and numpy >= 2.11
40
+ adios4dolfinx.write_attributes(
41
+ comm=self.mesh.comm,
42
+ filename=path,
43
+ name="markers",
44
+ attributes={k: np.array(v, dtype=np.uint8) for k, v in self.markers.items()},
45
+ )
40
46
 
41
47
  if self.cfun is not None:
42
48
  adios4dolfinx.write_meshtags(
@@ -52,31 +58,34 @@ class Geometry:
52
58
  filename=path,
53
59
  meshtag_name="Facet tags",
54
60
  )
55
- if self.efun is not None:
56
- adios4dolfinx.write_meshtags(
57
- meshtags=self.efun,
58
- mesh=self.mesh,
59
- filename=path,
60
- meshtag_name="Edge tags",
61
- )
62
- if self.vfun is not None:
63
- adios4dolfinx.write_meshtags(
64
- meshtags=self.vfun,
65
- mesh=self.mesh,
66
- filename=path,
67
- meshtag_name="Vertex tags",
68
- )
61
+ # if self.efun is not None:
62
+ # adios4dolfinx.write_meshtags(
63
+ # meshtags=self.efun,
64
+ # mesh=self.mesh,
65
+ # filename=path,
66
+ # meshtag_name="Edge tags",
67
+ # )
68
+ # if self.vfun is not None:
69
+ # adios4dolfinx.write_meshtags(
70
+ # meshtags=self.vfun,
71
+ # mesh=self.mesh,
72
+ # filename=path,
73
+ # meshtag_name="Vertex tags",
74
+ # )
69
75
 
70
76
  if self.f0 is not None:
71
77
  el = self.f0.ufl_element()
72
78
  arr = utils.element2array(el)
73
-
74
- adios4dolfinx.write_attributes(
75
- comm=self.mesh.comm,
76
- filename=path,
77
- name="function_space",
78
- attributes={k: arr for k in ("f0", "s0", "n0")},
79
- )
79
+ if Version(np.__version__) <= Version("2.11") or Version(adios2.__version__) >= Version(
80
+ "2.10.2"
81
+ ):
82
+ # This is broken in adios for numpy >= 2.11
83
+ adios4dolfinx.write_attributes(
84
+ comm=self.mesh.comm,
85
+ filename=path,
86
+ name="function_space",
87
+ attributes={k: arr for k in ("f0", "s0", "n0")},
88
+ )
80
89
  adios4dolfinx.write_function(u=self.f0, filename=path, name="f0")
81
90
  if self.s0 is not None:
82
91
  adios4dolfinx.write_function(u=self.s0, filename=path, name="s0")
@@ -682,7 +682,6 @@ def slab(
682
682
  )
683
683
 
684
684
  geo = Geometry.from_folder(comm=comm, folder=outdir)
685
-
686
685
  return geo
687
686
 
688
687
 
@@ -10,6 +10,7 @@ from mpi4py import MPI
10
10
  import basix
11
11
  import dolfinx
12
12
  import numpy as np
13
+ from packaging.version import Version
13
14
  from structlog import get_logger
14
15
 
15
16
  logger = get_logger()
@@ -32,7 +33,7 @@ def distribute_entity_data(
32
33
  marked_entities: np.ndarray,
33
34
  entity_values: np.ndarray,
34
35
  ) -> tuple[np.ndarray, np.ndarray]:
35
- if dolfinx.__version__ >= "0.9.0":
36
+ if Version(dolfinx.__version__) >= Version("0.9.0"):
36
37
  local_entities, local_values = dolfinx.io.utils.distribute_entity_data(
37
38
  mesh, tdim, marked_entities, entity_values
38
39
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cardiac-geometriesx
3
- Version: 0.4.1
3
+ Version: 0.4.3
4
4
  Summary: A python library for cardiac geometries
5
5
  Author-email: Henrik Finsberg <henriknf@simula.no>
6
6
  License: MIT
@@ -0,0 +1,16 @@
1
+ cardiac_geometries/__init__.py,sha256=2W_ywAeLjyRk5MqSPAodHa4UN2lOnW1h8tmGLQ3gaJ0,150
2
+ cardiac_geometries/cli.py,sha256=GKcsMNhVFoxWDr-o3jiDCXmTvPgCSEB9Kws8AvYIK4Q,19678
3
+ cardiac_geometries/geometry.py,sha256=JSsLKfXej4DSgzRbivC-_jvyjiY6zkXcRCRL93IIys8,6504
4
+ cardiac_geometries/gui.py,sha256=9WYR850wLrqsUrVUC37E2SaO0OWA_oagSe-YNrsxz3k,8376
5
+ cardiac_geometries/mesh.py,sha256=_vNNMpQWyLEZ3TmsHAUh0l3Z2TYuQBy6Os-6nB9_Z9A,26908
6
+ cardiac_geometries/utils.py,sha256=hR-uV9lzmfM_kQkqHY9MmJ_b3-Lv5oTsNOKCb-0nn_U,20616
7
+ cardiac_geometries/fibers/__init__.py,sha256=WpRrn9Iakl-3m8IGtFkqP0LXGjw5EZHZ8Eg9JCnCdrg,137
8
+ cardiac_geometries/fibers/lv_ellipsoid.py,sha256=LZNhxzTsn-h88xXGP5bNfnWKhdvBROUjWjt8yrQFW48,6010
9
+ cardiac_geometries/fibers/slab.py,sha256=TYQhckJ8mwXz_08Cx3QsPQMtemkaxZ955SnSMrDfBPE,3898
10
+ cardiac_geometries/fibers/utils.py,sha256=bEz2MMSRhzYhiRSFahdqQRsOWzCCauERKU2V6tdgSkQ,3239
11
+ cardiac_geometriesx-0.4.3.dist-info/LICENSE,sha256=lo5K2rJPZOSv6luutGHbzzi3IpXNaB9E2UWq60qvNx0,1111
12
+ cardiac_geometriesx-0.4.3.dist-info/METADATA,sha256=mpSvjuPehah4Z-XxkLrZkcq7U-HUxg66uPFpAFD2BTM,4185
13
+ cardiac_geometriesx-0.4.3.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
14
+ cardiac_geometriesx-0.4.3.dist-info/entry_points.txt,sha256=xOBnlc6W-H9oCDYLNz3kpki26OmpfYSoFSrmi_4V-Ec,52
15
+ cardiac_geometriesx-0.4.3.dist-info/top_level.txt,sha256=J0gQxkWR2my5Vf7Qt8buDY8ZOjYdVfIweVunCGXWKNE,19
16
+ cardiac_geometriesx-0.4.3.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (75.1.0)
2
+ Generator: setuptools (75.3.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,16 +0,0 @@
1
- cardiac_geometries/__init__.py,sha256=2W_ywAeLjyRk5MqSPAodHa4UN2lOnW1h8tmGLQ3gaJ0,150
2
- cardiac_geometries/cli.py,sha256=GKcsMNhVFoxWDr-o3jiDCXmTvPgCSEB9Kws8AvYIK4Q,19678
3
- cardiac_geometries/geometry.py,sha256=s-1BIDKvP9M3uu3Sl8JpGRnTnXZAa9Aq3FfpIIEAxhY,5982
4
- cardiac_geometries/gui.py,sha256=9WYR850wLrqsUrVUC37E2SaO0OWA_oagSe-YNrsxz3k,8376
5
- cardiac_geometries/mesh.py,sha256=Ejciny48mnKKN20RrY9DwLY7_Lh1jb6Kldj4CW1wr1o,26909
6
- cardiac_geometries/utils.py,sha256=8QKkdK3JFZMH3qF4PzvEVfk7vMB5Ciui-KFIct2Kd2g,20560
7
- cardiac_geometries/fibers/__init__.py,sha256=WpRrn9Iakl-3m8IGtFkqP0LXGjw5EZHZ8Eg9JCnCdrg,137
8
- cardiac_geometries/fibers/lv_ellipsoid.py,sha256=nJYkwvacH1xMhuWAV06NRR4fFzyprowfWv4UIQkCPQM,5830
9
- cardiac_geometries/fibers/slab.py,sha256=TYQhckJ8mwXz_08Cx3QsPQMtemkaxZ955SnSMrDfBPE,3898
10
- cardiac_geometries/fibers/utils.py,sha256=rOGWyJTRQ7M1W5_JBOIuVPw5LGBVB0u_LGxBicfc--w,3190
11
- cardiac_geometriesx-0.4.1.dist-info/LICENSE,sha256=lo5K2rJPZOSv6luutGHbzzi3IpXNaB9E2UWq60qvNx0,1111
12
- cardiac_geometriesx-0.4.1.dist-info/METADATA,sha256=zbG7thVfZ1t_0dusLr0y8-YhOfo4pUNBD9POw9Ge2Q0,4185
13
- cardiac_geometriesx-0.4.1.dist-info/WHEEL,sha256=GV9aMThwP_4oNCtvEC2ec3qUYutgWeAzklro_0m4WJQ,91
14
- cardiac_geometriesx-0.4.1.dist-info/entry_points.txt,sha256=xOBnlc6W-H9oCDYLNz3kpki26OmpfYSoFSrmi_4V-Ec,52
15
- cardiac_geometriesx-0.4.1.dist-info/top_level.txt,sha256=J0gQxkWR2my5Vf7Qt8buDY8ZOjYdVfIweVunCGXWKNE,19
16
- cardiac_geometriesx-0.4.1.dist-info/RECORD,,