fem.FunctionSpace v.s. fem.functionspace in 0.8.0.dev0 r27568 a34b0c9

Hi. I’m about to leave, but I wanted to let you know that I get different results with =fem.FunctionSpace= and =fem.functionspace=. This may be expected, but just in case… (I will continue this report as soon as possible).

#!/usr/bin/env python

# This file uses the code from
# https://newfrac.github.io/fenicsx-fracture/notebooks/plasticity/plasticity.html
# which holds an MIT license, under the Copyright (c) 2021 Jack S. Hale.
#
# Contents were removed from the original and two comments were added

from dolfinx import fem
from dolfinx.io import gmshio
from mpi4py import MPI
import ufl
import gmsh

# ---- Meshing begins ----

# Geometric parameters
geom = {"Re": 1.3, "Ri": 1., "lc": 0.03}

mech = {"E": 1., "nu": 0.3,
        "sig0": 250. / 70.e3, "H": 1. / 99.}

stud = {"deg u": 2, "deg sig": 2, "N incr": 50}

R_e, R_i = geom["Re"], geom["Ri"]  # external/internal radius

# mesh parameters
lc = 0.03
gdim = 2
verbosity = 10

mesh_comm = MPI.COMM_WORLD
model_rank = 0
gmsh.initialize()
facet_tags = {"Lx": 1, "Ly":2, "inner": 3, "outer": 4}
cell_tags = {"all": 20}
if mesh_comm.rank == model_rank:
    model = gmsh.model()
    model.add("Quart_cylinder")
    model.setCurrent("Quart_cylinder")
    # Create the points
    pix = model.occ.addPoint(R_i, 0.0, 0, lc)
    pex = model.occ.addPoint(R_e, 0, 0, lc)
    piy = model.occ.addPoint(0., R_i, 0, lc)
    pey = model.occ.addPoint(0., R_e, 0, lc)
    center = model.occ.addPoint(0., 0., 0, lc)
    # Create the lines
    lx = model.occ.addLine(pix, pex, tag = facet_tags["Lx"])
    lout = model.occ.addCircleArc(pex, center, pey, tag = facet_tags["outer"])
    ly = model.occ.addLine(pey, piy, tag = facet_tags["Ly"])
    lin = model.occ.addCircleArc(piy, center, pix, tag = facet_tags["inner"])
    # Create the surface
    cloop1 = model.occ.addCurveLoop([lx, lout, ly, lin])
    surface_1 = model.occ.addPlaneSurface([cloop1], tag = cell_tags["all"])
    model.occ.synchronize()
    # Assign mesh and facet tags
    surface_entities = [entity[1] for entity in model.getEntities(2)]
    model.addPhysicalGroup(2, surface_entities, tag=cell_tags["all"])
    model.setPhysicalName(2, 2, "Quart_cylinder surface")
    for (key, value) in facet_tags.items():
        model.addPhysicalGroup(1, [value], tag=value)
        model.setPhysicalName(1, value, key)
    # Finalize mesh
    model.occ.synchronize()
    gmsh.option.setNumber('General.Verbosity', 0)
    model.mesh.generate(gdim)
    if mesh_comm == model_rank:
        my_model = model
    else :
        my_model = None

msh, cell_tags, facet_tags = gmshio.model_to_mesh(
            model, mesh_comm, 0., gdim=2)
# ---- Meshing ends ----

msh.topology.create_connectivity(msh.topology.dim - 1, msh.topology.dim)

deg_u = stud["deg u"]
deg_stress = stud["deg sig"]

This code is an update to 0.8.0 r27568 a34b0c9:

msh_cell_type = msh.basix_cell()
Ve = basix.ufl.element(
    'Lagrange', msh_cell_type, degree=deg_u, shape=(msh.geometry.dim,))
V = fem.FunctionSpace(msh, Ve)

yields

Traceback (most recent call last):
  File "plasticity.py", line 81, in <module>
TypeError: FunctionSpace.__init__() missing 1 required positional argument: 'cppV'

This works

msh_cell_type = msh.basix_cell()
Ve = basix.ufl.element(
    'Lagrange', msh_cell_type, degree=deg_u, shape=(msh.geometry.dim,))
V = fem.functionspace(msh, Ve)

Thank you.

See: Remove deprecated `fem.FunctionSpace` function by francesco-ballarin · Pull Request #2818 · FEniCS/dolfinx · GitHub
and Add shape argument to `FunctionSpace` for creating blocked scalar element spaces by garth-wells · Pull Request #2766 · FEniCS/dolfinx · GitHub

1 Like