Closed jorgensd closed 11 months ago
Replacing Ve * Qe
with basix.ufl.mixed_element([Ve, Qe])
will get rid of most of these warnings. For the others, I'm working on changes in UFL to get rid of them.
@mscroggs can we close this now?
I think these warnings are all gone now. @jorgensd can you check and close this if so?
Adapted test passes with:
import dolfinx
import basix.ufl
from mpi4py import MPI
def test():
N = 4
mesh = dolfinx.mesh.create_unit_square(
MPI.COMM_WORLD, N, N)
print(dolfinx.common.git_commit_hash)
cellname = mesh.ufl_cell().cellname()
Ve = basix.ufl.element(basix.ElementFamily.P, cellname, 2, shape=(mesh.geometry.dim,))
Qe = basix.ufl.element(basix.ElementFamily.P, cellname, 1)
W = dolfinx.fem.functionspace(mesh, basix.ufl.mixed_element([Ve, Qe]))
yielding:
root@xxyyzz:~/shared# python3 -m pytest -xsv test_112.py -W error
============================= test session starts ==============================
platform linux -- Python 3.10.12, pytest-7.4.2, pluggy-1.3.0 -- /usr/bin/python3
cachedir: .pytest_cache
rootdir: /root/shared
plugins: xdist-3.3.1
collected 1 item
test.py::test fed77865d61895ba1c5ddaaa843cb1c3e90686a7
PASSED
Hi all, I still receive tons of ufl warnings even when using basix.ufl.mixed_element
I ran the code @jorgensd posted and obtained:
$ python3 -m pytest -xsv mwe.py
=============================================================================== test session starts ===============================================================================
platform linux -- Python 3.12.1, pytest-7.4.4, pluggy-1.3.0 -- /opt/conda/envs/fenicsx/bin/python3
cachedir: .pytest_cache
rootdir: /workspaces/FESTIM
collected 1 item
mwe.py::test 4604094c8c3e6dbf6034b25df5ee3ccd1ec2d3b3
PASSED
================================================================================ warnings summary =================================================================================
../../opt/conda/envs/fenicsx/lib/python3.12/site-packages/ufl/core/ufl_type.py:56
../../opt/conda/envs/fenicsx/lib/python3.12/site-packages/ufl/core/ufl_type.py:56
../../opt/conda/envs/fenicsx/lib/python3.12/site-packages/ufl/core/ufl_type.py:56
../../opt/conda/envs/fenicsx/lib/python3.12/site-packages/ufl/core/ufl_type.py:56
../../opt/conda/envs/fenicsx/lib/python3.12/site-packages/ufl/core/ufl_type.py:56
../../opt/conda/envs/fenicsx/lib/python3.12/site-packages/ufl/core/ufl_type.py:56
../../opt/conda/envs/fenicsx/lib/python3.12/site-packages/ufl/core/ufl_type.py:56
../../opt/conda/envs/fenicsx/lib/python3.12/site-packages/ufl/core/ufl_type.py:56
/opt/conda/envs/fenicsx/lib/python3.12/site-packages/ufl/core/ufl_type.py:56: DeprecationWarning: attach_operators_from_hash_data deprecated, please use UFLObject instead.
warnings.warn("attach_operators_from_hash_data deprecated, please use UFLObject instead.", DeprecationWarning)
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
========================================================================== 1 passed, 8 warnings in 0.51s ==========================================================================
Hi all, I still receive tons of ufl warnings even when using basix.ufl.mixed_element
I ran the code @jorgensd posted and obtained:
$ python3 -m pytest -xsv mwe.py =============================================================================== test session starts =============================================================================== platform linux -- Python 3.12.1, pytest-7.4.4, pluggy-1.3.0 -- /opt/conda/envs/fenicsx/bin/python3 cachedir: .pytest_cache rootdir: /workspaces/FESTIM collected 1 item mwe.py::test 4604094c8c3e6dbf6034b25df5ee3ccd1ec2d3b3 PASSED ================================================================================ warnings summary ================================================================================= ../../opt/conda/envs/fenicsx/lib/python3.12/site-packages/ufl/core/ufl_type.py:56 ../../opt/conda/envs/fenicsx/lib/python3.12/site-packages/ufl/core/ufl_type.py:56 ../../opt/conda/envs/fenicsx/lib/python3.12/site-packages/ufl/core/ufl_type.py:56 ../../opt/conda/envs/fenicsx/lib/python3.12/site-packages/ufl/core/ufl_type.py:56 ../../opt/conda/envs/fenicsx/lib/python3.12/site-packages/ufl/core/ufl_type.py:56 ../../opt/conda/envs/fenicsx/lib/python3.12/site-packages/ufl/core/ufl_type.py:56 ../../opt/conda/envs/fenicsx/lib/python3.12/site-packages/ufl/core/ufl_type.py:56 ../../opt/conda/envs/fenicsx/lib/python3.12/site-packages/ufl/core/ufl_type.py:56 /opt/conda/envs/fenicsx/lib/python3.12/site-packages/ufl/core/ufl_type.py:56: DeprecationWarning: attach_operators_from_hash_data deprecated, please use UFLObject instead. warnings.warn("attach_operators_from_hash_data deprecated, please use UFLObject instead.", DeprecationWarning) -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html ========================================================================== 1 passed, 8 warnings in 0.51s ==========================================================================
It doesn't seem like you have an up to date image of dolfinx, as the test refers to
mwe.py::test 4604094c8c3e6dbf6034b25df5ee3ccd1ec2d3b3
which is a commit from october: https://github.com/FEniCS/dolfinx/commit/fed77865d61895ba1c5ddaaa843cb1c3e90686a7
It doesn't seem like you have an up to date image of dolfinx, as the test refers to
I installed it with conda
conda install -c conda-forge fenics-dolfinx mpich pyvista
I've recently been trying to reduce the number of warnings: https://github.com/festim-dev/FESTIM/pull/683 and noticed that the changes introduced by this commit haven't been released yet.
Should the conda environment use the dev version of ufl?
I checked and confirm I'm using dolfinx 0.7.2 but the release notes of 0.7.3 state there's no need to upgrade
I checked and confirm I'm using dolfinx 0.7.2 but the release notes of 0.7.3 state there's no need to upgrade
Ah, sorry, I took the wrong git hash. It is correct that you are using a newer version: https://github.com/conda-forge/fenics-dolfinx-feedstock/commit/4604094c8c3e6dbf6034b25df5ee3ccd1ec2d3b3
The "error"/"warning" is present in ghcr.io/fenics/dolfinx/dolfinx:v0.7.2
and ghcr.io/fenics/dolfinx/dolfinx:v0.7.3
but does not exist on nightly
. There I get a rather strange warning:
with
python3 -m pytest -xvs mwe_1.py -Wd
import dolfinx
import basix.ufl
from mpi4py import MPI
def test():
N = 4
mesh = dolfinx.mesh.create_unit_square(
MPI.COMM_WORLD, N, N)
cellname = mesh.ufl_cell().cellname()
Ve = basix.ufl.element(basix.ElementFamily.P, cellname,
2, shape=(mesh.geometry.dim,))
Qe = basix.ufl.element(basix.ElementFamily.P, cellname, 1)
W = dolfinx.fem.functionspace(mesh, basix.ufl.mixed_element([Ve, Qe]))
mwe_1.py::test
/usr/local/lib/python3.10/dist-packages/ffcx/codegeneration/jit.py:69: ResourceWarning: unclosed file <_io.TextIOWrapper name='/root/.cache/fenics/libffcx_elements_1f01ab63c5abaab6255c0fdd2e80237ed970cf33.c' mode='x' encoding='UTF-8'>
open(c_filename, "x")
Enable tracemalloc to get traceback where the object was allocated.
See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.
-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
@RemDelaporteMathurin The last strange error message has been resolved in https://github.com/FEniCS/ffcx/pull/654
How to reproduce the bug
Using a mixed element created with basix creates a stack of warnings
Minimal Example (Python)
Output (Python)
Version
main branch
DOLFINx git commit
ee86abd93f957ce1a899fd8ec2c5a2f40b34301f
Installation
Using the nightly docker images (also verified when building from source).
Additional information
No response