comparison diffOp.jl @ 174:187295479984 boundary_conditions

Sketch implementation of sat methods for Neumann and Dirichlet
author Jonatan Werpers <jonatan@werpers.com>
date Wed, 12 Jun 2019 15:09:45 +0200
parents fabd475bb258
children bcd2029c590d
comparison
equal deleted inserted replaced
173:fabd475bb258 174:187295479984
203 A BoundaryCondition should implement the method 203 A BoundaryCondition should implement the method
204 sat(::DiffOp, v::AbstractArray, data::AbstractArray, ...) 204 sat(::DiffOp, v::AbstractArray, data::AbstractArray, ...)
205 """ 205 """
206 abstract type BoundaryCondition end 206 abstract type BoundaryCondition end
207 207
208 struct Neumann{Bid<:BoundaryIdentifier} <: BoundaryCondition end
209
210 function sat(L::Laplace{2,T}, bc::Neumann{Bid}, v::AbstractArray{T,2}, g::AbstractVector{T}, I::CartesianIndex{2}) where {T,Bid}
211 e = BoundaryValue(L.op, L.grid, Bid())
212 d = NormalDerivative(L.op, L.grid, Bid())
213 Hᵧ = BoundaryQuadrature(L.op, L.grid, Bid())
214 # TODO: Implement BoundaryQuadrature method
215
216 return -L.Hi*e*Hᵧ*(d'*v - g)
217 # Need to handle d'*v - g so that it is an AbstractArray that TensorMappings can act on
218 end
219
208 struct Dirichlet{Bid<:BoundaryIdentifier} <: BoundaryCondition 220 struct Dirichlet{Bid<:BoundaryIdentifier} <: BoundaryCondition
209 tau::Float64 221 tau::Float64
210 end 222 end
211 223
212 struct Neumann{Bid<:BoundaryIdentifier} <: BoundaryCondition 224 function sat(L::Laplace{2,T}, bc::Dirichlet{Bid}, v::AbstractArray{T,2}, g::AbstractVector{T}, i::CartesianIndex{2}) where {T,Bid}
213 end 225 e = BoundaryValue(L.op, L.grid, Bid())
214 226 d = NormalDerivative(L.op, L.grid, Bid())
215 function sat(L::Laplace{2}, bc::Neumann{CartesianBoundary{1,R}}, v::AbstractArray{T,2} where T, g::AbstractVector, i::CartesianIndex{2}) where R 227 Hᵧ = BoundaryQuadrature(L.op, L.grid, Bid())
216 228 # TODO: Implement BoundaryQuadrature method
217 # Hi * e * H_gamma * (d'*v - g) 229
218 # e, d, H_gamma applied based on bc.boundaryId 230 return -L.Hi*(tau/h*e + d)*Hᵧ*(e'*v - g)
219 end 231 # Need to handle scalar multiplication and addition of TensorMapping
220
221 function sat(L::Laplace{2}, bc::Dirichlet{CartesianBoundary{1,R}}, v::AbstractArray{T,2} where T, g::AbstractVector, i::CartesianIndex{2}) where R
222 # Hi * (tau/h*e + sig*d) * H_gamma * (e'*v - g)
223 # e, d, H_gamma applied based on bc.boundaryId
224 end 232 end
225 233
226 # function apply(s::MyWaveEq{D}, v::AbstractArray{T,D}, i::CartesianIndex{D}) where D 234 # function apply(s::MyWaveEq{D}, v::AbstractArray{T,D}, i::CartesianIndex{D}) where D
227 # return apply(s.L, v, i) + 235 # return apply(s.L, v, i) +
228 # sat(s.L, Dirichlet{CartesianBoundary{1,Lower}}(s.tau), v, s.g_w, i) + 236 # sat(s.L, Dirichlet{CartesianBoundary{1,Lower}}(s.tau), v, s.g_w, i) +