From 546035b3fefbbe4291775d7ac3c3c08aa72b9bcb Mon Sep 17 00:00:00 2001 From: Stephan Hilb <stephan@ecshi.net> Date: Tue, 25 Jan 2022 12:41:05 +0100 Subject: [PATCH] add basic mesh refinement test --- test/runtests.jl | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/runtests.jl b/test/runtests.jl index 906ec15..f91f879 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -28,3 +28,24 @@ Random.seed!(0) @test img == img_sampled end + +@testset "mesh refinement" begin + # simple hashing + val(f) = integrate(f.space.mesh, (x; f) -> dot(f, f); f) + + mesh = init_grid(zeros(5, 5)) + + f = FeFunction(FeSpace(mesh, P1(), (2, 3))) + f.data .= rand(size(f.data)...) + + for i = 1:2 + # refine roughly half of all cells + cells_ref = Set(findall(_ -> rand(Bool), cells(mesh))) + + mesh_new, (f_new,) = refine(mesh, cells_ref; f) + + @test isapprox(val(f), val(f_new)) + + (mesh, f) = (mesh_new, f_new) + end +end -- GitLab