267267 end
268268end
269269
270+ # Inlined version of the interface flux computation for non-conservative equations
271+ @inline function calc_mpi_interface_flux! (surface_flux_values,
272+ mesh:: Union {ParallelP4estMesh{3 },
273+ ParallelT8codeMesh{3 }},
274+ nonconservative_terms:: True , equations,
275+ surface_integral, dg:: DG , cache,
276+ interface_index, normal_direction,
277+ interface_i_node_index,
278+ interface_j_node_index, local_side,
279+ surface_i_node_index, surface_j_node_index,
280+ local_direction_index, local_element_index)
281+ @unpack u = cache. mpi_interfaces
282+ surface_flux, nonconservative_flux = surface_integral. surface_flux
283+
284+ u_ll, u_rr = get_surface_node_vars (u, equations, dg,
285+ interface_i_node_index, interface_j_node_index,
286+ interface_index)
287+
288+ # Compute flux and non-conservative term for this side of the interface
289+ if local_side == 1
290+ flux_ = surface_flux (u_ll, u_rr, normal_direction, equations)
291+ noncons_flux_ = nonconservative_flux (u_ll, u_rr, normal_direction, equations)
292+ else # local_side == 2
293+ flux_ = - surface_flux (u_ll, u_rr, - normal_direction, equations)
294+ noncons_flux_ = - nonconservative_flux (u_rr, u_ll, - normal_direction, equations)
295+ end
296+
297+ for v in eachvariable (equations)
298+ surface_flux_values[v, surface_i_node_index, surface_j_node_index,
299+ local_direction_index, local_element_index] = flux_[v] +
300+ 0.5f0 * noncons_flux_[v]
301+ end
302+ end
303+
270304function prolong2mpimortars! (cache, u,
271305 mesh:: Union{ParallelP4estMesh{3}, ParallelT8codeMesh{3}} ,
272306 equations,
@@ -384,12 +418,13 @@ function calc_mpi_mortar_flux!(surface_flux_values,
384418 surface_integral, dg:: DG , cache)
385419 @unpack local_neighbor_ids, local_neighbor_positions, node_indices = cache. mpi_mortars
386420 @unpack contravariant_vectors = cache. elements
387- @unpack fstar_primary_threaded, fstar_tmp_threaded = cache
421+ @unpack fstar_primary_threaded, fstar_secondary_threaded, fstar_tmp_threaded = cache
388422 index_range = eachnode (dg)
389423
390424 @threaded for mortar in eachmpimortar (dg, cache)
391425 # Choose thread-specific pre-allocated container
392- fstar = fstar_primary_threaded[Threads. threadid ()]
426+ fstar_primary = fstar_primary_threaded[Threads. threadid ()]
427+ fstar_secondary = fstar_secondary_threaded[Threads. threadid ()]
393428 fstar_tmp = fstar_tmp_threaded[Threads. threadid ()]
394429
395430 # Get index information on the small elements
@@ -412,7 +447,8 @@ function calc_mpi_mortar_flux!(surface_flux_values,
412447 normal_direction = get_normal_direction (cache. mpi_mortars, i, j,
413448 position, mortar)
414449
415- calc_mpi_mortar_flux! (fstar, mesh, nonconservative_terms, equations,
450+ calc_mpi_mortar_flux! (fstar_primary, fstar_secondary, mesh,
451+ nonconservative_terms, equations,
416452 surface_integral, dg, cache,
417453 mortar, position, normal_direction,
418454 i, j)
@@ -433,14 +469,15 @@ function calc_mpi_mortar_flux!(surface_flux_values,
433469
434470 mpi_mortar_fluxes_to_elements! (surface_flux_values,
435471 mesh, equations, mortar_l2, dg, cache,
436- mortar, fstar, u_buffer, fstar_tmp)
472+ mortar, fstar_primary, fstar_secondary, u_buffer,
473+ fstar_tmp)
437474 end
438475
439476 return nothing
440477end
441478
442479# Inlined version of the mortar flux computation on small elements for conservation laws
443- @inline function calc_mpi_mortar_flux! (fstar ,
480+ @inline function calc_mpi_mortar_flux! (fstar_primary, fstar_secondary ,
444481 mesh:: Union {ParallelP4estMesh{3 },
445482 ParallelT8codeMesh{3 }},
446483 nonconservative_terms:: False , equations,
@@ -456,16 +493,48 @@ end
456493 flux = surface_flux (u_ll, u_rr, normal_direction, equations)
457494
458495 # Copy flux to buffer
459- set_node_vars! (fstar, flux, equations, dg, i_node_index, j_node_index,
496+ set_node_vars! (fstar_primary, flux, equations, dg, i_node_index, j_node_index,
497+ position_index)
498+ set_node_vars! (fstar_secondary, flux, equations, dg, i_node_index, j_node_index,
460499 position_index)
461500end
462501
502+ # Inlined version of the mortar flux computation on small elements for non-conservative equations
503+ @inline function calc_mpi_mortar_flux! (fstar_primary, fstar_secondary,
504+ mesh:: Union {ParallelP4estMesh{3 },
505+ ParallelT8codeMesh{3 }},
506+ nonconservative_terms:: True , equations,
507+ surface_integral, dg:: DG , cache,
508+ mortar_index, position_index, normal_direction,
509+ i_node_index, j_node_index)
510+ @unpack u = cache. mpi_mortars
511+ surface_flux, nonconservative_flux = surface_integral. surface_flux
512+
513+ u_ll, u_rr = get_surface_node_vars (u, equations, dg, position_index, i_node_index,
514+ j_node_index, mortar_index)
515+
516+ flux = surface_flux (u_ll, u_rr, normal_direction, equations)
517+ noncons_flux_primary = nonconservative_flux (u_ll, u_rr, normal_direction, equations)
518+ noncons_flux_secondary = nonconservative_flux (u_rr, u_ll, normal_direction,
519+ equations)
520+
521+ for v in eachvariable (equations)
522+ fstar_primary[v, i_node_index, j_node_index, position_index] = flux[v] +
523+ 0.5f0 *
524+ noncons_flux_primary[v]
525+ fstar_secondary[v, i_node_index, j_node_index, position_index] = flux[v] +
526+ 0.5f0 *
527+ noncons_flux_secondary[v]
528+ end
529+ end
530+
463531@inline function mpi_mortar_fluxes_to_elements! (surface_flux_values,
464532 mesh:: Union {ParallelP4estMesh{3 },
465533 ParallelT8codeMesh{3 }},
466534 equations,
467535 mortar_l2:: LobattoLegendreMortarL2 ,
468- dg:: DGSEM , cache, mortar, fstar,
536+ dg:: DGSEM , cache, mortar, fstar_primary,
537+ fstar_secondary,
469538 u_buffer, fstar_tmp)
470539 @unpack local_neighbor_ids, local_neighbor_positions, node_indices = cache. mpi_mortars
471540 index_range = eachnode (dg)
@@ -487,22 +556,22 @@ end
487556 # Project small fluxes to large element.
488557 multiply_dimensionwise! (u_buffer,
489558 mortar_l2. reverse_lower, mortar_l2. reverse_lower,
490- view (fstar , .. , 1 ),
559+ view (fstar_secondary , .. , 1 ),
491560 fstar_tmp)
492561 add_multiply_dimensionwise! (u_buffer,
493562 mortar_l2. reverse_upper,
494563 mortar_l2. reverse_lower,
495- view (fstar , .. , 2 ),
564+ view (fstar_secondary , .. , 2 ),
496565 fstar_tmp)
497566 add_multiply_dimensionwise! (u_buffer,
498567 mortar_l2. reverse_lower,
499568 mortar_l2. reverse_upper,
500- view (fstar , .. , 3 ),
569+ view (fstar_secondary , .. , 3 ),
501570 fstar_tmp)
502571 add_multiply_dimensionwise! (u_buffer,
503572 mortar_l2. reverse_upper,
504573 mortar_l2. reverse_upper,
505- view (fstar , .. , 4 ),
574+ view (fstar_secondary , .. , 4 ),
506575 fstar_tmp)
507576 # The flux is calculated in the outward direction of the small elements,
508577 # so the sign must be switched to get the flux in outward direction
@@ -536,10 +605,10 @@ end
536605 for j in eachnode (dg)
537606 for i in eachnode (dg)
538607 for v in eachvariable (equations)
539- surface_flux_values[v, i, j, small_direction, element] = fstar [v,
540- i,
541- j,
542- position]
608+ surface_flux_values[v, i, j, small_direction, element] = fstar_primary [v,
609+ i,
610+ j,
611+ position]
543612 end
544613 end
545614 end
0 commit comments