I have an example I am cobbling together:
import numpy as np
import ufl
from mpi4py import MPI
from petsc4py.PETSc import ScalarType
from ufl import ds, dx, grad, inner
from dolfinx import fem, io, mesh, plot
msh = mesh.create_box(MPI.COMM_WORLD, [np.array([0.0, 0.0, 0.0]),
np.array([2.0, 1.0, 1.0])], [16, 16, 16],
mesh.CellType.tetrahedron)
V = fem.FunctionSpace(msh, ("Lagrange", 1))
facets = mesh.locate_entities_boundary(msh, dim=(msh.topology.dim - 1),
marker=lambda x: np.logical_or(np.isclose(x[0], 0.0),
np.isclose(x[0], 2.0)))
dofs = fem.locate_dofs_topological(V=V, entity_dim=1, entities=facets)
bc = fem.dirichletbc(value=ScalarType(0), dofs=dofs, V=V)
#for i, cell in enumerate(cells(mesh)):
# if i==1: # for the second element
# A = assemble_local(inner(grad(u), grad(v)) *dx, cell)
I got the comment prefixed code to enumerate cells from another post of the fenics discourse forum. It seems that cells and assemble_local are no longer accessible by those names.
I scanned the docker source for assemble_local and didn’t find anything there any longer. The cells function seems to be found in mesh, geometry and fem modules.
Is there a replacement in latest docker source for assemble_local someplace (maybe like some version of assemble…)?
Is fem.cells a suitable way to replace the comment prefixed code I found it to enumerate each cell?
(Wasn’t really officially part of my question but I feel curious here…),
(In terms of the usage of locate_entities_boundary that came from poisson example it seems that the lambda is only looking to the X co-ordinate for a bounds checking. I feel perplexed how that works without accounting for Y. Any insight on this? Suppose a box that lambda is moving to from a rectangle should checking just X with the lambda be sufficient for use with dolfinx or will other dimensions need to be looked at in terms of this style of coding with box now?)