From 82c7ff1fb6f6bde5181741bf836859907394c616 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Rueda-Ram=C3=ADrez?= Date: Tue, 22 Oct 2024 13:18:16 +0200 Subject: [PATCH 1/6] Added non-unique mortar fluxes to be able to handle non-conservative equations --- src/solvers/dgsem_p4est/dg_3d.jl | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/src/solvers/dgsem_p4est/dg_3d.jl b/src/solvers/dgsem_p4est/dg_3d.jl index 5aabbf7ac60..8a381a4e64a 100644 --- a/src/solvers/dgsem_p4est/dg_3d.jl +++ b/src/solvers/dgsem_p4est/dg_3d.jl @@ -10,8 +10,8 @@ function create_cache(mesh::Union{P4estMesh{3}, T8codeMesh{3}}, equations, mortar_l2::LobattoLegendreMortarL2, uEltype) # TODO: Taal compare performance of different types - fstar_threaded = [Array{uEltype, 4}(undef, nvariables(equations), nnodes(mortar_l2), - nnodes(mortar_l2), 4) + fstar_threaded = [Array{uEltype, 5}(undef, nvariables(equations), nnodes(mortar_l2), + nnodes(mortar_l2), 2, 4) for _ in 1:Threads.nthreads()] fstar_tmp_threaded = [Array{uEltype, 3}(undef, nvariables(equations), @@ -604,7 +604,9 @@ end # Copy flux to buffer set_node_vars!(fstar, flux, equations, dg, i_node_index, j_node_index, - position_index) + 1, position_index) + set_node_vars!(fstar, flux, equations, dg, i_node_index, j_node_index, + 2, position_index) end # Inlined version of the mortar flux computation on small elements for conservation fluxes @@ -627,12 +629,18 @@ end # Compute nonconservative flux and add it to the flux scaled by a factor of 0.5 based on # the interpretation of global SBP operators coupled discontinuously via # central fluxes/SATs - noncons = nonconservative_flux(u_ll, u_rr, normal_direction, equations) - flux_plus_noncons = flux + 0.5f0 * noncons + noncons_ll = nonconservative_flux(u_ll, u_rr, normal_direction, equations) + noncons_rr = nonconservative_flux(u_rr, u_ll, normal_direction, equations) + flux_plus_noncons_ll = flux + 0.5f0 * noncons_ll + flux_plus_noncons_rr = flux + 0.5f0 * noncons_rr # Copy to buffer - set_node_vars!(fstar, flux_plus_noncons, equations, dg, i_node_index, j_node_index, - position_index) + set_node_vars!(fstar, flux_plus_noncons_ll, equations, dg, i_node_index, + j_node_index, + 1, position_index) + set_node_vars!(fstar, flux_plus_noncons_rr, equations, dg, i_node_index, + j_node_index, + 2, position_index) end @inline function mortar_fluxes_to_elements!(surface_flux_values, @@ -653,6 +661,7 @@ end for j in eachnode(dg), i in eachnode(dg) for v in eachvariable(equations) surface_flux_values[v, i, j, small_direction, element] = fstar[v, i, j, + 1, position] end end @@ -661,19 +670,19 @@ end # Project small fluxes to large element. multiply_dimensionwise!(u_buffer, mortar_l2.reverse_lower, mortar_l2.reverse_lower, - view(fstar, .., 1), + view(fstar, .., 2, 1), fstar_tmp) add_multiply_dimensionwise!(u_buffer, mortar_l2.reverse_upper, mortar_l2.reverse_lower, - view(fstar, .., 2), + view(fstar, .., 2, 2), fstar_tmp) add_multiply_dimensionwise!(u_buffer, mortar_l2.reverse_lower, mortar_l2.reverse_upper, - view(fstar, .., 3), + view(fstar, .., 2, 3), fstar_tmp) add_multiply_dimensionwise!(u_buffer, mortar_l2.reverse_upper, mortar_l2.reverse_upper, - view(fstar, .., 4), + view(fstar, .., 2, 4), fstar_tmp) # The flux is calculated in the outward direction of the small elements, From 0553a802914beef0be21f63c0cf06d33b3b55b57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Rueda-Ram=C3=ADrez?= Date: Tue, 22 Oct 2024 14:27:33 +0200 Subject: [PATCH 2/6] format --- src/solvers/dgsem_p4est/dg_3d.jl | 73 ++++++++++++++++++-------------- 1 file changed, 42 insertions(+), 31 deletions(-) diff --git a/src/solvers/dgsem_p4est/dg_3d.jl b/src/solvers/dgsem_p4est/dg_3d.jl index 8a381a4e64a..0632e3d3d8e 100644 --- a/src/solvers/dgsem_p4est/dg_3d.jl +++ b/src/solvers/dgsem_p4est/dg_3d.jl @@ -10,9 +10,14 @@ function create_cache(mesh::Union{P4estMesh{3}, T8codeMesh{3}}, equations, mortar_l2::LobattoLegendreMortarL2, uEltype) # TODO: Taal compare performance of different types - fstar_threaded = [Array{uEltype, 5}(undef, nvariables(equations), nnodes(mortar_l2), - nnodes(mortar_l2), 2, 4) - for _ in 1:Threads.nthreads()] + fstar_primary_threaded = [Array{uEltype, 4}(undef, nvariables(equations), + nnodes(mortar_l2), + nnodes(mortar_l2), 4) + for _ in 1:Threads.nthreads()] + fstar_secondary_threaded = [Array{uEltype, 4}(undef, nvariables(equations), + nnodes(mortar_l2), + nnodes(mortar_l2), 4) + for _ in 1:Threads.nthreads()] fstar_tmp_threaded = [Array{uEltype, 3}(undef, nvariables(equations), nnodes(mortar_l2), nnodes(mortar_l2)) @@ -21,7 +26,7 @@ function create_cache(mesh::Union{P4estMesh{3}, T8codeMesh{3}}, equations, nnodes(mortar_l2)) for _ in 1:Threads.nthreads()] - (; fstar_threaded, fstar_tmp_threaded, u_threaded) + (; fstar_primary_threaded, fstar_secondary_threaded, fstar_tmp_threaded, u_threaded) end # index_to_start_step_3d(index::Symbol, index_range) @@ -521,12 +526,13 @@ function calc_mortar_flux!(surface_flux_values, surface_integral, dg::DG, cache) @unpack neighbor_ids, node_indices = cache.mortars @unpack contravariant_vectors = cache.elements - @unpack fstar_threaded, fstar_tmp_threaded = cache + @unpack fstar_primary_threaded, fstar_secondary_threaded, fstar_tmp_threaded = cache index_range = eachnode(dg) @threaded for mortar in eachmortar(dg, cache) # Choose thread-specific pre-allocated container - fstar = fstar_threaded[Threads.threadid()] + fstar_primary = fstar_primary_threaded[Threads.threadid()] + fstar_secondary = fstar_secondary_threaded[Threads.threadid()] fstar_tmp = fstar_tmp_threaded[Threads.threadid()] # Get index information on the small elements @@ -555,7 +561,8 @@ function calc_mortar_flux!(surface_flux_values, i_small, j_small, k_small, element) - calc_mortar_flux!(fstar, mesh, nonconservative_terms, equations, + calc_mortar_flux!(fstar_primary, fstar_secondary, mesh, + nonconservative_terms, equations, surface_integral, dg, cache, mortar, position, normal_direction, i, j) @@ -581,14 +588,15 @@ function calc_mortar_flux!(surface_flux_values, # "mortar_fluxes_to_elements!" instead. mortar_fluxes_to_elements!(surface_flux_values, mesh, equations, mortar_l2, dg, cache, - mortar, fstar, u_buffer, fstar_tmp) + mortar, fstar_primary, fstar_secondary, u_buffer, + fstar_tmp) end return nothing end # Inlined version of the mortar flux computation on small elements for conservation fluxes -@inline function calc_mortar_flux!(fstar, +@inline function calc_mortar_flux!(fstar_primary, fstar_secondary, mesh::Union{P4estMesh{3}, T8codeMesh{3}}, nonconservative_terms::False, equations, surface_integral, dg::DG, cache, @@ -603,15 +611,15 @@ end flux = surface_flux(u_ll, u_rr, normal_direction, equations) # Copy flux to buffer - set_node_vars!(fstar, flux, equations, dg, i_node_index, j_node_index, - 1, position_index) - set_node_vars!(fstar, flux, equations, dg, i_node_index, j_node_index, - 2, position_index) + set_node_vars!(fstar_primary, flux, equations, dg, i_node_index, j_node_index, + position_index) + set_node_vars!(fstar_secondary, flux, equations, dg, i_node_index, j_node_index, + position_index) end # Inlined version of the mortar flux computation on small elements for conservation fluxes # with nonconservative terms -@inline function calc_mortar_flux!(fstar, +@inline function calc_mortar_flux!(fstar_primary, fstar_secondary, mesh::Union{P4estMesh{3}, T8codeMesh{3}}, nonconservative_terms::True, equations, surface_integral, dg::DG, cache, @@ -629,26 +637,28 @@ end # Compute nonconservative flux and add it to the flux scaled by a factor of 0.5 based on # the interpretation of global SBP operators coupled discontinuously via # central fluxes/SATs - noncons_ll = nonconservative_flux(u_ll, u_rr, normal_direction, equations) - noncons_rr = nonconservative_flux(u_rr, u_ll, normal_direction, equations) - flux_plus_noncons_ll = flux + 0.5f0 * noncons_ll - flux_plus_noncons_rr = flux + 0.5f0 * noncons_rr + noncons_primary = nonconservative_flux(u_ll, u_rr, normal_direction, equations) + noncons_secondary = nonconservative_flux(u_rr, u_ll, normal_direction, equations) + flux_plus_noncons_primary = flux + 0.5f0 * noncons_primary + flux_plus_noncons_secondary = flux + 0.5f0 * noncons_secondary # Copy to buffer - set_node_vars!(fstar, flux_plus_noncons_ll, equations, dg, i_node_index, + set_node_vars!(fstar_primary, flux_plus_noncons_primary, equations, dg, + i_node_index, j_node_index, - 1, position_index) - set_node_vars!(fstar, flux_plus_noncons_rr, equations, dg, i_node_index, + position_index) + set_node_vars!(fstar_secondary, flux_plus_noncons_secondary, equations, dg, + i_node_index, j_node_index, - 2, position_index) + position_index) end @inline function mortar_fluxes_to_elements!(surface_flux_values, mesh::Union{P4estMesh{3}, T8codeMesh{3}}, equations, mortar_l2::LobattoLegendreMortarL2, - dg::DGSEM, cache, mortar, fstar, u_buffer, - fstar_tmp) + dg::DGSEM, cache, mortar, fstar_primary, + fstar_secondary, u_buffer, fstar_tmp) @unpack neighbor_ids, node_indices = cache.mortars index_range = eachnode(dg) @@ -660,9 +670,10 @@ end element = neighbor_ids[position, mortar] for j in eachnode(dg), i in eachnode(dg) for v in eachvariable(equations) - surface_flux_values[v, i, j, small_direction, element] = fstar[v, i, j, - 1, - position] + surface_flux_values[v, i, j, small_direction, element] = fstar_primary[v, + i, + j, + position] end end end @@ -670,19 +681,19 @@ end # Project small fluxes to large element. multiply_dimensionwise!(u_buffer, mortar_l2.reverse_lower, mortar_l2.reverse_lower, - view(fstar, .., 2, 1), + view(fstar_secondary, .., 1), fstar_tmp) add_multiply_dimensionwise!(u_buffer, mortar_l2.reverse_upper, mortar_l2.reverse_lower, - view(fstar, .., 2, 2), + view(fstar_secondary, .., 2), fstar_tmp) add_multiply_dimensionwise!(u_buffer, mortar_l2.reverse_lower, mortar_l2.reverse_upper, - view(fstar, .., 2, 3), + view(fstar_secondary, .., 3), fstar_tmp) add_multiply_dimensionwise!(u_buffer, mortar_l2.reverse_upper, mortar_l2.reverse_upper, - view(fstar, .., 2, 4), + view(fstar_secondary, .., 4), fstar_tmp) # The flux is calculated in the outward direction of the small elements, From 9fd429adab45ee8426f7b503a6a570325717040b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Rueda-Ram=C3=ADrez?= Date: Tue, 22 Oct 2024 14:54:48 +0200 Subject: [PATCH 3/6] Updated p4est 3d tests --- test/test_p4est_3d.jl | 168 ++++++++++++++++++++++++------------------ 1 file changed, 96 insertions(+), 72 deletions(-) diff --git a/test/test_p4est_3d.jl b/test/test_p4est_3d.jl index 5cec16300f8..efc2871c474 100644 --- a/test/test_p4est_3d.jl +++ b/test/test_p4est_3d.jl @@ -132,14 +132,14 @@ end 4.4993257426833716e-5, 5.10588457841744e-5, 5.102840924036687e-5, - 0.00019986264001630542 + 0.00019986264001630542, ], linf=[ 0.0016987332417202072, 0.003622956808262634, 0.002029576258317789, 0.0024206977281964193, - 0.008526972236273522 + 0.008526972236273522, ], tspan=(0.0, 0.01)) # Ensure that we do not have excessive memory allocations @@ -160,14 +160,14 @@ end 0.0014733349038567685, 0.00147333490385685, 0.001473334903856929, - 0.0028149479453087093 + 0.0028149479453087093, ], linf=[ 0.008070806335238156, 0.009007245083113125, 0.009007245083121784, 0.009007245083102688, - 0.01562861968368434 + 0.01562861968368434, ], tspan=(0.0, 1.0)) # Ensure that we do not have excessive memory allocations @@ -187,14 +187,14 @@ end 1.941857343642486e-14, 2.0232366394187278e-14, 2.3381518645408552e-14, - 7.083114561232324e-14 + 7.083114561232324e-14, ], linf=[ 7.269740365245525e-13, 3.289868377720495e-12, 4.440087186807773e-12, 3.8686831516088205e-12, - 9.412914891981927e-12 + 9.412914891981927e-12, ], tspan=(0.0, 0.03)) # Ensure that we do not have excessive memory allocations @@ -214,14 +214,14 @@ end 4.889826056731442e-15, 2.2921260987087585e-15, 4.268460455702414e-15, - 1.1356712092620279e-14 + 1.1356712092620279e-14, ], linf=[ 7.749356711883593e-14, 2.8792246364872653e-13, 1.1121659149182506e-13, 3.3228975127030935e-13, - 9.592326932761353e-13 + 9.592326932761353e-13, ], tspan=(0.0, 0.1)) # Ensure that we do not have excessive memory allocations @@ -240,12 +240,12 @@ end l2=[ 6.530157034651212e-16, 1.6057829680004379e-15, 3.31107455378537e-15, 3.908829498281281e-15, - 5.048390610424672e-15 + 5.048390610424672e-15, ], linf=[ 4.884981308350689e-15, 1.1921019726912618e-14, 1.5432100042289676e-14, 2.298161660974074e-14, - 6.039613253960852e-14 + 6.039613253960852e-14, ]) # Ensure that we do not have excessive memory allocations # (e.g., from type instabilities) @@ -266,14 +266,14 @@ end Float32(1.6057829680004379e-15), Float32(3.31107455378537e-15), Float32(3.908829498281281e-15), - Float32(5.048390610424672e-15) + Float32(5.048390610424672e-15), ], linf=[ Float32(4.884981308350689e-15), Float32(1.1921019726912618e-14), Float32(1.5432100042289676e-14), Float32(2.298161660974074e-14), - Float32(6.039613253960852e-14) + Float32(6.039613253960852e-14), ], RealT=Float32) # Ensure that we do not have excessive memory allocations @@ -293,14 +293,14 @@ end 4.889826056731442e-15, 2.2921260987087585e-15, 4.268460455702414e-15, - 1.1356712092620279e-14 + 1.1356712092620279e-14, ], linf=[ 7.749356711883593e-14, 4.513472928735496e-13, 2.9790059308254513e-13, 1.057154364048074e-12, - 1.6271428648906294e-12 + 1.6271428648906294e-12, ], tspan=(0.0, 0.1), surface_flux=flux_hllc) @@ -321,14 +321,14 @@ end 0.006192950051354618, 0.005970674274073704, 0.005965831290564327, - 0.02628875593094754 + 0.02628875593094754, ], linf=[ 0.3326911600075694, 0.2824952141320467, 0.41401037398065543, 0.45574161423218573, - 0.8099577682187109 + 0.8099577682187109, ], tspan=(0.0, 0.2), coverage_override=(polydeg = 3,)) # Prevent long compile time in CI @@ -349,14 +349,14 @@ end 0.006216054794583285, 0.006020401857347216, 0.006019175682769779, - 0.026228080232814154 + 0.026228080232814154, ], linf=[ 0.3169376449662026, 0.28950510175646726, 0.4402523227566396, 0.4869168122387365, - 0.7999141641954051 + 0.7999141641954051, ], tspan=(0.0, 0.2), volume_flux=flux_chandrashekar, @@ -378,14 +378,14 @@ end 4.33260474e-02, 4.33260474e-02, 4.33260474e-02, - 3.75260911e-01 + 3.75260911e-01, ], linf=[ 7.45329845e-01, 3.21754792e-01, 3.21754792e-01, 3.21754792e-01, - 4.76151527e+00 + 4.76151527e+00, ], tspan=(0.0, 0.3), coverage_override=(polydeg = 3,)) # Prevent long compile time in CI @@ -406,14 +406,14 @@ end 0.04863386374672001, 0.048633863746720116, 0.04863386374672032, - 0.3751015774232693 + 0.3751015774232693, ], linf=[ 0.789241521871487, 0.42046970270100276, 0.42046970270100276, 0.4204697027010028, - 4.730877375538398 + 4.730877375538398, ], tspan=(0.0, 0.3), surface_flux=flux_hlle) @@ -435,14 +435,14 @@ end 5.4254175153621895e-6, 5.677698851333843e-6, 5.8017136892469794e-6, - 1.3637854615117974e-5 + 1.3637854615117974e-5, ], linf=[ 0.00013996924184311865, 0.00013681539559939893, 0.00013681539539733834, 0.00013681539541021692, - 0.00016833038543762058 + 0.00016833038543762058, ], # Decrease tolerance of adaptive time stepping to get similar results across different systems abstol=1.0e-11, reltol=1.0e-11, @@ -465,14 +465,14 @@ end 3.8630261900166194e-5, 3.8672287531936816e-5, 3.6865116098660796e-5, - 0.05508620970403884 + 0.05508620970403884, ], linf=[ 2.268845333053271e-6, 0.000531462302113539, 0.0005314624461298934, 0.0005129931254772464, - 0.7942778058932163 + 0.7942778058932163, ], tspan=(0.0, 2e2), coverage_override=(trees_per_cube_face = (1, 1), polydeg = 3)) # Prevent long compile time in CI @@ -494,14 +494,14 @@ end 0.00021710076010951073, 0.0004386796338203878, 0.00020836270267103122, - 0.07601887903440395 + 0.07601887903440395, ], linf=[ 1.9107530539574924e-5, 0.02980358831035801, 0.048476331898047564, 0.02200137344113612, - 4.848310144356219 + 4.848310144356219, ], tspan=(0.0, 1e2), # Decrease tolerance of adaptive time stepping to get similar results across different systems @@ -525,14 +525,14 @@ end 0.004122532789279737, 0.0042448149597303616, 0.0036361316700401765, - 0.007389845952982495 + 0.007389845952982495, ], linf=[ 0.04530610539892499, 0.02765695110527666, 0.05670295599308606, 0.048396544302230504, - 0.1154589758186293 + 0.1154589758186293, ]) # Ensure that we do not have excessive memory allocations # (e.g., from type instabilities) @@ -547,16 +547,28 @@ end @trixi_testset "elixir_mhd_alfven_wave_nonconforming.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_alfven_wave_nonconforming.jl"), - l2=[0.00019018725889431733, 0.0006523517707148006, - 0.0002401595437705759, 0.0007796920661427565, - 0.0007095787460334334, 0.0006558819731628876, - 0.0003565026134076906, 0.0007904654548841712, - 9.437300326448332e-7], - linf=[0.0012482306861187897, 0.006408776208178299, - 0.0016845452099629663, 0.0068711236542984555, - 0.004626581522263695, 0.006614624811393632, - 0.0030068344747734566, 0.008277825749754025, - 1.3475027166309006e-5], + l2=[ + 0.0001788543743594658, + 0.000624334205581902, + 0.00022892869974368887, + 0.0007223464581156573, + 0.0006651366626523314, + 0.0006287275014743352, + 0.000344484339916008, + 0.0007179788287557142, + 8.632896980651243e-7, + ], + linf=[ + 0.0010730565632763867, + 0.004596749809344033, + 0.0013235269262853733, + 0.00468874234888117, + 0.004719267084104306, + 0.004228339352211896, + 0.0037503625505571625, + 0.005104176909383168, + 9.738081186490818e-6, + ], tspan=(0.0, 0.25), coverage_override=(trees_per_dimension = (1, 1, 1),)) # Ensure that we do not have excessive memory allocations @@ -571,16 +583,28 @@ end @trixi_testset "elixir_mhd_shockcapturing_amr.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_shockcapturing_amr.jl"), - l2=[0.006297229188267704, 0.006436347763092648, - 0.0071091348227321095, 0.00652953798427642, - 0.0206148702828057, 0.005561406556411695, - 0.007570747563696005, 0.005571060186513173, - 3.888176398720913e-6], - linf=[0.20904050630623572, 0.1863002690612441, - 0.2347653795205547, 0.19430178062881898, - 0.6858488630270272, 0.15169972127018583, - 0.22431157058134898, 0.16823638722404644, - 0.0005208971463830214], + l2=[ + 0.0062973565893792004, + 0.006436273914579104, + 0.007112703307027178, + 0.006529650167358523, + 0.020607452343745017, + 0.005560993001492338, + 0.007576418168749763, + 0.0055721349394598635, + 3.8269125984310296e-6, + ], + linf=[ + 0.2090718196650192, + 0.1863884052971854, + 0.23475479927204168, + 0.19460789763442982, + 0.6859816363887359, + 0.15171474186273914, + 0.22404690260234983, + 0.16808957604979002, + 0.0005083795485317637, + ], tspan=(0.0, 0.04), coverage_override=(maxiters = 6, initial_refinement_level = 1, base_level = 1, max_level = 2)) @@ -597,26 +621,26 @@ end @trixi_testset "elixir_mhd_amr_entropy_bounded.jl" begin @test_trixi_include(joinpath(EXAMPLES_DIR, "elixir_mhd_amr_entropy_bounded.jl"), l2=[ - 0.005430176785094096, - 0.006185803468926062, - 0.012158513265762224, - 0.006185144232789619, - 0.03509140423905665, - 0.004968215426326584, - 0.006553519141867704, - 0.005008885124643863, - 5.165777182726578e-6 + 0.005430006338127661, + 0.006186402899876596, + 0.012171513410597289, + 0.006181479343504159, + 0.035068817354117605, + 0.004967715666538709, + 0.006592173316509503, + 0.0050151140388451105, + 5.146547644807638e-6, ], linf=[ - 0.1864317840224794, - 0.2041246899193812, - 0.36992946717578445, - 0.2327158690965257, - 1.0368624176126007, - 0.1846308291826353, - 0.2062255411778191, - 0.18955666546331185, - 0.0005208969502913304 + 0.18655204102670386, + 0.20397573777286138, + 0.3700839435299759, + 0.23329319876321034, + 1.0348619438460904, + 0.18462694496595722, + 0.20648634653698617, + 0.18947822281424997, + 0.0005083794158781671, ], tspan=(0.0, 0.04), coverage_override=(maxiters = 6, initial_refinement_level = 1, @@ -637,11 +661,11 @@ end l2=[ 0.04452389418193219, 0.03688186699434862, 0.03688186699434861, 0.03688186699434858, - 0.044523894181932186 + 0.044523894181932186, ], linf=[ 0.2295447498696467, 0.058369658071546704, - 0.05836965807154648, 0.05836965807154648, 0.2295447498696468 + 0.05836965807154648, 0.05836965807154648, 0.2295447498696468, ]) # Ensure that we do not have excessive memory allocations # (e.g., from type instabilities) @@ -660,14 +684,14 @@ end 0.018525073963833696, 0.019102348105917946, 0.01920515438943838, - 0.15060493968460148 + 0.15060493968460148, ], linf=[ 0.2994949779783401, 0.5530175050084679, 0.5335803757792128, 0.5647252867336123, - 3.6462732329242566 + 3.6462732329242566, ], tspan=(0.0, 0.025), coverage_override=(maxiters = 6,)) From 2ab09dfd849e9a0f03df4cbbbc67754c95f341e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Rueda-Ram=C3=ADrez?= Date: Tue, 22 Oct 2024 14:55:52 +0200 Subject: [PATCH 4/6] Updated parabolic and parallel p4est 3d implementations for new naming convention --- src/solvers/dgsem_p4est/dg_3d_parabolic.jl | 4 ++-- src/solvers/dgsem_p4est/dg_3d_parallel.jl | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/solvers/dgsem_p4est/dg_3d_parabolic.jl b/src/solvers/dgsem_p4est/dg_3d_parabolic.jl index 3f286ca01fc..c415a582fd7 100644 --- a/src/solvers/dgsem_p4est/dg_3d_parabolic.jl +++ b/src/solvers/dgsem_p4est/dg_3d_parabolic.jl @@ -788,12 +788,12 @@ function calc_mortar_flux_divergence!(surface_flux_values, surface_integral, dg::DG, cache) @unpack neighbor_ids, node_indices = cache.mortars @unpack contravariant_vectors = cache.elements - @unpack fstar_threaded, fstar_tmp_threaded = cache + @unpack fstar_primary_threaded, fstar_tmp_threaded = cache index_range = eachnode(dg) @threaded for mortar in eachmortar(dg, cache) # Choose thread-specific pre-allocated container - fstar = fstar_threaded[Threads.threadid()] + fstar = fstar_primary_threaded[Threads.threadid()] fstar_tmp = fstar_tmp_threaded[Threads.threadid()] # Get index information on the small elements diff --git a/src/solvers/dgsem_p4est/dg_3d_parallel.jl b/src/solvers/dgsem_p4est/dg_3d_parallel.jl index 635c8dc795e..3daca10e821 100644 --- a/src/solvers/dgsem_p4est/dg_3d_parallel.jl +++ b/src/solvers/dgsem_p4est/dg_3d_parallel.jl @@ -384,12 +384,12 @@ function calc_mpi_mortar_flux!(surface_flux_values, surface_integral, dg::DG, cache) @unpack local_neighbor_ids, local_neighbor_positions, node_indices = cache.mpi_mortars @unpack contravariant_vectors = cache.elements - @unpack fstar_threaded, fstar_tmp_threaded = cache + @unpack fstar_primary_threaded, fstar_tmp_threaded = cache index_range = eachnode(dg) @threaded for mortar in eachmpimortar(dg, cache) # Choose thread-specific pre-allocated container - fstar = fstar_threaded[Threads.threadid()] + fstar = fstar_primary_threaded[Threads.threadid()] fstar_tmp = fstar_tmp_threaded[Threads.threadid()] # Get index information on the small elements From 35aaf4e031048cd75e53b2d6696bcd9978a8e68f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Rueda-Ram=C3=ADrez?= Date: Tue, 22 Oct 2024 15:06:19 +0200 Subject: [PATCH 5/6] format --- test/test_p4est_3d.jl | 80 +++++++++++++++++++++---------------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/test/test_p4est_3d.jl b/test/test_p4est_3d.jl index efc2871c474..3d2db528a14 100644 --- a/test/test_p4est_3d.jl +++ b/test/test_p4est_3d.jl @@ -132,14 +132,14 @@ end 4.4993257426833716e-5, 5.10588457841744e-5, 5.102840924036687e-5, - 0.00019986264001630542, + 0.00019986264001630542 ], linf=[ 0.0016987332417202072, 0.003622956808262634, 0.002029576258317789, 0.0024206977281964193, - 0.008526972236273522, + 0.008526972236273522 ], tspan=(0.0, 0.01)) # Ensure that we do not have excessive memory allocations @@ -160,14 +160,14 @@ end 0.0014733349038567685, 0.00147333490385685, 0.001473334903856929, - 0.0028149479453087093, + 0.0028149479453087093 ], linf=[ 0.008070806335238156, 0.009007245083113125, 0.009007245083121784, 0.009007245083102688, - 0.01562861968368434, + 0.01562861968368434 ], tspan=(0.0, 1.0)) # Ensure that we do not have excessive memory allocations @@ -187,14 +187,14 @@ end 1.941857343642486e-14, 2.0232366394187278e-14, 2.3381518645408552e-14, - 7.083114561232324e-14, + 7.083114561232324e-14 ], linf=[ 7.269740365245525e-13, 3.289868377720495e-12, 4.440087186807773e-12, 3.8686831516088205e-12, - 9.412914891981927e-12, + 9.412914891981927e-12 ], tspan=(0.0, 0.03)) # Ensure that we do not have excessive memory allocations @@ -214,14 +214,14 @@ end 4.889826056731442e-15, 2.2921260987087585e-15, 4.268460455702414e-15, - 1.1356712092620279e-14, + 1.1356712092620279e-14 ], linf=[ 7.749356711883593e-14, 2.8792246364872653e-13, 1.1121659149182506e-13, 3.3228975127030935e-13, - 9.592326932761353e-13, + 9.592326932761353e-13 ], tspan=(0.0, 0.1)) # Ensure that we do not have excessive memory allocations @@ -240,12 +240,12 @@ end l2=[ 6.530157034651212e-16, 1.6057829680004379e-15, 3.31107455378537e-15, 3.908829498281281e-15, - 5.048390610424672e-15, + 5.048390610424672e-15 ], linf=[ 4.884981308350689e-15, 1.1921019726912618e-14, 1.5432100042289676e-14, 2.298161660974074e-14, - 6.039613253960852e-14, + 6.039613253960852e-14 ]) # Ensure that we do not have excessive memory allocations # (e.g., from type instabilities) @@ -266,14 +266,14 @@ end Float32(1.6057829680004379e-15), Float32(3.31107455378537e-15), Float32(3.908829498281281e-15), - Float32(5.048390610424672e-15), + Float32(5.048390610424672e-15) ], linf=[ Float32(4.884981308350689e-15), Float32(1.1921019726912618e-14), Float32(1.5432100042289676e-14), Float32(2.298161660974074e-14), - Float32(6.039613253960852e-14), + Float32(6.039613253960852e-14) ], RealT=Float32) # Ensure that we do not have excessive memory allocations @@ -293,14 +293,14 @@ end 4.889826056731442e-15, 2.2921260987087585e-15, 4.268460455702414e-15, - 1.1356712092620279e-14, + 1.1356712092620279e-14 ], linf=[ 7.749356711883593e-14, 4.513472928735496e-13, 2.9790059308254513e-13, 1.057154364048074e-12, - 1.6271428648906294e-12, + 1.6271428648906294e-12 ], tspan=(0.0, 0.1), surface_flux=flux_hllc) @@ -321,14 +321,14 @@ end 0.006192950051354618, 0.005970674274073704, 0.005965831290564327, - 0.02628875593094754, + 0.02628875593094754 ], linf=[ 0.3326911600075694, 0.2824952141320467, 0.41401037398065543, 0.45574161423218573, - 0.8099577682187109, + 0.8099577682187109 ], tspan=(0.0, 0.2), coverage_override=(polydeg = 3,)) # Prevent long compile time in CI @@ -349,14 +349,14 @@ end 0.006216054794583285, 0.006020401857347216, 0.006019175682769779, - 0.026228080232814154, + 0.026228080232814154 ], linf=[ 0.3169376449662026, 0.28950510175646726, 0.4402523227566396, 0.4869168122387365, - 0.7999141641954051, + 0.7999141641954051 ], tspan=(0.0, 0.2), volume_flux=flux_chandrashekar, @@ -378,14 +378,14 @@ end 4.33260474e-02, 4.33260474e-02, 4.33260474e-02, - 3.75260911e-01, + 3.75260911e-01 ], linf=[ 7.45329845e-01, 3.21754792e-01, 3.21754792e-01, 3.21754792e-01, - 4.76151527e+00, + 4.76151527e+00 ], tspan=(0.0, 0.3), coverage_override=(polydeg = 3,)) # Prevent long compile time in CI @@ -406,14 +406,14 @@ end 0.04863386374672001, 0.048633863746720116, 0.04863386374672032, - 0.3751015774232693, + 0.3751015774232693 ], linf=[ 0.789241521871487, 0.42046970270100276, 0.42046970270100276, 0.4204697027010028, - 4.730877375538398, + 4.730877375538398 ], tspan=(0.0, 0.3), surface_flux=flux_hlle) @@ -435,14 +435,14 @@ end 5.4254175153621895e-6, 5.677698851333843e-6, 5.8017136892469794e-6, - 1.3637854615117974e-5, + 1.3637854615117974e-5 ], linf=[ 0.00013996924184311865, 0.00013681539559939893, 0.00013681539539733834, 0.00013681539541021692, - 0.00016833038543762058, + 0.00016833038543762058 ], # Decrease tolerance of adaptive time stepping to get similar results across different systems abstol=1.0e-11, reltol=1.0e-11, @@ -465,14 +465,14 @@ end 3.8630261900166194e-5, 3.8672287531936816e-5, 3.6865116098660796e-5, - 0.05508620970403884, + 0.05508620970403884 ], linf=[ 2.268845333053271e-6, 0.000531462302113539, 0.0005314624461298934, 0.0005129931254772464, - 0.7942778058932163, + 0.7942778058932163 ], tspan=(0.0, 2e2), coverage_override=(trees_per_cube_face = (1, 1), polydeg = 3)) # Prevent long compile time in CI @@ -494,14 +494,14 @@ end 0.00021710076010951073, 0.0004386796338203878, 0.00020836270267103122, - 0.07601887903440395, + 0.07601887903440395 ], linf=[ 1.9107530539574924e-5, 0.02980358831035801, 0.048476331898047564, 0.02200137344113612, - 4.848310144356219, + 4.848310144356219 ], tspan=(0.0, 1e2), # Decrease tolerance of adaptive time stepping to get similar results across different systems @@ -525,14 +525,14 @@ end 0.004122532789279737, 0.0042448149597303616, 0.0036361316700401765, - 0.007389845952982495, + 0.007389845952982495 ], linf=[ 0.04530610539892499, 0.02765695110527666, 0.05670295599308606, 0.048396544302230504, - 0.1154589758186293, + 0.1154589758186293 ]) # Ensure that we do not have excessive memory allocations # (e.g., from type instabilities) @@ -556,7 +556,7 @@ end 0.0006287275014743352, 0.000344484339916008, 0.0007179788287557142, - 8.632896980651243e-7, + 8.632896980651243e-7 ], linf=[ 0.0010730565632763867, @@ -567,7 +567,7 @@ end 0.004228339352211896, 0.0037503625505571625, 0.005104176909383168, - 9.738081186490818e-6, + 9.738081186490818e-6 ], tspan=(0.0, 0.25), coverage_override=(trees_per_dimension = (1, 1, 1),)) @@ -592,7 +592,7 @@ end 0.005560993001492338, 0.007576418168749763, 0.0055721349394598635, - 3.8269125984310296e-6, + 3.8269125984310296e-6 ], linf=[ 0.2090718196650192, @@ -603,7 +603,7 @@ end 0.15171474186273914, 0.22404690260234983, 0.16808957604979002, - 0.0005083795485317637, + 0.0005083795485317637 ], tspan=(0.0, 0.04), coverage_override=(maxiters = 6, initial_refinement_level = 1, @@ -629,7 +629,7 @@ end 0.004967715666538709, 0.006592173316509503, 0.0050151140388451105, - 5.146547644807638e-6, + 5.146547644807638e-6 ], linf=[ 0.18655204102670386, @@ -640,7 +640,7 @@ end 0.18462694496595722, 0.20648634653698617, 0.18947822281424997, - 0.0005083794158781671, + 0.0005083794158781671 ], tspan=(0.0, 0.04), coverage_override=(maxiters = 6, initial_refinement_level = 1, @@ -661,11 +661,11 @@ end l2=[ 0.04452389418193219, 0.03688186699434862, 0.03688186699434861, 0.03688186699434858, - 0.044523894181932186, + 0.044523894181932186 ], linf=[ 0.2295447498696467, 0.058369658071546704, - 0.05836965807154648, 0.05836965807154648, 0.2295447498696468, + 0.05836965807154648, 0.05836965807154648, 0.2295447498696468 ]) # Ensure that we do not have excessive memory allocations # (e.g., from type instabilities) @@ -684,14 +684,14 @@ end 0.018525073963833696, 0.019102348105917946, 0.01920515438943838, - 0.15060493968460148, + 0.15060493968460148 ], linf=[ 0.2994949779783401, 0.5530175050084679, 0.5335803757792128, 0.5647252867336123, - 3.6462732329242566, + 3.6462732329242566 ], tspan=(0.0, 0.025), coverage_override=(maxiters = 6,)) From f19d4d8ae262d2bcb216a40142c8bae1b863872c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Rueda-Ram=C3=ADrez?= Date: Wed, 23 Oct 2024 14:18:56 +0200 Subject: [PATCH 6/6] Fixed problem with parabolic non-conforming discretization --- src/solvers/dgsem_p4est/dg_3d_parabolic.jl | 25 +++++++++++++--------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/solvers/dgsem_p4est/dg_3d_parabolic.jl b/src/solvers/dgsem_p4est/dg_3d_parabolic.jl index c415a582fd7..b1204e5a15c 100644 --- a/src/solvers/dgsem_p4est/dg_3d_parabolic.jl +++ b/src/solvers/dgsem_p4est/dg_3d_parabolic.jl @@ -271,7 +271,8 @@ end mesh::P4estMesh{3}, equations::AbstractEquationsParabolic, mortar_l2::LobattoLegendreMortarL2, - dg::DGSEM, cache, mortar, fstar, u_buffer, + dg::DGSEM, cache, mortar, fstar_primary, + fstar_secondary, u_buffer, fstar_tmp) @unpack neighbor_ids, node_indices = cache.mortars index_range = eachnode(dg) @@ -283,8 +284,10 @@ end element = neighbor_ids[position, mortar] for j in eachnode(dg), i in eachnode(dg) for v in eachvariable(equations) - surface_flux_values[v, i, j, small_direction, element] = fstar[v, i, j, - position] + surface_flux_values[v, i, j, small_direction, element] = fstar_primary[v, + i, + j, + position] end end end @@ -292,19 +295,19 @@ end # Project small fluxes to large element. multiply_dimensionwise!(u_buffer, mortar_l2.reverse_lower, mortar_l2.reverse_lower, - view(fstar, .., 1), + view(fstar_secondary, .., 1), fstar_tmp) add_multiply_dimensionwise!(u_buffer, mortar_l2.reverse_upper, mortar_l2.reverse_lower, - view(fstar, .., 2), + view(fstar_secondary, .., 2), fstar_tmp) add_multiply_dimensionwise!(u_buffer, mortar_l2.reverse_lower, mortar_l2.reverse_upper, - view(fstar, .., 3), + view(fstar_secondary, .., 3), fstar_tmp) add_multiply_dimensionwise!(u_buffer, mortar_l2.reverse_upper, mortar_l2.reverse_upper, - view(fstar, .., 4), + view(fstar_secondary, .., 4), fstar_tmp) # The flux is calculated in the outward direction of the small elements, @@ -842,7 +845,7 @@ function calc_mortar_flux_divergence!(surface_flux_values, # this reuses the hyperbolic version of `mortar_fluxes_to_elements!` mortar_fluxes_to_elements!(surface_flux_values, mesh, equations, mortar_l2, dg, cache, - mortar, fstar, u_buffer, fstar_tmp) + mortar, fstar, fstar, u_buffer, fstar_tmp) end return nothing @@ -851,7 +854,7 @@ end # NOTE: Use analogy to "calc_mortar_flux!" for hyperbolic eqs with no nonconservative terms. # Reasoning: "calc_interface_flux!" for parabolic part is implemented as the version for # hyperbolic terms with conserved terms only, i.e., no nonconservative terms. -@inline function calc_mortar_flux!(fstar, +@inline function calc_mortar_flux!(fstar_primary, fstar_secondary, mesh::P4estMesh{3}, nonconservative_terms::False, equations::AbstractEquationsParabolic, @@ -867,7 +870,9 @@ end # TODO: parabolic; only BR1 at the moment flux_ = 0.5f0 * (u_ll + u_rr) # Copy flux to buffer - set_node_vars!(fstar, flux_, equations, dg, i_node_index, j_node_index, + set_node_vars!(fstar_primary, flux_, equations, dg, i_node_index, j_node_index, + position_index) + set_node_vars!(fstar_secondary, flux_, equations, dg, i_node_index, j_node_index, position_index) end