From c4cbb5a97a76745f51f279770b6d2c449fca1828 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Tue, 29 Jul 2025 13:47:12 +0200 Subject: [PATCH 01/38] example linear newton krylov --- .../tree_1d_dgsem/elixir_diffusion_ldg.jl | 5 +- .../elixir_diffusion_ldg_newton_krylov.jl | 59 +++++++++++++++++++ test/Project.toml | 2 + test/test_parabolic_1d.jl | 14 +++++ 4 files changed, 77 insertions(+), 3 deletions(-) create mode 100644 examples/tree_1d_dgsem/elixir_diffusion_ldg_newton_krylov.jl diff --git a/examples/tree_1d_dgsem/elixir_diffusion_ldg.jl b/examples/tree_1d_dgsem/elixir_diffusion_ldg.jl index 68f5c650c01..143a9cc9840 100644 --- a/examples/tree_1d_dgsem/elixir_diffusion_ldg.jl +++ b/examples/tree_1d_dgsem/elixir_diffusion_ldg.jl @@ -44,15 +44,14 @@ boundary_conditions_parabolic = boundary_condition_periodic solver_parabolic = ViscousFormulationLocalDG() semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), initial_condition, - solver; - solver_parabolic, + solver; solver_parabolic, boundary_conditions = (boundary_conditions, boundary_conditions_parabolic)) ############################################################################### # ODE solvers, callbacks etc. -# Create ODE problem with time span from 0.0 to 1.0 +# Create ODE problem with time span from 0.0 to 0.1 tspan = (0.0, 0.1) ode = semidiscretize(semi, tspan) diff --git a/examples/tree_1d_dgsem/elixir_diffusion_ldg_newton_krylov.jl b/examples/tree_1d_dgsem/elixir_diffusion_ldg_newton_krylov.jl new file mode 100644 index 00000000000..8278ff14e89 --- /dev/null +++ b/examples/tree_1d_dgsem/elixir_diffusion_ldg_newton_krylov.jl @@ -0,0 +1,59 @@ +using Trixi +using OrdinaryDiffEqSDIRK +using LinearSolve # For Jacobian-free Newton-Krylov (GMRES) solver +using ADTypes # For automatic differentiation via finite differences + +############################################################################### +# semidiscretization of the linear (advection) diffusion equation + +advection_velocity = 0.0 # Note: This renders the equation mathematically purely parabolic +equations = LinearScalarAdvectionEquation1D(advection_velocity) +diffusivity() = 0.5 +equations_parabolic = LaplaceDiffusion1D(diffusivity(), equations) + +# surface flux does not matter for pure diffusion problem +solver = DGSEM(polydeg = 3, surface_flux = flux_central) + +coordinates_min = -convert(Float64, pi) +coordinates_max = convert(Float64, pi) + +mesh = TreeMesh(coordinates_min, coordinates_max, + initial_refinement_level = 4, + n_cells_max = 30_000) + +function initial_condition_pure_diffusion_1d_convergence_test(x, t, + equation) + nu = diffusivity() + c = 0 + A = 1 + omega = 1 + scalar = c + A * sin(omega * sum(x)) * exp(-nu * omega^2 * t) + return SVector(scalar) +end +initial_condition = initial_condition_pure_diffusion_1d_convergence_test + +solver_parabolic = ViscousFormulationLocalDG() +semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), + initial_condition, + solver; solver_parabolic) + +############################################################################### +# ODE solvers, callbacks etc. + +tspan = (0.0, 2.0) +ode = semidiscretize(semi, tspan) + +summary_callback = SummaryCallback() +analysis_callback = AnalysisCallback(semi, interval = 10) +alive_callback = AliveCallback(alive_interval = 1) + +callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback) + +############################################################################### +# run the simulation + +sol = solve(ode, + # Use (diagonally) implicit Runge-Kutta method with Jacobian-free Newton-Krylov (GMRES) solver + # See https://docs.sciml.ai/DiffEqDocs/stable/tutorials/advanced_ode_example/#Using-Jacobian-Free-Newton-Krylov + KenCarp47(autodiff = AutoFiniteDiff(), linsolve = KrylovJL_GMRES()); + ode_default_options()..., callback = callbacks) diff --git a/test/Project.toml b/test/Project.toml index b085cf23860..49dfe2fd6b5 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -13,6 +13,7 @@ ExplicitImports = "7d51a73a-1435-4ff3-83d9-f097790105c7" FFMPEG = "c87230d0-a227-11e9-1b43-d7ebe4e7570a" ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +LinearSolve = "7ed4a6bd-45f5-4d41-b270-4a48e9bafcae" MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195" NLsolve = "2774e3e8-f4cf-5e23-947b-6d7e65073b56" OrdinaryDiffEqFeagin = "101fe9f7-ebb6-4678-b671-3a81e7194747" @@ -45,6 +46,7 @@ ExplicitImports = "1.0.1" FFMPEG = "0.4" ForwardDiff = "0.10.36, 1" LinearAlgebra = "1" +LinearSolve = "3.23.0" MPI = "0.20.6" NLsolve = "4.5.1" OrdinaryDiffEqFeagin = "1" diff --git a/test/test_parabolic_1d.jl b/test/test_parabolic_1d.jl index 8969b06eb13..7bcac79cea9 100644 --- a/test/test_parabolic_1d.jl +++ b/test/test_parabolic_1d.jl @@ -58,6 +58,20 @@ end end end +@trixi_testset "TreeMesh1D: elixir_diffusion_ldg_newton_krylov.jl" begin + @test_trixi_include(joinpath(examples_dir(), "tree_1d_dgsem", + "elixir_diffusion_ldg_newton_krylov.jl"), + l2=[6.542981787119615e-6], linf=[1.712011459781282e-5]) + # Ensure that we do not have excessive memory allocations + # (e.g., from type instabilities) + let + 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 + end +end + @trixi_testset "TreeMesh1D: elixir_advection_diffusion_restart.jl" begin @test_trixi_include(joinpath(examples_dir(), "tree_1d_dgsem", "elixir_advection_diffusion_restart.jl"), From 8a4fdcda13087f2cd8addb98ee19e48b12e86085 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Tue, 29 Jul 2025 14:17:37 +0200 Subject: [PATCH 02/38] Nonlinear example --- ...avierstokes_viscous_shock_newton_krylov.jl | 171 ++++++++++++++++++ test/test_parabolic_2d.jl | 25 +++ 2 files changed, 196 insertions(+) create mode 100644 examples/p4est_2d_dgsem/elixir_navierstokes_viscous_shock_newton_krylov.jl diff --git a/examples/p4est_2d_dgsem/elixir_navierstokes_viscous_shock_newton_krylov.jl b/examples/p4est_2d_dgsem/elixir_navierstokes_viscous_shock_newton_krylov.jl new file mode 100644 index 00000000000..525ab1d9b00 --- /dev/null +++ b/examples/p4est_2d_dgsem/elixir_navierstokes_viscous_shock_newton_krylov.jl @@ -0,0 +1,171 @@ +using Trixi +using OrdinaryDiffEqSDIRK +using LinearSolve # For Jacobian-free Newton-Krylov (GMRES) solver +using ADTypes # For automatic differentiation via finite differences + +# This is the classic 1D viscous shock wave problem with analytical solution +# for a special value of the Prandtl number. +# The original references are: +# +# - R. Becker (1922) +# Stoßwelle und Detonation. +# [DOI: 10.1007/BF01329605](https://doi.org/10.1007/BF01329605) +# +# English translations: +# Impact waves and detonation. Part I. +# https://ntrs.nasa.gov/api/citations/19930090862/downloads/19930090862.pdf +# Impact waves and detonation. Part II. +# https://ntrs.nasa.gov/api/citations/19930090863/downloads/19930090863.pdf +# +# - M. Morduchow, P. A. Libby (1949) +# On a Complete Solution of the One-Dimensional Flow Equations +# of a Viscous, Head-Conducting, Compressible Gas +# [DOI: 10.2514/8.11882](https://doi.org/10.2514/8.11882) +# +# +# The particular problem considered here is described in +# - L. G. Margolin, J. M. Reisner, P. M. Jordan (2017) +# Entropy in self-similar shock profiles +# [DOI: 10.1016/j.ijnonlinmec.2017.07.003](https://doi.org/10.1016/j.ijnonlinmec.2017.07.003) + +### Fixed parameters ### + +# Special value for which nonlinear solver can be omitted +# Corresponds essentially to fixing the Mach number +alpha = 0.5 +# We want kappa = cp * mu = mu_bar to ensure constant enthalpy +prandtl_number() = 3 / 4 + +### Free choices: ### +gamma() = 5 / 3 + +# In Margolin et al., the Navier-Stokes equations are given for an +# isotropic stress tensor τ, i.e., ∇ ⋅ τ = μ Δu +mu_isotropic() = 0.15 +mu_bar() = mu_isotropic() / (gamma() - 1) # Re-scaled viscosity + +rho_0() = 1 +v() = 1 # Shock speed + +domain_length = 4.0 + +### Derived quantities ### + +Ma() = 2 / sqrt(3 - gamma()) # Mach number for alpha = 0.5 +c_0() = v() / Ma() # Speed of sound ahead of the shock + +# From constant enthalpy condition +p_0() = c_0()^2 * rho_0() / gamma() + +l() = mu_bar() / (rho_0() * v()) * 2 * gamma() / (gamma() + 1) # Appropriate length scale + +""" + initial_condition_viscous_shock(x, t, equations) + +Classic 1D viscous shock wave problem with analytical solution +for a special value of the Prandtl number. +The version implemented here is described in +- L. G. Margolin, J. M. Reisner, P. M. Jordan (2017) + Entropy in self-similar shock profiles + [DOI: 10.1016/j.ijnonlinmec.2017.07.003](https://doi.org/10.1016/j.ijnonlinmec.2017.07.003) +""" +function initial_condition_viscous_shock(x, t, equations) + y = x[1] - v() * t # Translated coordinate + + # Coordinate transformation. See eq. (33) in Margolin et al. (2017) + chi = 2 * exp(y / (2 * l())) + + w = 1 + 1 / (2 * chi^2) * (1 - sqrt(1 + 2 * chi^2)) + + rho = rho_0() / w + u = v() * (1 - w) + p = p_0() * 1 / w * (1 + (gamma() - 1) / 2 * Ma()^2 * (1 - w^2)) + + return prim2cons(SVector(rho, u, 0, p), equations) +end +initial_condition = initial_condition_viscous_shock + +############################################################################### +# semidiscretization of the ideal compressible Navier-Stokes equations + +equations = CompressibleEulerEquations2D(gamma()) + +# Trixi implements the stress tensor in deviatoric form, thus we need to +# convert the "isotropic viscosity" to the "deviatoric viscosity" +mu_deviatoric() = mu_bar() * 3 / 4 +equations_parabolic = CompressibleNavierStokesDiffusion2D(equations, mu = mu_deviatoric(), + Prandtl = prandtl_number(), + gradient_variables = GradientVariablesEntropy()) + +solver = DGSEM(polydeg = 3, surface_flux = flux_hlle) + +coordinates_min = (-domain_length / 2, -domain_length / 2) +coordinates_max = (domain_length / 2, domain_length / 2) + +trees_per_dimension = (12, 3) +mesh = P4estMesh(trees_per_dimension, + polydeg = 3, initial_refinement_level = 0, + coordinates_min = coordinates_min, coordinates_max = coordinates_max, + periodicity = (false, true)) + +### Inviscid boundary conditions ### + +# Prescribe pure influx based on initial conditions +function boundary_condition_inflow(u_inner, normal_direction::AbstractVector, x, t, + surface_flux_function, + equations::CompressibleEulerEquations2D) + u_cons = initial_condition_viscous_shock(x, t, equations) + flux = Trixi.flux(u_cons, normal_direction, equations) + + return flux +end + +boundary_conditions = Dict(:x_neg => boundary_condition_inflow, + :x_pos => boundary_condition_do_nothing) + +### Viscous boundary conditions ### +# For the viscous BCs, we use the known analytical solution +velocity_bc = NoSlip() do x, t, equations_parabolic + Trixi.velocity(initial_condition_viscous_shock(x, + t, + equations_parabolic), + equations_parabolic) +end + +heat_bc = Isothermal() do x, t, equations_parabolic + Trixi.temperature(initial_condition_viscous_shock(x, + t, + equations_parabolic), + equations_parabolic) +end + +boundary_condition_parabolic = BoundaryConditionNavierStokesWall(velocity_bc, heat_bc) + +boundary_conditions_parabolic = Dict(:x_neg => boundary_condition_parabolic, + :x_pos => boundary_condition_parabolic) + +semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabolic), + initial_condition, solver; + boundary_conditions = (boundary_conditions, + boundary_conditions_parabolic)) + +############################################################################### +# ODE solvers, callbacks etc. + +tspan = (0.0, 1.0) +ode = semidiscretize(semi, tspan) + +summary_callback = SummaryCallback() +alive_callback = AliveCallback(alive_interval = 1) +analysis_callback = AnalysisCallback(semi, interval = 100) + +callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback) + +############################################################################### +# run the simulation + +sol = solve(ode, + # Use (diagonally) implicit Runge-Kutta method with Jacobian-free Newton-Krylov (GMRES) solver + # See https://docs.sciml.ai/DiffEqDocs/stable/tutorials/advanced_ode_example/#Using-Jacobian-Free-Newton-Krylov + KenCarp47(autodiff = AutoFiniteDiff(), linsolve = KrylovJL_GMRES()); + ode_default_options()..., callback = callbacks) diff --git a/test/test_parabolic_2d.jl b/test/test_parabolic_2d.jl index 41450ffea1f..091bbedcc07 100644 --- a/test/test_parabolic_2d.jl +++ b/test/test_parabolic_2d.jl @@ -866,6 +866,31 @@ end end end +@trixi_testset "P4estMesh2D: elixir_navierstokes_viscous_shock_newton_krylov.jl" begin + @test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", + "elixir_navierstokes_viscous_shock_newton_krylov.jl"), + l2=[ + 0.0050454344200822595, + 0.004688806400845471, + 2.636511509998046e-5, + 0.0047873461533362765 + ], + linf=[ + 0.02208819271861917, + 0.024209434405893293, + 0.0007989190783110008, + 0.026948544666356877 + ]) + # Ensure that we do not have excessive memory allocations + # (e.g., from type instabilities) + let + 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 + end +end + @trixi_testset "elixir_navierstokes_SD7003airfoil.jl" begin @test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", "elixir_navierstokes_SD7003airfoil.jl"), From 94f250a0f9a4e801b74f8e77bdce5d9b3b0febad Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Tue, 29 Jul 2025 14:18:35 +0200 Subject: [PATCH 03/38] comment --- .../elixir_navierstokes_viscous_shock_newton_krylov.jl | 2 +- examples/tree_1d_dgsem/elixir_diffusion_ldg_newton_krylov.jl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/p4est_2d_dgsem/elixir_navierstokes_viscous_shock_newton_krylov.jl b/examples/p4est_2d_dgsem/elixir_navierstokes_viscous_shock_newton_krylov.jl index 525ab1d9b00..f0f61b04e8c 100644 --- a/examples/p4est_2d_dgsem/elixir_navierstokes_viscous_shock_newton_krylov.jl +++ b/examples/p4est_2d_dgsem/elixir_navierstokes_viscous_shock_newton_krylov.jl @@ -165,7 +165,7 @@ callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback) # run the simulation sol = solve(ode, - # Use (diagonally) implicit Runge-Kutta method with Jacobian-free Newton-Krylov (GMRES) solver + # Use (diagonally) implicit Runge-Kutta method with Jacobian-free (!) Newton-Krylov (GMRES) solver # See https://docs.sciml.ai/DiffEqDocs/stable/tutorials/advanced_ode_example/#Using-Jacobian-Free-Newton-Krylov KenCarp47(autodiff = AutoFiniteDiff(), linsolve = KrylovJL_GMRES()); ode_default_options()..., callback = callbacks) diff --git a/examples/tree_1d_dgsem/elixir_diffusion_ldg_newton_krylov.jl b/examples/tree_1d_dgsem/elixir_diffusion_ldg_newton_krylov.jl index 8278ff14e89..972b8194912 100644 --- a/examples/tree_1d_dgsem/elixir_diffusion_ldg_newton_krylov.jl +++ b/examples/tree_1d_dgsem/elixir_diffusion_ldg_newton_krylov.jl @@ -53,7 +53,7 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback) # run the simulation sol = solve(ode, - # Use (diagonally) implicit Runge-Kutta method with Jacobian-free Newton-Krylov (GMRES) solver + # Use (diagonally) implicit Runge-Kutta method with Jacobian-free (!) Newton-Krylov (GMRES) solver # See https://docs.sciml.ai/DiffEqDocs/stable/tutorials/advanced_ode_example/#Using-Jacobian-Free-Newton-Krylov KenCarp47(autodiff = AutoFiniteDiff(), linsolve = KrylovJL_GMRES()); ode_default_options()..., callback = callbacks) From 2a51e91a85f4ab10912db4bc0d83de52654f87dc Mon Sep 17 00:00:00 2001 From: Daniel Doehring Date: Tue, 29 Jul 2025 14:54:51 +0200 Subject: [PATCH 04/38] Update test/Project.toml --- test/Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Project.toml b/test/Project.toml index 49dfe2fd6b5..306144d2a9b 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -46,7 +46,7 @@ ExplicitImports = "1.0.1" FFMPEG = "0.4" ForwardDiff = "0.10.36, 1" LinearAlgebra = "1" -LinearSolve = "3.23.0" +LinearSolve = "3" MPI = "0.20.6" NLsolve = "4.5.1" OrdinaryDiffEqFeagin = "1" From 16dc218738d2c2652c12c6a7f3435766bc9904e8 Mon Sep 17 00:00:00 2001 From: Daniel Doehring Date: Tue, 29 Jul 2025 14:58:43 +0200 Subject: [PATCH 05/38] Update test/Project.toml --- test/Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Project.toml b/test/Project.toml index 306144d2a9b..85c54527b1c 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -46,7 +46,7 @@ ExplicitImports = "1.0.1" FFMPEG = "0.4" ForwardDiff = "0.10.36, 1" LinearAlgebra = "1" -LinearSolve = "3" +LinearSolve = "2, 3" MPI = "0.20.6" NLsolve = "4.5.1" OrdinaryDiffEqFeagin = "1" From 238afe3741d12304939731cfede0f6dd6456b468 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Tue, 29 Jul 2025 15:32:21 +0200 Subject: [PATCH 06/38] check different sciml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 27f5bbca28e..14da32c3014 100644 --- a/Project.toml +++ b/Project.toml @@ -102,7 +102,7 @@ RecipesBase = "1.3.4" RecursiveArrayTools = "3.31.1" Reexport = "1.2" Requires = "1.3" -SciMLBase = "2.67.0" +SciMLBase = "1, 2" SimpleUnPack = "1.1" SparseArrays = "1" StableRNGs = "1.0.2" From 1221c949a227d1afd60c9b333103538b8d1fed3b Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Tue, 29 Jul 2025 15:33:43 +0200 Subject: [PATCH 07/38] v --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 14da32c3014..7477a7608ca 100644 --- a/Project.toml +++ b/Project.toml @@ -102,7 +102,7 @@ RecipesBase = "1.3.4" RecursiveArrayTools = "3.31.1" Reexport = "1.2" Requires = "1.3" -SciMLBase = "1, 2" +SciMLBase = "2" SimpleUnPack = "1.1" SparseArrays = "1" StableRNGs = "1.0.2" From 3453202904e9de3b937cbb98376b7b2eec2d31be Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Tue, 29 Jul 2025 15:35:40 +0200 Subject: [PATCH 08/38] v --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 7477a7608ca..8597fc7ff94 100644 --- a/Project.toml +++ b/Project.toml @@ -102,7 +102,7 @@ RecipesBase = "1.3.4" RecursiveArrayTools = "3.31.1" Reexport = "1.2" Requires = "1.3" -SciMLBase = "2" +SciMLBase = "2.x" SimpleUnPack = "1.1" SparseArrays = "1" StableRNGs = "1.0.2" From 7512dce637c710075234d77b56a84f6393bfc1ce Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Tue, 29 Jul 2025 15:37:01 +0200 Subject: [PATCH 09/38] v --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 8597fc7ff94..7477a7608ca 100644 --- a/Project.toml +++ b/Project.toml @@ -102,7 +102,7 @@ RecipesBase = "1.3.4" RecursiveArrayTools = "3.31.1" Reexport = "1.2" Requires = "1.3" -SciMLBase = "2.x" +SciMLBase = "2" SimpleUnPack = "1.1" SparseArrays = "1" StableRNGs = "1.0.2" From 57e59892b900471d82ab826a70ec593fb613b8a3 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Tue, 29 Jul 2025 15:38:48 +0200 Subject: [PATCH 10/38] v --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index 7477a7608ca..04bb89a3a1a 100644 --- a/Project.toml +++ b/Project.toml @@ -102,7 +102,7 @@ RecipesBase = "1.3.4" RecursiveArrayTools = "3.31.1" Reexport = "1.2" Requires = "1.3" -SciMLBase = "2" +SciMLBase = "2.53" SimpleUnPack = "1.1" SparseArrays = "1" StableRNGs = "1.0.2" From 1ae7504f372f759fb5088c5588994465e9dd63c2 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Tue, 29 Jul 2025 15:43:26 +0200 Subject: [PATCH 11/38] v --- test/Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Project.toml b/test/Project.toml index 85c54527b1c..d69c2be64a0 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -46,7 +46,7 @@ ExplicitImports = "1.0.1" FFMPEG = "0.4" ForwardDiff = "0.10.36, 1" LinearAlgebra = "1" -LinearSolve = "2, 3" +LinearSolve = "2.7, 3" MPI = "0.20.6" NLsolve = "4.5.1" OrdinaryDiffEqFeagin = "1" From a1ffd0d2d37d9ed8ccc3cc93880fd71888af87e7 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Tue, 29 Jul 2025 15:46:34 +0200 Subject: [PATCH 12/38] v --- test/Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Project.toml b/test/Project.toml index d69c2be64a0..2ce9e49bfbd 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -46,7 +46,7 @@ ExplicitImports = "1.0.1" FFMPEG = "0.4" ForwardDiff = "0.10.36, 1" LinearAlgebra = "1" -LinearSolve = "2.7, 3" +LinearSolve = "2.7-2.39, 3" MPI = "0.20.6" NLsolve = "4.5.1" OrdinaryDiffEqFeagin = "1" From 0adb28409932ac95ae92b6b46b19c8994598e508 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Tue, 29 Jul 2025 15:48:08 +0200 Subject: [PATCH 13/38] v --- test/Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Project.toml b/test/Project.toml index 2ce9e49bfbd..85c54527b1c 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -46,7 +46,7 @@ ExplicitImports = "1.0.1" FFMPEG = "0.4" ForwardDiff = "0.10.36, 1" LinearAlgebra = "1" -LinearSolve = "2.7-2.39, 3" +LinearSolve = "2, 3" MPI = "0.20.6" NLsolve = "4.5.1" OrdinaryDiffEqFeagin = "1" From b1800561979a8e05b8e61602be1a0efc81df4787 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Tue, 29 Jul 2025 15:51:39 +0200 Subject: [PATCH 14/38] v --- test/Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Project.toml b/test/Project.toml index 85c54527b1c..27f11f43692 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -46,7 +46,7 @@ ExplicitImports = "1.0.1" FFMPEG = "0.4" ForwardDiff = "0.10.36, 1" LinearAlgebra = "1" -LinearSolve = "2, 3" +LinearSolve = "1, 2, 3" MPI = "0.20.6" NLsolve = "4.5.1" OrdinaryDiffEqFeagin = "1" From 83dce58e0791f9af9bf5e6565eef479e9203ea0c Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Tue, 29 Jul 2025 15:54:47 +0200 Subject: [PATCH 15/38] v --- Project.toml | 2 +- test/Project.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Project.toml b/Project.toml index 04bb89a3a1a..c39e1271810 100644 --- a/Project.toml +++ b/Project.toml @@ -102,7 +102,7 @@ RecipesBase = "1.3.4" RecursiveArrayTools = "3.31.1" Reexport = "1.2" Requires = "1.3" -SciMLBase = "2.53" +SciMLBase = "2.67" SimpleUnPack = "1.1" SparseArrays = "1" StableRNGs = "1.0.2" diff --git a/test/Project.toml b/test/Project.toml index 27f11f43692..85c54527b1c 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -46,7 +46,7 @@ ExplicitImports = "1.0.1" FFMPEG = "0.4" ForwardDiff = "0.10.36, 1" LinearAlgebra = "1" -LinearSolve = "1, 2, 3" +LinearSolve = "2, 3" MPI = "0.20.6" NLsolve = "4.5.1" OrdinaryDiffEqFeagin = "1" From 41f0b7ce217b3c6d93b6e87460d6a60afc059fba Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Tue, 29 Jul 2025 15:59:53 +0200 Subject: [PATCH 16/38] v --- test/Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Project.toml b/test/Project.toml index 85c54527b1c..d69c2be64a0 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -46,7 +46,7 @@ ExplicitImports = "1.0.1" FFMPEG = "0.4" ForwardDiff = "0.10.36, 1" LinearAlgebra = "1" -LinearSolve = "2, 3" +LinearSolve = "2.7, 3" MPI = "0.20.6" NLsolve = "4.5.1" OrdinaryDiffEqFeagin = "1" From 9497f15b56199b3439c8d3a120f4303426a93570 Mon Sep 17 00:00:00 2001 From: Daniel Doehring Date: Tue, 29 Jul 2025 17:03:41 +0200 Subject: [PATCH 17/38] Update test/Project.toml --- test/Project.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/test/Project.toml b/test/Project.toml index 4a46e2d8660..0842c1fcba5 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -44,7 +44,6 @@ ECOS = "1.1.2" ExplicitImports = "1.0.1" ForwardDiff = "0.10.36, 1" LinearAlgebra = "1" -LinearSolve = "2.7, 3" MPI = "0.20.6" NLsolve = "4.5.1" OrdinaryDiffEqFeagin = "1" From da5500b2ef386fdb67cb05d287644a358e710cca Mon Sep 17 00:00:00 2001 From: Daniel Doehring Date: Tue, 29 Jul 2025 17:13:40 +0200 Subject: [PATCH 18/38] Update Project.toml --- Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Project.toml b/Project.toml index c39e1271810..27f5bbca28e 100644 --- a/Project.toml +++ b/Project.toml @@ -102,7 +102,7 @@ RecipesBase = "1.3.4" RecursiveArrayTools = "3.31.1" Reexport = "1.2" Requires = "1.3" -SciMLBase = "2.67" +SciMLBase = "2.67.0" SimpleUnPack = "1.1" SparseArrays = "1" StableRNGs = "1.0.2" From fcdfd3932b1490db0790752bead50fbe8405c092 Mon Sep 17 00:00:00 2001 From: Daniel Doehring Date: Thu, 14 Aug 2025 20:52:34 +0000 Subject: [PATCH 19/38] ci --- test/test_parabolic_2d.jl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/test_parabolic_2d.jl b/test/test_parabolic_2d.jl index 091bbedcc07..0a0b5e2a8f8 100644 --- a/test/test_parabolic_2d.jl +++ b/test/test_parabolic_2d.jl @@ -870,16 +870,16 @@ end @test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", "elixir_navierstokes_viscous_shock_newton_krylov.jl"), l2=[ - 0.0050454344200822595, - 0.004688806400845471, - 2.636511509998046e-5, - 0.0047873461533362765 + 0.0065651548865949556, + 0.005095321719983898, + 3.581942361738427e-5, + 0.0055182642123342 ], linf=[ - 0.02208819271861917, - 0.024209434405893293, - 0.0007989190783110008, - 0.026948544666356877 + 0.032598680917245826, + 0.02246663207410171, + 0.0009383062266496081, + 0.024308186569039547 ]) # Ensure that we do not have excessive memory allocations # (e.g., from type instabilities) From 23656826c7865b01ea29575b5ef3bdb2d2754e2e Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Fri, 15 Aug 2025 09:47:12 +0200 Subject: [PATCH 20/38] compat --- test/Project.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/test/Project.toml b/test/Project.toml index 8aa67666ee0..2beaa619af1 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -45,6 +45,7 @@ ECOS = "1.1.2" ExplicitImports = "1.0.1" ForwardDiff = "0.10.36, 1" LinearAlgebra = "1" +LinearSolve = "1" Measurements = "2.14.0" MPI = "0.20.6" NLsolve = "4.5.1" From 6409d7cfc72003555b0ae30a0cace247dda51975 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Fri, 15 Aug 2025 09:49:51 +0200 Subject: [PATCH 21/38] v --- test/Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Project.toml b/test/Project.toml index 2beaa619af1..35bdb3c021b 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -45,7 +45,7 @@ ECOS = "1.1.2" ExplicitImports = "1.0.1" ForwardDiff = "0.10.36, 1" LinearAlgebra = "1" -LinearSolve = "1" +LinearSolve = "1, 2, 3" Measurements = "2.14.0" MPI = "0.20.6" NLsolve = "4.5.1" From 98012be6b4cd2218f3457ee3206a7d9af10decd5 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Fri, 15 Aug 2025 09:53:24 +0200 Subject: [PATCH 22/38] v --- test/Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Project.toml b/test/Project.toml index 35bdb3c021b..ded7bf18bf0 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -45,7 +45,7 @@ ECOS = "1.1.2" ExplicitImports = "1.0.1" ForwardDiff = "0.10.36, 1" LinearAlgebra = "1" -LinearSolve = "1, 2, 3" +LinearSolve = "2, 3" Measurements = "2.14.0" MPI = "0.20.6" NLsolve = "4.5.1" From 178736e372c5010730f442b3a15dd11b18ff3a8f Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Fri, 15 Aug 2025 09:56:01 +0200 Subject: [PATCH 23/38] v --- test/Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Project.toml b/test/Project.toml index ded7bf18bf0..dc4f42574b5 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -45,7 +45,7 @@ ECOS = "1.1.2" ExplicitImports = "1.0.1" ForwardDiff = "0.10.36, 1" LinearAlgebra = "1" -LinearSolve = "2, 3" +LinearSolve = "2.7.0" Measurements = "2.14.0" MPI = "0.20.6" NLsolve = "4.5.1" From 1e8ae90c8d88e09fa7ee9af28c793df6858013ad Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Fri, 15 Aug 2025 09:59:58 +0200 Subject: [PATCH 24/38] v --- test/Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Project.toml b/test/Project.toml index dc4f42574b5..c55273e6883 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -45,7 +45,7 @@ ECOS = "1.1.2" ExplicitImports = "1.0.1" ForwardDiff = "0.10.36, 1" LinearAlgebra = "1" -LinearSolve = "2.7.0" +LinearSolve = "*" Measurements = "2.14.0" MPI = "0.20.6" NLsolve = "4.5.1" From 8a517feb95beab09b89c2d3c385cfe3c2c814a6c Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Fri, 15 Aug 2025 10:03:38 +0200 Subject: [PATCH 25/38] v --- test/Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Project.toml b/test/Project.toml index c55273e6883..5756d37d557 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -45,7 +45,7 @@ ECOS = "1.1.2" ExplicitImports = "1.0.1" ForwardDiff = "0.10.36, 1" LinearAlgebra = "1" -LinearSolve = "*" +LinearSolve = "0, 1, 2, 3" Measurements = "2.14.0" MPI = "0.20.6" NLsolve = "4.5.1" From bb9c18526c744b00ea004ac17b4604ff5be4c105 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Fri, 15 Aug 2025 10:06:15 +0200 Subject: [PATCH 26/38] v --- test/Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Project.toml b/test/Project.toml index 5756d37d557..35bdb3c021b 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -45,7 +45,7 @@ ECOS = "1.1.2" ExplicitImports = "1.0.1" ForwardDiff = "0.10.36, 1" LinearAlgebra = "1" -LinearSolve = "0, 1, 2, 3" +LinearSolve = "1, 2, 3" Measurements = "2.14.0" MPI = "0.20.6" NLsolve = "4.5.1" From ae4d19d71c5b7813df6138b6032db4585cee85fc Mon Sep 17 00:00:00 2001 From: Daniel Doehring Date: Fri, 15 Aug 2025 10:26:51 +0200 Subject: [PATCH 27/38] Update test/Project.toml Co-authored-by: Joshua Lampert <51029046+JoshuaLampert@users.noreply.github.com> --- test/Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Project.toml b/test/Project.toml index 35bdb3c021b..a1a91a63683 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -45,7 +45,7 @@ ECOS = "1.1.2" ExplicitImports = "1.0.1" ForwardDiff = "0.10.36, 1" LinearAlgebra = "1" -LinearSolve = "1, 2, 3" +LinearSolve = "2.7, 3" Measurements = "2.14.0" MPI = "0.20.6" NLsolve = "4.5.1" From d7a4d774ffb6082b59b41b810183a13a10c79bb2 Mon Sep 17 00:00:00 2001 From: Daniel Doehring Date: Fri, 15 Aug 2025 10:38:09 +0200 Subject: [PATCH 28/38] Update test/Project.toml Co-authored-by: Joshua Lampert <51029046+JoshuaLampert@users.noreply.github.com> --- test/Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Project.toml b/test/Project.toml index a1a91a63683..495f9e0584a 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -45,7 +45,7 @@ ECOS = "1.1.2" ExplicitImports = "1.0.1" ForwardDiff = "0.10.36, 1" LinearAlgebra = "1" -LinearSolve = "2.7, 3" +LinearSolve = "2.32, 3" Measurements = "2.14.0" MPI = "0.20.6" NLsolve = "4.5.1" From e04e649526883e10928f98d2bead64107d7b66b1 Mon Sep 17 00:00:00 2001 From: Joshua Lampert <51029046+JoshuaLampert@users.noreply.github.com> Date: Fri, 15 Aug 2025 10:49:07 +0200 Subject: [PATCH 29/38] Update test/Project.toml --- test/Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Project.toml b/test/Project.toml index 495f9e0584a..5cd8669d71d 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -45,7 +45,7 @@ ECOS = "1.1.2" ExplicitImports = "1.0.1" ForwardDiff = "0.10.36, 1" LinearAlgebra = "1" -LinearSolve = "2.32, 3" +LinearSolve = "2.35, 3" Measurements = "2.14.0" MPI = "0.20.6" NLsolve = "4.5.1" From add1a0c06c5a87f5393bdd5c5a9e29b01b46bf62 Mon Sep 17 00:00:00 2001 From: Joshua Lampert <51029046+JoshuaLampert@users.noreply.github.com> Date: Fri, 15 Aug 2025 10:51:58 +0200 Subject: [PATCH 30/38] Update test/Project.toml --- test/Project.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/Project.toml b/test/Project.toml index 5cd8669d71d..225f150b004 100644 --- a/test/Project.toml +++ b/test/Project.toml @@ -45,7 +45,7 @@ ECOS = "1.1.2" ExplicitImports = "1.0.1" ForwardDiff = "0.10.36, 1" LinearAlgebra = "1" -LinearSolve = "2.35, 3" +LinearSolve = "2.36.1, 3" Measurements = "2.14.0" MPI = "0.20.6" NLsolve = "4.5.1" From 11a9ac686eade7959a0029b75b377a98a2e2ae46 Mon Sep 17 00:00:00 2001 From: Daniel Doehring Date: Wed, 20 Aug 2025 23:12:27 +0200 Subject: [PATCH 31/38] Update test/test_parabolic_2d.jl --- test/test_parabolic_2d.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/test/test_parabolic_2d.jl b/test/test_parabolic_2d.jl index 0a0b5e2a8f8..d7e315c0a69 100644 --- a/test/test_parabolic_2d.jl +++ b/test/test_parabolic_2d.jl @@ -869,6 +869,7 @@ end @trixi_testset "P4estMesh2D: elixir_navierstokes_viscous_shock_newton_krylov.jl" begin @test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", "elixir_navierstokes_viscous_shock_newton_krylov.jl"), + tspan=(0.0, 0.1), l2=[ 0.0065651548865949556, 0.005095321719983898, From 65ff9f4e6acd9bc1fc8c9b798a7a04624a05b0ff Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Thu, 21 Aug 2025 09:06:15 +0200 Subject: [PATCH 32/38] up --- test/test_parabolic_2d.jl | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/test/test_parabolic_2d.jl b/test/test_parabolic_2d.jl index d7e315c0a69..7cdf3187f45 100644 --- a/test/test_parabolic_2d.jl +++ b/test/test_parabolic_2d.jl @@ -869,18 +869,18 @@ end @trixi_testset "P4estMesh2D: elixir_navierstokes_viscous_shock_newton_krylov.jl" begin @test_trixi_include(joinpath(examples_dir(), "p4est_2d_dgsem", "elixir_navierstokes_viscous_shock_newton_krylov.jl"), - tspan=(0.0, 0.1), + tspan=(0.0, 0.1), l2=[ - 0.0065651548865949556, - 0.005095321719983898, - 3.581942361738427e-5, - 0.0055182642123342 + 3.42748644991602e-5, + 2.5929914323049254e-5, + 3.320624732423191e-10, + 2.853483829000886e-5 ], linf=[ - 0.032598680917245826, - 0.02246663207410171, - 0.0009383062266496081, - 0.024308186569039547 + 0.0001869124748734574, + 0.00014018080282174328, + 6.605711572371913e-9, + 0.00014458925257399002 ]) # Ensure that we do not have excessive memory allocations # (e.g., from type instabilities) From bfb58db780fe20501d1dbc4db8d95b82418f2c9a Mon Sep 17 00:00:00 2001 From: Daniel Doehring Date: Thu, 21 Aug 2025 10:22:08 +0200 Subject: [PATCH 33/38] Update test/test_parabolic_2d.jl --- test/test_parabolic_2d.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/test_parabolic_2d.jl b/test/test_parabolic_2d.jl index 7cdf3187f45..f3f4b8c1e96 100644 --- a/test/test_parabolic_2d.jl +++ b/test/test_parabolic_2d.jl @@ -871,10 +871,10 @@ end "elixir_navierstokes_viscous_shock_newton_krylov.jl"), tspan=(0.0, 0.1), l2=[ - 3.42748644991602e-5, - 2.5929914323049254e-5, - 3.320624732423191e-10, - 2.853483829000886e-5 + 3.4274530977374974e-5, + 2.5929583658087707e-5, + 3.280129456724307e-10, + 2.8534270876379244e-5 ], linf=[ 0.0001869124748734574, From 18f038cf1b9e7be64b1bc1f6737e57ab21a2a01a Mon Sep 17 00:00:00 2001 From: Daniel Doehring Date: Thu, 21 Aug 2025 10:23:12 +0200 Subject: [PATCH 34/38] Update test/test_parabolic_2d.jl --- test/test_parabolic_2d.jl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/test_parabolic_2d.jl b/test/test_parabolic_2d.jl index f3f4b8c1e96..7fd1249a28f 100644 --- a/test/test_parabolic_2d.jl +++ b/test/test_parabolic_2d.jl @@ -877,10 +877,10 @@ end 2.8534270876379244e-5 ], linf=[ - 0.0001869124748734574, - 0.00014018080282174328, - 6.605711572371913e-9, - 0.00014458925257399002 + 0.00018690961095946257, + 0.00014018207622679135, + 7.840992289556565e-9, + 0.00014458475979295393 ]) # Ensure that we do not have excessive memory allocations # (e.g., from type instabilities) From 38a21b9e6383f28a508e84077e0aace575b117b7 Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Fri, 29 Aug 2025 15:06:04 +0200 Subject: [PATCH 35/38] tolerances --- ...avierstokes_viscous_shock_newton_krylov.jl | 21 +++++++++++++------ .../elixir_diffusion_ldg_newton_krylov.jl | 19 ++++++++++++----- test/test_parabolic_1d.jl | 2 +- test/test_parabolic_2d.jl | 16 +++++++------- 4 files changed, 38 insertions(+), 20 deletions(-) diff --git a/examples/p4est_2d_dgsem/elixir_navierstokes_viscous_shock_newton_krylov.jl b/examples/p4est_2d_dgsem/elixir_navierstokes_viscous_shock_newton_krylov.jl index f0f61b04e8c..e8ba18ce1b7 100644 --- a/examples/p4est_2d_dgsem/elixir_navierstokes_viscous_shock_newton_krylov.jl +++ b/examples/p4est_2d_dgsem/elixir_navierstokes_viscous_shock_newton_krylov.jl @@ -1,4 +1,5 @@ using Trixi + using OrdinaryDiffEqSDIRK using LinearSolve # For Jacobian-free Newton-Krylov (GMRES) solver using ADTypes # For automatic differentiation via finite differences @@ -152,7 +153,7 @@ semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabol ############################################################################### # ODE solvers, callbacks etc. -tspan = (0.0, 1.0) +tspan = (0.0, 0.1) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() @@ -164,8 +165,16 @@ callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback) ############################################################################### # run the simulation -sol = solve(ode, - # Use (diagonally) implicit Runge-Kutta method with Jacobian-free (!) Newton-Krylov (GMRES) solver - # See https://docs.sciml.ai/DiffEqDocs/stable/tutorials/advanced_ode_example/#Using-Jacobian-Free-Newton-Krylov - KenCarp47(autodiff = AutoFiniteDiff(), linsolve = KrylovJL_GMRES()); - ode_default_options()..., callback = callbacks) +# Tolerances for GMRES residual, see https://jso.dev/Krylov.jl/stable/solvers/unsymmetric/#Krylov.gmres +atol_lin_solve = 1e-3 +rtol_lin_solve = 1e-3 + +# Jacobian-free Newton-Krylov (GMRES) solver +linsolve = KrylovJL_GMRES(atol = atol_lin_solve, rtol = rtol_lin_solve) + +# Use (diagonally) implicit Runge-Kutta, see +# https://docs.sciml.ai/DiffEqDocs/stable/tutorials/advanced_ode_example/#Using-Jacobian-Free-Newton-Krylov +ode_alg = Kvaerno4(autodiff = AutoFiniteDiff(), linsolve = linsolve) + +sol = solve(ode, ode_alg; + ode_default_options()..., callback = callbacks); diff --git a/examples/tree_1d_dgsem/elixir_diffusion_ldg_newton_krylov.jl b/examples/tree_1d_dgsem/elixir_diffusion_ldg_newton_krylov.jl index 972b8194912..ba6837f3681 100644 --- a/examples/tree_1d_dgsem/elixir_diffusion_ldg_newton_krylov.jl +++ b/examples/tree_1d_dgsem/elixir_diffusion_ldg_newton_krylov.jl @@ -1,4 +1,5 @@ using Trixi + using OrdinaryDiffEqSDIRK using LinearSolve # For Jacobian-free Newton-Krylov (GMRES) solver using ADTypes # For automatic differentiation via finite differences @@ -52,8 +53,16 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback) ############################################################################### # run the simulation -sol = solve(ode, - # Use (diagonally) implicit Runge-Kutta method with Jacobian-free (!) Newton-Krylov (GMRES) solver - # See https://docs.sciml.ai/DiffEqDocs/stable/tutorials/advanced_ode_example/#Using-Jacobian-Free-Newton-Krylov - KenCarp47(autodiff = AutoFiniteDiff(), linsolve = KrylovJL_GMRES()); - ode_default_options()..., callback = callbacks) +# Tolerances for GMRES residual, see https://jso.dev/Krylov.jl/stable/solvers/unsymmetric/#Krylov.gmres +atol_lin_solve = 1e-4 +rtol_lin_solve = 1e-3 + +# Jacobian-free Newton-Krylov (GMRES) solver +linsolve = KrylovJL_GMRES(atol = atol_lin_solve, rtol = rtol_lin_solve) + +# Use (diagonally) implicit Runge-Kutta, see +# https://docs.sciml.ai/DiffEqDocs/stable/tutorials/advanced_ode_example/#Using-Jacobian-Free-Newton-Krylov +ode_alg = KenCarp47(autodiff = AutoFiniteDiff(), linsolve = linsolve) + +sol = solve(ode, ode_alg; + ode_default_options()..., callback = callbacks); diff --git a/test/test_parabolic_1d.jl b/test/test_parabolic_1d.jl index 7bcac79cea9..69b8453c0ee 100644 --- a/test/test_parabolic_1d.jl +++ b/test/test_parabolic_1d.jl @@ -61,7 +61,7 @@ end @trixi_testset "TreeMesh1D: elixir_diffusion_ldg_newton_krylov.jl" begin @test_trixi_include(joinpath(examples_dir(), "tree_1d_dgsem", "elixir_diffusion_ldg_newton_krylov.jl"), - l2=[6.542981787119615e-6], linf=[1.712011459781282e-5]) + l2=[6.535800308207845e-6], linf=[1.713067629272036e-5]) # Ensure that we do not have excessive memory allocations # (e.g., from type instabilities) let diff --git a/test/test_parabolic_2d.jl b/test/test_parabolic_2d.jl index 7fd1249a28f..2031369c04e 100644 --- a/test/test_parabolic_2d.jl +++ b/test/test_parabolic_2d.jl @@ -871,16 +871,16 @@ end "elixir_navierstokes_viscous_shock_newton_krylov.jl"), tspan=(0.0, 0.1), l2=[ - 3.4274530977374974e-5, - 2.5929583658087707e-5, - 3.280129456724307e-10, - 2.8534270876379244e-5 + 3.468124487467954e-5, + 2.6454590757059137e-5, + 2.760644360948994e-9, + 2.8741949366621678e-5 ], linf=[ - 0.00018690961095946257, - 0.00014018207622679135, - 7.840992289556565e-9, - 0.00014458475979295393 + 0.0001876434544800798, + 0.0001407366652957931, + 3.8442024323011775e-8, + 0.00014533466340793666 ]) # Ensure that we do not have excessive memory allocations # (e.g., from type instabilities) From e0a38a47f5fe2181b625c9d358f78f2724b2dcf5 Mon Sep 17 00:00:00 2001 From: Daniel Doehring Date: Fri, 29 Aug 2025 13:51:14 +0000 Subject: [PATCH 36/38] ci vals --- test/test_parabolic_2d.jl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/test_parabolic_2d.jl b/test/test_parabolic_2d.jl index 2031369c04e..ddb8633d736 100644 --- a/test/test_parabolic_2d.jl +++ b/test/test_parabolic_2d.jl @@ -871,16 +871,16 @@ end "elixir_navierstokes_viscous_shock_newton_krylov.jl"), tspan=(0.0, 0.1), l2=[ - 3.468124487467954e-5, - 2.6454590757059137e-5, - 2.760644360948994e-9, - 2.8741949366621678e-5 + 3.4677658586629764e-5, + 2.644535969146463e-5, + 5.151654279170342e-10, + 2.8739954093187323e-5 ], linf=[ - 0.0001876434544800798, - 0.0001407366652957931, - 3.8442024323011775e-8, - 0.00014533466340793666 + 0.00018767198825853093, + 0.00014073307933715196, + 7.408371400746554e-9, + 0.00014528672293634415 ]) # Ensure that we do not have excessive memory allocations # (e.g., from type instabilities) From 61834b041f43eb158407013ecc7278e362b1086b Mon Sep 17 00:00:00 2001 From: Daniel_Doehring Date: Mon, 1 Sep 2025 10:02:08 +0200 Subject: [PATCH 37/38] ode solver tols --- ...r_navierstokes_viscous_shock_newton_krylov.jl | 9 ++++++--- .../elixir_diffusion_ldg_newton_krylov.jl | 7 +++++-- test/test_parabolic_1d.jl | 2 +- test/test_parabolic_2d.jl | 16 ++++++++-------- 4 files changed, 20 insertions(+), 14 deletions(-) diff --git a/examples/p4est_2d_dgsem/elixir_navierstokes_viscous_shock_newton_krylov.jl b/examples/p4est_2d_dgsem/elixir_navierstokes_viscous_shock_newton_krylov.jl index e8ba18ce1b7..7ea78642724 100644 --- a/examples/p4est_2d_dgsem/elixir_navierstokes_viscous_shock_newton_krylov.jl +++ b/examples/p4est_2d_dgsem/elixir_navierstokes_viscous_shock_newton_krylov.jl @@ -153,7 +153,7 @@ semi = SemidiscretizationHyperbolicParabolic(mesh, (equations, equations_parabol ############################################################################### # ODE solvers, callbacks etc. -tspan = (0.0, 0.1) +tspan = (0.0, 1.0) ode = semidiscretize(semi, tspan) summary_callback = SummaryCallback() @@ -166,8 +166,8 @@ callbacks = CallbackSet(summary_callback, alive_callback, analysis_callback) # run the simulation # Tolerances for GMRES residual, see https://jso.dev/Krylov.jl/stable/solvers/unsymmetric/#Krylov.gmres -atol_lin_solve = 1e-3 -rtol_lin_solve = 1e-3 +atol_lin_solve = 1e-5 +rtol_lin_solve = 1e-5 # Jacobian-free Newton-Krylov (GMRES) solver linsolve = KrylovJL_GMRES(atol = atol_lin_solve, rtol = rtol_lin_solve) @@ -176,5 +176,8 @@ linsolve = KrylovJL_GMRES(atol = atol_lin_solve, rtol = rtol_lin_solve) # https://docs.sciml.ai/DiffEqDocs/stable/tutorials/advanced_ode_example/#Using-Jacobian-Free-Newton-Krylov ode_alg = Kvaerno4(autodiff = AutoFiniteDiff(), linsolve = linsolve) +atol_ode_solve = 1e-4 +rtol_ode_solve = 1e-4 sol = solve(ode, ode_alg; + abstol = atol_ode_solve, reltol = rtol_ode_solve, ode_default_options()..., callback = callbacks); diff --git a/examples/tree_1d_dgsem/elixir_diffusion_ldg_newton_krylov.jl b/examples/tree_1d_dgsem/elixir_diffusion_ldg_newton_krylov.jl index ba6837f3681..8d20593bc0e 100644 --- a/examples/tree_1d_dgsem/elixir_diffusion_ldg_newton_krylov.jl +++ b/examples/tree_1d_dgsem/elixir_diffusion_ldg_newton_krylov.jl @@ -54,8 +54,8 @@ callbacks = CallbackSet(summary_callback, analysis_callback, alive_callback) # run the simulation # Tolerances for GMRES residual, see https://jso.dev/Krylov.jl/stable/solvers/unsymmetric/#Krylov.gmres -atol_lin_solve = 1e-4 -rtol_lin_solve = 1e-3 +atol_lin_solve = 1e-6 +rtol_lin_solve = 1e-5 # Jacobian-free Newton-Krylov (GMRES) solver linsolve = KrylovJL_GMRES(atol = atol_lin_solve, rtol = rtol_lin_solve) @@ -64,5 +64,8 @@ linsolve = KrylovJL_GMRES(atol = atol_lin_solve, rtol = rtol_lin_solve) # https://docs.sciml.ai/DiffEqDocs/stable/tutorials/advanced_ode_example/#Using-Jacobian-Free-Newton-Krylov ode_alg = KenCarp47(autodiff = AutoFiniteDiff(), linsolve = linsolve) +atol_ode_solve = 1e-5 +rtol_ode_solve = 1e-4 sol = solve(ode, ode_alg; + abstol = atol_ode_solve, reltol = rtol_ode_solve, ode_default_options()..., callback = callbacks); diff --git a/test/test_parabolic_1d.jl b/test/test_parabolic_1d.jl index 69b8453c0ee..41692015764 100644 --- a/test/test_parabolic_1d.jl +++ b/test/test_parabolic_1d.jl @@ -61,7 +61,7 @@ end @trixi_testset "TreeMesh1D: elixir_diffusion_ldg_newton_krylov.jl" begin @test_trixi_include(joinpath(examples_dir(), "tree_1d_dgsem", "elixir_diffusion_ldg_newton_krylov.jl"), - l2=[6.535800308207845e-6], linf=[1.713067629272036e-5]) + l2=[4.2710445174631516e-6], linf=[2.28491835256861e-5]) # Ensure that we do not have excessive memory allocations # (e.g., from type instabilities) let diff --git a/test/test_parabolic_2d.jl b/test/test_parabolic_2d.jl index ddb8633d736..f8d6efb864a 100644 --- a/test/test_parabolic_2d.jl +++ b/test/test_parabolic_2d.jl @@ -871,16 +871,16 @@ end "elixir_navierstokes_viscous_shock_newton_krylov.jl"), tspan=(0.0, 0.1), l2=[ - 3.4677658586629764e-5, - 2.644535969146463e-5, - 5.151654279170342e-10, - 2.8739954093187323e-5 + 3.468221017662057e-5, + 2.6486636244768717e-5, + 7.41055097401974e-10, + 2.8748476231704967e-5 ], linf=[ - 0.00018767198825853093, - 0.00014073307933715196, - 7.408371400746554e-9, - 0.00014528672293634415 + 0.0001875548310485975, + 0.000140469756708117, + 1.125834917760754e-8, + 0.00014500713316789593 ]) # Ensure that we do not have excessive memory allocations # (e.g., from type instabilities) From f5af542c104951ca535fc511c318ee09b7cbf4c0 Mon Sep 17 00:00:00 2001 From: Daniel Doehring Date: Mon, 1 Sep 2025 10:43:00 +0200 Subject: [PATCH 38/38] Update test/test_parabolic_2d.jl --- test/test_parabolic_2d.jl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/test_parabolic_2d.jl b/test/test_parabolic_2d.jl index f8d6efb864a..72825a37c4a 100644 --- a/test/test_parabolic_2d.jl +++ b/test/test_parabolic_2d.jl @@ -871,16 +871,16 @@ end "elixir_navierstokes_viscous_shock_newton_krylov.jl"), tspan=(0.0, 0.1), l2=[ - 3.468221017662057e-5, - 2.6486636244768717e-5, - 7.41055097401974e-10, - 2.8748476231704967e-5 + 3.468233560427797e-5, + 2.64864594855224e-5, + 7.879490760481979e-10, + 2.8748482665365446e-5 ], linf=[ - 0.0001875548310485975, - 0.000140469756708117, - 1.125834917760754e-8, - 0.00014500713316789593 + 0.00018754529350140103, + 0.00014045634087878067, + 9.043610782328732e-9, + 0.00014499382160382268 ]) # Ensure that we do not have excessive memory allocations # (e.g., from type instabilities)