changeset 882:9098fc936776 feature/variable_derivatives

Add the coefficient as a part of the struct. Wrap tests in testsets
author Jonatan Werpers <jonatan@werpers.com>
date Fri, 21 Jan 2022 09:20:58 +0100
parents aa4875f9a530
children 61f5850ca456
files src/SbpOperators/SbpOperators.jl src/SbpOperators/volumeops/derivatives/second_derivative_variable.jl test/SbpOperators/volumeops/derivatives/second_derivative_variable_test.jl
diffstat 3 files changed, 24 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/SbpOperators/SbpOperators.jl	Thu Jan 20 15:18:14 2022 +0100
+++ b/src/SbpOperators/SbpOperators.jl	Fri Jan 21 09:20:58 2022 +0100
@@ -9,6 +9,8 @@
     even = 1
 end
 
+export closure_size
+
 include("stencil.jl")
 include("readoperator.jl")
 include("volumeops/volume_operator.jl")
--- a/src/SbpOperators/volumeops/derivatives/second_derivative_variable.jl	Thu Jan 20 15:18:14 2022 +0100
+++ b/src/SbpOperators/volumeops/derivatives/second_derivative_variable.jl	Fri Jan 21 09:20:58 2022 +0100
@@ -27,16 +27,18 @@
 
 """
     SecondDerivativeVariable{T,N,M,K} <: TensorOperator{T,1}
-Implements a one-dimensional constant coefficients volume operator
+
+Implements the one-dimensional second derivative with variable coefficients.
 """
-struct SecondDerivativeVariable{T,N,M,K} <: TensorMapping{T,1,1}
+struct SecondDerivativeVariable{T,N,M,K,TArray<:AbstractVector} <: TensorMapping{T,1,1}
     inner_stencil::NestedStencil{T,N}
     closure_stencils::NTuple{M,NestedStencil{T,K}}
     size::NTuple{1,Int}
+    coefficient::TArray
 end
 
-function SecondDerivativeVariable(grid::EquidistantGrid{1}, inner_stencil, closure_stencils)
-    return SecondDerivativeVariable(inner_stencil, Tuple(closure_stencils), size(grid))
+function SecondDerivativeVariable(grid::EquidistantGrid{1}, coeff::AbstractVector, inner_stencil, closure_stencils)
+    return SecondDerivativeVariable(inner_stencil, Tuple(closure_stencils), size(grid), coeff)
 end
 
 closure_size(::SecondDerivativeVariable{T,N,M}) where {T,N,M} = M
--- a/test/SbpOperators/volumeops/derivatives/second_derivative_variable_test.jl	Thu Jan 20 15:18:14 2022 +0100
+++ b/test/SbpOperators/volumeops/derivatives/second_derivative_variable_test.jl	Fri Jan 21 09:20:58 2022 +0100
@@ -9,6 +9,7 @@
 
 @testset "SecondDerivativeVariable" begin
     g = EquidistantGrid(11, 0., 1.)
+    c = [  1,  3,  6, 10, 15, 21, 28, 36, 45, 55, 66]
 
     interior_stencil = CenteredNestedStencil((-1/2,  -1/2, 0.),( 1/2,     1.,  1/2),(   0.,  -1/2, -1/2))
     closure_stencils = [
@@ -16,7 +17,20 @@
         NestedStencil((-1/2, -1/2, 0.),( 1/2,   1., 1/2), center = 2),
     ]
 
-    @test SecondDerivativeVariable(interior_stencil,Tuple(closure_stencils), (4,)) isa TensorMapping
-    @test SecondDerivativeVariable(g, interior_stencil, closure_stencils) isa TensorMapping
+    @testset "Constructors" begin
+        @test SecondDerivativeVariable(interior_stencil,Tuple(closure_stencils), (4,), c) isa TensorMapping
+        @test SecondDerivativeVariable(g, c, interior_stencil, closure_stencils) isa TensorMapping
+    end
+
+    @testset "sizes" begin
+        D₂ᶜ = SecondDerivativeVariable(g, c, interior_stencil, closure_stencils)
+        @test closure_size(D₂ᶜ) == 2
+        @test range_size(D₂ᶜ) == (11,)
+        @test domain_size(D₂ᶜ) == (11,)
+    end
+
+    @testset "application" begin
+        # @test D₂(c)*v =
+    end
 end