Mercurial > repos > public > sbplib_julia
comparison src/SbpOperators/volumeops/derivatives/second_derivative_variable.jl @ 901:5bbc3ea3821b feature/variable_derivatives
Implement building from stencil set. Add tests for real operators
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Mon, 14 Feb 2022 11:55:38 +0100 |
parents | 422c9f22cf92 |
children | 33c7e266e1a9 |
comparison
equal
deleted
inserted
replaced
900:00159066485b | 901:5bbc3ea3821b |
---|---|
40 return new{Dir,T,D,N,M,K,TArray}(inner_stencil,closure_stencils,size, coefficient) | 40 return new{Dir,T,D,N,M,K,TArray}(inner_stencil,closure_stencils,size, coefficient) |
41 end | 41 end |
42 end | 42 end |
43 | 43 |
44 function SecondDerivativeVariable(grid::EquidistantGrid, coeff::AbstractArray, inner_stencil, closure_stencils, dir) | 44 function SecondDerivativeVariable(grid::EquidistantGrid, coeff::AbstractArray, inner_stencil, closure_stencils, dir) |
45 return SecondDerivativeVariable{dir, dimension(grid)}(inner_stencil, Tuple(closure_stencils), size(grid), coeff) | 45 Δxᵢ = spacing(grid)[dir] |
46 scaled_inner_stencil = scale(inner_stencil, 1/Δxᵢ^2) | |
47 scaled_closure_stencils = scale.(Tuple(closure_stencils), 1/Δxᵢ^2) | |
48 return SecondDerivativeVariable{dir, dimension(grid)}(scaled_inner_stencil, scaled_closure_stencils, size(grid), coeff) | |
46 end | 49 end |
47 | 50 |
48 function SecondDerivativeVariable(grid::EquidistantGrid{1}, coeff::AbstractVector, inner_stencil, closure_stencils) | 51 function SecondDerivativeVariable(grid::EquidistantGrid{1}, coeff::AbstractVector, inner_stencil, closure_stencils) |
49 return SecondDerivativeVariable(grid, coeff, inner_stencil, closure_stencils, 1) | 52 return SecondDerivativeVariable(grid, coeff, inner_stencil, closure_stencils, 1) |
53 end | |
54 | |
55 function SecondDerivativeVariable(grid::EquidistantGrid, coeff::AbstractArray, stencil_set, dir) | |
56 inner_stencil = parse_nested_stencil(eltype(coeff), stencil_set["D2variable"]["inner_stencil"]) | |
57 closure_stencils = parse_nested_stencil.(eltype(coeff), stencil_set["D2variable"]["closure_stencils"]) | |
58 | |
59 return SecondDerivativeVariable(grid, coeff, inner_stencil, closure_stencils, dir) | |
50 end | 60 end |
51 | 61 |
52 derivative_direction(::SecondDerivativeVariable{Dir}) where {Dir} = Dir | 62 derivative_direction(::SecondDerivativeVariable{Dir}) where {Dir} = Dir |
53 | 63 |
54 closure_size(op::SecondDerivativeVariable) = length(op.closure_stencils) | 64 closure_size(op::SecondDerivativeVariable) = length(op.closure_stencils) |