Skip to content
Snippets Groups Projects
Commit 84f01d31 authored by Stephan Hilb's avatar Stephan Hilb
Browse files

fix estimator per cell scaling

parent 3eaf3226
No related branches found
No related tags found
No related merge requests found
...@@ -156,6 +156,35 @@ end ...@@ -156,6 +156,35 @@ end
interpolate!(dst::FeFunction, ::DP1, expr::Function; params...) = interpolate!(dst::FeFunction, ::DP1, expr::Function; params...) =
interpolate!(dst, P1(), expr; params...) interpolate!(dst, P1(), expr; params...)
project!(dst::FeFunction, expr::Function; params...) =
project!(dst, dst.space.element, expr; params...)
function project!(dst::FeFunction, ::DP0, expr; params...)
# same as interpolate!, but scaling by cell size
params = NamedTuple(params)
space = dst.space
mesh = space.mesh
for cell in cells(mesh)
delmap = jacobian(elmap(mesh, cell), SA[0., 0.])
intel = abs(det(delmap))
for f in params
bind!(f, cell)
end
vertices = mesh.vertices[:, mesh.cells[:, cell]]
centroid = SArray{Tuple{ndims_domain(mesh)}}(mean(vertices, dims = 2))
lcentroid = SA[1/3, 1/3]
opvalues = map(f -> evaluate(f, lcentroid), params)
gdofs = space.dofmap[:, 1, cell]
dst.data[gdofs] .= myvec(expr(centroid; opvalues...)) .* intel
end
end
function bind!(f::FeFunction, cell) function bind!(f::FeFunction, cell)
f.ldata .= vec(f.data[f.space.dofmap[:, :, cell]]) f.ldata .= vec(f.data[f.space.dofmap[:, :, cell]])
return f return f
......
...@@ -200,7 +200,7 @@ function estimate!(ctx::L1L2TVContext) ...@@ -200,7 +200,7 @@ function estimate!(ctx::L1L2TVContext)
w = FeFunction(ctx.u.space) w = FeFunction(ctx.u.space)
nablaw = nabla(w) nablaw = nabla(w)
solve_primal!(w, ctx) solve_primal!(w, ctx)
interpolate!(ctx.est, estf; ctx.g, ctx.u, ctx.p1, ctx.p2, ctx.nablau, w, nablaw, ctx.tdata) project!(ctx.est, estf; ctx.g, ctx.u, ctx.p1, ctx.p2, ctx.nablau, w, nablaw, ctx.tdata)
end end
function refine(ctx::L1L2TVContext, marked_cells) function refine(ctx::L1L2TVContext, marked_cells)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment