@@ -54,33 +54,181 @@ function AgFEMSpace(
5454 FESpaceWithLinearConstraints (aggdof_to_fdof,aggdof_to_dofs,aggdof_to_coeffs,f)
5555end
5656
57+ function _setup_agfem_constraints (
58+ n_fdofs,
59+ acell_to_acellin,
60+ acell_to_dof_ids,
61+ acell_to_coeffs,
62+ acell_to_proj,
63+ acell_to_gcell,
64+ acell_to_is_owned= fill (true ,length (acell_to_acellin)))
65+
66+ fdof_to_is_agg, fdof_to_acell, fdof_to_ldof =
67+ _allocate_fdof_to_data (n_fdofs)
68+
69+ _fill_fdof_to_data! (fdof_to_is_agg,
70+ fdof_to_acell,
71+ fdof_to_ldof,
72+ acell_to_acellin,
73+ acell_to_dof_ids,
74+ acell_to_gcell)
75+
76+ aggdof_to_fdof = findall (fdof_to_is_agg)
77+
78+ n_aggdofs = length (aggdof_to_fdof)
79+ aggdof_to_dofs_ptrs = zeros (Int32,n_aggdofs+ 1 )
80+
81+ _fill_aggdof_to_dofs_ptrs! (aggdof_to_dofs_ptrs,
82+ aggdof_to_fdof,
83+ fdof_to_acell,
84+ acell_to_acellin,
85+ acell_to_dof_ids,
86+ acell_to_is_owned)
87+
88+ aggdof_to_dofs_data, aggdof_to_coeffs_data =
89+ _allocate_aggdof_to_data (aggdof_to_dofs_ptrs,
90+ acell_to_coeffs)
91+
92+ _fill_aggdof_to_dofs_data! (aggdof_to_dofs_data,
93+ aggdof_to_dofs_ptrs,
94+ aggdof_to_fdof,
95+ fdof_to_acell,
96+ acell_to_acellin,
97+ acell_to_dof_ids,
98+ acell_to_is_owned)
99+
100+ _fill_aggdof_to_coeffs_data! (aggdof_to_coeffs_data,
101+ aggdof_to_dofs_ptrs,
102+ aggdof_to_fdof,
103+ fdof_to_acell,
104+ fdof_to_ldof,
105+ acell_to_coeffs,
106+ acell_to_proj,
107+ acell_to_is_owned)
108+
109+ aggdof_to_dofs = Table (aggdof_to_dofs_data,
110+ aggdof_to_dofs_ptrs)
111+ aggdof_to_coeffs = Table (aggdof_to_coeffs_data,
112+ aggdof_to_dofs_ptrs)
113+
114+ aggdof_to_fdof, aggdof_to_dofs, aggdof_to_coeffs
115+ end
116+
117+ function _alloc_and_fill_aggdof_to_dofs_ptrs (
118+ n_fdofs,
119+ acell_to_acellin,
120+ acell_to_dof_ids,
121+ acell_to_gcell,
122+ acell_to_is_owned)
123+
124+ fdof_to_is_agg, fdof_to_acell, fdof_to_ldof =
125+ _allocate_fdof_to_data (n_fdofs)
126+
127+ _fill_fdof_to_data! (fdof_to_is_agg,
128+ fdof_to_acell,
129+ fdof_to_ldof,
130+ acell_to_acellin,
131+ acell_to_dof_ids,
132+ acell_to_gcell)
133+
134+ aggdof_to_fdof = findall (fdof_to_is_agg)
135+
136+ n_aggdofs = length (aggdof_to_fdof)
137+ aggdof_to_dofs_ptrs = zeros (Int32,n_aggdofs+ 1 )
138+
139+ _fill_aggdof_to_dofs_ptrs! (aggdof_to_dofs_ptrs,
140+ aggdof_to_fdof,
141+ fdof_to_acell,
142+ acell_to_acellin,
143+ acell_to_dof_ids,
144+ acell_to_is_owned)
145+
146+ aggdof_to_dofs_ptrs, aggdof_to_fdof, fdof_to_acell, fdof_to_ldof
147+ end
148+
149+ function _alloc_and_fill_aggdof_to_dofs_data (
150+ aggdof_to_fdof,
151+ aggdof_to_dofs_ptrs,
152+ acell_to_acellin,
153+ acell_to_dof_ids,
154+ acell_to_coeffs,
155+ acell_to_proj,
156+ acell_to_is_owned,
157+ fdof_to_acell,
158+ fdof_to_ldof)
159+
160+ aggdof_to_dofs_data, aggdof_to_coeffs_data =
161+ _allocate_aggdof_to_data (aggdof_to_dofs_ptrs,
162+ acell_to_coeffs)
163+
164+ _fill_aggdof_to_dofs_data! (aggdof_to_dofs_data,
165+ aggdof_to_dofs_ptrs,
166+ aggdof_to_fdof,
167+ fdof_to_acell,
168+ acell_to_acellin,
169+ acell_to_dof_ids,
170+ acell_to_is_owned)
171+
172+ _fill_aggdof_to_coeffs_data! (aggdof_to_coeffs_data,
173+ aggdof_to_dofs_ptrs,
174+ aggdof_to_fdof,
175+ fdof_to_acell,
176+ fdof_to_ldof,
177+ acell_to_coeffs,
178+ acell_to_proj,
179+ acell_to_is_owned)
180+
181+ aggdof_to_dofs = Table (aggdof_to_dofs_data,
182+ aggdof_to_dofs_ptrs)
183+ aggdof_to_coeffs = Table (aggdof_to_coeffs_data,
184+ aggdof_to_dofs_ptrs)
185+
186+ aggdof_to_dofs, aggdof_to_coeffs
187+ end
188+
189+ function _fill_acell_to_acellin_and_to_gcell (trian_a,bgcell_to_bgcellin,bgcell_to_gcell)
190+ D = num_cell_dims (trian_a)
191+ glue = get_glue (trian_a,Val (D))
192+ acell_to_bgcell = glue. tface_to_mface
193+ bgcell_to_acell = glue. mface_to_tface
194+ acell_to_bgcellin =
195+ collect (lazy_map (Reindex (bgcell_to_bgcellin),acell_to_bgcell))
196+ T = eltype (bgcell_to_acell)
197+ acell_to_acellin = map (acell_to_bgcellin) do bgcin
198+ iszero (bgcin) ? zero (T) : T (bgcell_to_acell[bgcin])
199+ end
200+ acell_to_gcell = lazy_map (Reindex (bgcell_to_gcell),acell_to_bgcell)
201+ acell_to_acellin, acell_to_gcell
202+ end
203+
57204function _allocate_fdof_to_data (n_fdofs)
58- fdof_to_isagg = fill (true ,n_fdofs)
205+ fdof_to_is_agg = fill (true ,n_fdofs)
59206 fdof_to_acell = zeros (Int32,n_fdofs)
60207 fdof_to_ldof = zeros (Int16,n_fdofs)
61- fdof_to_isagg , fdof_to_acell, fdof_to_ldof
208+ fdof_to_is_agg , fdof_to_acell, fdof_to_ldof
62209end
63210
64211function _fill_fdof_to_data! (
65- fdof_to_isagg ,
212+ fdof_to_is_agg ,
66213 fdof_to_acell,
67214 fdof_to_ldof,
68215 acell_to_acellin,
69216 acell_to_dof_ids,
70217 acell_to_gcell)
71218
72- n_acells = length (acell_to_acellin)
219+ # RMK: There can be owned dofs sitting around non-owned
220+ # cells that are mapped to an acell for which acellin is
221+ # zero (i.e., outside the ghost layer).
73222 cache = array_cache (acell_to_dof_ids)
74- for acell in 1 : n_acells
75- acellin = acell_to_acellin[acell]
223+ for (acell, acellin) in enumerate (acell_to_acellin)
76224 iscut = acell != acellin
77225 dofs = getindex! (cache,acell_to_dof_ids,acell)
78226 gcell = acell_to_gcell[acell]
79227 for (ldof,dof) in enumerate (dofs)
80228 if dof > 0
81229 fdof = dof
82230 acell_dof = fdof_to_acell[fdof]
83- fdof_to_isagg [fdof] &= iscut
231+ fdof_to_is_agg [fdof] &= iscut
84232 if acell_dof == 0 || gcell > acell_to_gcell[acell_dof]
85233 fdof_to_acell[fdof] = acell
86234 fdof_to_ldof[fdof] = ldof
@@ -97,12 +245,12 @@ function _fill_aggdof_to_dofs_ptrs!(
97245 fdof_to_acell,
98246 acell_to_acellin,
99247 acell_to_dof_ids,
100- fdof_to_is_owned = fill ( true , length (fdof_to_acell)) )
248+ acell_to_is_owned )
101249
102250 cache = array_cache (acell_to_dof_ids)
103251 for (aggdof,fdof) in enumerate (aggdof_to_fdof)
104- ! fdof_to_is_owned[fdof] && continue
105252 acell = fdof_to_acell[fdof]
253+ ! acell_to_is_owned[acell] && continue
106254 acellin = acell_to_acellin[acell]
107255 dofs = getindex! (cache,acell_to_dof_ids,acellin)
108256 aggdof_to_dofs_ptrs[aggdof+ 1 ] = length (dofs)
@@ -127,12 +275,12 @@ function _fill_aggdof_to_dofs_data!(
127275 fdof_to_acell,
128276 acell_to_acellin,
129277 acell_to_dof_ids,
130- fdof_to_is_owned = fill ( true , length (fdof_to_acell)) )
278+ acell_to_is_owned )
131279
132280 cache = array_cache (acell_to_dof_ids)
133281 for (aggdof,fdof) in enumerate (aggdof_to_fdof)
134- ! fdof_to_is_owned[fdof] && continue
135282 acell = fdof_to_acell[fdof]
283+ ! acell_to_is_owned[acell] && continue
136284 acellin = acell_to_acellin[acell]
137285 dofs = getindex! (cache,acell_to_dof_ids,acellin)
138286 p = aggdof_to_dofs_ptrs[aggdof]- 1
@@ -151,7 +299,7 @@ function _fill_aggdof_to_coeffs_data!(
151299 fdof_to_ldof,
152300 acell_to_coeffs,
153301 acell_to_proj,
154- fdof_to_is_owned = fill ( true , length (fdof_to_acell)) )
302+ acell_to_is_owned )
155303
156304 cache2 = array_cache (acell_to_coeffs)
157305 cache3 = array_cache (acell_to_proj)
@@ -160,8 +308,8 @@ function _fill_aggdof_to_coeffs_data!(
160308 z = zero (T)
161309
162310 for (aggdof,fdof) in enumerate (aggdof_to_fdof)
163- ! fdof_to_is_owned[fdof] && continue
164311 acell = fdof_to_acell[fdof]
312+ ! acell_to_is_owned[acell] && continue
165313 coeffs = getindex! (cache2,acell_to_coeffs,acell)
166314 proj = getindex! (cache3,acell_to_proj,acell)
167315 ldof = fdof_to_ldof[fdof]
@@ -175,60 +323,4 @@ function _fill_aggdof_to_coeffs_data!(
175323 end
176324 end
177325 nothing
178- end
179-
180- function _setup_agfem_constraints (
181- n_fdofs,
182- acell_to_acellin,
183- acell_to_dof_ids,
184- acell_to_coeffs,
185- acell_to_proj,
186- acell_to_gcell)
187-
188- fdof_to_isagg, fdof_to_acell, fdof_to_ldof =
189- _allocate_fdof_to_data (n_fdofs)
190-
191- _fill_fdof_to_data! (fdof_to_isagg,
192- fdof_to_acell,
193- fdof_to_ldof,
194- acell_to_acellin,
195- acell_to_dof_ids,
196- acell_to_gcell)
197-
198- aggdof_to_fdof = findall (fdof_to_isagg)
199-
200- n_aggdofs = length (aggdof_to_fdof)
201- aggdof_to_dofs_ptrs = zeros (Int32,n_aggdofs+ 1 )
202-
203- _fill_aggdof_to_dofs_ptrs! (aggdof_to_dofs_ptrs,
204- aggdof_to_fdof,
205- fdof_to_acell,
206- acell_to_acellin,
207- acell_to_dof_ids)
208-
209- aggdof_to_dofs_data, aggdof_to_coeffs_data =
210- _allocate_aggdof_to_data (aggdof_to_dofs_ptrs,
211- acell_to_coeffs)
212-
213- _fill_aggdof_to_dofs_data! (aggdof_to_dofs_data,
214- aggdof_to_dofs_ptrs,
215- aggdof_to_fdof,
216- fdof_to_acell,
217- acell_to_acellin,
218- acell_to_dof_ids)
219-
220- _fill_aggdof_to_coeffs_data! (aggdof_to_coeffs_data,
221- aggdof_to_dofs_ptrs,
222- aggdof_to_fdof,
223- fdof_to_acell,
224- fdof_to_ldof,
225- acell_to_coeffs,
226- acell_to_proj)
227-
228- aggdof_to_dofs = Table (aggdof_to_dofs_data,
229- aggdof_to_dofs_ptrs)
230- aggdof_to_coeffs = Table (aggdof_to_coeffs_data,
231- aggdof_to_dofs_ptrs)
232-
233- aggdof_to_fdof, aggdof_to_dofs, aggdof_to_coeffs
234- end
326+ end
0 commit comments