Sudden error in boundary conditions

Hi everyone,

I’ve been working on this file for quite some time now without any error, using dolfinx version 0.6, in which I set the value of a function in a function space the following way:

import numpy as np
import ufl
from dolfinx import *
import dolfinx.fem.petsc
import dolfinx
from mpi4py import MPI
from dolfinx import fem, mesh, plot
from dolfinx.fem import (Constant, Function, FunctionSpace, 
                         assemble_scalar, dirichletbc, form, locate_dofs_geometrical, set_bc)

L = 20 
domain = mesh.create_box(MPI.COMM_WORLD,[[0.0,0.0,0.0], [L, 1, 1]], [20, 2, 2], mesh.CellType.hexahedron)
# Function spaces
V_me = ufl.VectorElement("CG", domain.ufl_cell(), 2, 3) # Vector elems for the trial function of the mechanical problem
V_el = ufl.FiniteElement("CG", domain.ufl_cell(), 1) # Scalar elems for the trial function of the electro problem
W_elem = ufl.MixedElement(V_me,V_el) # Mixed elements
W = fem.FunctionSpace(domain, W_elem)
W0, _ = W.sub(0).collapse() 
u_bc = Function(W0) 

So far, it’s been working great but since I updated to dolfinx version 0.7 it yields the following error:

AttributeError: 'Vector' object has no attribute 'set'

How could I rewrite the code so that i works with this newer version?

Thanks in advance!

u_bc.x.array[:] = 0

1 Like