multiphenics / multiphenicsx

multiphenicsx - easy prototyping of multiphysics problems in FEniCSx
https://multiphenics.github.io/
GNU Lesser General Public License v3.0
40 stars 7 forks source link

multiphenics/fem/petsc.py file bug #10

Closed jhdark closed 1 year ago

jhdark commented 1 year ago

Hi guys

Love the use of this package and would love to use it for work in my thesis, however, there may have been some updates to dolfinx that broke some things here. Although I may very well be doing something daft here. When trying to run the navier-stokes tutorial I get the following error:

AttributeError                            Traceback (most recent call last)
Cell In [6], line 1
----> 1 import multiphenicsx.fem
      2 import multiphenicsx.io

File /usr/local/lib/python3.10/dist-packages/multiphenicsx/fem/__init__.py:9
      1 # Copyright (C) 2016-2023 by the multiphenicsx authors
      2 #
      3 # This file is part of multiphenicsx.
      4 #
      5 # SPDX-License-Identifier: LGPL-3.0-or-later
      6 """Tools for assembling finite element forms with restrictions."""
----> 9 import multiphenicsx.fem.petsc  # import module rather than its content to be consistent with dolfinx.fem.petsc
     10 from multiphenicsx.fem.dofmap_restriction import DofMapRestriction

File /usr/local/lib/python3.10/dist-packages/multiphenicsx/fem/petsc.py:21
     18 import numpy.typing
     19 import petsc4py.PETSc
---> 21 from multiphenicsx.cpp import cpp_library as mcpp
     23 DolfinxConstantsType = np.typing.NDArray[petsc4py.PETSc.ScalarType]
     24 DolfinxCoefficientsType = typing.Dict[
     25     typing.Tuple[dcpp.fem.IntegralType, int],
     26     np.typing.NDArray[petsc4py.PETSc.ScalarType]
     27 ]
...
---> 70 jit_options = dolfinx.jit.get_options()
     71 output_dir = kwargs.get("output_dir", str(jit_options["cache_dir"]))
     72 assert isinstance(output_dir, str)

AttributeError: module 'dolfinx.jit' has no attribute 'get_options

I'm using the most recent version of dolfinx in the associated docker container v0.5.1.

francesco-ballarin commented 1 year ago

multiphenicsx is compatible with dolfinx main branch, and not necessarily with current or previous dolfinx releases. In particular, the change in dolfinx which you mention happened in September 2022, see https://github.com/multiphenics/multiphenicsx/commit/9a2d65fd8b3f15c5eced034440fead867ea38043

In your git clone of multiphenicsx, do a git checkout of the commit previous to that, i.e. git checkout 4ebd05c, and reinstall with pip. That has solved a similar issue for a couple of other users, and I believe it will solve yours too.

jhdark commented 1 year ago

Brilliant will give it a try!

francesco-ballarin commented 1 year ago

Hi @jhdark , unless I hear anything back from you I'll assume that this is solved, and close the issue in a couple of days (or you may close it yourself even before that, if the fix above does indeed help).

jhdark commented 1 year ago

can confirm that did fix the issue thanks!

francesco-ballarin commented 1 year ago

Great, closing.