@@ -301,30 +301,53 @@ function _get_periodic_coupling_matrix(
301301 eval_point, set_start = interpolate_on_boundaryfaces (fe_vector, xgrid, give_opposite!)
302302
303303 # precompute approximate search region for each boundary face in b_from
304- search_areas = Dict {TiG, Vector{TiG}} ( )
304+ searchareas = ExtendableGrids . VariableTargetAdjacency (TiG )
305305 coords = xgrid[Coordinates]
306306 facenodes = xgrid[FaceNodes]
307- box_from = zeros (TvG, 2 )
307+ faces_to = zeros (Int, 1 )
308+ coords_from = coords[:, facenodes[:, 1 ]]
309+ coords_to = coords[:, facenodes[:, 1 ]]
310+ nodes_per_faces = size (coords_from, 2 )
311+ dim = size (coords_from, 1 )
312+ box_from = [Float64[0 , 0 ], Float64[0 , 0 ], Float64[0 , 0 ]]
313+ box_to = [Float64[0 , 0 ], Float64[0 , 0 ], Float64[0 , 0 ]]
314+ nfaces_to = 0
308315 for face_from in faces_in_b_from
309- coords_from = coords[:, facenodes[:, face_from]]
316+ for j in 1 : nodes_per_faces, k in 1 : dim
317+ coords_from[k, j] = coords[k, facenodes[j, face_from]]
318+ end
319+ fill! (faces_to, 0 )
320+ nfaces_to = 0
310321
311322 # transfer the coords_from to the other side
312323 transfer_face! (coords_from)
313324
314325 # get the extrama in each component ( = bounding box of the face)
315- @views box_from = extrema (coords_from, dims = (2 ))[:]
326+ for k in 1 : dim
327+ box_from[k][1 ] = minimum (view (coords_from, k, :))
328+ box_from[k][2 ] = maximum (view (coords_from, k, :))
329+ end
316330
317331 for face_to in faces_in_b_to
318- @views coords_to = coords[:, facenodes[:, face_to]]
319- @views box_to = extrema (coords_to, dims = (2 ))[:]
332+ for j in 1 : nodes_per_faces, k in 1 : dim
333+ coords_to[k, j] = coords[k, facenodes[j, face_to]]
334+ end
335+ for k in 1 : dim
336+ box_to[k][1 ] = minimum (view (coords_to, k, :))
337+ box_to[k][2 ] = maximum (view (coords_to, k, :))
338+ end
320339
321340 if do_boxes_overlap (box_from, box_to)
322- if ! haskey (search_areas, face_from)
323- search_areas[face_from] = []
341+ nfaces_to += 1
342+ if length (faces_to) < nfaces_to
343+ push! (faces_to, face_to)
344+ else
345+ faces_to[nfaces_to] = face_to
324346 end
325- push! (search_areas[face_from], face_to)
326347 end
327348 end
349+
350+ append! (searchareas, view (faces_to, 1 : nfaces_to))
328351 end
329352
330353 # loop over boundary face indices: we need this index for dofs_on_boundary
@@ -347,14 +370,16 @@ function _get_periodic_coupling_matrix(
347370 fe_vector. entries[local_dof] = 1.0
348371
349372 # interpolate on the opposite boundary using x_trafo = give_opposite
350- if ! haskey (search_areas, face_numbers_of_bfaces[i_boundary_face])
373+
374+ j = findfirst (== (face_numbers_of_bfaces[i_boundary_face]), faces_in_b_from)
375+ if j <= 0
351376 throw (" face $(face_numbers_of_bfaces[i_boundary_face]) is not on source boundary. Are the from/to regions and the give_opposite function correct?" )
352377 end
353378
354379 interpolate! (
355380 fe_vector_target[1 ],
356381 ON_FACES, eval_point,
357- items = search_areas[face_numbers_of_bfaces[i_boundary_face]],
382+ items = view (searchareas, :, j)
358383 )
359384
360385 # deactivate entry
0 commit comments