Hi i am trying to solve equations in a mixed functionspace, i struggle with implementing the right formulation, as i am not able to add the functions, from the functionspace, although it is necessary to solve the equation over time.
The follwoing code:
from fenics import *
num_steps = 20 # number of time steps
dt = 0.005 # time step size
T = dt * num_steps # final time
t = 0
## declare mesh and submesh ###
height = 1.0
width = 1.0
length = 1.0
mesh = BoxMesh(Point(0.0, 0.0, 0.0), Point(length,width,height), 9, 9, 9)
marker = MeshFunction("size_t", mesh, mesh.topology().dim() - 1, 0)
for f in facets(mesh):
marker[f] = height - DOLFIN_EPS < f.midpoint().z() < height + DOLFIN_EPS
submesh = MeshView.create(marker, 1)
#Create Functionspace of two elements for the biharmonic equation
X = FiniteElement('CG', submesh.ufl_cell(), 2)
Y = FiniteElement('CG', submesh.ufl_cell(), 2)
Z = X * Y
S = FunctionSpace(submesh, Z)
#Create FunctionSpace for the heat equation
V = FunctionSpace(mesh, 'CG', 2)
#Create FunctionSpace for the whole domain
Omega = MixedFunctionSpace(S,V)
u_m = Function(Omega)
u_n = Function(Omega)
v_n = Function(Omega)
u_Plate, v_Volume = TrialFunctions(Omega)
phi, psi = TestFunctions(Omega)
dP = Measure('dx', domain = Omega.sub_space(0).mesh())
dV = Measure('dx', domain = Omega.sub_space(1).mesh())
a1 = -dt*dt*(inner(grad(u_Plate[0]),grad(phi[0])) + inner(grad(u_Plate[1]),grad(phi[1])) + u_Plate[1]*phi[0])*dP + (u_Plate[0]*phi[1])*dP
a2 = (inner(v_Volume,psi) + 2*dt * inner(grad(v_Volume), grad(psi)))*dV
a = a1 + a2
f = Constant(0.0)
fv = Constant(0.0)
L1 = (2*u_n[0]*phi[1] - u_m[0]*phi[1])*dP + dt*dt*(inner(f,phi[1]))*dP
L2 = (inner(v_n,psi) + dt*inner(fv,psi))*dV
L = L1 + L2
u_Platte = Function(Omega)
# Solve variational problem
solve(a == L, u_Platte, bcs , solver_parameters={"linear_solver":"direct"})
Throws following error message:
AttributeError: 'Function' object has no attribute '_ufl_shape'
How can i resolve this?