Skip to content

Commit 52cec03

Browse files
committed
NonConformingGridTopology: implemented get_faces
1 parent 8a90d4f commit 52cec03

File tree

2 files changed

+45
-8
lines changed

2 files changed

+45
-8
lines changed

test/dev/NonConformingGridTopologies.jl

Lines changed: 41 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ module NonConformingGridTopologies
33
using Gridap
44
using Gridap.Helpers
55

6-
import Gridap.Geometry: get_faces
76
using Gridap.Geometry: GridTopology
87
using Gridap.Geometry: UnstructuredGridTopology
98
using Gridap.Geometry: get_grid_topology
10-
using Gridap.Arrays: Table, length_to_ptrs!
9+
import Gridap.Geometry: get_faces
10+
using Gridap.Arrays: Table, length_to_ptrs!, lazy_append
1111

1212
using GridapDistributed
1313

@@ -40,7 +40,10 @@ module NonConformingGridTopologies
4040
map(Broadcasting(first),ncg.hanging_faces_glue)
4141

4242
hanging_faces_to_cell_ptrs =
43-
map(Broadcasting(ones),tfill(Int32,Val{D}()),ncg.num_hanging_faces.+1)
43+
map(Broadcasting(zeros),tfill(Int32,Val{D}()),
44+
ncg.num_regular_faces.+ncg.num_hanging_faces.+1)
45+
map(_ones_on_hanging_faces!,hanging_faces_to_cell_ptrs,
46+
ncg.num_hanging_faces)
4447
map(length_to_ptrs!,hanging_faces_to_cell_ptrs)
4548

4649
cell_to_hanging_faces_data =
@@ -69,7 +72,13 @@ module NonConformingGridTopologies
6972
Table(d,p)
7073
end
7174

72-
hanging_faces_to_coarse_cell, coarse_cell_to_hanging_faces
75+
coarse_cell_to_hanging_faces, hanging_faces_to_coarse_cell
76+
end
77+
78+
function _ones_on_hanging_faces!(
79+
ptrs::Vector{Int32},num_hanging_faces::Int)
80+
ptrs[end-num_hanging_faces+1:end] .= 1
81+
return nothing
7382
end
7483

7584
function _count_owned_hanging_faces(x::AbstractArray{<:Integer},num_cells::Int)
@@ -102,13 +111,37 @@ module NonConformingGridTopologies
102111
collect1d(ncgt.conforming_grid_topology.polytopes)
103112

104113
function get_faces(ncgt::NonConformingGridTopology{Dc,Dp,T,O},
105-
::Val{Dc},dimto::Integer) where {Dc,Dp,T,O}
106-
@show ncgt.coarse_cell_to_hanging_faces[dimto+1]
114+
dimfrom::Integer,dimto::Integer) where {Dc,Dp,T,O}
115+
get_faces(ncgt,Val{dimfrom}(),Val{dimto}())
116+
end
117+
118+
function get_faces(ncgt::NonConformingGridTopology{Dc,Dp,T,O},
119+
::Val{Df},::Val{Dt}) where {Dc,Dp,T,O,Df,Dt}
120+
get_faces(ncgt.conforming_grid_topology,Df,Dt)
121+
end
122+
123+
function get_faces(ncgt::NonConformingGridTopology{Dc,Dp,T,O},
124+
::Val{Dc},::Val{Dt}) where {Dc,Dp,T,O,Dt}
125+
r = get_faces(ncgt.conforming_grid_topology,Dc,Dt)
126+
h = ncgt.coarse_cell_to_hanging_faces[Dt+1]
127+
# Not sure which one of these is better
128+
# map(lazy_append,r,h)
129+
map(vcat,r,h)
130+
end
131+
132+
function get_faces(ncgt::NonConformingGridTopology{Dc,Dp,T,O},
133+
::Val{Df},::Val{Dc}) where {Dc,Dp,T,O,Df}
134+
r = get_faces(ncgt.conforming_grid_topology,Df,Dc)
135+
h = ncgt.hanging_faces_to_coarse_cell[Df+1]
136+
# Not sure which one of these is better
137+
# map(lazy_append,r,h)
138+
map(vcat,r,h)
107139
end
108140

141+
# Overload case dimfrom == dimto == Dc to avoid ambiguity
109142
function get_faces(ncgt::NonConformingGridTopology{Dc,Dp,T,O},
110-
dimfrom::Integer,::Val{Dc}) where {Dc,Dp,T,O}
111-
@show ncgt.hanging_faces_to_coarse_cell[dimfrom+1]
143+
::Val{Dc},::Val{Dc}) where {Dc,Dp,T,O}
144+
get_faces(ncgt.conforming_grid_topology,Dc,Dc)
112145
end
113146

114147
# What other procs do I need? Review CA (e.g., facet_to_inoutcut)

test/dev/eric_dev.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ module DistributedAggregationP4estMeshes
4242
get_faces(ncgt,0,D)
4343
get_faces(ncgt,D,1)
4444
get_faces(ncgt,1,D)
45+
get_faces(ncgt,D,2)
46+
get_faces(ncgt,2,D)
47+
# get_faces(ncgt,D,3)
48+
# get_faces(ncgt,3,D)
4549
end
4650

4751
end

0 commit comments

Comments
 (0)