diff --git a/src/mesh.jl b/src/mesh.jl index 10bcd1d5530ce7de0ad8895576fff134f0e8674d..86a9f23cfbb72d8b5e72476a91d225983a7616db 100644 --- a/src/mesh.jl +++ b/src/mesh.jl @@ -340,6 +340,14 @@ function save(filename::String, mesh::Mesh, fs...) vtk_save(vtk) end +function area(mesh, cell) + A = SArray{Tuple{ndims_space(mesh), nvertices_cell(mesh)}}( + view(mesh.vertices, :, view(mesh.cells, :, cell))) + return det(A[:, 2:3] .- A[:, 1]) / 2 +end + +area(mesh) = mapreduce(cell -> area(mesh, cell), +, cells(mesh)) + function diam(mesh, cell) A = SArray{Tuple{ndims_space(mesh), nvertices_cell(mesh)}}( view(mesh.vertices, :, view(mesh.cells, :, cell))) diff --git a/src/run.jl b/src/run.jl index 39a4a51a774bb6d902dc49defcede6641bbd036e..a92111124c2d2abbba85f4889759dbaa4a78e72e 100644 --- a/src/run.jl +++ b/src/run.jl @@ -310,12 +310,14 @@ function denoise(img; name, params...) estimate!(ctx) pvd[k] = save_denoise(ctx, k) println() + + norm_step = sqrt((norm_l2(ctx.du)^2 + norm_l2(ctx.dp1)^2 + norm_l2(ctx.dp2)^2) / area(mesh)) + println("ndofs: $(ndofs(ctx.u.space)), est: $(norm_l2(ctx.est)))") println("primal energy: $(primal_energy(ctx))") + println("norm_step: $(norm_step)") - norm_step = sqrt(norm_l2(ctx.du)^2 + norm_l2(ctx.dp1)^2 + norm_l2(ctx.dp2)) - norm_step = sqrt(norm_l2(ctx.du)^2) - norm_step <= 1e-2 && break + norm_step <= 1e-1 && break end marked_cells = mark(ctx; theta = 0.5) #println(marked_cells) @@ -327,7 +329,7 @@ function denoise(img; name, params...) ctx.g.data .= gnew.data #interpolate!(ctx.g, x -> norm(x .- m) < norm(m .- 1) / 3) - k >= 50 && break + k >= 100 && break end vtk_save(pvd) return ctx