diff src/SbpOperators/volumeops/laplace/laplace.jl @ 873:9929c99754fb laplace_benchmarks

Add some benchmarks using the Laplace Operator Set
author Vidar Stiernström <vidar.stiernstrom@it.uu.se>
date Wed, 19 Jan 2022 13:15:45 +0100
parents 1970ebceabe4
children 067a322e4f73
line wrap: on
line diff
--- a/src/SbpOperators/volumeops/laplace/laplace.jl	Fri Jul 02 14:23:33 2021 +0200
+++ b/src/SbpOperators/volumeops/laplace/laplace.jl	Wed Jan 19 13:15:45 2022 +0100
@@ -22,6 +22,7 @@
     e::StaticDict{<:BoundaryIdentifier,<:TensorMapping} # Boundary restriction operators.
     d::StaticDict{<:BoundaryIdentifier,<:TensorMapping} # Normal derivative operators
     H_boundary::StaticDict{<:BoundaryIdentifier,<:TensorMapping} # Boundary quadrature operators # TODO: Boundary inner product?
+    order::Int
 end
 export Laplace
 
@@ -48,7 +49,7 @@
     d_pairs = ntuple(i -> ids[i] => normal_derivative(grid,d_closure_stencil,ids[i]),n_ids)
     Hᵧ_pairs = ntuple(i -> ids[i] => inner_product(boundary_grid(grid,ids[i]),H_closure_stencils),n_ids)
 
-    return Laplace(Δ, H, H⁻¹, StaticDict(e_pairs), StaticDict(d_pairs), StaticDict(Hᵧ_pairs))
+    return Laplace(Δ, H, H⁻¹, StaticDict(e_pairs), StaticDict(d_pairs), StaticDict(Hᵧ_pairs), order)
 end
 
 # TODO: Consider pretty printing of the following form
@@ -58,6 +59,14 @@
 LazyTensors.domain_size(L::Laplace) = LazyTensors.domain_size(L.D)
 LazyTensors.apply(L::Laplace, v::AbstractArray, I...) = LazyTensors.apply(L.D,v,I...)
 
+"""
+    closure_size(L::Lapalace)
+
+Returns the inner product operator associated with `L`
+
+"""
+closure_size(L::Laplace) = closure_size(L.D)
+export closure_size
 
 """
     inner_product(L::Lapalace)
@@ -124,6 +133,54 @@
 boundary_quadrature(L::Laplace,ids::Vararg{BoundaryIdentifier,N}) where N = ntuple(i->L.H_boundary[ids[i]],N)
 export boundary_quadrature
 
+abstract type BoundaryConditionType end
+struct NeumannBC <: BoundaryConditionType end
+struct DirichletBC <: BoundaryConditionType end
+export NeumannBC
+
+boundary_condition(L, id, ::NeumannBC) = neumann_bc(L, id)
+boundary_condition(L, id, ::DirichletBC) = dirichlet_bc(L, id)
+export boundary_condition
+
+function neumann_bc(L::Laplace, id::BoundaryIdentifier)
+    H_inv = inverse_inner_product(L)
+    e = boundary_restriction(L,id)
+    d = normal_derivative(L,id)
+    H_b = boundary_quadrature(L,id)
+    tau = H_inv∘e'∘H_b
+    closure = tau∘d
+    # TODO: Return penalty once we have implemented scalar scaling of the operators.
+    return closure
+end
+
+function dirichlet_bc(L::Laplace, id::BoundaryIdentifier)
+    error("Not implemented")
+    # H_inv = inverse_inner_product(L)
+    # e = boundary_restriction(L,id)
+    # d = normal_derivative(L,id)
+    # H_b = boundary_quadrature(L,id)
+    # gamma = borrowing_parameter(L)
+    # tuning = 1.2
+    # S = ScalingOperator(tuning * -1.0/gamma)
+    # tau = H_inv∘(S∘e' + d')∘H_b
+    # closure = tau∘e
+    # penalty = ScalingOperator(-1)∘tau
+    # return (closure, penalty)
+end
+
+# function borrowing_parameter(L)
+#     if L.order == 2
+#         return 0.4
+#     elseif L.order == 4
+#         return 0.2508
+#     elseif L.order == 6
+#         return 0.1878
+#     elseif L.order == 8
+#         return 0.0015
+#     elseif L.order == 10
+#         return 0.0351
+#     end
+# end
 
 """
     laplace(grid, inner_stencil, closure_stencils)