0

我正在研究 fenics 中的混合配方。运行代码时,它给了我一个错误:UFLException:无法添加具有不同形状的表达式。我是新手。任何人都可以帮助我完整的代码是

mesh = UnitSquareMesh(10,10)
RT1 = VectorElement("RT", mesh.ufl_cell(), 1)
CG1 = FiniteElement("CG", mesh.ufl_cell(), 1)
RT2 = VectorElement("RT", mesh.ufl_cell(), 1)
mixed = MixedElement([RT1, CG1, RT1])
W = FunctionSpace(mesh, mixed) 
(vpsi, vphi, vbigphi ) = TestFunctions(W)
trials_1 = TrialFunction(W) 
Sol1, Sol0 = Function(W) , Function(W)
(psi1, phi1, bigphi1) = split(Sol1)
(psi0, phi0, bigphi0) = split(Sol0)
def boundary(x):
return x[0] < DOLFIN_EPS or x[0] > 1.0 - DOLFIN_EPS or
x[1] < DOLFIN_EPS or x[1] > 1.0 - DOLFIN_EPS
      
 u00 = Constant(0.0)
 bc1 = DirichletBC(V2, u00, boundary)
 uinitial = Expression(" exp(x[1] + x[0] - t)", t = 0, degree = 2)
 u0 = interpolate(uinitial, V2)
 q0 = interpolate(grad(uinitial), V1)
 a2 = (dot(bigphi1, vpsi) -  ( 1/(1 + u0**2) + 1 )*dot(psi1, vpsi) )* dx
4

1 回答 1

0

我的代码使用

RT1 = FiniteElement("RT", mesh.ufl_cell(), 1)

代替

RT1 = VectorElement("RT", mesh.ufl_cell(), 1)

于 2020-08-25T06:45:37.187 回答