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 VectorOfArray in wrap_array for DGMulti solvers #2150

Merged
merged 86 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from 46 commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
3b02770
update bound on RecursiveArrayTools to have access to 3.27.3
jlchan Nov 7, 2024
9b21e12
comment out broken precompile statements
jlchan Nov 7, 2024
e66bcd9
adding VoA for DGMulti
jlchan Nov 7, 2024
8da6bfa
Apply suggestions from code review
jlchan Nov 7, 2024
d997c8f
Merge branch 'main' into jc/wrap_VectorOfArray
jlchan Nov 7, 2024
a20dc52
run `Trixi.rhs!` twice to try to avoid excessive allocations
jlchan Nov 7, 2024
781a7d8
bump lower compat of RecursiveArrayTools
jlchan Nov 7, 2024
1d04471
run Trixi.rhs! twice to reduce allocation count
jlchan Nov 8, 2024
c10b421
update l2, linf errors
jlchan Nov 8, 2024
88d08a1
Apply suggestions from code review
jlchan Nov 8, 2024
595a75e
Update test/test_dgmulti_2d.jl
jlchan Nov 8, 2024
b5c218d
Apply suggestions from code review
jlchan Nov 8, 2024
ddc13c3
Apply suggestions from code review
jlchan Nov 8, 2024
fea32d2
Merge branch 'jc/wrap_VectorOfArray' of https://github.com/trixi-fram…
jlchan Nov 8, 2024
d69dbc7
bump LinearAlgebra lower compat for Downgrade CI
jlchan Nov 8, 2024
823caf1
Merge branch 'main' into jc/wrap_VectorOfArray
jlchan Nov 8, 2024
bd16969
Merge branch 'main' into jc/wrap_VectorOfArray
jlchan Nov 8, 2024
0ab4c2e
Merge branch 'main' into jc/wrap_VectorOfArray
jlchan Nov 8, 2024
7d893f3
Merge branch 'main' into jc/wrap_VectorOfArray
jlchan Nov 11, 2024
6277745
Merge remote-tracking branch 'origin/jc/wrap_VectorOfArray' into jc/w…
jlchan Nov 11, 2024
1b700bc
fixing one precompile statement
jlchan Nov 13, 2024
203a77f
Merge branch 'main' into jc/wrap_VectorOfArray
jlchan Nov 13, 2024
0a62556
Revert "fixing one precompile statement"
jlchan Nov 13, 2024
f39883f
Merge branch 'main' into jc/wrap_VectorOfArray
jlchan Nov 14, 2024
13c9c31
Merge branch 'jc/wrap_VectorOfArray' of https://github.com/trixi-fram…
jlchan Nov 14, 2024
8e80b5d
change mu::Float64 to mu::Function in elixir
jlchan Nov 14, 2024
771d95e
update CI
jlchan Nov 14, 2024
3689ebd
Merge branch 'main' into jc/wrap_VectorOfArray
jlchan Nov 14, 2024
ed4246f
Formatting suggestions
jlchan Nov 14, 2024
3740464
fix threaded CI test values
jlchan Nov 14, 2024
e3a7cd8
bump LinearAlgebra compat to fix threaded_legacy tests
jlchan Nov 14, 2024
fd523c8
Merge branch 'main' into jc/wrap_VectorOfArray
jlchan Nov 14, 2024
9e4701a
Update test/test_threaded.jl
jlchan Nov 14, 2024
aeab87d
unwrap VoA for jacobian computations
jlchan Nov 14, 2024
60e6ecf
unwrap VoA for PlotData1D/PlotData2D
jlchan Nov 14, 2024
f5c96da
Update src/semidiscretization/semidiscretization.jl
jlchan Nov 14, 2024
de4d78e
Update src/visualization/types.jl
jlchan Nov 14, 2024
9f494c9
Unpack VoA for visualization test
jlchan Nov 14, 2024
181ac56
bump Julia compat and ci.yml to v1.10
jlchan Nov 14, 2024
1a89762
Merge branch 'jc/wrap_VectorOfArray' of https://github.com/trixi-fram…
jlchan Nov 14, 2024
27729cc
Update test/test_visualization.jl
jlchan Nov 14, 2024
025d968
fix VoA in test_visualization
jlchan Nov 14, 2024
d7b70a6
Update test/test_dgmulti_3d.jl
jlchan Nov 15, 2024
8481581
Update test/test_dgmulti_3d.jl
jlchan Nov 15, 2024
fdf1ff5
uncommenting precompile statement
jlchan Nov 15, 2024
31a85a5
Merge branch 'main' into jc/wrap_VectorOfArray
jlchan Nov 16, 2024
ac33292
Merge branch 'main' into jc/wrap_VectorOfArray
ranocha Jan 28, 2025
825485f
Merge branch 'main' into jc/wrap_VectorOfArray
jlchan Jan 31, 2025
bed695a
Auto stash before merge of "jc/wrap_VectorOfArray" and "origin/jc/wra…
jlchan Jan 31, 2025
dc96351
removing IfElse.jl from Project.toml (why did I add this?)
jlchan Jan 31, 2025
f52fc6b
mark allocation tests as broken for now
jlchan Jan 31, 2025
89e5657
mark allocation tests as broken for now
jlchan Jan 31, 2025
fdbf134
Merge remote-tracking branch 'origin/jc/wrap_VectorOfArray' into jc/w…
jlchan Jan 31, 2025
0f3183b
update dgmulti tests
jlchan Jan 31, 2025
7ad3729
Merge branch 'main' into jc/wrap_VectorOfArray
jlchan Feb 4, 2025
5dc5722
Merge branch 'main' into jc/wrap_VectorOfArray
JoshuaLampert Feb 4, 2025
e02238e
remove @test_broken for passing tests
jlchan Feb 4, 2025
2de33ee
update DGMulti FDSBP 3D CI values
jlchan Feb 4, 2025
10219d7
update parabolic dispatch
jlchan Feb 5, 2025
2a68258
update parabolic dispatch
jlchan Feb 5, 2025
000794f
Merge branch 'jc/wrap_VectorOfArray' of https://github.com/trixi-fram…
jlchan Feb 5, 2025
cc3c532
Apply suggestions from code review
jlchan Feb 5, 2025
aaa0947
Remove additional Trixi.rhs! call in tests
JoshuaLampert Feb 5, 2025
72f958b
Reduce number of allowed allocations
JoshuaLampert Feb 5, 2025
92d8bc4
remove additional Trixi.rhs! calls and reduce number of allowed alloc…
JoshuaLampert Feb 5, 2025
fad0e11
remove more Trixi.rhs! calls
JoshuaLampert Feb 5, 2025
33e18d9
format
JoshuaLampert Feb 5, 2025
96b112b
clean up parabolic rhs test
jlchan Feb 5, 2025
5b85a9b
Merge branch 'jc/wrap_VectorOfArray' of https://github.com/trixi-fram…
jlchan Feb 5, 2025
d91af5f
Merge branch 'main' into jc/wrap_VectorOfArray
jlchan Feb 5, 2025
7114f3d
Update test/test_parabolic_2d.jl
jlchan Feb 5, 2025
0bcdc6b
Update test/test_dgmulti_1d.jl
jlchan Feb 5, 2025
0955a25
use CFL based time stepping to fix positivity issue
JoshuaLampert Feb 6, 2025
768ef25
Merge branch 'main' into jc/wrap_VectorOfArray
JoshuaLampert Feb 6, 2025
9cf54fc
format
JoshuaLampert Feb 6, 2025
11bb917
fix docs
JoshuaLampert Feb 6, 2025
898592f
fix test values (use the ones I get locally)
JoshuaLampert Feb 6, 2025
4cd807f
Keep mu as a constant instead of a function
JoshuaLampert Feb 6, 2025
1ac1d41
try to fix precompiling of summary callback
JoshuaLampert Feb 6, 2025
e38c127
fix precompile
JoshuaLampert Feb 6, 2025
83c2892
try compat "1" for LinearAlgebra
JoshuaLampert Feb 6, 2025
a0d96af
revert precompile stuff
JoshuaLampert Feb 6, 2025
ea0f41f
remove #= FIXME comments
jlchan Feb 6, 2025
1d320f9
Update test/test_parabolic_3d.jl
jlchan Feb 6, 2025
a572bcb
Update test/test_parabolic_3d.jl
jlchan Feb 6, 2025
536f6a7
add news and bump dev version
ranocha Feb 7, 2025
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
6 changes: 1 addition & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,7 @@ jobs:
- mpi
- threaded
include:
- version: '1.8'
os: ubuntu-latest
arch: x64
trixi_test: threaded_legacy
- version: '1.9'
- version: '1.10'
os: ubuntu-latest
arch: x64
trixi_test: threaded_legacy
Expand Down
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ FillArrays = "0.13.2, 1"
ForwardDiff = "0.10.24"
HDF5 = "0.16.10, 0.17"
IfElse = "0.1"
LinearAlgebra = "1"
LinearAlgebra = "1.8.5, 1.10"
LinearMaps = "2.7, 3.0"
LoopVectorization = "0.12.151"
MPI = "0.20.6"
Expand All @@ -94,7 +94,7 @@ PrecompileTools = "1.1"
Preferences = "1.3"
Printf = "1"
RecipesBase = "1.1"
RecursiveArrayTools = "2.38.10"
RecursiveArrayTools = "3.27.1"
Reexport = "1.0"
Requires = "1.1"
SciMLBase = "1.90, 2"
Expand All @@ -115,7 +115,7 @@ TriplotBase = "0.1"
TriplotRecipes = "0.1"
TrixiBase = "0.1.3"
UUIDs = "1.6"
julia = "1.8"
julia = "1.10"

