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

WIP: Node-level visualization support for coefficients of Subcell limiting #1610

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
d37fa21
Add IDP positivity limiting for conservative variables
bennibolm May 15, 2023
a139380
Add elixir with modified blast wave
bennibolm May 17, 2023
891526f
Add documentation
bennibolm May 17, 2023
a24ae11
Merge branch 'main' into IDPlimiting-positivity-cons
bennibolm May 22, 2023
b9ea8cf
Fix parameter type
bennibolm May 24, 2023
f228b0a
Adjust output of summary callback
bennibolm May 24, 2023
ea548da
Merge changes from `subcell-limiting` and `main`
bennibolm Jun 2, 2023
d801349
Merge branch 'main' into IDPlimiting-positivity-cons
bennibolm Jun 2, 2023
4359416
Fix test with right time stepping
bennibolm Jun 2, 2023
8f1f02f
Implement first suggestions
bennibolm Jun 3, 2023
68806e0
Implement suggestions
bennibolm Jun 5, 2023
cf66b94
Fix elixir
bennibolm Jun 5, 2023
a689a6c
Relocate `perform_idp_correction!`
bennibolm Jun 6, 2023
ecc4a18
Rename variable in `snake_case`
bennibolm Jun 6, 2023
8be446a
Implement other suggestions
bennibolm Jun 6, 2023
7acc24f
Rename container variables using `snake_case`
bennibolm Jun 6, 2023
6a46217
Delete timer
bennibolm Jun 6, 2023
e2262e5
Merge `subcell-limiting` (Adapt docstrings)
bennibolm Jun 6, 2023
70d3476
Merge `subcell-limiting`
bennibolm Jun 6, 2023
7979558
Merge `subcell-limiting` (Renaming and dispatch)
bennibolm Jun 10, 2023
b290d5b
Fix documentation
bennibolm Jun 10, 2023
01741c0
Merge branch 'main' into IDPlimiting-positivity-cons
bennibolm Jun 12, 2023
374fccf
Implement positivty limiter with numbers of cons vars
bennibolm Jun 14, 2023
a05a793
Merge branch 'main' into IDPlimiting-positivity-cons
bennibolm Jun 14, 2023
4e693d4
Merge branch 'IDPlimiting-positivity-cons' of https://github.com/benn…
bennibolm Jun 14, 2023
8dc8041
Merge branch 'main' into IDPlimiting-positivity-cons
bennibolm Jun 16, 2023
5f21d5d
Merge branch 'IDPlimiting-positivity-cons' into IDPlimiting-positivit…
bennibolm Jun 16, 2023
1ab075c
Merge suggestions already implemented in `subcell-limiting`
bennibolm Jun 16, 2023
3c7633d
Fix elixir
bennibolm Jun 16, 2023
43de3b7
Merge branch 'IDPlimiting-positivity-cons' into IDPlimiting-positivit…
bennibolm Jun 16, 2023
6cfbbff
Merge pull request #113 from bennibolm/IDPlimiting-positivity-cons-2
bennibolm Jun 19, 2023
b85e9b8
Merge branch 'main' into IDPlimiting-positivity-cons
bennibolm Jun 20, 2023
1785623
Merge branch 'IDPlimiting-positivity-cons' of https://github.com/benn…
bennibolm Jun 20, 2023
dd75ff6
Update docstring and output
bennibolm Jun 20, 2023
5cd186a
Restructure parameter for positivity limiting
bennibolm Jun 21, 2023
9d6d6f5
Add test for "show" routine
bennibolm Jun 21, 2023
7cb8597
Rename Limiters and Containers
bennibolm Jul 5, 2023
f4b6542
Rename antidiffusive stage callback
bennibolm Jul 6, 2023
0c634ed
Relocate subcell limiter code
bennibolm Jul 7, 2023
b055542
Move create_cache routine to specific file
bennibolm Jul 10, 2023
c287c96
Merge branch 'main' into IDPlimiting-positivity-cons
bennibolm Jul 10, 2023
111b334
Merge branch 'main' into IDPlimiting-positivity-cons
bennibolm Aug 9, 2023
0aad20b
Implement suggestions
bennibolm Aug 9, 2023
5c88cf2
Merge branch 'main' into IDPlimiting-positivity-cons
ranocha Aug 9, 2023
106d28b
Add node variables code for IDP limiter
bennibolm Aug 10, 2023
064a3f6
Merge branch 'main' into subcell-limiting-node-variables
bennibolm Aug 18, 2023
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
11 changes: 9 additions & 2 deletions src/callbacks_step/save_solution.jl
Original file line number Diff line number Diff line change
Expand Up @@ -222,21 +222,28 @@ end
end
end

