FEniCS version: 2019.1.0 installed via Conda
Consider the following MWE on mixed spaces:
from dolfin import *
## Spaces
mesh = UnitSquareMesh(2, 2)
P1 = FiniteElement('CG', triangle, 1)
P0 = FiniteElement('DG', triangle, 0)
elem = MixedElement([P1, P0, P0])
W = FunctionSpace(mesh, elem)
## Trial and Test functions
w1, w2, w3 = TrialFunctions(W)
t1, t2, t3 = TestFunction(W)
## global dofs
dofs0 = W.sub(0).dofmap().dofs()
dofs1 = W.sub(1).dofmap().dofs()
dofs2 = W.sub(2).dofmap().dofs()
print(dofs0, dofs1, dofs2)
## Interpolate
f1 = interpolate(Expression('-x[1]', degree = 1), W.sub(1).collapse())
assigner0 = FunctionAssigner(W.sub(1), f1.function_space())
f1V = Function(W)
assigner0.assign(f1V.sub(1), f1)
f3 = interpolate(Constant(1), W.sub(1).collapse())
assigner2 = FunctionAssigner(W.sub(1), f3.function_space())
z0 = Function(W)
assigner2.assign(z0.sub(1), f3)
f4 = interpolate(Constant(-1.7), W.sub(2).collapse())
assigner3 = FunctionAssigner(W.sub(2), f4.function_space())
alp0 = Function(W)
assigner3.assign(alp0.sub(2), f4)
## Working on local spaces
z = z0.vector()[dofs1]
alp = alp0.vector()[dofs2]
f1VV = f1V.vector()[dofs1]
# Condition check
A = alp + (z-f1VV)
marked_cellsA = []
CellMarker = MeshFunction('size_t', mesh, mesh.topology().dim())
CellMarker.set_all(0) # 0 -> all elements
cell_indices = CellMarker.where_equal(0)
Wloc = W.sub(1).collapse().dofmap()
for cell in cell_indices:
cell_dofs = Wloc.cell_dofs(cell)
values = A[cell_dofs]
for value in values:
if value >= 0:
marked_cellsA.append(cell)
CellMarker.array()[marked_cellsA] = 1
print(marked_cellsA)
## Mark the cells
dAct = Measure('dx', subdomain_data=CellMarker)
## Integrations
Eq1 = t2*w2*dx
Eq2 = t2*w2*dAct(1)
Output
[0, 1, 2, 5, 6, 11, 14, 17, 22] [3, 7, 9, 12, 15, 18, 20, 23] [4, 8, 10, 13, 16, 19, 21, 24]
[0, 3]
Questions:
-
What does dx represent in the case of mixed spaces? Is it still integration over elements, if yes then how is it related to the global dofs?
-
How are the marke_cellsA local dofs belonging to P0, i.e., [{\color{blue}0}\; {\color{green}3}] linked with the global dofs [{\color{blue}3}, 7, 9, {\color{green}12}, 15, 18, 20, 23] and [{\color{blue}4}, 8, 10, {\color{green}13}, 16, 19, 21, 24], respectively (Is there a 1-1 mapping between them represented by blue and green colours).
-
What should one expect from the internal Eq2 = t2w2dAct(1)?