changeset 668:2d56a53a1646 feature/laplace_opset

Simplify construction of boundary-operator pairs in Laplace constructor
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Sun, 31 Jan 2021 22:19:53 +0100
parents f3a0d1f7d842
children bf48761c1345
files src/SbpOperators/volumeops/laplace/laplace.jl
diffstat 1 files changed, 10 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/src/SbpOperators/volumeops/laplace/laplace.jl	Sun Jan 31 21:04:02 2021 +0100
+++ b/src/SbpOperators/volumeops/laplace/laplace.jl	Sun Jan 31 22:19:53 2021 +0100
@@ -36,22 +36,17 @@
     H =  DiagonalQuadrature(grid, H_closure_stencils)
     H⁻¹ =  InverseDiagonalQuadrature(grid, H_closure_stencils)
 
-    # Pair boundary operators and boundary quadratures with the boundary ids
-    e_pairs = ()
-    d_pairs = ()
-    Hᵧ_pairs = ()
+    # Pair operators with boundary ids
+    bids = boundary_identifiers(grid)
+    # Boundary operators
+    e_pairs = ntuple(i -> Pair(bids[i],BoundaryRestriction(grid,e_closure_stencil,bids[i])),length(bids))
+    d_pairs = ntuple(i -> Pair(bids[i],NormalDerivative(grid,d_closure_stencil,bids[i])),length(bids))
+    # Boundary quadratures are constructed on the lower-dimensional grid defined
+    # by the coordinite directions orthogonal to that of the boundary.
     dims = collect(1:dimension(grid))
-    for id ∈ boundary_identifiers(grid)
-        # Boundary operators
-        e_pairs = (e_pairs...,Pair(id,BoundaryRestriction(grid,e_closure_stencil,id)))
-        d_pairs = (d_pairs...,Pair(id,NormalDerivative(grid,d_closure_stencil,id)))
-        # Boundary quadratures
-        # Construct these on the lower-dimensional grid in the
-        # coordinite directions orthogonal to dim(id)
-        orth_dims = dims[dims .!= dim(id)]
-        orth_grid = restrict(grid,orth_dims)
-        Hᵧ_pairs = (Hᵧ_pairs...,Pair(id,DiagonalQuadrature(orth_grid,H_closure_stencils)))
-    end
+    orth_grids = ntuple(i -> restrict(grid,dims[dims .!= dim(bids[i])]),length(bids))
+    Hᵧ_pairs = ntuple(i -> Pair(bids[i],DiagonalQuadrature(orth_grids[i],H_closure_stencils)),length(bids))
+
     return Laplace(Δ, H, H⁻¹, Dict(e_pairs), Dict(d_pairs), Dict(Hᵧ_pairs))
 end