Hello everyone,
I cannot find any dofs at the boundaries for a discontinuous element (either DG0 nor DG1). What am I doing wrong?
Thank you.
Here is the MWE:
import dolfinx
import mpi4py.MPI
import numpy as np
import ufl
# mesh
domain = dolfinx.mesh.create_unit_square(mpi4py.MPI.COMM_WORLD, 10, 10)
# boundaries
boundaries = [(3, lambda x: np.isclose(x[0], 0)), # left side = 3
(4, lambda x: np.isclose(x[0], 1)), # right side = 4
(5, lambda x: np.isclose(x[1], 0)), # bottom = 5
(6, lambda x: np.isclose(x[1], 1))] # on top = 6
# create facet tags
facet_indices, facet_markers = [], []
fdim = domain.topology.dim - 1
for (marker, locator) in boundaries:
facets = dolfinx.mesh.locate_entities_boundary(domain, fdim, locator)
facet_indices.append(facets)
facet_markers.append(np.full_like(facets, marker))
facet_indices = np.hstack(facet_indices).astype(np.int32)
facet_markers = np.hstack(facet_markers).astype(np.int32)
sorted_facets = np.argsort(facet_indices)
facet_tag = dolfinx.mesh.meshtags(domain, fdim, facet_indices[sorted_facets], facet_markers[sorted_facets])
# create mixed functionspace
P_T = ufl.FiniteElement("CG", domain.ufl_cell(), 1)
P_L = ufl.FiniteElement("DG", domain.ufl_cell(), 1)
element = P_T * P_L
V = dolfinx.fem.FunctionSpace(domain, element)
# search dofs of discontionious subspace
dofs_boundary3_sub0 = dolfinx.fem.locate_dofs_topological(V.sub(0), facet_tag.dim, facet_tag.find(3))
dofs_boundary3_sub1 = dolfinx.fem.locate_dofs_topological(V.sub(1), facet_tag.dim, facet_tag.find(3))
print("DOFS of subspace 0 at boundary 3:", dofs_boundary3_sub0)
print("DOFS of subspace 1 at boundary 3:", dofs_boundary3_sub1)
DOFS of subspace 0 at boundary 3: [334 366 433 493 546 592 631 663 688 706 717]
DOFS of subspace 1 at boundary 3: []