Spatial dimension in assembling matrices
I'm trying to solve the wave equation in FEniCS. I've adapted the Poisson demos and the advection demo to try to integrate it. When I run this script I get an error "Need to know the spatial dimension to compute the shape of derivatives."
The error is associated with the assembly of the matrix A. I'm not sure how to go about debugging this error. Thanks,
Derek
from dolfin import *
from numpy import pi
# Create mesh and define function space
mesh = UnitSquare(100,100)
V = FunctionSpace(mesh, "CG", 1)
W = V*V
c0 = 1.0
# Parameters
T = 5.0
dt = 0.1
t = dt
# Define Dirichlet boundary (x = 0 or x = 1
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
# Define boundary condition
# (p0, g0) = Function(W)
p0 = Constant(0.0)
g0 = Constant(0.0)
bc = DirichletBC(W, (p0,g0), boundary)
# Define variational problem
(p, g) = TrialFunction(W)
(v, w) = TestFunction(W)
p_mid = 0.5*(p+p0)
g_mid = 0.5*(g+g0)
f = Constant(0.0)
a = v*(g-g0)*dx -w*(p-p0)*dx + dt * ( dot(grad(
L = f*dx
p1 = Point(0.1,0.1)
A = assemble(a)
bc.apply(A)
solver = LUSolver(A)
solver.
out_file = File("test.pvd")
while t<T:
b = assemble(L)
bc.apply(b)
delta = PointSource(V, p1, sin(2*pi*t))
delta.apply(b)
solver.
p0 = p
plot(p)
out_file<<(p,t)
t += dt
interactive()
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- DOLFIN Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Praveen C
- Solved:
- Last query:
- Last reply: