FEniCS version: 2019.1.0 installed via Conda.
I tried performing same conditional operations on the finite element spaces P0 \times P0:
- On a mixed space [P1 \times P1 \times P0 \times P0], where P1 and P0 are finite elements.
- On a mixed space [P1 \times P0 \times P0], where P1 is a vector element and P0 are finite elements,
with varying outputs. I don’t understand the reason for it. In this regard I constructed the following MWE:
from dolfin import *
import ufl
import numpy as np
mesh = UnitSquareMesh(1,1)
P1S = FiniteElement('CG', triangle, 1)
P1V = VectorElement('CG', triangle, 1)
P0 = FiniteElement('DG', triangle, 0)
####### Working Componenetwise ###########
elemS = MixedElement([P1S, P1S, P0, P0])
WS = FunctionSpace(mesh, elemS)
v1, v2, q1, q2 = TestFunctions(WS)
zaI = interpolate(Constant(-0.1), WS.sub(2).collapse());
a1 = FunctionAssigner(WS.sub(2), zaI.function_space());
zaV = Function(WS);
a1.assign(zaV.sub(2), zaI);
z1I = interpolate(Constant(0), WS.sub(2).collapse());
a3 = FunctionAssigner(WS.sub(2), z1I.function_space());
z1V = Function(WS);
a3.assign(z1V.sub(2), z1I);
SActAx = ufl.conditional(ufl.le((z1V[2] - zaV[2]), 0), 1, 0)
temp0 = assemble(SActAx*q1*dx); np.savetxt('temp0.txt', temp0.get_local())
dof0 = WS.sub(0).dofmap().dofs()
dof1 = WS.sub(1).dofmap().dofs()
dof2 = WS.sub(2).dofmap().dofs()
dof3 = WS.sub(3).dofmap().dofs()
print(dof0, dof1, dof2, dof3)
####### Vector #######
elemV = MixedElement([P1V, P0, P0])
WV = FunctionSpace(mesh, elemV)
v, p1, p2 = TestFunctions(WV)
zaIv = interpolate(Constant(-0.1), WV.sub(1).collapse());
a1v = FunctionAssigner(WV.sub(1), zaIv.function_space());
zaVv = Function(WV);
a1v.assign(zaVv.sub(1), zaIv);
z1Iv = interpolate(Constant(0), WV.sub(1).collapse());
a3v = FunctionAssigner(WV.sub(1), z1Iv.function_space());
z1Vv = Function(WV);
a3v.assign(z1Vv.sub(1), z1Iv);
VActAx = ufl.conditional(ufl.le((z1Vv[1] - zaVv[1]), 0), 1, 0)
temp0v = assemble(VActAx*p1*dx); np.savetxt('temp0v.txt', temp0v.get_local())
dof0v = WV.sub(0).dofmap().dofs()
dof1v = WV.sub(1).dofmap().dofs()
dof2v = WV.sub(2).dofmap().dofs()
print(dof0v, dof1v, dof2v)
Output:
[0, 1, 2, 8] [3, 4, 5, 9] [6, 10] [7, 11]
[0, 1, 2, 3, 4, 5, 8, 9] [6, 10] [7, 11]
The output in temp0.txt
and temp0v.txt
files, respectively,
0.000000000000000000e+00
0.000000000000000000e+00
0.000000000000000000e+00
0.000000000000000000e+00
0.000000000000000000e+00
0.000000000000000000e+00
0.000000000000000000e+00
0.000000000000000000e+00
0.000000000000000000e+00
0.000000000000000000e+00
0.000000000000000000e+00
0.000000000000000000e+00
0.000000000000000000e+00
0.000000000000000000e+00
0.000000000000000000e+00
0.000000000000000000e+00
0.000000000000000000e+00
0.000000000000000000e+00
5.000000000000000000e-01
0.000000000000000000e+00
0.000000000000000000e+00
0.000000000000000000e+00
5.000000000000000000e-01
0.000000000000000000e+00
Doubt: Why are the outputs not same, even though I am essentially performing the same operation and the degrees of freedom associated with P0 \times P0 spaces is same?