'dolfinx.cpp.mesh.Topology' object has no attribute 'cell_type'

I am trying to run Von Mises elasto-plasticity — FEniCSx Fracture Mechanics tutorial.
and I am getting this error

AttributeError: 'dolfinx.cpp.mesh.Topology' object has no attribute 'cell_type'

(My dolfinx version is : 0.7.1)

Can anyone help me resolve this issue?


As we are preparing DOLFINx to support mixed cell meshes, dolfinx.cpp.mesh.Topology.cell_type has been renamed
dolfinx.cpp.mehs.Topology.cell_types to reflect that we might have multiple types of cells in a mesh. This returns a list of cells in the mesh (currently it is an array with one entry).


Thank you, Where can I find the documentation for


As this is a binding directly to C++, the docs are a bit tricky to find, But they are usually directly mirrors of the C++ docs: Mesh (dolfinx::mesh) — DOLFINx 0.3.1 documentation

1 Like

Thanks again; the following function from the specified tutorial still gives me back error after changing to cell_types

def interpolate_quadrature(ufl_expr, fem_func:fem.Function):
    q_dim = fem_func.function_space._ufl_element.degree()
    mesh = fem_func.ufl_function_space().mesh
    basix_celltype = getattr(basix.CellType, mesh.topology.cell_type.name)
    quadrature_points, weights = basix.make_quadrature(basix_celltype, q_dim)
    map_c = mesh.topology.index_map(mesh.topology.dim)
    num_cells = map_c.size_local + map_c.num_ghosts
    cells = np.arange(0, num_cells, dtype=np.int32)

    expr_expr = fem.Expression(ufl_expr, quadrature_points)
    expr_eval = expr_expr.eval(cells)
    fem_func.x.array[:] = expr_eval.flatten()[:]

Is there anything else that has been changed in this version?

Also is there a preferred version of dolfinx for this particular tutorial (Von Mises elasto-plasticity — FEniCSx Fracture Mechanics) ?

The FEniCSx Fracture mechanics uses an old version of FEniCSx (i think it is 0.6.0).
I cannot list everything that has changed.
See: Computational fracture mechanics examples with FEniCSx — FEniCSx Fracture Mechanics
for how they get dependencies

1 Like