Skip to content

Commit 5e913bc

Browse files
Merge pull request #188 from gridap/specialized_rt_constructor_for_dist_trian
Specialized rt constructor for dist trian
2 parents adb85be + e12d74f commit 5e913bc

File tree

3 files changed

+73
-12
lines changed

3 files changed

+73
-12
lines changed

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Added
1111

1212
- 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).
13+
- Added missing `FESpace` constructors for distributed triangulations specialized for the RT FEs case. Since PR[#188](https://github.com/gridap/GridapDistributed.jl/pull/188)
1314

1415
## [0.4.10] - 2025-09-29
1516

src/DivConformingFESpaces.jl

Lines changed: 60 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,78 @@
1-
21
function FESpaces.FESpace(model::DistributedDiscreteModel,
32
reffe::Tuple{RaviartThomas,Any,Any};
4-
conformity=nothing,kwargs...)
3+
conformity=nothing,
4+
split_own_and_ghost=false,
5+
constraint=nothing,
6+
kwargs...)
57

68
cell_reffes = map(local_views(model)) do m
79
basis,reffe_args,reffe_kwargs = reffe
810
cell_reffe = ReferenceFE(m,basis,reffe_args...;reffe_kwargs...)
911
end
10-
_common_fe_space_constructor(model,cell_reffes;conformity,kwargs...)
12+
_common_fe_space_constructor(model,cell_reffes;conformity,split_own_and_ghost,kwargs...)
1113
end
1214

1315
function FESpace(model::DistributedDiscreteModel,
1416
reffe::GenericRefFE{RaviartThomas};
15-
conformity=nothing, kwargs...)
17+
conformity=nothing,
18+
split_own_and_ghost=false,
19+
constraint=nothing,
20+
kwargs...)
1621
cell_reffes = map(local_views(model)) do m
1722
Fill(reffe,num_cells(m))
1823
end
19-
_common_fe_space_constructor(model,cell_reffes;conformity,kwargs...)
24+
_common_fe_space_constructor(model,cell_reffes;conformity,split_own_and_ghost,kwargs...)
25+
end
26+
27+
function _setup_dmodel_and_dtrian(_trian::DistributedTriangulation)
28+
trian = add_ghost_cells(_trian)
29+
models = map(local_views(trian)) do t
30+
get_active_model(t)
31+
end
32+
GenericDistributedDiscreteModel(models, generate_cell_gids(trian)), trian
33+
end
34+
35+
function FESpace(
36+
_trian::DistributedTriangulation,
37+
reffe::Tuple{RaviartThomas,Any,Any};
38+
conformity=nothing,
39+
split_own_and_ghost=false,
40+
constraint=nothing,kwargs...
41+
)
42+
dmodel, dtrian = _setup_dmodel_and_dtrian(_trian)
43+
cell_reffes = map(local_views(dmodel)) do m
44+
basis,reffe_args,reffe_kwargs = reffe
45+
cell_reffe = ReferenceFE(m,basis,reffe_args...;reffe_kwargs...)
46+
end
47+
_common_fe_space_constructor(dmodel,cell_reffes,dtrian;conformity,split_own_and_ghost,kwargs...)
48+
end
49+
50+
function FESpace(_trian::DistributedTriangulation,
51+
reffe::GenericRefFE{RaviartThomas};
52+
conformity=nothing,
53+
split_own_and_ghost=false,
54+
constraint=nothing,
55+
kwargs...)
56+
dmodel, dtrian = _setup_dmodel_and_dtrian(_trian)
57+
cell_reffes = map(local_views(dmodel)) do m
58+
Fill(reffe,num_cells(m))
59+
end
60+
_common_fe_space_constructor(dmodel,cell_reffes,dtrian;conformity,split_own_and_ghost,kwargs...)
61+
end
62+
63+
function _common_fe_space_constructor(model,cell_reffes,trian;conformity,split_own_and_ghost,kwargs...)
64+
sign_flips=_generate_sign_flips(model,cell_reffes)
65+
spaces = map(local_views(model),sign_flips,cell_reffes,local_views(trian)) do m,sign_flip,cell_reffe,trian
66+
conf = Conformity(testitem(cell_reffe),conformity)
67+
cell_fe = CellFE(m,cell_reffe,conf,sign_flip)
68+
FESpace(m, cell_fe; trian=trian, kwargs...)
69+
end
70+
gids = generate_gids(model,spaces)
71+
vector_type = _find_vector_type(spaces,gids;split_own_and_ghost=split_own_and_ghost)
72+
DistributedSingleFieldFESpace(spaces,gids,trian,vector_type)
2073
end
2174

22-
function _common_fe_space_constructor(model,cell_reffes;conformity,kwargs...)
75+
function _common_fe_space_constructor(model,cell_reffes;conformity,split_own_and_ghost,kwargs...)
2376
sign_flips=_generate_sign_flips(model,cell_reffes)
2477
spaces = map(local_views(model),sign_flips,cell_reffes) do m,sign_flip,cell_reffe
2578
conf = Conformity(testitem(cell_reffe),conformity)
@@ -28,7 +81,7 @@ function _common_fe_space_constructor(model,cell_reffes;conformity,kwargs...)
2881
end
2982
gids = generate_gids(model,spaces)
3083
trian = DistributedTriangulation(map(get_triangulation,spaces),model)
31-
vector_type = _find_vector_type(spaces,gids)
84+
vector_type = _find_vector_type(spaces,gids;split_own_and_ghost=split_own_and_ghost)
3285
DistributedSingleFieldFESpace(spaces,gids,trian,vector_type)
3386
end
3487

test/DivConformingTests.jl

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,10 @@ function setup_p2_model()
5959
Gridap.Geometry.UnstructuredDiscreteModel(grid)
6060
end
6161

62-
function f(model,reffe)
62+
function f(model,reffe,trian,das)
6363
V = FESpace(model,reffe,conformity=:Hdiv)
6464
U = TrialFESpace(V)
6565

66-
das = FullyAssembledRows()
67-
trian = Triangulation(das,model)
6866
degree = 2
6967
= Measure(trian,degree)
7068
a(u,v) = ( uv )*
@@ -82,6 +80,7 @@ function f(model,reffe)
8280
dc2 = dc.contribs.items[2]
8381
c1 = Gridap.CellData.get_contribution(dc1,t1)
8482
c2 = Gridap.CellData.get_contribution(dc2,t2)
83+
8584
tol = 1.0e-12
8685
@test norm(c1[1]-c2[2]) < tol
8786
@test norm(c1[2]-c2[1]) < tol
@@ -122,10 +121,18 @@ function main(distribute,nranks)
122121

123122
model = GridapDistributed.DistributedDiscreteModel(models,gids)
124123

124+
das = FullyAssembledRows()
125+
trian = Triangulation(das,model)
126+
125127
reffe=ReferenceFE(raviart_thomas,Float64,0)
126-
f(model,reffe)
128+
f(model,reffe,trian,das)
129+
f(trian,reffe,trian,das)
130+
f(Triangulation(model),reffe,trian,das)
131+
127132
reffe=ReferenceFE(QUAD, raviart_thomas, 0)
128-
f(model,reffe)
133+
f(model,reffe,trian,das)
134+
f(trian,reffe,trian,das)
135+
f(Triangulation(model),reffe,trian,das)
129136
end
130137

131138
end # module

0 commit comments

Comments
 (0)