@@ -54,18 +54,22 @@ function AgFEMSpace(
5454 FESpaceWithLinearConstraints (aggdof_to_fdof,aggdof_to_dofs,aggdof_to_coeffs,f)
5555end
5656
57- function _setup_agfem_constraints (
58- n_fdofs,
57+ function _allocate_fdof_to_data (n_fdofs)
58+ fdof_to_isagg = fill (true ,n_fdofs)
59+ fdof_to_acell = zeros (Int32,n_fdofs)
60+ fdof_to_ldof = zeros (Int16,n_fdofs)
61+ fdof_to_isagg, fdof_to_acell, fdof_to_ldof
62+ end
63+
64+ function _fill_fdof_to_data! (
65+ fdof_to_isagg,
66+ fdof_to_acell,
67+ fdof_to_ldof,
5968 acell_to_acellin,
6069 acell_to_dof_ids,
61- acell_to_coeffs,
62- acell_to_proj,
6370 acell_to_gcell)
6471
6572 n_acells = length (acell_to_acellin)
66- fdof_to_isagg = fill (true ,n_fdofs)
67- fdof_to_acell = zeros (Int32,n_fdofs)
68- fdof_to_ldof = zeros (Int16,n_fdofs)
6973 cache = array_cache (acell_to_dof_ids)
7074 for acell in 1 : n_acells
7175 acellin = acell_to_acellin[acell]
@@ -84,26 +88,50 @@ function _setup_agfem_constraints(
8488 end
8589 end
8690 end
91+ nothing
92+ end
8793
88- aggdof_to_fdof = findall (fdof_to_isagg)
89-
90- n_aggdofs = length (aggdof_to_fdof)
91- aggdof_to_dofs_ptrs = zeros (Int32,n_aggdofs+ 1 )
94+ function _fill_aggdof_to_dofs_ptrs! (
95+ aggdof_to_dofs_ptrs,
96+ aggdof_to_fdof,
97+ fdof_to_acell,
98+ acell_to_acellin,
99+ acell_to_dof_ids,
100+ fdof_to_is_owned= fill (true ,length (fdof_to_acell)))
92101
93- for aggdof in 1 : n_aggdofs
94- fdof = aggdof_to_fdof[aggdof]
102+ cache = array_cache (acell_to_dof_ids)
103+ for (aggdof,fdof) in enumerate (aggdof_to_fdof)
104+ ! fdof_to_is_owned[fdof] && continue
95105 acell = fdof_to_acell[fdof]
96106 acellin = acell_to_acellin[acell]
97107 dofs = getindex! (cache,acell_to_dof_ids,acellin)
98108 aggdof_to_dofs_ptrs[aggdof+ 1 ] = length (dofs)
99109 end
110+ nothing
111+ end
100112
113+ function _allocate_aggdof_to_data (aggdof_to_dofs_ptrs,
114+ acell_to_coeffs)
101115 length_to_ptrs! (aggdof_to_dofs_ptrs)
102116 ndata = aggdof_to_dofs_ptrs[end ]- 1
103117 aggdof_to_dofs_data = zeros (Int,ndata)
118+ T = eltype (eltype (acell_to_coeffs))
119+ aggdof_to_coeffs_data = zeros (T,ndata)
120+ aggdof_to_dofs_data, aggdof_to_coeffs_data
121+ end
104122
105- for aggdof in 1 : n_aggdofs
106- fdof = aggdof_to_fdof[aggdof]
123+ function _fill_aggdof_to_dofs_data! (
124+ aggdof_to_dofs_data,
125+ aggdof_to_dofs_ptrs,
126+ aggdof_to_fdof,
127+ fdof_to_acell,
128+ acell_to_acellin,
129+ acell_to_dof_ids,
130+ fdof_to_is_owned= fill (true ,length (fdof_to_acell)))
131+
132+ cache = array_cache (acell_to_dof_ids)
133+ for (aggdof,fdof) in enumerate (aggdof_to_fdof)
134+ ! fdof_to_is_owned[fdof] && continue
107135 acell = fdof_to_acell[fdof]
108136 acellin = acell_to_acellin[acell]
109137 dofs = getindex! (cache,acell_to_dof_ids,acellin)
@@ -112,18 +140,27 @@ function _setup_agfem_constraints(
112140 aggdof_to_dofs_data[p+ i] = dof
113141 end
114142 end
143+ nothing
144+ end
115145
116- aggdof_to_dofs = Table (aggdof_to_dofs_data,aggdof_to_dofs_ptrs)
146+ function _fill_aggdof_to_coeffs_data! (
147+ aggdof_to_coeffs_data,
148+ aggdof_to_dofs_ptrs,
149+ aggdof_to_fdof,
150+ fdof_to_acell,
151+ fdof_to_ldof,
152+ acell_to_coeffs,
153+ acell_to_proj,
154+ fdof_to_is_owned= fill (true ,length (fdof_to_acell)))
117155
118156 cache2 = array_cache (acell_to_coeffs)
119157 cache3 = array_cache (acell_to_proj)
120158
121159 T = eltype (eltype (acell_to_coeffs))
122160 z = zero (T)
123161
124- aggdof_to_coefs_data = zeros (T,ndata)
125- for aggdof in 1 : n_aggdofs
126- fdof = aggdof_to_fdof[aggdof]
162+ for (aggdof,fdof) in enumerate (aggdof_to_fdof)
163+ ! fdof_to_is_owned[fdof] && continue
127164 acell = fdof_to_acell[fdof]
128165 coeffs = getindex! (cache2,acell_to_coeffs,acell)
129166 proj = getindex! (cache3,acell_to_proj,acell)
@@ -134,11 +171,64 @@ function _setup_agfem_constraints(
134171 for c in 1 : size (coeffs,2 )
135172 coeff += coeffs[ldof,c]* proj[c,b]
136173 end
137- aggdof_to_coefs_data [p+ b] = coeff
174+ aggdof_to_coeffs_data [p+ b] = coeff
138175 end
139176 end
177+ 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 )
140202
141- aggdof_to_coeffs = Table (aggdof_to_coefs_data,aggdof_to_dofs_ptrs)
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)
142232
143233 aggdof_to_fdof, aggdof_to_dofs, aggdof_to_coeffs
144234end
0 commit comments