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

Draft
wants to merge 46 commits into
base: main
Choose a base branch
from
Draft
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
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
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"
jlchan marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Member

Choose a reason for hiding this comment

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

You are setting this compatibility version so high that SciMLBase will also adopt a higher version, forcing you to use the new version of the DiscreteCallback struct.

That's why even if you're using Julia 1.10 but it still failed here https://github.com/trixi-framework/Trixi.jl/actions/runs/11871869411/job/33084910314?pr=2150#step:7:24

Either change this to a lower version or adopt the new DiscreteCallback struct in precompile.

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
jlchan marked this conversation as resolved.
Show resolved Hide resolved
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