Skip to content
Snippets Groups Projects
Commit c83dc738 authored by Florian Atteneder's avatar Florian Atteneder
Browse files

mesh: implement differentiate for FVElement

parent a961f68b
No related branches found
No related tags found
1 merge request!101Refactor GRHD project
This commit is part of merge request !101. Comments created here will be created in the context of that merge request.
......@@ -411,6 +411,27 @@ function differentiate!(du, u, mesh::Mesh1d)
duk .*= invdetJk
end
end
function differentiate!(du, u, mesh::Mesh1d{FVElement})
@unpack x, invdetJ = get_static_variables(mesh.cache)
K, = mesh.tree.dims
for k in 2:K-1
du[k] = (u[k+1]-u[k-1])/(x[k+1]-x[k-1])
end
x1, x2, x3 = x[1], x[2], x[3]
M = [ 1 x1 x1^2;
1 x2 x2^2;
1 x3 x3^2 ]
uu = u[1:3]
b = M \ uu
du[1] = b[2] + 2*b[3]*x1
x1, x2, x3 = x[end], x[end-1], x[end-2]
M = [ 1 x1 x1^2;
1 x2 x2^2;
1 x3 x3^2 ]
uu = u[end:-1:end-2]
b = M \ uu
du[end] = b[2] + 2*b[3]*x1
end
function differentiate(u, mesh)
du = similar(u)
differentiate!(du, u, mesh)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment