@@ -161,14 +161,14 @@ end
161161# compact variant of lazy_interpolate! specialized on ON_FACES interpolations
162162function interpolate_on_boundaryfaces (
163163 source:: FEVector{Tv, TvG, TiG} ,
164+ xgrid:: ExtendableGrid{TvG, TiG} ,
164165 give_opposite,
165166 start_cell:: Int = 1 , # TODO we interpolate on the "b_from" side: a proper start cell should be given
166167 eps = 1.0e-13 ,
167168 kwargs... ,
168169 ) where {Tv, TvG, TiG}
169170
170171 # wrap point evaluation into function that is put into normal interpolate!
171- xgrid = source[1 ]. FES. xgrid
172172 xdim:: Int = size (xgrid[Coordinates], 1 )
173173 PE = PointEvaluator ([(1 , Identity)], source)
174174 xref = zeros (TvG, xdim)
@@ -197,41 +197,19 @@ function interpolate_on_boundaryfaces(
197197 return __eval_point, __setstartcell
198198end
199199
200- """
201- get_periodic_coupling_matrix(
202- FES::FESpace,
203- xgrid::ExtendableGrid,
200+ function get_periodic_coupling_matrix (
201+ FES:: FESpace{Tv} ,
202+ xgrid:: ExtendableGrid{TvG, TiG} ,
204203 b_from,
205204 b_to,
206205 give_opposite!:: Function ;
207- mask = :auto,
208- sparsity_tol = 1.0e-12
209- )
210-
211- Compute a coupling information for each dof on one boundary as a linear combination of dofs on another boundary
212-
213- Input:
214- - FES: FE space to be coupled
215- - xgrid: the grid
216- - b_from: boundary region of the grid which dofs should be replaced in terms of dofs on b_to
217- - b_to: boundary region of the grid with dofs to replace the dofs in b_from
218- - give_opposite! Function in (y,x)
219- - mask: (optional) vector of masking components
220- - sparsity_tol: threshold for treating an interpolated value as zero
221-
222- give_opposite!(y,x) has to be defined in a way that for each x ∈ b_from the resulting y is in the opposite boundary.
223- For each x in the grid, the resulting y has to be in the grid, too: incorporate some mirroring of the coordinates.
224- Example: If b_from is at x[1] = 0 and the opposite boundary is at y[1] = 1, then give_opposite!(y,x) = y .= [ 1-x[1], x[2] ]
225-
226- The return value is a (𝑛 × 𝑛) sparse matrix 𝐴 (𝑛 is the total number of dofs) containing the periodic coupling information.
227- The relation ship between the degrees of freedome is dofᵢ = ∑ⱼ Aⱼᵢ ⋅ dofⱼ.
228- It is guaranteed that
229- i) Aⱼᵢ=0 if dofᵢ is 𝑛𝑜𝑡 on the boundary b_from.
230- ii) Aⱼᵢ=0 if the opposite of dofᵢ is not in the same grid cell as dofⱼ.
231- Note that A is transposed for efficient col-wise storage.
206+ kwargs...
207+ ) where {Tv, TvG, TiG}
208+ @warn " get_periodic_coupling_matrix with grid argument is deprecated"
209+ return _get_periodic_coupling_matrix (FES, xgrid, b_from, b_to, give_opposite!; kwargs... )
210+ end
232211
233- """
234- function get_periodic_coupling_matrix (
212+ function _get_periodic_coupling_matrix (
235213 FES:: FESpace{Tv} ,
236214 xgrid:: ExtendableGrid{TvG, TiG} ,
237215 b_from,
@@ -320,7 +298,7 @@ function get_periodic_coupling_matrix(
320298 return
321299 end
322300
323- eval_point, set_start = interpolate_on_boundaryfaces (fe_vector, give_opposite!)
301+ eval_point, set_start = interpolate_on_boundaryfaces (fe_vector, xgrid, give_opposite!)
324302
325303 # precompute approximate search region for each boundary face in b_from
326304 search_areas = Dict {TiG, Vector{TiG}} ()
@@ -398,6 +376,48 @@ function get_periodic_coupling_matrix(
398376 return sparse (result)
399377end
400378
379+ """
380+ get_periodic_coupling_matrix(
381+ FES::FESpace,
382+ b_from,
383+ b_to,
384+ give_opposite!::Function;
385+ mask = :auto,
386+ sparsity_tol = 1.0e-12
387+ )
388+
389+ Compute a coupling information for each dof on one boundary as a linear combination of dofs on another boundary
390+
391+ Input:
392+ - FES: FE space to be coupled (on its dofgrid)
393+ - b_from: boundary region of the grid which dofs should be replaced in terms of dofs on b_to
394+ - b_to: boundary region of the grid with dofs to replace the dofs in b_from
395+ - give_opposite! Function in (y,x)
396+ - mask: (optional) vector of masking components
397+ - sparsity_tol: threshold for treating an interpolated value as zero
398+
399+ give_opposite!(y,x) has to be defined in a way that for each x ∈ b_from the resulting y is in the opposite boundary.
400+ For each x in the grid, the resulting y has to be in the grid, too: incorporate some mirroring of the coordinates.
401+ Example: If b_from is at x[1] = 0 and the opposite boundary is at y[1] = 1, then give_opposite!(y,x) = y .= [ 1-x[1], x[2] ]
402+
403+ The return value is a (𝑛 × 𝑛) sparse matrix 𝐴 (𝑛 is the total number of dofs) containing the periodic coupling information.
404+ The relation ship between the degrees of freedome is dofᵢ = ∑ⱼ Aⱼᵢ ⋅ dofⱼ.
405+ It is guaranteed that
406+ i) Aⱼᵢ=0 if dofᵢ is 𝑛𝑜𝑡 on the boundary b_from.
407+ ii) Aⱼᵢ=0 if the opposite of dofᵢ is not in the same grid cell as dofⱼ.
408+ Note that A is transposed for efficient col-wise storage.
409+
410+ """
411+ function get_periodic_coupling_matrix (
412+ FES,
413+ b_from,
414+ b_to,
415+ give_opposite!;
416+ kwargs...
417+ )
418+ return _get_periodic_coupling_matrix (FES, FES. dofgrid, b_from, b_to, give_opposite!; kwargs... )
419+ end
420+
401421
402422# # determines a common assembly grid for the given arrays of finite element spaces
403423function determine_assembly_grid (FES_test, FES_ansatz = [], FES_args = [])
0 commit comments