What has become of VectorElement? It is referenced in the ufl documentation and this tutorial but I can’t find its definition in the latest ufl version.
On the main branch of DOLFINx, ufl.VectorElement
has been replaced with basix.ufl.element(family, cell, degree, shape=(N,))
to create a N-dimensional vector space for a given Finite element family.
what about the fem.VectorFunctionSpace is it also updated
See: Add shape argument to `FunctionSpace` for creating blocked scalar element spaces by garth-wells · Pull Request #2766 · FEniCS/dolfinx · GitHub
as it highlights the api change
i have tried used the command
from dolfinx.fem import (Expression, Function, FunctionSpaceBase, dirichletbc,
form, functionspace, locate_dofs_topological)
i am using FEniCSx on Colab research
ImportError Traceback (most recent call last)
in <cell line: 1>()
----> 1 from dolfinx.fem import (Expression, Function, FunctionSpaceBase, dirichletbc,
2 form, functionspace, locate_dofs_topological)
3
4 shape = (gdim,)
5 Vu = dolfinx.fem.functionspace(mesh, (‘CG’, 2, shape))
ImportError: cannot import name ‘FunctionSpaceBase’ from ‘dolfinx.fem’ (/usr/local/lib/python3.10/dist-packages/dolfinx/fem/init.py)
Just remove FunctionSpaceBasee as an import. That is what your error message is stating isn’t defined
hi dokken,
i have even tried that and not able to create the vector functional space
we have
gdim = mesh.geometry.dim
M = functionspace(mesh, (“Lagrange”, 1, (gdim,)))
AttributeError Traceback (most recent call last)
in <cell line: 1>()
----> 1 M = functionspace(mesh, (“Lagrange”, 1, (gdim,)))
2
3 u = ufl.TrialFunction(Vu)
4 v = ufl.TestFunction(Vu)
5
/usr/local/lib/python3.10/dist-packages/dolfinx/fem/function.py in functionspace(mesh, element, form_compiler_options, jit_options)
592 ufl_e = basix.ufl.element(
593 e.family,
→ 594 mesh.basix_cell(),
595 e.degree,
596 shape=e.shape,
AttributeError: module ‘dolfinx.mesh’ has no attribute ‘basix_cell’
i am using FEniCSx on google colab
try:
import dolfinx
except ImportError:
!wget “https://fem-on-colab.github.io/releases/fenicsx-install-real.sh” -O “/tmp/fenicsx-install.sh” && bash “/tmp/fenicsx-install.sh”
import dolfinx
Could you provide a minimal reproducible example, which I can run myself, as it Seems like you are not sending in mesh correctly, But i cannot be certain as you haven’t included all imports and definitions
you surely have a from dolfinx import mesh
at the top of your file, and are not creating the actual mesh (or maybe you are creating it, but calling it msh
or domain
)
Note that screenshot is from the “latest” UFL document.
But:
$ python
Python 3.13.0 | packaged by conda-forge | (main, Oct 8 2024, 20:04:32) [GCC 13.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ufl
>>> ufl.__version__
'2024.2.0'
>>> ufl.VectorElement
Traceback (most recent call last):
File "<python-input-2>", line 1, in <module>
ufl.VectorElement
AttributeError: module 'ufl' has no attribute 'VectorElement'
Moreover, google returns no hits for:
'2024.2.0' site:https://fenics.readthedocs.io
Here is my environment.yml
file for conda
:
name: ioniser
channels:
- nvidia
- conda-forge
- default
dependencies:
- fenics-dolfinx
- python-gmsh
- pyvista
- scipy
- petsc4py
- fenics-ufl
- cuda-toolkit
That is not the latest documentation. That page is for the latest ufl
compatible with dolfin
.
For the latest documentation see https://docs.fenicsproject.org/