@@ -13,11 +13,15 @@ function create_cache(mesh::Union{P4estMesh{2}, T8codeMesh{2}}, equations,
1313 MA2d = MArray{Tuple{nvariables (equations), nnodes (mortar_l2)},
1414 uEltype, 2 ,
1515 nvariables (equations) * nnodes (mortar_l2)}
16- fstar_upper_threaded = MA2d[MA2d (undef) for _ in 1 : Threads. nthreads ()]
17- fstar_lower_threaded = MA2d[MA2d (undef) for _ in 1 : Threads. nthreads ()]
16+ fstar_primary_upper_threaded = MA2d[MA2d (undef) for _ in 1 : Threads. nthreads ()]
17+ fstar_primary_lower_threaded = MA2d[MA2d (undef) for _ in 1 : Threads. nthreads ()]
18+ fstar_secondary_upper_threaded = MA2d[MA2d (undef) for _ in 1 : Threads. nthreads ()]
19+ fstar_secondary_lower_threaded = MA2d[MA2d (undef) for _ in 1 : Threads. nthreads ()]
1820 u_threaded = MA2d[MA2d (undef) for _ in 1 : Threads. nthreads ()]
1921
20- (; fstar_upper_threaded, fstar_lower_threaded, u_threaded)
22+ (; fstar_primary_upper_threaded, fstar_primary_lower_threaded,
23+ fstar_secondary_upper_threaded, fstar_secondary_lower_threaded,
24+ u_threaded)
2125end
2226
2327# index_to_start_step_2d(index::Symbol, index_range)
@@ -451,13 +455,17 @@ function calc_mortar_flux!(surface_flux_values,
451455 surface_integral, dg:: DG , cache)
452456 @unpack neighbor_ids, node_indices = cache. mortars
453457 @unpack contravariant_vectors = cache. elements
454- @unpack fstar_upper_threaded, fstar_lower_threaded = cache
458+ @unpack (fstar_primary_upper_threaded, fstar_primary_lower_threaded,
459+ fstar_secondary_upper_threaded, fstar_secondary_lower_threaded) = cache
455460 index_range = eachnode (dg)
456461
457462 @threaded for mortar in eachmortar (dg, cache)
458463 # Choose thread-specific pre-allocated container
459- fstar = (fstar_lower_threaded[Threads. threadid ()],
460- fstar_upper_threaded[Threads. threadid ()])
464+ fstar_primary = (fstar_primary_lower_threaded[Threads. threadid ()],
465+ fstar_primary_upper_threaded[Threads. threadid ()])
466+
467+ fstar_secondary = (fstar_secondary_lower_threaded[Threads. threadid ()],
468+ fstar_secondary_upper_threaded[Threads. threadid ()])
461469
462470 # Get index information on the small elements
463471 small_indices = node_indices[1 , mortar]
@@ -480,7 +488,8 @@ function calc_mortar_flux!(surface_flux_values,
480488 contravariant_vectors,
481489 i_small, j_small, element)
482490
483- calc_mortar_flux! (fstar, mesh, nonconservative_terms, equations,
491+ calc_mortar_flux! (fstar_primary, fstar_secondary,
492+ mesh, nonconservative_terms, equations,
484493 surface_integral, dg, cache,
485494 mortar, position, normal_direction,
486495 node)
@@ -501,14 +510,15 @@ function calc_mortar_flux!(surface_flux_values,
501510 # "mortar_fluxes_to_elements!" instead.
502511 mortar_fluxes_to_elements! (surface_flux_values,
503512 mesh, equations, mortar_l2, dg, cache,
504- mortar, fstar, u_buffer)
513+ mortar, fstar_primary, fstar_secondary,
514+ u_buffer)
505515 end
506516
507517 return nothing
508518end
509519
510520# Inlined version of the mortar flux computation on small elements for conservation laws
511- @inline function calc_mortar_flux! (fstar ,
521+ @inline function calc_mortar_flux! (fstar_primary, fstar_secondary ,
512522 mesh:: Union{P4estMesh{2}, T8codeMesh{2}} ,
513523 nonconservative_terms:: False , equations,
514524 surface_integral, dg:: DG , cache,
@@ -523,12 +533,13 @@ end
523533 flux = surface_flux (u_ll, u_rr, normal_direction, equations)
524534
525535 # Copy flux to buffer
526- set_node_vars! (fstar[position_index], flux, equations, dg, node_index)
536+ set_node_vars! (fstar_primary[position_index], flux, equations, dg, node_index)
537+ set_node_vars! (fstar_secondary[position_index], flux, equations, dg, node_index)
527538end
528539
529540# Inlined version of the mortar flux computation on small elements for equations with conservative and
530541# nonconservative terms
531- @inline function calc_mortar_flux! (fstar ,
542+ @inline function calc_mortar_flux! (fstar_primary, fstar_secondary ,
532543 mesh:: Union{P4estMesh{2}, T8codeMesh{2}} ,
533544 nonconservative_terms:: True , equations,
534545 surface_integral, dg:: DG , cache,
@@ -547,19 +558,25 @@ end
547558 # The nonconservative flux is scaled by a factor of 0.5 based on
548559 # the interpretation of global SBP operators coupled discontinuously via
549560 # central fluxes/SATs
550- noncons = nonconservative_flux (u_ll, u_rr, normal_direction, equations)
561+ noncons_primary = nonconservative_flux (u_ll, u_rr, normal_direction, equations)
562+ noncons_secondary = nonconservative_flux (u_rr, u_ll, normal_direction, equations)
551563
552- flux_plus_noncons = flux + 0.5f0 * noncons
564+ flux_plus_noncons_primary = flux + 0.5f0 * noncons_primary
565+ flux_plus_noncons_secondary = flux + 0.5f0 * noncons_secondary
553566
554567 # Copy to buffer
555- set_node_vars! (fstar[position_index], flux_plus_noncons, equations, dg, node_index)
568+ set_node_vars! (fstar_primary[position_index], flux_plus_noncons_primary, equations,
569+ dg, node_index)
570+ set_node_vars! (fstar_secondary[position_index], flux_plus_noncons_secondary,
571+ equations, dg, node_index)
556572end
557573
558574@inline function mortar_fluxes_to_elements! (surface_flux_values,
559575 mesh:: Union{P4estMesh{2}, T8codeMesh{2}} ,
560576 equations,
561577 mortar_l2:: LobattoLegendreMortarL2 ,
562- dg:: DGSEM , cache, mortar, fstar, u_buffer)
578+ dg:: DGSEM , cache, mortar, fstar_primary,
579+ fstar_secondary, u_buffer)
563580 @unpack neighbor_ids, node_indices = cache. mortars
564581
565582 # Copy solution small to small
@@ -570,16 +587,16 @@ end
570587 element = neighbor_ids[position, mortar]
571588 for i in eachnode (dg)
572589 for v in eachvariable (equations)
573- surface_flux_values[v, i, small_direction, element] = fstar [position][v,
574- i]
590+ surface_flux_values[v, i, small_direction, element] = fstar_primary [position][v,
591+ i]
575592 end
576593 end
577594 end
578595
579596 # Project small fluxes to large element.
580597 multiply_dimensionwise! (u_buffer,
581- mortar_l2. reverse_upper, fstar [2 ],
582- mortar_l2. reverse_lower, fstar [1 ])
598+ mortar_l2. reverse_upper, fstar_secondary [2 ],
599+ mortar_l2. reverse_lower, fstar_secondary [1 ])
583600
584601 # The flux is calculated in the outward direction of the small elements,
585602 # so the sign must be switched to get the flux in outward direction
0 commit comments