Skip to content

Validate PlotData2D with LinearScalarAdvectionEquation3D #2377

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
52 changes: 52 additions & 0 deletions test/test_visualization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,58 @@ end
end
end
end

@trixi_testset "PlotData2D" begin
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@trixi_testset "PlotData2D" begin
@trixi_testset "PlotData1D and PlotData2D from 3D simulation" begin

equations = LinearScalarAdvectionEquation3D((0.2, -0.7, 0.5))
solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs)
ode_solver = CarpenterKennedy2N54(williamson_condition = false)
coordinates_min = (-1.0, -1.0, -1.0)
coordinates_max = (+1.0, +1.0, +1.0)
diffusivity() = 5.0e-4
equations_parabolic = LaplaceDiffusion3D(diffusivity(), equations)
solver_parabolic = ViscousFormulationBassiRebay1()
boundary_conditions = boundary_condition_periodic
boundary_conditions_parabolic = boundary_condition_periodic
initial_refinement_level = 3

function initial_condition_diffusive_convergence_test(x, t,
equation::LinearScalarAdvectionEquation3D)
x_trans = x - equation.advection_velocity * t
nu = diffusivity()
c = 1.0;
A = 0.5;
L = 2;
f = 1 / L;
Comment on lines +712 to +715
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
c = 1.0;
A = 0.5;
L = 2;
f = 1 / L;
c = 1.0
A = 0.5
L = 2
f = 1 / L

omega = 2 * pi * f
scalar = c + A * sin(omega * sum(x_trans)) * exp(-2 * nu * omega^2 * t)
return SVector(scalar)
end
initial_condition = initial_condition_diffusive_convergence_test

@testset "TreeMesh" begin
mesh = TreeMesh(coordinates_min, coordinates_max;
n_cells_max = 10^4,
initial_refinement_level = initial_refinement_level)
sol = solve(ode, ode_solver; dt = 1.0, adaptive = false,
save_everystep = false)
Comment on lines +726 to +727
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is the ode defined?


pd = @inferred PlotData2D(sol)
@test length(pd.data) == 1

for i in eachindex(pd.x)
x = SVector(pd.x[i], pd.y[i], 0.0)
u = initial_condition(x, 0.1, equations)[1]
@test isapprox(pd.data[1][i], u, atol = 0.9)
end

pd = @inferred PlotData1D(ode.u0, ode.p, slice = :z)
for i in eachindex(pd.x)
x = SVector(0, 0, pd.x[i])
u = initial_condition(x, 0.1, equations)[1]
@test isapprox(pd.data[1], u, atol = 0.5)
end
Comment on lines +732 to +743
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tolerances are quite large. Maybe the time integration method should be adapted to get better results?

end
end
end

@timed_testset "plotting TimeIntegratorSolution" begin
Expand Down
Loading