Skip to content

Commit

Permalink
Update to tensorproductspectraloperator tests after PR #127 API change
Browse files Browse the repository at this point in the history
  • Loading branch information
valeriabarra committed Sep 13, 2021
1 parent dc1aad7 commit 9d4062a
Showing 1 changed file with 42 additions and 8 deletions.
50 changes: 42 additions & 8 deletions test/tensorproductspectraloperators.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,50 @@ space = Spaces.SpectralElementSpace2D(ts_topology, quad)

coords = Fields.coordinate_field(space)

@testset "TensorProductMesh: gradient" begin
@testset "TensorProductMesh: interpolate / restrict" begin
INq = 9
Iquad = Spaces.Quadratures.GLL{INq}()
Ispace = Spaces.SpectralElementSpace2D(ts_topology, Iquad)

I = Operators.Interpolate(Ispace)
R = Operators.Restrict(space)

f = sin.(coords.x1 .+ 2 .* coords.x2)

interpolated_field = I.(f)
Spaces.weighted_dss!(interpolated_field)

@test axes(interpolated_field).quadrature_style == Iquad
@test axes(interpolated_field).topology == ts_topology

restrict_field = R.(f)
Spaces.weighted_dss!(restrict_field)

@test axes(restrict_field).quadrature_style == quad
@test axes(restrict_field).topology == ts_topology

interp_restrict_field = R.(I.(f))
Spaces.weighted_dss!(interp_restrict_field)

@test axes(interp_restrict_field).quadrature_style == quad
@test axes(interp_restrict_field).topology == ts_topology

@test norm(interp_restrict_field .- f) 3.0e-4
end

@testset "gradient" begin
f = sin.(coords.x1 .+ 2 .* coords.x2)

grad = Operators.Gradient()
gradf = grad.(f)
Spaces.weighted_dss!(gradf)

@test gradf
Geometry.Cartesian12Vector.(
cos.(coords.x1 .+ 2 .* coords.x2),
2 .* cos.(coords.x1 .+ 2 .* coords.x2),
Geometry.Covariant12Vector.(
Geometry.Cartesian12Vector.(
cos.(coords.x1 .+ 2 .* coords.x2),
2 .* cos.(coords.x1 .+ 2 .* coords.x2),
),
) rtol = 1e-2
end

Expand All @@ -43,7 +76,7 @@ end
gradf = wgrad.(f)
Spaces.weighted_dss!(gradf)

@test gradf
@test Geometry.Cartesian12Vector.(gradf)
Geometry.Cartesian12Vector.(
cos.(coords.x1 .+ 2 .* coords.x2),
2 .* cos.(coords.x1 .+ 2 .* coords.x2),
Expand Down Expand Up @@ -224,20 +257,21 @@ end
(k^2 + l^2)^2 * sin(k * coords.x1 + l * coords.x2),
0.0,
)

curl = Operators.Curl()
wcurl = Operators.WeakCurl()

sdiv = Operators.Divergence()
wgrad = Operators.WeakGradient()

χ = Spaces.weighted_dss!(
@. wgrad(sdiv(y)) - Geometry.Cartesian12Vector(
@. Geometry.Cartesian12Vector(wgrad(sdiv(y))) -
Geometry.Cartesian12Vector(
wcurl(Geometry.Covariant3Vector(curl(y))),
)
)
∇⁴y = Spaces.weighted_dss!(
@. wgrad(sdiv(χ)) - Geometry.Cartesian12Vector(
@. Geometry.Cartesian12Vector(wgrad(sdiv(χ))) -
Geometry.Cartesian12Vector(
wcurl(Geometry.Covariant3Vector(curl(χ))),
)
)
Expand Down

0 comments on commit 9d4062a

Please sign in to comment.