Mercurial > repos > public > sbplib_julia
comparison DiffOps/src/laplace.jl @ 251:89a101a63e7a boundary_conditions
Merge
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Thu, 27 Jun 2019 14:37:21 +0200 |
parents | 863a98d9e798 3d83b4d78b55 |
children | 9405c19b76bc |
comparison
equal
deleted
inserted
replaced
250:863a98d9e798 | 251:89a101a63e7a |
---|---|
1 struct Laplace{Dim,T<:Real,N,M,K} <: DiffOpCartesian{Dim} | 1 struct Laplace{Dim,T<:Real,N,M,K} <: DiffOpCartesian{Dim} |
2 grid::EquidistantGrid{Dim,T} | 2 grid::EquidistantGrid{Dim,T} |
3 a::T | 3 a::T |
4 op::D2{Float64,N,M,K} | 4 op::D2{Float64,N,M,K} |
5 # e::BoundaryValue | |
6 # d::NormalDerivative | |
7 end | 5 end |
6 | |
7 boundary_value(L::Laplace, bId::CartesianBoundary) = BoundaryValue(L.op, L.grid, bId) | |
8 normal_derivative(L::Laplace, bId::CartesianBoundary) = NormalDerivative(L.op, L.grid, bId) | |
9 boundary_quadrature(L::Laplace, bId::CartesianBoundary) = throw(MethodError) # TODO: Implement this | |
8 | 10 |
9 function apply(L::Laplace{Dim}, v::AbstractArray{T,Dim} where T, I::CartesianIndex{Dim}) where Dim | 11 function apply(L::Laplace{Dim}, v::AbstractArray{T,Dim} where T, I::CartesianIndex{Dim}) where Dim |
10 error("not implemented") | 12 error("not implemented") |
11 end | 13 end |
12 | 14 |
100 | 102 |
101 | 103 |
102 struct Neumann{Bid<:BoundaryIdentifier} <: BoundaryCondition end | 104 struct Neumann{Bid<:BoundaryIdentifier} <: BoundaryCondition end |
103 | 105 |
104 function sat(L::Laplace{2,T}, bc::Neumann{Bid}, v::AbstractArray{T,2}, g::AbstractVector{T}, I::CartesianIndex{2}) where {T,Bid} | 106 function sat(L::Laplace{2,T}, bc::Neumann{Bid}, v::AbstractArray{T,2}, g::AbstractVector{T}, I::CartesianIndex{2}) where {T,Bid} |
105 e = BoundaryValue(L.op, L.grid, Bid()) | 107 e = boundary_value(L.op, Bid()) |
106 d = NormalDerivative(L.op, L.grid, Bid()) | 108 d = normal_derivative(L.op, Bid()) |
107 Hᵧ = BoundaryQuadrature(L.op, L.grid, Bid()) | 109 Hᵧ = boundary_quadrature(L.op, Bid()) |
108 # TODO: Implement BoundaryQuadrature method | |
109 | 110 |
110 return -L.Hi*e*Hᵧ*(d'*v - g) | 111 return -L.Hi*e*Hᵧ*(d'*v - g) |
111 # Need to handle d'*v - g so that it is an AbstractArray that TensorMappings can act on | 112 # Need to handle d'*v - g so that it is an AbstractArray that TensorMappings can act on |
112 end | 113 end |
113 | 114 |
114 struct Dirichlet{Bid<:BoundaryIdentifier} <: BoundaryCondition | 115 struct Dirichlet{Bid<:BoundaryIdentifier} <: BoundaryCondition |
115 tau::Float64 | 116 tau::Float64 |
116 end | 117 end |
117 | 118 |
118 function sat(L::Laplace{2,T}, bc::Dirichlet{Bid}, v::AbstractArray{T,2}, g::AbstractVector{T}, i::CartesianIndex{2}) where {T,Bid} | 119 function sat(L::Laplace{2,T}, bc::Dirichlet{Bid}, v::AbstractArray{T,2}, g::AbstractVector{T}, i::CartesianIndex{2}) where {T,Bid} |
119 e = BoundaryValue(L.op, L.grid, Bid()) | 120 e = boundary_value(L.op, Bid()) |
120 d = NormalDerivative(L.op, L.grid, Bid()) | 121 d = normal_derivative(L.op, Bid()) |
121 Hᵧ = BoundaryQuadrature(L.op, L.grid, Bid()) | 122 Hᵧ = boundary_quadrature(L.op, Bid()) |
122 # TODO: Implement BoundaryQuadrature method | |
123 | 123 |
124 return -L.Hi*(tau/h*e + d)*Hᵧ*(e'*v - g) | 124 return -L.Hi*(tau/h*e + d)*Hᵧ*(e'*v - g) |
125 # Need to handle scalar multiplication and addition of TensorMapping | 125 # Need to handle scalar multiplication and addition of TensorMapping |
126 end | 126 end |
127 | 127 |