Skip to content

Commit

Permalink
Merge branch 'feature-t8code-support' of github.com:trixi-framework/T…
Browse files Browse the repository at this point in the history
…rixi2Vtk.jl into feature-t8code-support
  • Loading branch information
Johannes Markert committed Nov 15, 2024
2 parents 18c8fe4 + c836fa7 commit 40d84a6
Show file tree
Hide file tree
Showing 9 changed files with 178 additions and 75 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,13 @@ jobs:
# - 'nightly'
os:
- ubuntu-latest
- macOS-latest
- windows-latest
arch:
- x64
include:
- version: '1.9'
os: macOS-latest
arch: arm64
- version: '1.7'
os: ubuntu-latest
arch: x64
Expand Down
4 changes: 2 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Trixi2Vtk"
uuid = "bc1476a1-1ca6-4cc3-950b-c312b255ff95"
authors = ["Michael Schlottke-Lakemper <[email protected]>", "Hendrik Ranocha <[email protected]>"]
version = "0.3.16-pre"
version = "0.3.19-DEV"

[deps]
Glob = "c27321d9-0574-5035-807b-f59d2c89b15c"
Expand All @@ -18,6 +18,6 @@ HDF5 = "0.14, 0.15, 0.16, 0.17"
ProgressMeter = "1.3"
StaticArrays = "0.12, 1.0"
TimerOutputs = "0.5"
Trixi = "0.5, 0.6, 0.7"
Trixi = "0.5, 0.6, 0.7, 0.8, 0.9"
WriteVTK = "1.7"
julia = "1.7"
28 changes: 27 additions & 1 deletion src/convert.jl
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ function trixi2vtk(filename::AbstractString...;
barlen = 40)
end

# Show warning when reinterpolating node-level data of subcell limiting
# Auxiliary variable to show warning only once
has_warned_about_interpolation = false

# Iterate over input files
for (index, filename) in enumerate(filenames)
verbose && println("Processing file $filename ($(index)/$(length(filenames)))...")
Expand Down Expand Up @@ -124,7 +128,7 @@ function trixi2vtk(filename::AbstractString...;
if is_datafile
verbose && println("| Reading data file...")
@timeit "read data" (labels, data, n_elements, n_nodes,
element_variables, time) = read_datafile(filename)
element_variables, node_variables, time) = read_datafile(filename)

assert_cells_elements(n_elements, mesh, filename, meshfile)

Expand Down Expand Up @@ -202,6 +206,28 @@ function trixi2vtk(filename::AbstractString...;
verbose && println("| | Element variable: $label...")
@timeit label vtk_celldata[label] = variable
end

# Add node variables
for (label, variable) in node_variables
verbose && println("| | Node variable: $label...")
if reinterpolate
# Show warning if node-level data of subcell limiting are reinterpolated.
if label == "limiting_coefficient" && !has_warned_about_interpolation
println("WARNING: The limiting coefficients are no continuous field but happens " *
"to be represented by a piecewise-constant approximation. Thus, reinterpolation " *
"does not give a meaningful representation.")
has_warned_about_interpolation = true
end
@timeit "interpolate data" interpolated_cell_data = interpolate_data(Val(format),
reshape(variable, size(variable)..., 1),
mesh, n_visnodes, verbose)
else
@timeit "interpolate data" interpolated_cell_data = reshape(variable,
n_visnodes^ndims_ * n_elements)
end
# Add to node_data
@timeit label vtk_nodedata[label] = interpolated_cell_data
end
end
end
end
Expand Down
17 changes: 16 additions & 1 deletion src/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,21 @@ 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{Array{Float64}, Array{Int}}}()
index = 1
while haskey(file, "node_variables_$index")
varname = read(attributes(file["node_variables_$index"])["name"])
nodedata = read(file["node_variables_$index"])
if ndims_ == 2
node_variables[varname] = Array{Float64}(undef, n_nodes, n_nodes, n_elements)
@views node_variables[varname][:, :, :] .= nodedata
else
error("Unsupported number of spatial dimensions: ", ndims_)
end
index +=1
end

return labels, data, n_elements, n_nodes, element_variables, node_variables, time
end
end
5 changes: 4 additions & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
OrdinaryDiffEq = "1dea7af3-3e70-54e6-95c3-0bf5283fa5ed"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
ReadVTK = "dc215faf-f008-4882-a9f7-a79a826fadc3"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Trixi = "a7f1ee26-1774-49b1-8366-f1abc58fbfcb"
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"

[compat]
Documenter = "0.27, 1"
Downloads = "1"
OrdinaryDiffEq = "6"
ReadVTK = "0.1, 0.2"
Trixi = "0.5, 0.6, 0.7"
Trixi = "0.5, 0.6, 0.7, 0.8, 0.9"
Loading

0 comments on commit 40d84a6

Please sign in to comment.