Skip to content

Commit

Permalink
Now saving cell conformity within the FESpaceLevel
Browse files Browse the repository at this point in the history
  • Loading branch information
JordiManyer committed Dec 5, 2023
1 parent 696565c commit 7704503
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 7 deletions.
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ GridapPETSc = "bcdc36c2-0c3e-11ea-095a-c9dadae499f1"
IterativeSolvers = "42fd0dbc-a981-5370-80f2-aaf504508153"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195"
P4est_wrapper = "3743d7c0-8adf-11ea-380b-7d33b0ecc1da"
PartitionedArrays = "5a9dfac6-5c52-46f7-8278-5e2210713be9"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Expand Down
33 changes: 26 additions & 7 deletions src/MultilevelTools/FESpaceHierarchies.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
struct FESpaceHierarchyLevel{A,B}
level :: Int
fe_space :: A
fe_space_red :: B
struct FESpaceHierarchyLevel{A,B,C}
level :: Int
fe_space :: A
fe_space_red :: B
cell_conformity :: C
end

struct FESpaceHierarchy
Expand Down Expand Up @@ -44,23 +45,41 @@ end

# Test/Trial FESpaces for ModelHierarchyLevels

function _cell_conformity(model::DiscreteModel,
reffe::Tuple{<:Gridap.FESpaces.ReferenceFEName,Any,Any};
conformity=nothing, kwargs...)
basis, reffe_args, reffe_kwargs = reffe
cell_reffe = ReferenceFE(model,basis,reffe_args...;reffe_kwargs...)
conformity = Conformity(Gridap.Arrays.testitem(cell_reffe),conformity)
return CellConformity(cell_reffe,conformity)
end

function _cell_conformity(model::GridapDistributed.DistributedDiscreteModel,args...;kwargs...)
cell_conformities = map(local_views(model)) do model
_cell_conformity(model,args...;kwargs...)
end
return cell_conformities
end

function Gridap.FESpaces.FESpace(
mh::ModelHierarchyLevel{A,B,C,Nothing},args...;kwargs...) where {A,B,C}
Vh = FESpace(get_model(mh),args...;kwargs...)
FESpaceHierarchyLevel(mh.level,Vh,nothing)
cell_conformity = _cell_conformity(get_model(mh),args...;kwargs...)
return FESpaceHierarchyLevel(mh.level,Vh,nothing,cell_conformity)
end

function Gridap.FESpaces.FESpace(mh::ModelHierarchyLevel{A,B,C,D},args...;kwargs...) where {A,B,C,D}
cparts, _ = get_old_and_new_parts(mh.red_glue,Val(false))
Vh = i_am_in(cparts) ? FESpace(get_model_before_redist(mh),args...;kwargs...) : nothing
Vh_red = FESpace(get_model(mh),args...;kwargs...)
FESpaceHierarchyLevel(mh.level,Vh,Vh_red)
cell_conformity = _cell_conformity(get_model(mh),args...;kwargs...)
return FESpaceHierarchyLevel(mh.level,Vh,Vh_red,cell_conformity)
end

function Gridap.FESpaces.TrialFESpace(a::FESpaceHierarchyLevel,args...;kwargs...)
Uh = !isa(a.fe_space,Nothing) ? TrialFESpace(a.fe_space,args...;kwargs...) : nothing
Uh_red = !isa(a.fe_space_red,Nothing) ? TrialFESpace(a.fe_space_red,args...;kwargs...) : nothing
FESpaceHierarchyLevel(a.level,Uh,Uh_red)
return FESpaceHierarchyLevel(a.level,Uh,Uh_red,a.cell_conformity)
end

# Test/Trial FESpaces for ModelHierarchies/FESpaceHierarchy
Expand Down
1 change: 1 addition & 0 deletions src/MultilevelTools/MultilevelTools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ using Gridap.Algebra
using Gridap.Geometry
using Gridap.FESpaces
using Gridap.Adaptivity
using Gridap.ReferenceFEs
using PartitionedArrays

using GridapDistributed
Expand Down

0 comments on commit 7704503

Please sign in to comment.