From d066fa88860504610e8e9dc75c02c14afa8a4ca1 Mon Sep 17 00:00:00 2001 From: Francesc Verdugo Date: Fri, 6 Dec 2024 18:11:26 +0100 Subject: [PATCH 1/2] Caching more in AbstractFESpace --- src/interpolation.jl | 50 ++++++++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/src/interpolation.jl b/src/interpolation.jl index dd74e26..192af6e 100644 --- a/src/interpolation.jl +++ b/src/interpolation.jl @@ -307,6 +307,18 @@ end abstract type AbstractSpace <: GT.AbstractType end +function setup_space(space::AbstractSpace) + if space.cache !== nothing + return space + end + state = generate_dof_ids(space) + face_dofs = state.cell_to_dofs + free_and_dirichlet_dofs = state.free_and_dirichlet_dofs + dirichlet_dof_location = state.dirichlet_dof_location + cache = space_cache(;face_dofs,free_and_dirichlet_dofs,dirichlet_dof_location) + replace_cache(space,cache) +end + function space_cache(;kwargs...) (;kwargs...) end @@ -861,11 +873,17 @@ function face_dofs(space::AbstractSpace,field) end function free_and_dirichlet_dofs(V::AbstractSpace) + if V.cache !== nothing + return V.cache.free_and_dirichlet_dofs + end state = generate_dof_ids(V) state.free_and_dirichlet_dofs end function dirichlet_dof_location(V::AbstractSpace) + if V.cache !== nothing + return V.cache.dirichlet_dof_location + end state = generate_dof_ids(V) state.dirichlet_dof_location end @@ -1536,14 +1554,14 @@ struct IsoParametricSpace{A,B,C} <: AbstractSpace cache::C end -function setup_space(V::IsoParametricSpace) - if V.cache !== nothing - return V - end - face_dofs = GT.face_dofs(V) - cache = space_cache(;face_dofs) - replace_cache(V,cache) -end +#function setup_space(V::IsoParametricSpace) +# if V.cache !== nothing +# return V +# end +# face_dofs = GT.face_dofs(V) +# cache = space_cache(;face_dofs) +# replace_cache(V,cache) +#end function replace_cache(V::IsoParametricSpace,cache) GT.iso_parametric_space( @@ -1667,14 +1685,14 @@ struct LagrangeSpace{A,B,C,F,G,H,I} <: AbstractSpace cache::I end -function setup_space(space::LagrangeSpace) - if space.cache !== nothing - return space - end - face_dofs = GT.face_dofs(space) - cache = space_cache(;face_dofs) - replace_cache(space,cache) -end +#function setup_space(space::LagrangeSpace) +# if space.cache !== nothing +# return space +# end +# face_dofs = GT.face_dofs(space) +# cache = space_cache(;face_dofs) +# replace_cache(space,cache) +#end function replace_cache(space::LagrangeSpace,cache) GT.lagrange_space( From cba7510acaa64b7bc727b4668f32f3579d3a8f23 Mon Sep 17 00:00:00 2001 From: Francesc Verdugo Date: Fri, 6 Dec 2024 19:29:40 +0100 Subject: [PATCH 2/2] Fix IsoParametricSpace --- src/interpolation.jl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/interpolation.jl b/src/interpolation.jl index 192af6e..138d0f3 100644 --- a/src/interpolation.jl +++ b/src/interpolation.jl @@ -1554,14 +1554,14 @@ struct IsoParametricSpace{A,B,C} <: AbstractSpace cache::C end -#function setup_space(V::IsoParametricSpace) -# if V.cache !== nothing -# return V -# end -# face_dofs = GT.face_dofs(V) -# cache = space_cache(;face_dofs) -# replace_cache(V,cache) -#end +function setup_space(V::IsoParametricSpace) + if V.cache !== nothing + return V + end + face_dofs = GT.face_dofs(V) + cache = space_cache(;face_dofs) + replace_cache(V,cache) +end function replace_cache(V::IsoParametricSpace,cache) GT.iso_parametric_space(