changeset 152:f54dd4408fa7 boundary_conditions

Merge with default
author Jonatan Werpers <jonatan@werpers.com>
date Mon, 15 Apr 2019 16:15:04 +0200
parents e0c8f5cf3a3f (diff) ce56727e4232 (current diff)
children 754c36796ac8
files diffOp.jl
diffstat 3 files changed, 60 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/TODO.txt	Fri Feb 22 15:22:34 2019 +0100
+++ b/TODO.txt	Mon Apr 15 16:15:04 2019 +0200
@@ -10,3 +10,5 @@
 
 Konvertera till paket
 Skriv tester
+
+Specificera operatorer i TOML eller nĂ¥got liknande?
--- a/diffOp.jl	Fri Feb 22 15:22:34 2019 +0100
+++ b/diffOp.jl	Mon Apr 15 16:15:04 2019 +0200
@@ -129,3 +129,59 @@
     I = Index{Unknown}.(Tuple(i))
     apply(L, v, I)
 end
+
+# Boundary operators
+
+function apply_e(L::Laplace{2}, v::AbstractArray{T,2} where T, ::CartesianBoundary{1,R}, j::Int) where R
+    @inbounds vy = view(v, :, j)
+    return apply_e(L.op,vy, R)
+end
+
+function apply_e(L::Laplace{2}, v::AbstractArray{T,2} where T, ::CartesianBoundary{2,R}, i::Int) where R
+    @inbounds vx = view(v, i, :)
+    return apply_e(L.op, vy, R)
+end
+
+function apply_d(L::Laplace{2}, v::AbstractArray{T,2} where T, ::CartesianBoundary{1,R}, j::Int) where R
+    @inbounds vy = view(v, :, j)
+    return apply_d(L.op,vy, R)
+end
+
+function apply_d(L::Laplace{2}, v::AbstractArray{T,2} where T, ::CartesianBoundary{2,R}, i::Int) where R
+    @inbounds vx = view(v, i, :)
+    return apply_d(L.op, vy, R)
+end
+
+
+function apply_e_T(L::Laplace{2}, v::AbstractArray{T,2} where T, boundaryId, i::Int)
+
+end
+
+function apply_d_T(L::Laplace{2}, v::AbstractArray{T,2} where T, boundaryId, i::Int)
+
+end
+
+"""
+A BoundaryCondition should implement the method
+    sat(::DiffOp, v::AbstractArray, data::AbstractArray, ...)
+"""
+abstract type BoundaryCondition end
+
+struct Dirichlet{Bid<:BoundaryIdentifier} <: BoundaryCondition
+    tau::Float64
+end
+
+struct Neumann{Bid<:BoundaryIdentifier} <: BoundaryCondition
+end
+
+function sat(L::Laplace{2}, bc::Neumann{CartesianBoundary{1,R}}, v::AbstractArray{T,2} where T, g::AbstractVector{T}, i::CartesianIndex{2}) where R
+
+    # Hi * e * H_gamma * (d'*v - g)
+    # e, d, H_gamma applied based on bc.boundaryId
+end
+
+function sat(L::Laplace{2}, bc::Dirichlet{CartesianBoundary{1,R}}, v::AbstractArray{T,2} where T, g::AbstractVector{T}, i::CartesianIndex{2})
+    # Hi * (tau/h*e + sig*d) * H_gamma * (e'*v - g)
+    # e, d, H_gamma applied based on bc.boundaryId
+end
+
--- a/grid.jl	Fri Feb 22 15:22:34 2019 +0100
+++ b/grid.jl	Mon Apr 15 16:15:04 2019 +0200
@@ -1,7 +1,7 @@
 module Grid
 
-# TODO: Where is this used?
-abstract type BoundaryId end
+abstract type BoundaryIdentifier end
+struct CartesianBoundary{Dim, R<:Region} <: BoundaryIdentifier end
 
 include("AbstractGrid.jl")
 include("EquidistantGrid.jl")