diff --git a/test/test_elements_add_fields.jl b/test/test_elements_add_fields.jl new file mode 100644 index 0000000..e67c50e --- /dev/null +++ b/test/test_elements_add_fields.jl @@ -0,0 +1,14 @@ +# This file is a part of JuliaFEM. +# License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE.md + +using JuliaFEM.Test + +using JuliaFEM.Core: Quad4, update! + +@testset "add new discrete constant time-variant field and interpolate it" begin + element = Quad4([1, 2, 3, 4]) + element["my field"] = (0.0 => 0.0, 1.0 => 1.0) + @test isapprox(element("my field", [0.0, 0.0], 0.5), 0.5) + update!(element, "my field 2", 0.0 => 0.0, 1.0 => 1.0) + @test isapprox(element("my field 2", [0.0, 0.0], 0.5), 0.5) +end diff --git a/test/test_fields_time_interpolation.jl b/test/test_fields_time_interpolation.jl new file mode 100644 index 0000000..bf8c303 --- /dev/null +++ b/test/test_fields_time_interpolation.jl @@ -0,0 +1,19 @@ +# This file is a part of JuliaFEM. +# License is MIT: see https://github.com/JuliaFEM/JuliaFEM.jl/blob/master/LICENSE.md + +using JuliaFEM.Test + +using JuliaFEM.Core: DCTV, DCTI + +@testset "test interpolation of discrete constant time-variant field" begin + f = DCTV(0.0 => 0.0, 1.0 => 1.0) + # time interpolation of time-variant fields results it's + # time-invariant counterpart + @test isapprox(f(-1.0), DCTI(0.0)) + @test isapprox(f( 0.0), DCTI(0.0)) + @test isapprox(f( 0.3), DCTI(0.3)) + @test isapprox(f( 0.5), DCTI(0.5)) + @test isapprox(f( 0.9), DCTI(0.9)) + @test isapprox(f( 1.0), DCTI(1.0)) + @test isapprox(f( 1.5), DCTI(1.0)) +end