xref: /libCEED/julia/LibCEED.jl/test/rundevtests.jl (revision 1ad466088344f9c7a89b938b3cea7230e969fe10)
1a697ff73SWill Paznerusing Test, LibCEED, LinearAlgebra, StaticArrays
2a697ff73SWill Pazner
3edf04919SJeremy L Thompsonfunction checkoutput(str, fname)
4edf04919SJeremy L Thompson    if str != getoutput(fname)
5edf04919SJeremy L Thompson        write(fname, str)
6edf04919SJeremy L Thompson        return false
7edf04919SJeremy L Thompson    end
8edf04919SJeremy L Thompson    return true
9edf04919SJeremy L Thompsonend
10edf04919SJeremy L Thompson
11*ed094490SJeremy L Thompson@testset "LibCEED Development Tests" begin
12*ed094490SJeremy L Thompson    @testset "Operator" begin
13*ed094490SJeremy L Thompson        c = Ceed()
14*ed094490SJeremy L Thompson        @interior_qf id = (
15*ed094490SJeremy L Thompson            c,
16*ed094490SJeremy L Thompson            (input, :in, EVAL_INTERP),
17*ed094490SJeremy L Thompson            (output, :out, EVAL_INTERP),
18*ed094490SJeremy L Thompson            begin
19*ed094490SJeremy L Thompson                output[] = input
20*ed094490SJeremy L Thompson            end,
21*ed094490SJeremy L Thompson        )
22*ed094490SJeremy L Thompson        b = create_tensor_h1_lagrange_basis(c, 3, 1, 3, 3, GAUSS_LOBATTO)
23*ed094490SJeremy L Thompson        n = getnumnodes(b)
24*ed094490SJeremy L Thompson        offsets = Vector{CeedInt}(0:n-1)
25*ed094490SJeremy L Thompson        r = create_elem_restriction(c, 1, n, 1, 1, n, offsets)
26*ed094490SJeremy L Thompson        op = Operator(
27*ed094490SJeremy L Thompson            c;
28*ed094490SJeremy L Thompson            qf=id,
29*ed094490SJeremy L Thompson            fields=[
30*ed094490SJeremy L Thompson                (:input, r, b, CeedVectorActive()),
31*ed094490SJeremy L Thompson                (:output, r, b, CeedVectorActive()),
32*ed094490SJeremy L Thompson            ],
33*ed094490SJeremy L Thompson        )
34*ed094490SJeremy L Thompson
35*ed094490SJeremy L Thompson        v = rand(CeedScalar, n)
36*ed094490SJeremy L Thompson        v1 = CeedVector(c, v)
37*ed094490SJeremy L Thompson        v2 = CeedVector(c, n)
38*ed094490SJeremy L Thompson
39*ed094490SJeremy L Thompson        comp_op = create_composite_operator(c, [op])
40*ed094490SJeremy L Thompson        apply!(comp_op, v1, v2)
41*ed094490SJeremy L Thompson        @test @witharray_read(a1 = v1, @witharray_read(a2 = v2, a1 == a2))
42*ed094490SJeremy L Thompson    end
43*ed094490SJeremy L Thompsonend
44