Closed jtgreen closed 1 year ago
This is intentional. mshr
is deprecated and not maintained anymore. I will try to create new BiV example that uses gmsh instead. The plan is to do that during this PR: https://github.com/finsberg/ldrb/pull/58
I only looked cursorily at work, but I had seen the try statements for mshr and meshio and thought it was strange it would fault without completing the import (the full stack shows it errors simply on geometry = line at the beginning of the biv example); I’ll take a closer look but it should complete the import with meshio then. Maybe I never looked at the object and it did import.
Full stack:
In [1]: import dolfin as df
...:
...: import ldrb
...:
...: # Here we just create a lv mesh. Here you can use yor own mesh instead.
...: geometry = ldrb.create_biv_mesh()
...:
...: # The mesh
...: mesh = geometry.mesh
...: # The facet function (function with marking for the boundaries)
...: ffun = geometry.ffun
...: # A dictionary with keys and values for the markers
...: markers = geometry.markers
...:
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
Cell In[1], line 6
3 import ldrb
5 # Here we just create a lv mesh. Here you can use yor own mesh instead.
----> 6 geometry = ldrb.create_biv_mesh()
8 # The mesh
9 mesh = geometry.mesh
File /usr/lib/python3/dist-packages/ldrb/utils.py:323, in create_biv_mesh(N, a_endo_lv, b_endo_lv, c_endo_lv, a_epi_lv, b_epi_lv, c_epi_lv, center_lv, a_endo_rv, b_endo_rv, c_endo_rv, a_epi_rv, b_epi_rv, c_epi_rv, center_rv, base_x, markers)
306 r"""
307 Create an biv-ellipsoidal mesh.
308
(...)
320
321 """
322 if not has_mshr():
--> 323 raise RuntimeError("Cannot create mesh with mshr. It is not installed")
325 import mshr
327 df.info("Creating BiV mesh. This could take some time...")
RuntimeError: Cannot create mesh with mshr. It is not installed
In utils.py:
def create_biv_mesh(
N: int = 13,
a_endo_lv: float = 1.5,
b_endo_lv: float = 0.5,
c_endo_lv: float = 0.5,
a_epi_lv: float = 2.0,
b_epi_lv: float = 1.0,
c_epi_lv: float = 1.0,
center_lv: Tuple[float, float, float] = (0.0, 0.0, 0.0),
a_endo_rv: float = 1.45,
b_endo_rv: float = 1.25,
c_endo_rv: float = 0.75,
a_epi_rv: float = 1.75,
b_epi_rv: float = 1.5,
c_epi_rv: float = 1.0,
center_rv: Tuple[float, float, float] = (0.0, 0.5, 0.0),
base_x: float = 0.0,
markers: Optional[Dict[str, int]] = None,
) -> Geometry:
r"""
Create an biv-ellipsoidal mesh.
An ellipsoid is given by the equation
.. math::
\frac{x^2}{a} + \frac{y^2}{b} + \frac{z^2}{c} = 1
We create three ellipsoids, one for the LV and RV endocardium
and one for the epicardium and subtract them and then cut the base.
For simplicity we assume that the longitudinal axis is in
in :math:`x`-direction and as default the base is located
at the :math:`x=0` plane.
"""
if not has_mshr():
raise RuntimeError("Cannot create mesh with mshr. It is not installed")
import mshr
I dont see how this wouldn't execute as a runtime error in the biv example.
The function has_mshr
tries to import mshr
when you first import ldrb
se e.g https://github.com/finsberg/ldrb/blob/f132e28522ae2ba0aa6707fa45f8975387eb8295/ldrb/utils.py#L14-L19
An ImportError
would probably be more suited here I guess.
Understood. I guess what I'm getting at is, you said it doesn't have to use mshr, that its outdated and replaced by meshio, but when I try to run the example, it has to use mshr. What am I missing? lol
I would imagine given your awesome docker container I should be able to load the container and just run the examples, but they fail with that error...
Oh, disregard, I see what you're saying: the example is broken!
Correct, I will try to make a new example with a BiV using gmsh
instead.
Thanks!
I’m going to try and import one of these publically available vtk meshes too, though I’m running into issues with the ffun and the markers when using pyview.
(from within container) During BiV example, following output:
File /usr/lib/python3/dist-packages/ldrb/utils.py:323, in create_biv_mesh(N, a_endo_lv, b_endo_lv, c_endo_lv, a_epi_lv, b_epi_lv, c_epi_lv, center_lv, a_endo_rv, b_endo_rv, c_endo_rv, a_epi_rv, b_epi_rv, c_epi_rv, center_rv, base_x, markers) 306 r""" 307 Create an biv-ellipsoidal mesh. 308 (...) 320 321 """ 322 if not has_mshr(): --> 323 raise RuntimeError("Cannot create mesh with mshr. It is not installed") 325 import mshr 327 df.info("Creating BiV mesh. This could take some time...")
RuntimeError: Cannot create mesh with mshr. It is not installed