Hello,
I believe this is a simple question but have not found a solution. I have a fem.Function
with a vector function space and I am trying to interpolate a constant value onto one of the subspaces. In this attempt, I get a long error message (pasted below) and the kernel keeps running, producing the error messages, until I manually stop it. The MWE is
import numpy
from dolfinx import mesh, fem, nls, plot, cpp
import ufl
from mpi4py import MPI
from petsc4py import PETSc
import pyvista
import gmsh
from dolfinx.io import gmshio
gmsh.initialize()
dx_min = 0.1
dx_max = 0.1
cyl = gmsh.model.occ.addDisk(0, 0, 0, 1, 1)
gmsh.model.occ.synchronize()
gdim = 2
gmsh.model.addPhysicalGroup(gdim, [cyl], 1)
gmsh.option.setNumber("Mesh.CharacteristicLengthMin",dx_min)
gmsh.option.setNumber("Mesh.CharacteristicLengthMax",dx_max)
gmsh.model.mesh.generate(gdim)
# convert to fenics format
gmsh_model_rank = 0
mesh_comm = MPI.COMM_WORLD
domain, cell_markers, facet_markers = gmshio.model_to_mesh(gmsh.model, mesh_comm, gmsh_model_rank, gdim=gdim)
# vector function space
W = fem.VectorFunctionSpace(domain, ("CG",1))
# create function and set values of sub
u = fem.Function(W)
u.sub(0).interpolate(fem.Constant(domain, PETSc.ScalarType(1)))
Error messages:
Couldn't map 'c_0' to a float, returning ufl object without evaluation. WARNING:UFL:Couldn't map 'c_0' to a float, returning ufl object without evaluation. Couldn't map 'c_0' to a float, returning ufl object without evaluation. WARNING:UFL:Couldn't map 'c_0' to a float, returning ufl object without evaluation. Couldn't map 'c_0' to a float, returning ufl object without evaluation. WARNING:UFL:Couldn't map 'c_0' to a float, returning ufl object without evaluation. Couldn't map 'c_0' to a float, returning ufl object without evaluation. WARNING:UFL:Couldn't map 'c_0' to a float, returning ufl object without evaluation. Couldn't map 'c_0' to a float, returning ufl object without evaluation. Couldn't map 'c_0' to a float, returning ufl object without evaluation. WARNING:UFL:Couldn't map 'c_0' to a float, returning ufl object without evaluation. Couldn't map 'c_0' to a float, returning ufl object without evaluation. WARNING:UFL:Couldn't map 'c_0' to a float, returning ufl object without evaluation. Couldn't map 'c_0' to a float, returning ufl object without evaluation. Couldn't map 'c_0' to a float, returning ufl object without evaluation. WARNING:UFL:Couldn't map 'c_0' to a float, returning ufl object without evaluation. Couldn't map 'c_0' to a float, returning ufl object without evaluation. WARNING:UFL:Couldn't map 'c_0' to a float, returning ufl object without evaluation. Couldn't map 'c_0' to a float, returning ufl object without evaluation. WARNING:UFL:Couldn't map 'c_0' to a float, returning ufl object without evaluation. Couldn't map 'c_0' to a float, returning ufl object without evaluation. WARNING:UFL:Couldn't map 'c_0' to a float, returning ufl object without evaluation. Couldn't map 'c_0' to a float, returning ufl object without evaluation. Couldn't map 'c_0' to a float, returning ufl object without evaluation. WARNING:UFL:Couldn't map 'c_0' to a float, returning ufl object without evaluation. Couldn't map 'c_0' to a float, returning ufl object without evaluation. Couldn't map 'c_0' to a float, returning ufl object without evaluation.
Thanks!