Mercurial > repos > public > sbplib_julia
changeset 1667:cea116c7d019 feature/grids/plotting
Close before merge
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Sat, 29 Jun 2024 17:05:28 +0200 |
parents | e2e468c45ed6 (current diff) 5938f713e0d6 (diff) |
children | bcc2be934326 |
files | |
diffstat | 5 files changed, 25 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- a/Notes.md Sat Jun 29 07:14:31 2024 -0700 +++ b/Notes.md Sat Jun 29 17:05:28 2024 +0200 @@ -21,6 +21,21 @@ sat(::DifferentialOperator, grid, stencil_set, bc) = ... ``` + +### Update 2024-06-26 +We will run into trouble if we start assuming things about the coupling +between the continuous and discrete setting. We could add representations of +continuous operators but we will also need representations of discrete +operators. Ideally it should be possible to ignore the continuous +representations and only work with the discrete operators without losing +functionality. The discrete representations does not have to be LazyTensors. +The could be used as inputs to methods for `sat`, `difference_operator` and so +on. + +To see need for a fully functional discrete layer we can consider the +optimization of material parameters or something similar. In this case we do +not necessarily want to handle continuous objects. + ## Reading operators Jonatan's suggestion is to add methods to `Laplace`, `SecondDerivative` and
--- a/src/RegionIndices/RegionIndices.jl Sat Jun 29 07:14:31 2024 -0700 +++ b/src/RegionIndices/RegionIndices.jl Sat Jun 29 17:05:28 2024 +0200 @@ -13,7 +13,7 @@ Index{R,T}(i::T) where {R<:Region,T<:Integer} = new{R,T}(i) Index{R}(i::T) where {R<:Region,T<:Integer} = new{R,T}(i) Index(i::T, ::Type{R}) where {R<:Region,T<:Integer} = Index{R,T}(i) - Index(t::Tuple{T, DataType}) where {R<:Region,T<:Integer} = Index{t[2],T}(t[1]) # TBD: This is not very specific in what types are allowed in t[2]. Can this be fixed? + Index(t::Tuple{T, DataType}) where T<:Integer = Index{t[2],T}(t[1]) # TBD: This is not very specific in what types are allowed in t[2]. Can this be fixed? end export Index
--- a/test/LazyTensors/lazy_tensor_operations_test.jl Sat Jun 29 07:14:31 2024 -0700 +++ b/test/LazyTensors/lazy_tensor_operations_test.jl Sat Jun 29 17:05:28 2024 +0200 @@ -4,13 +4,13 @@ using Tullio -struct DummyMapping{T,R,D} <: LazyTensor{T,R,D} end +struct TransposableDummyMapping{T,R,D} <: LazyTensor{T,R,D} end -LazyTensors.apply(m::DummyMapping{T,R}, v, I::Vararg{Any,R}) where {T,R} = :apply -LazyTensors.apply_transpose(m::DummyMapping{T,R,D}, v, I::Vararg{Any,D}) where {T,R,D} = :apply_transpose +LazyTensors.apply(m::TransposableDummyMapping{T,R}, v, I::Vararg{Any,R}) where {T,R} = :apply +LazyTensors.apply_transpose(m::TransposableDummyMapping{T,R,D}, v, I::Vararg{Any,D}) where {T,R,D} = :apply_transpose -LazyTensors.range_size(m::DummyMapping) = :range_size -LazyTensors.domain_size(m::DummyMapping) = :domain_size +LazyTensors.range_size(m::TransposableDummyMapping) = :range_size +LazyTensors.domain_size(m::TransposableDummyMapping) = :domain_size struct SizeDoublingMapping{T,R,D} <: LazyTensor{T,R,D} @@ -24,7 +24,7 @@ @testset "Mapping transpose" begin - m = DummyMapping{Float64,2,3}() + m = TransposableDummyMapping{Float64,2,3}() @test m' isa LazyTensor{Float64, 3,2} @test m'' == m @test apply(m',zeros(Float64,(0,0)), 0, 0, 0) == :apply_transpose
--- a/test/SbpOperators/volumeops/derivatives/dissipation_test.jl Sat Jun 29 07:14:31 2024 -0700 +++ b/test/SbpOperators/volumeops/derivatives/dissipation_test.jl Sat Jun 29 17:05:28 2024 +0200 @@ -13,20 +13,9 @@ using Sbplib.SbpOperators: dissipation_lower_closure_stencils,dissipation_upper_closure_stencils using Sbplib.SbpOperators: dissipation_transpose_lower_closure_stencils, dissipation_transpose_upper_closure_stencils -""" - monomial(x,k) - -Evaluates ``x^k/k!` with the convetion that it is ``0`` for all ``k<0``. -Has the property that ``d/dx monomial(x,k) = monomial(x,k-1)`` -""" -function monomial(x,k) - if k < 0 - return zero(x) - end - x^k/factorial(k) -end @testset "undivided_skewed04" begin + monomial(x,k) = k < 0 ? zero(x) : x^k/factorial(k) g = equidistant_grid(0., 11., 20) D,Dᵀ = undivided_skewed04(g, 1)
--- a/test/SbpOperators/volumeops/derivatives/first_derivative_test.jl Sat Jun 29 07:14:31 2024 -0700 +++ b/test/SbpOperators/volumeops/derivatives/first_derivative_test.jl Sat Jun 29 17:05:28 2024 +0200 @@ -7,19 +7,6 @@ using Sbplib.SbpOperators: closure_size, Stencil, VolumeOperator -""" - monomial(x,k) - -Evaluates ``x^k/k!` with the convetion that it is ``0`` for all ``k<0``. -Has the property that ``d/dx monomial(x,k) = monomial(x,k-1)`` -""" -function monomial(x,k) - if k < 0 - return zero(x) - end - x^k/factorial(k) -end - @testset "first_derivative" begin @testset "Constructors" begin stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order=2) @@ -39,6 +26,8 @@ @testset "Accuracy conditions" begin N = 20 g = equidistant_grid(0//1, 2//1, N) + + monomial(x,k) = k < 0 ? zero(x) : x^k/factorial(k) @testset for order ∈ [2,4] stencil_set = read_stencil_set(sbp_operators_path()*"standard_diagonal.toml"; order) D₁ = first_derivative(g, stencil_set)