VectorFunctionSpace with Raviart-Thomas elements


340
views
0
6 months ago by
Hello, I am trying to discretize matrix-valued H(div) functions with Raviart-Thomas elements. Unfortunately, I cannot assemble these functions. For example, the program below crushes. 
from fenics import *

mesh = UnitSquareMesh(2,2)
f = Constant(((1,1),(1,1)))

RTxRT = VectorFunctionSpace(mesh,'RT',1)
sigma = interpolate(f,RTxRT)

res = assemble(inner(sigma,sigma)*dx)​
Is there a way to circumvent this problem? Best regards, Johannes
Community: FEniCS Project

2 Answers


2
6 months ago by
Sorry, did not understand the problem in the first answer. Behaviour is a bit non-intuitive, but as workaround try
from dolfin import *

mesh = UnitSquareMesh(2,2)
f = Constant((1, 1, 1, 1))

RT_elem = FiniteElement("RT", triangle, 1)
RTxRT = FunctionSpace(mesh, MixedElement([RT_elem, RT_elem]))

sigma = interpolate(f, RTxRT)

res = assemble(inner(sigma, sigma) * dx)​

Note that I am defining the whole space via MixedElement and also note, the Constant expression is now flattened.
An alternative workaround reads:
from fenics import *

mesh = UnitSquareMesh(2,2)
f = Constant(((1,1),(1,1)))

RTxRT = VectorFunctionSpace(mesh,'RT',1)
sigma = interpolate(f,RTxRT)

DGtensor_elem = TensorElement('DG',mesh.ufl_cell(),1)  
DGtensor_space = FunctionSpace(mesh,DGtensor_elem)
DGtensor_h = interpolate(sigma,DGtensor_space)

res = assemble(inner(DGtensor_h,DGtensor_h)*dx)​
written 5 months ago by Johannes  
1
6 months ago by
VectorFunctionSpace is a symbolic short-hand for saying: "give me n-tuple of the following space." For that reason, even though the Raviart-Thomas space is space of vector functions you must call
RT = FunctionSpace(mesh, "RT", 1)​
 and keep in mind that members of RT are functions with vector rank.
Hello, I want to discretize the space H(div,Ω)2  = H(div,Ω) x H(div,Ω). Therefore, I need a tupel of Raviart-Thomas functions. Interpolate seems to work. I do not understand, why assemble fails.
written 6 months ago by Johannes  
Please login to add an answer/comment or follow this question.

Similar posts:
Search »