Hello, everyone, may I ask a question? This question is confusing me.
uu=Function(V)
I want to construct a new vector: [ uu_{2x}, 1], where uu_{2x} is the x-derivative of uu second component.
And I try to construct as fellow,
n_ss=as_vector([uu[1].dx(0),1]),
but this way can not work.
The MME, which is a simple possion equation
from dolfin import *
# Create mesh and define function space
mesh = UnitSquareMesh(32, 32)
V = FunctionSpace(mesh, "Lagrange", 1)
# Define Dirichlet boundary (x = 0 or x = 1)
def boundary(x):
return x[0] < DOLFIN_EPS or x[0] > 1.0 - DOLFIN_EPS
# Define boundary condition
u0 = Constant(0.0)
bc = DirichletBC(V, u0, boundary)
# Define variational problem
u = TrialFunction(V)
v = TestFunction(V)
f = Expression('10*exp(-(pow(x[0] - 0.5, 2) + pow(x[1] - 0.5, 2)) / 0.02)',degree=2)
g = Expression('sin(5*x[0])',degree=2)
uu=Function(V)
n_ss=as_vector([uu[1].dx(0),1])
F = (inner(grad(u), grad(v)))*dx+dot(n_ss,v)*dx-f*v*dx - g*v*ds
a, L= lhs(F), rhs(F)
# Compute solution
u = Function(V)
solve(a == L, u, bc)
plot(u)