Mercurial > repos > public > sbplib_julia
comparison DiffOps/src/laplace.jl @ 269:ccef055233a2 boundary_conditions
Move general methods for D2 to ConstantStencilOperator and increase verbosity of method names for clarity
| author | Vidar Stiernström <vidar.stiernstrom@it.uu.se> |
|---|---|
| date | Thu, 05 Dec 2019 10:48:31 +0100 |
| parents | f67ce2eb6019 |
| children | babc4288e6a6 |
comparison
equal
deleted
inserted
replaced
| 268:f67ce2eb6019 | 269:ccef055233a2 |
|---|---|
| 8 error("not implemented") | 8 error("not implemented") |
| 9 end | 9 end |
| 10 | 10 |
| 11 # u = L*v | 11 # u = L*v |
| 12 function apply(L::Laplace{1}, v::AbstractVector, i::Int) | 12 function apply(L::Laplace{1}, v::AbstractVector, i::Int) |
| 13 uᵢ = L.a * SbpOperators.apply(L.op, inverse_spacing(L.grid)[1], v, i) | 13 uᵢ = L.a * SbpOperators.apply_2nd_derivative(L.op, inverse_spacing(L.grid)[1], v, i) |
| 14 return uᵢ | 14 return uᵢ |
| 15 end | 15 end |
| 16 | 16 |
| 17 @inline function apply(L::Laplace{2}, v::AbstractArray{T,2} where T, I::Tuple{Index{R1}, Index{R2}}) where {R1, R2} | 17 @inline function apply(L::Laplace{2}, v::AbstractArray{T,2} where T, I::Tuple{Index{R1}, Index{R2}}) where {R1, R2} |
| 18 # 2nd x-derivative | 18 # 2nd x-derivative |
| 19 @inbounds vx = view(v, :, Int(I[2])) | 19 @inbounds vx = view(v, :, Int(I[2])) |
| 20 @inbounds uᵢ = L.a*SbpOperators.apply(L.op, inverse_spacing(L.grid)[1], vx , I[1]) | 20 @inbounds uᵢ = L.a*SbpOperators.apply_2nd_derivative(L.op, inverse_spacing(L.grid)[1], vx , I[1]) |
| 21 # 2nd y-derivative | 21 # 2nd y-derivative |
| 22 @inbounds vy = view(v, Int(I[1]), :) | 22 @inbounds vy = view(v, Int(I[1]), :) |
| 23 @inbounds uᵢ += L.a*SbpOperators.apply(L.op, inverse_spacing(L.grid)[2], vy, I[2]) | 23 @inbounds uᵢ += L.a*SbpOperators.apply_2nd_derivative(L.op, inverse_spacing(L.grid)[2], vy, I[2]) |
| 24 # NOTE: the package qualifier 'SbpOperators' can problably be removed once all "applying" objects use LazyTensors | 24 # NOTE: the package qualifier 'SbpOperators' can problably be removed once all "applying" objects use LazyTensors |
| 25 return uᵢ | 25 return uᵢ |
| 26 end | 26 end |
| 27 | 27 |
| 28 # Slow but maybe convenient? | 28 # Slow but maybe convenient? |
| 111 # TODO: Make this independent of dimension | 111 # TODO: Make this independent of dimension |
| 112 function LazyTensors.apply(e::BoundaryValue, v::AbstractArray, I::NTuple{2,Int}) | 112 function LazyTensors.apply(e::BoundaryValue, v::AbstractArray, I::NTuple{2,Int}) |
| 113 i = I[dim(e.bId)] | 113 i = I[dim(e.bId)] |
| 114 j = I[3-dim(e.bId)] | 114 j = I[3-dim(e.bId)] |
| 115 N_i = size(e.grid)[dim(e.bId)] | 115 N_i = size(e.grid)[dim(e.bId)] |
| 116 return apply_e(e.op, v[j], N_i, i, region(e.bId)) | 116 return apply_boundary_value(e.op, v[j], N_i, i, region(e.bId)) |
| 117 end | 117 end |
| 118 | 118 |
| 119 function LazyTensors.apply_transpose(e::BoundaryValue, v::AbstractArray, I::NTuple{1,Int}) | 119 function LazyTensors.apply_transpose(e::BoundaryValue, v::AbstractArray, I::NTuple{1,Int}) |
| 120 u = selectdim(v,3-dim(e.bId),I[1]) | 120 u = selectdim(v,3-dim(e.bId),I[1]) |
| 121 return apply_e_T(e.op, u, region(e.bId)) | 121 return apply_boundary_value_transpose(e.op, u, region(e.bId)) |
| 122 end | 122 end |
| 123 | 123 |
| 124 """ | 124 """ |
| 125 NormalDerivative{T,N,M,K} <: TensorMapping{T,2,1} | 125 NormalDerivative{T,N,M,K} <: TensorMapping{T,2,1} |
| 126 | 126 |
| 143 function LazyTensors.apply(d::NormalDerivative, v::AbstractArray, I::NTuple{2,Int}) | 143 function LazyTensors.apply(d::NormalDerivative, v::AbstractArray, I::NTuple{2,Int}) |
| 144 i = I[dim(d.bId)] | 144 i = I[dim(d.bId)] |
| 145 j = I[3-dim(d.bId)] | 145 j = I[3-dim(d.bId)] |
| 146 N_i = size(d.grid)[dim(d.bId)] | 146 N_i = size(d.grid)[dim(d.bId)] |
| 147 h_inv = inverse_spacing(d.grid)[dim(d.bId)] | 147 h_inv = inverse_spacing(d.grid)[dim(d.bId)] |
| 148 return apply_d(d.op, h_inv, v[j], N_i, i, region(d.bId)) | 148 return apply_normal_derivative(d.op, h_inv, v[j], N_i, i, region(d.bId)) |
| 149 end | 149 end |
| 150 | 150 |
| 151 function LazyTensors.apply_transpose(d::NormalDerivative, v::AbstractArray, I::NTuple{1,Int}) | 151 function LazyTensors.apply_transpose(d::NormalDerivative, v::AbstractArray, I::NTuple{1,Int}) |
| 152 u = selectdim(v,3-dim(d.bId),I[1]) | 152 u = selectdim(v,3-dim(d.bId),I[1]) |
| 153 return apply_d_T(d.op, inverse_spacing(d.grid)[dim(d.bId)], u, region(d.bId)) | 153 return apply_normal_derivative_transpose(d.op, inverse_spacing(d.grid)[dim(d.bId)], u, region(d.bId)) |
| 154 end | 154 end |
| 155 | 155 |
| 156 """ | 156 """ |
| 157 BoundaryQuadrature{T,N,M,K} <: TensorOperator{T,1} | 157 BoundaryQuadrature{T,N,M,K} <: TensorOperator{T,1} |
| 158 | 158 |