[extras]
Convex = "f65535da-76fb-5f13-bab9-19810c17039a"
Expand Down
4 changes: 2 additions & 2 deletions examples/dgmulti_2d/elixir_navierstokes_lid_driven_cavity.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ using Trixi
# semidiscretization of the ideal compressible Navier-Stokes equations

prandtl_number() = 0.72
mu = 0.001
mu() = 0.001

equations = CompressibleEulerEquations2D(1.4)
equations_parabolic = CompressibleNavierStokesDiffusion2D(equations, mu = mu,
equations_parabolic = CompressibleNavierStokesDiffusion2D(equations, mu = mu(),
Prandtl = prandtl_number())

# Create DG solver with polynomial degree = 3 and (local) Lax-Friedrichs/Rusanov flux as surface flux
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ using Trixi
# semidiscretization of the compressible Navier-Stokes equations

prandtl_number() = 0.72
mu = 6.25e-4 # equivalent to Re = 1600
mu() = 6.25e-4 # equivalent to Re = 1600

equations = CompressibleEulerEquations3D(1.4)
equations_parabolic = CompressibleNavierStokesDiffusion3D(equations, mu = mu,
equations_parabolic = CompressibleNavierStokesDiffusion3D(equations, mu = mu(),
Prandtl = prandtl_number())

"""
Expand Down
1 change: 1 addition & 0 deletions src/Trixi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ using OffsetArrays: OffsetArray, OffsetVector
using P4est
using T8code
using RecipesBase: RecipesBase
using RecursiveArrayTools: VectorOfArray
using Requires: @require
using Static: Static, One, True, False
@reexport using StaticArrays: SVector
Expand Down
6 changes: 3 additions & 3 deletions src/auxiliary/precompile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -523,9 +523,9 @@ function _precompile_manual_()
typeof(Trixi.initialize_summary_callback),
typeof(SciMLBase.FINALIZE_DEFAULT)}
@assert Base.precompile(Tuple{typeof(show), Base.TTY, summary_callback_type})
@assert Base.precompile(Tuple{typeof(show), IOContext{Base.TTY}, MIME"text/plain",
summary_callback_type})
@assert Base.precompile(Tuple{summary_callback_type, Base.TTY})
# @assert Base.precompile(Tuple{typeof(show), IOContext{Base.TTY}, MIME"text/plain",
# summary_callback_type})
# @assert Base.precompile(Tuple{summary_callback_type, Base.TTY})

# TODO: SteadyStateCallback, AnalysisCallback

Expand Down
5 changes: 5 additions & 0 deletions src/semidiscretization/semidiscretization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,11 @@ function _jacobian_ad_forward(semi, t0, u0_ode, du_ode, config)
return J
end

# unpack u if it is wrapped in VectorOfArray (mainly for DGMulti solvers)
jacobian_ad_forward(semi::AbstractSemidiscretization, t0, u0_ode::VectorOfArray) = jacobian_ad_forward(semi,
t0,
parent(u0_ode))

# This version is specialized to `StructArray`s used by some `DGMulti` solvers.
# We need to convert the numerical solution vectors since ForwardDiff cannot
# handle arrays of `SVector`s.
Expand Down
12 changes: 8 additions & 4 deletions src/solvers/dgmulti/dg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,14 @@ end
# interface with semidiscretization_hyperbolic
wrap_array(u_ode, mesh::DGMultiMesh, equations, dg::DGMulti, cache) = u_ode
wrap_array_native(u_ode, mesh::DGMultiMesh, equations, dg::DGMulti, cache) = u_ode

# used to initialize `u_ode` in `semidiscretize`
function allocate_coefficients(mesh::DGMultiMesh, equations, dg::DGMulti, cache)
return VectorOfArray(allocate_nested_array(real(dg), nvariables(equations),
size(mesh.md.x), dg))
end
wrap_array(u_ode::VectorOfArray, mesh::DGMultiMesh, equations, dg::DGMulti, cache) = parent(u_ode)

function digest_boundary_conditions(boundary_conditions::NamedTuple{Keys, ValueTypes},
mesh::DGMultiMesh,
dg::DGMulti,
Expand Down Expand Up @@ -199,10 +207,6 @@ function create_cache(mesh::DGMultiMesh{NDIMS}, equations, dg::DGMultiWeakForm,
local_values_threaded, flux_threaded, rotated_flux_threaded)
end

function allocate_coefficients(mesh::DGMultiMesh, equations, dg::DGMulti, cache)
return allocate_nested_array(real(dg), nvariables(equations), size(mesh.md.x), dg)
end

function compute_coefficients!(u, initial_condition, t,
mesh::DGMultiMesh, equations, dg::DGMulti, cache)
md = mesh.md
Expand Down
14 changes: 14 additions & 0 deletions src/visualization/types.jl
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,20 @@ function PlotData1D(u, mesh::TreeMesh, equations, solver, cache;
orientation_x)
end

# unwrap u if it is VectorOfArray
PlotData1D(u::VectorOfArray, mesh, equations, dg::DGMulti{1}, cache; kwargs...) = PlotData1D(parent(u),
mesh,
equations,
dg,
cache;
kwargs...)
PlotData2D(u::VectorOfArray, mesh, equations, dg::DGMulti{2}, cache; kwargs...) = PlotData2D(parent(u),
mesh,
equations,
dg,
cache;
kwargs...)

function PlotData1D(u, mesh, equations, solver, cache;
solution_variables = nothing, nvisnodes = nothing,
slice = :x, point = (0.0, 0.0, 0.0), curve = nothing)
Expand Down
42 changes: 26 additions & 16 deletions test/test_dgmulti_1d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ isdir(outdir) && rm(outdir, recursive = true)
t = sol.t[end]
u_ode = sol.u[end]
du_ode = similar(u_ode)
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
Trixi.rhs!(du_ode, u_ode, semi, t) # run once first to deal with spurious allocations
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 5000
end
end

Expand All @@ -41,7 +42,8 @@ end
t = sol.t[end]
u_ode = sol.u[end]
du_ode = similar(u_ode)
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
Trixi.rhs!(du_ode, u_ode, semi, t) # run once first to deal with spurious allocations
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 5000
end
end

Expand All @@ -65,7 +67,8 @@ end
t = sol.t[end]
u_ode = sol.u[end]
du_ode = similar(u_ode)
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
Trixi.rhs!(du_ode, u_ode, semi, t) # run once first to deal with spurious allocations
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 5000
end
end

Expand All @@ -89,7 +92,8 @@ end
t = sol.t[end]
u_ode = sol.u[end]
du_ode = similar(u_ode)
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
Trixi.rhs!(du_ode, u_ode, semi, t) # run once first to deal with spurious allocations
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 5000
end
end

Expand All @@ -106,7 +110,8 @@ end
t = sol.t[end]
u_ode = sol.u[end]
du_ode = similar(u_ode)
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
Trixi.rhs!(du_ode, u_ode, semi, t) # run once first to deal with spurious allocations
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 5000
end
end

Expand All @@ -130,7 +135,8 @@ end
t = sol.t[end]
u_ode = sol.u[end]
du_ode = similar(u_ode)
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
Trixi.rhs!(du_ode, u_ode, semi, t) # run once first to deal with spurious allocations
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 5000
end
end

Expand Down Expand Up @@ -161,7 +167,8 @@ end
t = sol.t[end]
u_ode = sol.u[end]
du_ode = similar(u_ode)
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
Trixi.rhs!(du_ode, u_ode, semi, t) # run once first to deal with spurious allocations
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 5000
end
end

Expand All @@ -183,7 +190,8 @@ end
t = sol.t[end]
u_ode = sol.u[end]
du_ode = similar(u_ode)
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
Trixi.rhs!(du_ode, u_ode, semi, t) # run once first to deal with spurious allocations
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 5000
end
end

Expand All @@ -207,14 +215,14 @@ end
cells_per_dimension=(8,),
approximation_type=SBP(),
l2=[
3.03001101100507e-6,
1.692177335948727e-5,
3.002634351734614e-16,
1.1636653574178203e-15
3.0300196635805022e-6,
1.6921833812545857e-5,
2.9844594164368975e-16,
1.1012004949980629e-15
],
linf=[
1.2043401988570679e-5,
5.346847010329059e-5,
1.2043309307818717e-5,
5.346754311919e-5,
9.43689570931383e-16,
2.220446049250313e-15
])
Expand All @@ -224,7 +232,8 @@ end
t = sol.t[end]
u_ode = sol.u[end]
du_ode = similar(u_ode)
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
Trixi.rhs!(du_ode, u_ode, semi, t) # run once first to deal with spurious allocations
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 5000
end
end

Expand All @@ -250,7 +259,8 @@ end
t = sol.t[end]
u_ode = sol.u[end]
du_ode = similar(u_ode)
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 1000
Trixi.rhs!(du_ode, u_ode, semi, t) # run once first to deal with spurious allocations
@test (@allocated Trixi.rhs!(du_ode, u_ode, semi, t)) < 5000
end
end
end
Expand Down
Loading
Loading