node_variables = Dict{Symbol, Any}()
@trixi_timeit timer() "get node variables" get_node_variables!(node_variables,
semi)

@trixi_timeit timer() "save solution" save_solution_file(u_ode, t, dt, iter, semi,
solution_callback,
element_variables,
node_variables,
system = system)
end

@inline function save_solution_file(u_ode, t, dt, iter,
semi::AbstractSemidiscretization, solution_callback,
element_variables = Dict{Symbol, Any}();
element_variables = Dict{Symbol, Any}(),
node_variables = Dict{Symbol, Any}();
system = "")
mesh, equations, solver, cache = mesh_equations_solver_cache(semi)
u = wrap_array_native(u_ode, mesh, equations, solver, cache)
save_solution_file(u, t, dt, iter, mesh, equations, solver, cache,
solution_callback,
element_variables; system = system)
element_variables,
node_variables; system = system)
end

# TODO: Taal refactor, move save_mesh_file?
Expand Down
20 changes: 18 additions & 2 deletions src/callbacks_step/save_solution_dg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ function save_solution_file(u, time, dt, timestep,
UnstructuredMesh2D, SerialP4estMesh,
SerialT8codeMesh},
equations, dg::DG, cache,
solution_callback, element_variables = Dict{Symbol, Any}();
solution_callback,
element_variables = Dict{Symbol, Any}(),
node_variables = Dict{Symbol, Any}();
system = "")
@unpack output_directory, solution_variables = solution_callback

