10
10
function create_cache (mesh:: Union{P4estMesh{3}, T8codeMesh{3}} , equations,
11
11
mortar_l2:: LobattoLegendreMortarL2 , uEltype)
12
12
# TODO : Taal compare performance of different types
13
- fstar_threaded = [Array {uEltype, 4} (undef, nvariables (equations), nnodes (mortar_l2),
14
- nnodes (mortar_l2), 4 )
15
- for _ in 1 : Threads. nthreads ()]
13
+ fstar_primary_threaded = [Array {uEltype, 4} (undef, nvariables (equations),
14
+ nnodes (mortar_l2),
15
+ nnodes (mortar_l2), 4 )
16
+ for _ in 1 : Threads. nthreads ()]
17
+ fstar_secondary_threaded = [Array {uEltype, 4} (undef, nvariables (equations),
18
+ nnodes (mortar_l2),
19
+ nnodes (mortar_l2), 4 )
20
+ for _ in 1 : Threads. nthreads ()]
16
21
17
22
fstar_tmp_threaded = [Array {uEltype, 3} (undef, nvariables (equations),
18
23
nnodes (mortar_l2), nnodes (mortar_l2))
@@ -21,7 +26,7 @@ function create_cache(mesh::Union{P4estMesh{3}, T8codeMesh{3}}, equations,
21
26
nnodes (mortar_l2))
22
27
for _ in 1 : Threads. nthreads ()]
23
28
24
- (; fstar_threaded , fstar_tmp_threaded, u_threaded)
29
+ (; fstar_primary_threaded, fstar_secondary_threaded , fstar_tmp_threaded, u_threaded)
25
30
end
26
31
27
32
# index_to_start_step_3d(index::Symbol, index_range)
@@ -521,12 +526,13 @@ function calc_mortar_flux!(surface_flux_values,
521
526
surface_integral, dg:: DG , cache)
522
527
@unpack neighbor_ids, node_indices = cache. mortars
523
528
@unpack contravariant_vectors = cache. elements
524
- @unpack fstar_threaded , fstar_tmp_threaded = cache
529
+ @unpack fstar_primary_threaded, fstar_secondary_threaded , fstar_tmp_threaded = cache
525
530
index_range = eachnode (dg)
526
531
527
532
@threaded for mortar in eachmortar (dg, cache)
528
533
# Choose thread-specific pre-allocated container
529
- fstar = fstar_threaded[Threads. threadid ()]
534
+ fstar_primary = fstar_primary_threaded[Threads. threadid ()]
535
+ fstar_secondary = fstar_secondary_threaded[Threads. threadid ()]
530
536
fstar_tmp = fstar_tmp_threaded[Threads. threadid ()]
531
537
532
538
# Get index information on the small elements
@@ -555,7 +561,8 @@ function calc_mortar_flux!(surface_flux_values,
555
561
i_small, j_small, k_small,
556
562
element)
557
563
558
- calc_mortar_flux! (fstar, mesh, nonconservative_terms, equations,
564
+ calc_mortar_flux! (fstar_primary, fstar_secondary, mesh,
565
+ nonconservative_terms, equations,
559
566
surface_integral, dg, cache,
560
567
mortar, position, normal_direction,
561
568
i, j)
@@ -581,14 +588,15 @@ function calc_mortar_flux!(surface_flux_values,
581
588
# "mortar_fluxes_to_elements!" instead.
582
589
mortar_fluxes_to_elements! (surface_flux_values,
583
590
mesh, equations, mortar_l2, dg, cache,
584
- mortar, fstar, u_buffer, fstar_tmp)
591
+ mortar, fstar_primary, fstar_secondary, u_buffer,
592
+ fstar_tmp)
585
593
end
586
594
587
595
return nothing
588
596
end
589
597
590
598
# Inlined version of the mortar flux computation on small elements for conservation fluxes
591
- @inline function calc_mortar_flux! (fstar ,
599
+ @inline function calc_mortar_flux! (fstar_primary, fstar_secondary ,
592
600
mesh:: Union{P4estMesh{3}, T8codeMesh{3}} ,
593
601
nonconservative_terms:: False , equations,
594
602
surface_integral, dg:: DG , cache,
@@ -603,13 +611,15 @@ end
603
611
flux = surface_flux (u_ll, u_rr, normal_direction, equations)
604
612
605
613
# Copy flux to buffer
606
- set_node_vars! (fstar, flux, equations, dg, i_node_index, j_node_index,
614
+ set_node_vars! (fstar_primary, flux, equations, dg, i_node_index, j_node_index,
615
+ position_index)
616
+ set_node_vars! (fstar_secondary, flux, equations, dg, i_node_index, j_node_index,
607
617
position_index)
608
618
end
609
619
610
620
# Inlined version of the mortar flux computation on small elements for conservation fluxes
611
621
# with nonconservative terms
612
- @inline function calc_mortar_flux! (fstar ,
622
+ @inline function calc_mortar_flux! (fstar_primary, fstar_secondary ,
613
623
mesh:: Union{P4estMesh{3}, T8codeMesh{3}} ,
614
624
nonconservative_terms:: True , equations,
615
625
surface_integral, dg:: DG , cache,
@@ -627,20 +637,28 @@ end
627
637
# Compute nonconservative flux and add it to the flux scaled by a factor of 0.5 based on
628
638
# the interpretation of global SBP operators coupled discontinuously via
629
639
# central fluxes/SATs
630
- noncons = nonconservative_flux (u_ll, u_rr, normal_direction, equations)
631
- flux_plus_noncons = flux + 0.5f0 * noncons
640
+ noncons_primary = nonconservative_flux (u_ll, u_rr, normal_direction, equations)
641
+ noncons_secondary = nonconservative_flux (u_rr, u_ll, normal_direction, equations)
642
+ flux_plus_noncons_primary = flux + 0.5f0 * noncons_primary
643
+ flux_plus_noncons_secondary = flux + 0.5f0 * noncons_secondary
632
644
633
645
# Copy to buffer
634
- set_node_vars! (fstar, flux_plus_noncons, equations, dg, i_node_index, j_node_index,
646
+ set_node_vars! (fstar_primary, flux_plus_noncons_primary, equations, dg,
647
+ i_node_index,
648
+ j_node_index,
649
+ position_index)
650
+ set_node_vars! (fstar_secondary, flux_plus_noncons_secondary, equations, dg,
651
+ i_node_index,
652
+ j_node_index,
635
653
position_index)
636
654
end
637
655
638
656
@inline function mortar_fluxes_to_elements! (surface_flux_values,
639
657
mesh:: Union{P4estMesh{3}, T8codeMesh{3}} ,
640
658
equations,
641
659
mortar_l2:: LobattoLegendreMortarL2 ,
642
- dg:: DGSEM , cache, mortar, fstar, u_buffer ,
643
- fstar_tmp)
660
+ dg:: DGSEM , cache, mortar, fstar_primary ,
661
+ fstar_secondary, u_buffer, fstar_tmp)
644
662
@unpack neighbor_ids, node_indices = cache. mortars
645
663
index_range = eachnode (dg)
646
664
@@ -652,28 +670,30 @@ end
652
670
element = neighbor_ids[position, mortar]
653
671
for j in eachnode (dg), i in eachnode (dg)
654
672
for v in eachvariable (equations)
655
- surface_flux_values[v, i, j, small_direction, element] = fstar[v, i, j,
656
- position]
673
+ surface_flux_values[v, i, j, small_direction, element] = fstar_primary[v,
674
+ i,
675
+ j,
676
+ position]
657
677
end
658
678
end
659
679
end
660
680
661
681
# Project small fluxes to large element.
662
682
multiply_dimensionwise! (u_buffer,
663
683
mortar_l2. reverse_lower, mortar_l2. reverse_lower,
664
- view (fstar , .. , 1 ),
684
+ view (fstar_secondary , .. , 1 ),
665
685
fstar_tmp)
666
686
add_multiply_dimensionwise! (u_buffer,
667
687
mortar_l2. reverse_upper, mortar_l2. reverse_lower,
668
- view (fstar , .. , 2 ),
688
+ view (fstar_secondary , .. , 2 ),
669
689
fstar_tmp)
670
690
add_multiply_dimensionwise! (u_buffer,
671
691
mortar_l2. reverse_lower, mortar_l2. reverse_upper,
672
- view (fstar , .. , 3 ),
692
+ view (fstar_secondary , .. , 3 ),
673
693
fstar_tmp)
674
694
add_multiply_dimensionwise! (u_buffer,
675
695
mortar_l2. reverse_upper, mortar_l2. reverse_upper,
676
- view (fstar , .. , 4 ),
696
+ view (fstar_secondary , .. , 4 ),
677
697
fstar_tmp)
678
698
679
699
# The flux is calculated in the outward direction of the small elements,
0 commit comments