From b741a9a4f169212c785fe494dbaceb6809baa296 Mon Sep 17 00:00:00 2001 From: JordiManyer Date: Fri, 3 Jan 2025 09:41:50 +1100 Subject: [PATCH] Minor --- src/FESpaces/Pullbacks.jl | 33 +++++++++++-------- .../EdgeBasedRefinementTests.jl | 4 --- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/src/FESpaces/Pullbacks.jl b/src/FESpaces/Pullbacks.jl index 8afd972a6..26386fc1d 100644 --- a/src/FESpaces/Pullbacks.jl +++ b/src/FESpaces/Pullbacks.jl @@ -53,23 +53,28 @@ function get_cell_pushforward( return CoVariantPiolaMap(), change, (Jt,) end -# SignFlipMap +# NormalSignMap -struct SignFlipMap{T} <: Map +""" + struct NormalSignMap <: Map + ... + end +""" +struct NormalSignMap{T} <: Map model::T facet_owners::Vector{Int32} end -function SignFlipMap(model) +function NormalSignMap(model) facet_owners = compute_facet_owners(model) - SignFlipMap(model,facet_owners) + NormalSignMap(model,facet_owners) end -function return_value(k::SignFlipMap,reffe,facet_own_dofs,cell) +function return_value(k::NormalSignMap,reffe,facet_own_dofs,cell) Diagonal(fill(one(Float64), num_dofs(reffe))) end -function return_cache(k::SignFlipMap,reffe,facet_own_dofs,cell) +function return_cache(k::NormalSignMap,reffe,facet_own_dofs,cell) model = k.model Dc = num_cell_dims(model) topo = get_grid_topology(model) @@ -80,25 +85,25 @@ function return_cache(k::SignFlipMap,reffe,facet_own_dofs,cell) return cell_facets, cell_facets_cache, CachedVector(Float64) end -function evaluate!(cache,k::SignFlipMap,reffe,facet_own_dofs,cell) - cell_facets,cell_facets_cache,sign_flip_cache = cache +function evaluate!(cache,k::NormalSignMap,reffe,facet_own_dofs,cell) + cell_facets,cell_facets_cache,dof_sign_cache = cache facet_owners = k.facet_owners - setsize!(sign_flip_cache, (num_dofs(reffe),)) - sign_flip = sign_flip_cache.array - fill!(sign_flip, one(eltype(sign_flip))) + setsize!(dof_sign_cache, (num_dofs(reffe),)) + dof_sign = dof_sign_cache.array + fill!(dof_sign, one(eltype(dof_sign))) facets = getindex!(cell_facets_cache,cell_facets,cell) for (lfacet,facet) in enumerate(facets) owner = facet_owners[facet] if owner != cell for dof in facet_own_dofs[lfacet] - sign_flip[dof] = -1.0 + dof_sign[dof] = -1.0 end end end - return Diagonal(sign_flip) + return Diagonal(dof_sign) end function get_sign_flip(model::DiscreteModel{Dc}, cell_reffe) where Dc @@ -106,7 +111,7 @@ function get_sign_flip(model::DiscreteModel{Dc}, cell_reffe) where Dc get_facet_own_dofs(reffe) = view(get_face_own_dofs(reffe),get_dimrange(get_polytope(reffe),Dc-1)) cell_facet_own_dofs = lazy_map(get_facet_own_dofs, cell_reffe) cell_ids = IdentityVector(Int32(num_cells(model))) - return lazy_map(SignFlipMap(model), cell_reffe, cell_facet_own_dofs, cell_ids) + return lazy_map(NormalSignMap(model), cell_reffe, cell_facet_own_dofs, cell_ids) end function compute_facet_owners(model::DiscreteModel{Dc}) where {Dc} diff --git a/test/AdaptivityTests/EdgeBasedRefinementTests.jl b/test/AdaptivityTests/EdgeBasedRefinementTests.jl index d68ec1cad..929b26556 100644 --- a/test/AdaptivityTests/EdgeBasedRefinementTests.jl +++ b/test/AdaptivityTests/EdgeBasedRefinementTests.jl @@ -38,8 +38,6 @@ function test_grid_transfers(parent,model,order) U_f = TrialFESpace(V_f,sol) V_c = TestFESpace(parent,reffe;dirichlet_tags="boundary") U_c = TrialFESpace(V_c,sol) - V_c_fast = TestFESpace(parent,rrules,reffe;dirichlet_tags="boundary") - U_c_fast = TrialFESpace(V_c_fast,sol) # CellField: Coarse -> Fine cf_c_phy = CellField(sol,ctrian) @@ -78,14 +76,12 @@ function test_grid_transfers(parent,model,order) uh_c_inter = interpolate(uh_f,U_c) uh_c_inter2 = interpolate_everywhere(uh_f,U_c) uh_c_inter3 = interpolate_dirichlet(uh_f,U_c) - uh_c_inter4 = interpolate(uh_f,U_c_fast) @test l2_error(uh_f,uh_f_inter,dΩ_f) < 1.e-8 @test l2_error(uh_f,uh_f_inter2,dΩ_f) < 1.e-8 @test l2_error(uh_c,uh_c_inter,dΩ_c) < 1.e-8 @test l2_error(uh_c,uh_c_inter2,dΩ_c) < 1.e-8 - @test l2_error(uh_c,uh_c_inter4,dΩ_c) < 1.e-8 # Coarse FEFunction -> Fine FEFunction, by projection af(u,v) = ∫(v⋅u)*dΩ_f