Skip to content

Commit

Permalink
Merge pull request #1042 from gridap/conforming-fespaces
Browse files Browse the repository at this point in the history
Save conformity info for ConformingFESpaces
  • Loading branch information
JordiManyer authored Nov 8, 2024
2 parents 06de5f7 + 273e52d commit 21c4751
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 20 deletions.
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- Fixed constructor of RungeKutta with only one solver. Since PR[#999](https://github.com/gridap/Gridap.jl/pull/999).

### Changed

- Conforming FESpaces now keep track of their `CellConformity` info, within the `metadata` field. Since PR[#1042](https://github.com/gridap/Gridap.jl/pull/1042).

## [0.18.6] - 2024-08-29

### Fixed
Expand Down
3 changes: 2 additions & 1 deletion src/FESpaces/CLagrangianFESpaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ function CLagrangianFESpace(
dirichlet_dof_tag,
dirichlet_cells,
ntags,
glue)
glue
)

space
end
Expand Down
29 changes: 18 additions & 11 deletions src/FESpaces/ConformingFESpaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ function CellFE(
cell_dof_basis,
cell_shapefuns_domain,
cell_dof_basis_domain,
max_order)
max_order
)
end

function get_cell_dof_basis(model::DiscreteModel,
Expand Down Expand Up @@ -146,13 +147,15 @@ function _ConformingFESpace(
ntags = length(dirichlet_tags)

cell_dofs_ids, nfree, ndirichlet, dirichlet_dof_tag, dirichlet_cells = compute_conforming_cell_dofs(
cell_fe,CellConformity(cell_fe),grid_topology,face_labeling,dirichlet_tags,dirichlet_components)

cell_fe,CellConformity(cell_fe),grid_topology,face_labeling,dirichlet_tags,dirichlet_components
)

cell_shapefuns, cell_dof_basis = compute_cell_space(cell_fe,trian)

cell_is_dirichlet = fill(false,num_cells(trian))
cell_is_dirichlet[dirichlet_cells] .= true

metadata = CellConformity(cell_fe)
UnconstrainedFESpace(
vector_type,
nfree,
Expand All @@ -163,24 +166,28 @@ function _ConformingFESpace(
cell_is_dirichlet,
dirichlet_dof_tag,
dirichlet_cells,
ntags)
ntags,
metadata
)
end

function compute_cell_space(cell_shapefuns::AbstractArray{<:AbstractArray{<:Field}},
cell_dof_basis::AbstractArray{<:AbstractArray{<:Dof}},
cell_shapefuns_domain::DomainStyle,
cell_dof_basis_domain::DomainStyle,
trian::Triangulation)
SingleFieldFEBasis(cell_shapefuns,trian,TestBasis(),cell_shapefuns_domain),
CellDof(cell_dof_basis,trian,cell_dof_basis_domain)
SingleFieldFEBasis(cell_shapefuns,trian,TestBasis(),cell_shapefuns_domain),
CellDof(cell_dof_basis,trian,cell_dof_basis_domain)
end

function compute_cell_space(cellfe::CellFE,trian::Triangulation)
compute_cell_space(cellfe.cell_shapefuns,
cellfe.cell_dof_basis,
cellfe.cell_shapefuns_domain,
cellfe.cell_dof_basis_domain,
trian)
compute_cell_space(
cellfe.cell_shapefuns,
cellfe.cell_dof_basis,
cellfe.cell_shapefuns_domain,
cellfe.cell_dof_basis_domain,
trian
)
end

function compute_cell_space(cell_fe,trian::Triangulation)
Expand Down
10 changes: 5 additions & 5 deletions src/FESpaces/DiscontinuousFESpaces.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ function _DiscontinuousFESpace(
cell_is_dirichlet = Fill(false,num_cells(trian))
ntags = 0

metadata = CellConformity(cell_fe)
UnconstrainedFESpace(
vector_type,
nfree,
Expand All @@ -24,23 +25,22 @@ function _DiscontinuousFESpace(
cell_is_dirichlet,
dirichlet_dof_tag,
dirichlet_cells,
ntags)
ntags,
metadata
)
end

function compute_discontinuous_cell_dofs(cell_to_ctype,ctype_to_nldofs)

ncells = length(cell_to_ctype)
ptrs = zeros(Int32,ncells+1)
for (cell, ctype) in enumerate(cell_to_ctype)
nldofs = ctype_to_nldofs[ctype]
ptrs[cell+1] = nldofs
end

length_to_ptrs!(ptrs)

ndata = ptrs[end]-1
data = collect(Int32,1:ndata)

(Table(data,ptrs), ndata)

end
6 changes: 3 additions & 3 deletions test/FESpacesTests/CLagrangianFESpacesTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,11 @@ V = CLagrangianFESpace(VectorValue{2,Float64},grid,Vector{Float64},node_to_tag,m

reffe = ReferenceFE(lagrangian,Float64,2)
V = FESpace(model,reffe)
@test V.metadata === nothing
@test isa(V.metadata, FESpaces.CellConformity)

reffe = ReferenceFE(lagrangian,Float64,1)
V = FESpace(model,reffe,conformity=:L2)
@test V.metadata === nothing
@test isa(V.metadata, FESpaces.CellConformity)

# Check that the factory uses clagrangian when possible

Expand Down Expand Up @@ -107,6 +107,6 @@ partition = (3,3)
model = CartesianDiscreteModel(domain,partition,isperiodic=(false,true))
reffe = ReferenceFE(lagrangian,Float64,1)
V = FESpace(model,reffe)
@test V.metadata === nothing
@test isa(V.metadata, FESpaces.CellConformity)

end # module

0 comments on commit 21c4751

Please sign in to comment.