Skip to content
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

Use Analysis Callback DGMulti parabolic examples #2140

Merged
merged 3 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/dgmulti_2d/elixir_advection_diffusion.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ summary_callback = SummaryCallback()
alive_callback = AliveCallback(alive_interval = 10)
analysis_interval = 100
analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg))
callbacks = CallbackSet(summary_callback, alive_callback)
callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback)

###############################################################################
# run the simulation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ summary_callback = SummaryCallback()
alive_callback = AliveCallback(alive_interval = 10)
analysis_interval = 100
analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg))
callbacks = CallbackSet(summary_callback, alive_callback)
callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback)

###############################################################################
# run the simulation
Expand Down
2 changes: 1 addition & 1 deletion examples/dgmulti_2d/elixir_navierstokes_convergence.jl
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ summary_callback = SummaryCallback()
alive_callback = AliveCallback(alive_interval = 10)
analysis_interval = 100
analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg))
callbacks = CallbackSet(summary_callback, alive_callback)
callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback)

###############################################################################
# run the simulation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ summary_callback = SummaryCallback()
alive_callback = AliveCallback(alive_interval = 10)
analysis_interval = 100
analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg))
callbacks = CallbackSet(summary_callback, alive_callback)
callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback)

###############################################################################
# run the simulation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ summary_callback = SummaryCallback()
alive_callback = AliveCallback(alive_interval = 10)
analysis_interval = 100
analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg))
callbacks = CallbackSet(summary_callback, alive_callback)
callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback)

###############################################################################
# run the simulation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,8 @@ alive_callback = AliveCallback(alive_interval = 10)
analysis_interval = 100
analysis_callback = AnalysisCallback(semi, interval = analysis_interval, uEltype = real(dg),
extra_analysis_integrals = (energy_kinetic,
energy_internal,
enstrophy))
callbacks = CallbackSet(summary_callback, alive_callback)
energy_internal))
callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback)

###############################################################################
# run the simulation
Expand Down
2 changes: 2 additions & 0 deletions src/callbacks_step/analysis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,8 @@ function analyze(quantity::typeof(enstrophy), du, u, t,
mesh, equations, solver, cache = mesh_equations_solver_cache(semi)
equations_parabolic = semi.equations_parabolic
cache_parabolic = semi.cache_parabolic
# We do not apply `enstrophy` directly here because we might later have different `quantity`s
# that we wish to integrate, which can share this routine.
analyze(quantity, du, u, t, mesh, equations, equations_parabolic, solver, cache,
cache_parabolic)
end
Expand Down
40 changes: 0 additions & 40 deletions src/callbacks_step/analysis_dgmulti.jl
Original file line number Diff line number Diff line change
Expand Up @@ -135,46 +135,6 @@ function analyze(::Val{:linf_divb}, du, u, t,
return linf_divB
end

function integrate(func::typeof(enstrophy), u,
mesh::DGMultiMesh,
equations, equations_parabolic::CompressibleNavierStokesDiffusion3D,
dg::DGMulti,
cache, cache_parabolic; normalize = true)
gradients_x, gradients_y, gradients_z = cache_parabolic.gradients

# allocate local storage for gradients.
# TODO: can we avoid allocating here?
local_gradient_quadrature_values = ntuple(_ -> similar(cache_parabolic.local_u_values_threaded),
3)

integral = zero(eltype(u))
for e in eachelement(mesh, dg)
u_quadrature_values = cache_parabolic.local_u_values_threaded[Threads.threadid()]
gradient_x_quadrature_values = local_gradient_quadrature_values[1][Threads.threadid()]
gradient_y_quadrature_values = local_gradient_quadrature_values[2][Threads.threadid()]
gradient_z_quadrature_values = local_gradient_quadrature_values[3][Threads.threadid()]

# interpolate to quadrature on each element
apply_to_each_field(mul_by!(dg.basis.Vq), u_quadrature_values, view(u, :, e))
apply_to_each_field(mul_by!(dg.basis.Vq), gradient_x_quadrature_values,
view(gradients_x, :, e))
apply_to_each_field(mul_by!(dg.basis.Vq), gradient_y_quadrature_values,
view(gradients_y, :, e))
apply_to_each_field(mul_by!(dg.basis.Vq), gradient_z_quadrature_values,
view(gradients_z, :, e))

# integrate over the element
for i in eachindex(u_quadrature_values)
gradients_i = SVector(gradient_x_quadrature_values[i],
gradient_y_quadrature_values[i],
gradient_z_quadrature_values[i])
integral += mesh.md.wJq[i, e] *
func(u_quadrature_values[i], gradients_i, equations)
end
end
return integral
end

function create_cache_analysis(analyzer, mesh::DGMultiMesh,
equations, dg::DGMulti, cache,
RealT, uEltype)
Expand Down
Loading