compute Directional derivative
I'd like to compute the directional derivative of a function in direction u:
F(u) = \nabla_u (p^T * h(u))
with h(u) = (y, u \cdot \nabla \phi )_{L_2}
and u = \sum_k u_k \psi_k
y = \sum_i y_i \phi_i
That means h(u) reads:
h(u)_ij = \sum_k u_k \sum_T \int_T \phi_j \nabla \phi_i \cdot psi_k dx * y_j
DF(u) in direction of u_k should be a scalar for each u_k:
p^T * \sum_T \int_T \phi \nabla \phi \cdot psi_k dx * y
That means, DF(u) containing in each entry the directional derivative should be a vector
of length u.
My question is how to implement the single phi_k in the derivative.
Here is the code i've tried:
x_max = 10.0 # maximum x-coordinate
y_max = 10.0 # maximum y-coordinate
# divergence of mesh
x_div = 10
y_div = 10
mesh = Rectangle(0,0, x_max, y_max, x_div, y_div)
mesh.order()
V = FunctionSpace(mesh, "Lagrange",2)
U = FunctionSpace(mesh, "Raviart-Thomas", 1)
y = Function(V)
phi = TrialFunction(V)
u = Function(U)
p = Function(V)
h = y*dot(grad(phi),u) *dx
# I've tried to use a function on Function Space W to extract the \psi - Functions,
but it always results in a vector of dimension of y instead of u.
W = FunctionSpace(mesh, "DG", 0)
w = Function(W)
DF_k = inner(p,
vec = assemble(DF_k) # VECTOR OF DIMENSION OF Y INSTEAD OF U ...
I don't find my mistake, so please could you help me?! Thanks a lot in advance.
Question information
- Language:
- English Edit question
- Status:
- Solved
- For:
- DOLFIN Edit question
- Assignee:
- No assignee Edit question
- Solved by:
- Martin Sandve Alnæs
- Solved:
- Last query:
- Last reply: