Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- New overloads for the `TrialFESpace` constructor where the data to be imposed is passed as a `DistributedCellField`. Since PR[#183](https://github.com/gridap/GridapDistributed.jl/pull/183).
- Added missing `FESpace` constructors for distributed triangulations specialized for the RT FEs case. Since PR[#188](https://github.com/gridap/GridapDistributed.jl/pull/188)

## [0.4.10] - 2025-09-29

Expand Down
67 changes: 60 additions & 7 deletions src/DivConformingFESpaces.jl
Original file line number Diff line number Diff line change
@@ -1,25 +1,78 @@

function FESpaces.FESpace(model::DistributedDiscreteModel,
reffe::Tuple{RaviartThomas,Any,Any};
conformity=nothing,kwargs...)
conformity=nothing,
split_own_and_ghost=false,
constraint=nothing,
kwargs...)

cell_reffes = map(local_views(model)) do m
basis,reffe_args,reffe_kwargs = reffe
cell_reffe = ReferenceFE(m,basis,reffe_args...;reffe_kwargs...)
end
_common_fe_space_constructor(model,cell_reffes;conformity,kwargs...)
_common_fe_space_constructor(model,cell_reffes;conformity,split_own_and_ghost,kwargs...)
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The constraint parameter is declared but not used. The function should call _add_distributed_constraint on the returned space before returning it, similar to how the general FESpace constructors handle constraints. This would enable constraint functionality like :zeromean for Raviart-Thomas spaces.

Copilot uses AI. Check for mistakes.
end

function FESpace(model::DistributedDiscreteModel,
reffe::GenericRefFE{RaviartThomas};
conformity=nothing, kwargs...)
conformity=nothing,
split_own_and_ghost=false,
constraint=nothing,
kwargs...)
cell_reffes = map(local_views(model)) do m
Fill(reffe,num_cells(m))
end
_common_fe_space_constructor(model,cell_reffes;conformity,kwargs...)
_common_fe_space_constructor(model,cell_reffes;conformity,split_own_and_ghost,kwargs...)
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The constraint parameter is declared but not used. The function should call _add_distributed_constraint on the returned space before returning it, similar to how the general FESpace constructors handle constraints. This would enable constraint functionality like :zeromean for Raviart-Thomas spaces.

Copilot uses AI. Check for mistakes.
end

function _setup_dmodel_and_dtrian(_trian::DistributedTriangulation)
trian = add_ghost_cells(_trian)
models = map(local_views(trian)) do t
get_active_model(t)
end
GenericDistributedDiscreteModel(models, generate_cell_gids(trian)), trian
end
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is trailing whitespace at the end of this line. Remove the trailing whitespace for consistency with code style.

Suggested change
end
end

Copilot uses AI. Check for mistakes.

function FESpace(
_trian::DistributedTriangulation,
reffe::Tuple{RaviartThomas,Any,Any};
conformity=nothing,
split_own_and_ghost=false,
constraint=nothing,kwargs...
)
dmodel, dtrian = _setup_dmodel_and_dtrian(_trian)
cell_reffes = map(local_views(dmodel)) do m
basis,reffe_args,reffe_kwargs = reffe
cell_reffe = ReferenceFE(m,basis,reffe_args...;reffe_kwargs...)
end
_common_fe_space_constructor(dmodel,cell_reffes,dtrian;conformity,split_own_and_ghost,kwargs...)
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The constraint parameter is declared but not used. The function should call _add_distributed_constraint on the returned space before returning it, similar to how the general FESpace constructors handle constraints. This would enable constraint functionality like :zeromean for Raviart-Thomas spaces constructed from triangulations.

Copilot uses AI. Check for mistakes.
end

function FESpace(_trian::DistributedTriangulation,
reffe::GenericRefFE{RaviartThomas};
conformity=nothing,
split_own_and_ghost=false,
constraint=nothing,
kwargs...)
dmodel, dtrian = _setup_dmodel_and_dtrian(_trian)
cell_reffes = map(local_views(dmodel)) do m
Fill(reffe,num_cells(m))
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is inconsistent indentation here - an extra space is present at the beginning of this line. Remove it for consistency with the surrounding code.

Suggested change
Fill(reffe,num_cells(m))
Fill(reffe,num_cells(m))

Copilot uses AI. Check for mistakes.
end
_common_fe_space_constructor(dmodel,cell_reffes,dtrian;conformity,split_own_and_ghost,kwargs...)
Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The constraint parameter is declared but not used. The function should call _add_distributed_constraint on the returned space before returning it, similar to how the general FESpace constructors handle constraints. This would enable constraint functionality like :zeromean for Raviart-Thomas spaces constructed from triangulations.

Copilot uses AI. Check for mistakes.
end

function _common_fe_space_constructor(model,cell_reffes,trian;conformity,split_own_and_ghost,kwargs...)
sign_flips=_generate_sign_flips(model,cell_reffes)
spaces = map(local_views(model),sign_flips,cell_reffes,local_views(trian)) do m,sign_flip,cell_reffe,trian
conf = Conformity(testitem(cell_reffe),conformity)
cell_fe = CellFE(m,cell_reffe,conf,sign_flip)
FESpace(m, cell_fe; trian=trian, kwargs...)
end
gids = generate_gids(model,spaces)
vector_type = _find_vector_type(spaces,gids;split_own_and_ghost=split_own_and_ghost)
DistributedSingleFieldFESpace(spaces,gids,trian,vector_type)
end

function _common_fe_space_constructor(model,cell_reffes;conformity,kwargs...)
function _common_fe_space_constructor(model,cell_reffes;conformity,split_own_and_ghost,kwargs...)
sign_flips=_generate_sign_flips(model,cell_reffes)
spaces = map(local_views(model),sign_flips,cell_reffes) do m,sign_flip,cell_reffe
conf = Conformity(testitem(cell_reffe),conformity)
Expand All @@ -28,7 +81,7 @@ function _common_fe_space_constructor(model,cell_reffes;conformity,kwargs...)
end
gids = generate_gids(model,spaces)
trian = DistributedTriangulation(map(get_triangulation,spaces),model)
vector_type = _find_vector_type(spaces,gids)
vector_type = _find_vector_type(spaces,gids;split_own_and_ghost=split_own_and_ghost)
DistributedSingleFieldFESpace(spaces,gids,trian,vector_type)
end

Expand Down
17 changes: 12 additions & 5 deletions test/DivConformingTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,10 @@ function setup_p2_model()
Gridap.Geometry.UnstructuredDiscreteModel(grid)
end

function f(model,reffe)
function f(model,reffe,trian,das)
V = FESpace(model,reffe,conformity=:Hdiv)
U = TrialFESpace(V)

das = FullyAssembledRows()
trian = Triangulation(das,model)
degree = 2
dΩ = Measure(trian,degree)
a(u,v) = ∫( u⋅v )*dΩ
Expand All @@ -82,6 +80,7 @@ function f(model,reffe)
dc2 = dc.contribs.items[2]
c1 = Gridap.CellData.get_contribution(dc1,t1)
c2 = Gridap.CellData.get_contribution(dc2,t2)

Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line contains only whitespace. Remove the trailing whitespace for consistency with code style.

Suggested change

Copilot uses AI. Check for mistakes.
tol = 1.0e-12
@test norm(c1[1]-c2[2]) < tol
@test norm(c1[2]-c2[1]) < tol
Expand Down Expand Up @@ -122,10 +121,18 @@ function main(distribute,nranks)

model = GridapDistributed.DistributedDiscreteModel(models,gids)

das = FullyAssembledRows()
trian = Triangulation(das,model)

reffe=ReferenceFE(raviart_thomas,Float64,0)
f(model,reffe)
f(model,reffe,trian,das)
f(trian,reffe,trian,das)
f(Triangulation(model),reffe,trian,das)

Copy link

Copilot AI Dec 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line contains only whitespace. Remove the trailing whitespace for consistency with code style.

Suggested change

Copilot uses AI. Check for mistakes.
reffe=ReferenceFE(QUAD, raviart_thomas, 0)
f(model,reffe)
f(model,reffe,trian,das)
f(trian,reffe,trian,das)
f(Triangulation(model),reffe,trian,das)
end

end # module