Dear all,
I am hoping to apply a heatFlux in a DG0 function space as opposed to a CG1 function space:
Here is an MWE:
from fenics import *
mesh = BoxMesh.create(MPI.comm_world,[Point(0, 0, 0), Point(1,1,1)],[10,10,10],CellType.Type.hexahedron)
class negX(SubDomain):
def inside(self, x, on_boundary):
return near(x[0], Constant(0.0))
class posX(SubDomain):
def inside(self, x, on_boundary):
return near(x[0], Constant(1.0))
negX = negX(); posX = posX();
Surfaces = MeshFunction('size_t', mesh, 2)
Surfaces.set_all(0)
negX.mark(Surfaces, 1)
posX.mark(Surfaces, 2)
ds = Measure("ds")(subdomain_data=Surfaces)
A = FunctionSpace(mesh, "CG", 1)
B = FunctionSpace(mesh, "DG", 0)
Tn = Function(A)
Tn_plus_1 = Function(A)
timeStep = 1
heatFlux = 1
for i in range(1, 10):
##############################################################################
#Transient-heat
#Test & Trial functions (Temperature)
uA = TrialFunction(A)
vA = TestFunction(A)
uB = TrialFunction(B)
vB = TestFunction(B)
#Form (Temperature)
thermalForm = uA*vA*dx - Tn*vA*dx + Constant(timeStep)*inner(grad(uA),grad(vA))*dx - Constant(timeStep)*inner(heatFlux,vB)*ds(2)
a = lhs(thermalForm)
L = rhs(thermalForm)
#Solve
solve(a == L, Tn_plus_1)
#Update
Tn.assign(Tn_plus_1)
File('T.pvd') << Tn_plus_1
However I am getting the following error:
UFLException: Found different Arguments with same number and part.
Did you combine test or trial functions from different spaces?
The Arguments found are:
v_1
v_0
v_0
Is there a way to solve this problem using two different function spaces?
Many thanks