Expand Down Expand Up @@ -73,6 +75,16 @@ function save_solution_file(u, time, dt, timestep,
var = file["element_variables_$v"]
attributes(var)["name"] = string(key)
end

# Store node variables
for (v, (key, node_variable)) in enumerate(node_variables)
# Add to file
file["node_variables_$v"] = node_variable

# Add variable name as attribute
var = file["node_variables_$v"]
attributes(var)["name"] = string(key)
end
end

return filename
Expand All @@ -81,7 +93,9 @@ end
function save_solution_file(u, time, dt, timestep,
mesh::Union{ParallelTreeMesh, ParallelP4estMesh}, equations,
dg::DG, cache,
solution_callback, element_variables = Dict{Symbol, Any}();
solution_callback,
element_variables = Dict{Symbol, Any}(),
node_variables = Dict{Symbol, Any}();
system = "")
@unpack output_directory, solution_variables = solution_callback

Expand Down Expand Up @@ -111,6 +125,8 @@ function save_solution_file(u, time, dt, timestep,
n_vars = size(data, 1)
end

# TODO: In trixi2txt, the data file is read; including node_variables for every mesh.
# So, do we need node_variables here as well?
if HDF5.has_parallel()
save_solution_file_parallel(data, time, dt, timestep, n_vars, mesh, equations,
dg, cache, solution_variables, filename,
Expand Down
4 changes: 4 additions & 0 deletions src/semidiscretization/semidiscretization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,10 @@ function get_element_variables!(element_variables, u_ode,
get_element_variables!(element_variables, u, mesh_equations_solver_cache(semi)...)
end

function get_node_variables!(node_variables, semi::AbstractSemidiscretization)
get_node_variables!(node_variables, mesh_equations_solver_cache(semi)...)
end

# To implement AMR and use OrdinaryDiffEq.jl etc., we have to be a bit creative.
# Since the caches of the SciML ecosystem are immutable structs, we cannot simply
# change the underlying arrays therein. Hence, to support changing the number of
Expand Down
15 changes: 15 additions & 0 deletions src/solvers/dg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ function get_element_variables!(element_variables, u, mesh, equations,
nothing
end

function get_node_variables!(node_variables, mesh, equations,
volume_integral::AbstractVolumeIntegral, dg, cache)
nothing
end

"""
VolumeIntegralStrongForm()

Expand Down Expand Up @@ -214,6 +219,12 @@ function Base.show(io::IO, mime::MIME"text/plain",
end
end

function get_node_variables!(node_variables, mesh, equations,
volume_integral::VolumeIntegralSubcellLimiting, dg, cache)
get_node_variables!(node_variables, volume_integral.limiter, volume_integral,
equations)
end

# TODO: FD. Should this definition live in a different file because it is
# not strictly a DG method?
"""
Expand Down Expand Up @@ -403,6 +414,10 @@ function get_element_variables!(element_variables, u, mesh, equations, dg::DG, c
dg, cache)
end

function get_node_variables!(node_variables, mesh, equations, dg::DG, cache)
get_node_variables!(node_variables, mesh, equations, dg.volume_integral, dg, cache)
end

const MeshesDGSEM = Union{TreeMesh, StructuredMesh, UnstructuredMesh2D, P4estMesh,
T8codeMesh}

Expand Down
7 changes: 7 additions & 0 deletions src/solvers/dgsem_tree/subcell_limiters.jl
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,11 @@ function Base.show(io::IO, ::MIME"text/plain", limiter::SubcellLimiterIDP)
summary_box(io, "SubcellLimiterIDP", setup)
end
end

function get_node_variables!(node_variables, limiter::SubcellLimiterIDP,
::VolumeIntegralSubcellLimiting, equations)
node_variables[:alpha_limiter] = limiter.cache.container_subcell_limiter.alpha
# Note: alpha is not filled before the first timestep. (TODO?)
return nothing
end
end # @muladd
3 changes: 1 addition & 2 deletions src/solvers/dgsem_tree/subcell_limiters_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
#! format: noindent

# this method is used when the limiter is constructed as for shock-capturing volume integrals
function create_cache(indicator::Type{SubcellLimiterIDP},
equations::AbstractEquations{2},
function create_cache(limiter::Type{SubcellLimiterIDP}, equations::AbstractEquations{2},
basis::LobattoLegendreBasis, number_bounds)
subcell_limiter_coefficients = Trixi.ContainerSubcellLimiterIDP2D{real(basis)
}(0,
Expand Down
13 changes: 11 additions & 2 deletions utils/trixi2txt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ function trixi2txt(filename::AbstractString...;
center_level_0, length_level_0, leaf_cells, coordinates, levels = read_meshfile(meshfile)

# Read data
labels, data, n_elements, n_nodes, element_variables, time = read_datafile(filename)
labels, data, n_elements, n_nodes, element_variables, node_variables, time = read_datafile(filename)

# Check if dimensions match
if length(leaf_cells) != n_elements
Expand Down Expand Up @@ -263,7 +263,16 @@ function read_datafile(filename::String)
index += 1
end

return labels, data, n_elements, n_nodes, element_variables, time
# Extract node variable arrays
node_variables = Dict{String, Union{Vector{Float64}, Vector{Int}}}()
index = 1
while haskey(file, "node_variables_$index")
varname = read(attributes(file["node_variables_$index"])["name"])
node_variables[varname] = read(file["node_variables_$index"])
index += 1
end

return labels, data, n_elements, n_nodes, element_variables, node_variables, time
end
end

Expand Down