Skip to content

Commit 5498f78

Browse files
Plain vector for _threaded structures (#2639)
* Plain vector for `_threaded`structures * fmt * Update src/solvers/dgsem_tree/dg_3d.jl
1 parent 4010727 commit 5498f78

File tree

5 files changed

+137
-143
lines changed

5 files changed

+137
-143
lines changed

src/solvers/dgsem_p4est/dg_2d.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ function create_cache(mesh::Union{P4estMesh{2}, P4estMeshView{2}, T8codeMesh{2}}
1414
MA2d = MArray{Tuple{nvariables(equations), nnodes(mortar_l2)},
1515
uEltype, 2,
1616
nvariables(equations) * nnodes(mortar_l2)}
17-
fstar_primary_upper_threaded = MA2d[MA2d(undef) for _ in 1:Threads.maxthreadid()]
18-
fstar_primary_lower_threaded = MA2d[MA2d(undef) for _ in 1:Threads.maxthreadid()]
19-
fstar_secondary_upper_threaded = MA2d[MA2d(undef) for _ in 1:Threads.maxthreadid()]
20-
fstar_secondary_lower_threaded = MA2d[MA2d(undef) for _ in 1:Threads.maxthreadid()]
21-
u_threaded = MA2d[MA2d(undef) for _ in 1:Threads.maxthreadid()]
17+
fstar_primary_upper_threaded = [MA2d(undef) for _ in 1:Threads.maxthreadid()]
18+
fstar_primary_lower_threaded = [MA2d(undef) for _ in 1:Threads.maxthreadid()]
19+
fstar_secondary_upper_threaded = [MA2d(undef) for _ in 1:Threads.maxthreadid()]
20+
fstar_secondary_lower_threaded = [MA2d(undef) for _ in 1:Threads.maxthreadid()]
21+
u_threaded = [MA2d(undef) for _ in 1:Threads.maxthreadid()]
2222

2323
cache = (; fstar_primary_upper_threaded, fstar_primary_lower_threaded,
2424
fstar_secondary_upper_threaded, fstar_secondary_lower_threaded,

src/solvers/dgsem_tree/dg_1d.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,12 @@ function create_cache(mesh::Union{TreeMesh{1}, StructuredMesh{1}}, equations,
4141
dg, uEltype)
4242

4343
A2d = Array{uEltype, 2}
44-
fstar1_L_threaded = A2d[A2d(undef, nvariables(equations),
45-
nnodes(dg) + 1)
46-
for _ in 1:Threads.maxthreadid()]
47-
fstar1_R_threaded = A2d[A2d(undef, nvariables(equations),
48-
nnodes(dg) + 1)
49-
for _ in 1:Threads.maxthreadid()]
44+
fstar1_L_threaded = [A2d(undef, nvariables(equations),
45+
nnodes(dg) + 1)
46+
for _ in 1:Threads.maxthreadid()]
47+
fstar1_R_threaded = [A2d(undef, nvariables(equations),
48+
nnodes(dg) + 1)
49+
for _ in 1:Threads.maxthreadid()]
5050

5151
return (; cache..., fstar1_L_threaded, fstar1_R_threaded)
5252
end
@@ -55,12 +55,12 @@ function create_cache(mesh::Union{TreeMesh{1}, StructuredMesh{1}}, equations,
5555
volume_integral::AbstractVolumeIntegralPureLGLFiniteVolume,
5656
dg::DG, uEltype)
5757
A2d = Array{uEltype, 2}
58-
fstar1_L_threaded = A2d[A2d(undef, nvariables(equations),
59-
nnodes(dg) + 1)
60-
for _ in 1:Threads.maxthreadid()]
61-
fstar1_R_threaded = A2d[A2d(undef, nvariables(equations),
62-
nnodes(dg) + 1)
63-
for _ in 1:Threads.maxthreadid()]
58+
fstar1_L_threaded = [A2d(undef, nvariables(equations),
59+
nnodes(dg) + 1)
60+
for _ in 1:Threads.maxthreadid()]
61+
fstar1_R_threaded = [A2d(undef, nvariables(equations),
62+
nnodes(dg) + 1)
63+
for _ in 1:Threads.maxthreadid()]
6464

6565
return (; fstar1_L_threaded, fstar1_R_threaded)
6666
end

src/solvers/dgsem_tree/dg_2d.jl

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,18 @@ function create_cache(mesh::Union{TreeMesh{2}, StructuredMesh{2}, UnstructuredMe
4343

4444
A3d = Array{uEltype, 3}
4545

46-
fstar1_L_threaded = A3d[A3d(undef, nvariables(equations),
47-
nnodes(dg) + 1, nnodes(dg))
48-
for _ in 1:Threads.maxthreadid()]
49-
fstar1_R_threaded = A3d[A3d(undef, nvariables(equations),
50-
nnodes(dg) + 1, nnodes(dg))
51-
for _ in 1:Threads.maxthreadid()]
52-
fstar2_L_threaded = A3d[A3d(undef, nvariables(equations),
53-
nnodes(dg), nnodes(dg) + 1)
54-
for _ in 1:Threads.maxthreadid()]
55-
fstar2_R_threaded = A3d[A3d(undef, nvariables(equations),
56-
nnodes(dg), nnodes(dg) + 1)
57-
for _ in 1:Threads.maxthreadid()]
46+
fstar1_L_threaded = [A3d(undef, nvariables(equations),
47+
nnodes(dg) + 1, nnodes(dg))
48+
for _ in 1:Threads.maxthreadid()]
49+
fstar1_R_threaded = [A3d(undef, nvariables(equations),
50+
nnodes(dg) + 1, nnodes(dg))
51+
for _ in 1:Threads.maxthreadid()]
52+
fstar2_L_threaded = [A3d(undef, nvariables(equations),
53+
nnodes(dg), nnodes(dg) + 1)
54+
for _ in 1:Threads.maxthreadid()]
55+
fstar2_R_threaded = [A3d(undef, nvariables(equations),
56+
nnodes(dg), nnodes(dg) + 1)
57+
for _ in 1:Threads.maxthreadid()]
5858

5959
return (; cache...,
6060
fstar1_L_threaded, fstar1_R_threaded, fstar2_L_threaded, fstar2_R_threaded)
@@ -66,18 +66,18 @@ function create_cache(mesh::Union{TreeMesh{2}, StructuredMesh{2}, UnstructuredMe
6666
uEltype)
6767
A3d = Array{uEltype, 3}
6868

69-
fstar1_L_threaded = A3d[A3d(undef, nvariables(equations),
70-
nnodes(dg) + 1, nnodes(dg))
71-
for _ in 1:Threads.maxthreadid()]
72-
fstar1_R_threaded = A3d[A3d(undef, nvariables(equations),
73-
nnodes(dg) + 1, nnodes(dg))
74-
for _ in 1:Threads.maxthreadid()]
75-
fstar2_L_threaded = A3d[A3d(undef, nvariables(equations),
76-
nnodes(dg), nnodes(dg) + 1)
77-
for _ in 1:Threads.maxthreadid()]
78-
fstar2_R_threaded = A3d[A3d(undef, nvariables(equations),
79-
nnodes(dg), nnodes(dg) + 1)
80-
for _ in 1:Threads.maxthreadid()]
69+
fstar1_L_threaded = [A3d(undef, nvariables(equations),
70+
nnodes(dg) + 1, nnodes(dg))
71+
for _ in 1:Threads.maxthreadid()]
72+
fstar1_R_threaded = [A3d(undef, nvariables(equations),
73+
nnodes(dg) + 1, nnodes(dg))
74+
for _ in 1:Threads.maxthreadid()]
75+
fstar2_L_threaded = [A3d(undef, nvariables(equations),
76+
nnodes(dg), nnodes(dg) + 1)
77+
for _ in 1:Threads.maxthreadid()]
78+
fstar2_R_threaded = [A3d(undef, nvariables(equations),
79+
nnodes(dg), nnodes(dg) + 1)
80+
for _ in 1:Threads.maxthreadid()]
8181

8282
return (; fstar1_L_threaded, fstar1_R_threaded, fstar2_L_threaded,
8383
fstar2_R_threaded)
@@ -91,10 +91,10 @@ function create_cache(mesh::TreeMesh{2}, equations,
9191
MA2d = MArray{Tuple{nvariables(equations), nnodes(mortar_l2)},
9292
uEltype, 2,
9393
nvariables(equations) * nnodes(mortar_l2)}
94-
fstar_primary_upper_threaded = MA2d[MA2d(undef) for _ in 1:Threads.maxthreadid()]
95-
fstar_primary_lower_threaded = MA2d[MA2d(undef) for _ in 1:Threads.maxthreadid()]
96-
fstar_secondary_upper_threaded = MA2d[MA2d(undef) for _ in 1:Threads.maxthreadid()]
97-
fstar_secondary_lower_threaded = MA2d[MA2d(undef) for _ in 1:Threads.maxthreadid()]
94+
fstar_primary_upper_threaded = [MA2d(undef) for _ in 1:Threads.maxthreadid()]
95+
fstar_primary_lower_threaded = [MA2d(undef) for _ in 1:Threads.maxthreadid()]
96+
fstar_secondary_upper_threaded = [MA2d(undef) for _ in 1:Threads.maxthreadid()]
97+
fstar_secondary_lower_threaded = [MA2d(undef) for _ in 1:Threads.maxthreadid()]
9898

9999
# A2d = Array{uEltype, 2}
100100
# fstar_upper_threaded = [A2d(undef, nvariables(equations), nnodes(mortar_l2)) for _ in 1:Threads.maxthreadid()]

src/solvers/dgsem_tree/dg_2d_subcell_limiters.jl

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,25 +14,25 @@ function create_cache(mesh::Union{TreeMesh{2}, StructuredMesh{2}, P4estMesh{2}},
1414

1515
A3d = Array{uEltype, 3}
1616

17-
fhat1_L_threaded = A3d[A3d(undef, nvariables(equations),
18-
nnodes(dg) + 1, nnodes(dg))
19-
for _ in 1:Threads.maxthreadid()]
20-
fhat2_L_threaded = A3d[A3d(undef, nvariables(equations),
21-
nnodes(dg), nnodes(dg) + 1)
22-
for _ in 1:Threads.maxthreadid()]
23-
fhat1_R_threaded = A3d[A3d(undef, nvariables(equations),
24-
nnodes(dg) + 1, nnodes(dg))
25-
for _ in 1:Threads.maxthreadid()]
26-
fhat2_R_threaded = A3d[A3d(undef, nvariables(equations),
27-
nnodes(dg), nnodes(dg) + 1)
28-
for _ in 1:Threads.maxthreadid()]
29-
30-
flux_temp_threaded = A3d[A3d(undef, nvariables(equations),
31-
nnodes(dg), nnodes(dg))
32-
for _ in 1:Threads.maxthreadid()]
33-
fhat_temp_threaded = A3d[A3d(undef, nvariables(equations),
34-
nnodes(dg), nnodes(dg))
35-
for _ in 1:Threads.maxthreadid()]
17+
fhat1_L_threaded = [A3d(undef, nvariables(equations),
18+
nnodes(dg) + 1, nnodes(dg))
19+
for _ in 1:Threads.maxthreadid()]
20+
fhat2_L_threaded = [A3d(undef, nvariables(equations),
21+
nnodes(dg), nnodes(dg) + 1)
22+
for _ in 1:Threads.maxthreadid()]
23+
fhat1_R_threaded = [A3d(undef, nvariables(equations),
24+
nnodes(dg) + 1, nnodes(dg))
25+
for _ in 1:Threads.maxthreadid()]
26+
fhat2_R_threaded = [A3d(undef, nvariables(equations),
27+
nnodes(dg), nnodes(dg) + 1)
28+
for _ in 1:Threads.maxthreadid()]
29+
30+
flux_temp_threaded = [A3d(undef, nvariables(equations),
31+
nnodes(dg), nnodes(dg))
32+
for _ in 1:Threads.maxthreadid()]
33+
fhat_temp_threaded = [A3d(undef, nvariables(equations),
34+
nnodes(dg), nnodes(dg))
35+
for _ in 1:Threads.maxthreadid()]
3636

3737
antidiffusive_fluxes = ContainerAntidiffusiveFlux2D{uEltype}(0,
3838
nvariables(equations),
@@ -44,18 +44,18 @@ function create_cache(mesh::Union{TreeMesh{2}, StructuredMesh{2}, P4estMesh{2}},
4444
# Extract the nonconservative flux as a dispatch argument for `n_nonconservative_terms`
4545
_, volume_flux_noncons = volume_integral.volume_flux_dg
4646

47-
flux_nonconservative_temp_threaded = A4d[A4d(undef, nvariables(equations),
48-
n_nonconservative_terms(volume_flux_noncons),
49-
nnodes(dg), nnodes(dg))
50-
for _ in 1:Threads.maxthreadid()]
51-
fhat_nonconservative_temp_threaded = A4d[A4d(undef, nvariables(equations),
52-
n_nonconservative_terms(volume_flux_noncons),
53-
nnodes(dg), nnodes(dg))
54-
for _ in 1:Threads.maxthreadid()]
55-
phi_threaded = A4d[A4d(undef, nvariables(equations),
56-
n_nonconservative_terms(volume_flux_noncons),
57-
nnodes(dg), nnodes(dg))
58-
for _ in 1:Threads.maxthreadid()]
47+
flux_nonconservative_temp_threaded = [A4d(undef, nvariables(equations),
48+
n_nonconservative_terms(volume_flux_noncons),
49+
nnodes(dg), nnodes(dg))
50+
for _ in 1:Threads.maxthreadid()]
51+
fhat_nonconservative_temp_threaded = [A4d(undef, nvariables(equations),
52+
n_nonconservative_terms(volume_flux_noncons),
53+
nnodes(dg), nnodes(dg))
54+
for _ in 1:Threads.maxthreadid()]
55+
phi_threaded = [A4d(undef, nvariables(equations),
56+
n_nonconservative_terms(volume_flux_noncons),
57+
nnodes(dg), nnodes(dg))
58+
for _ in 1:Threads.maxthreadid()]
5959
cache = (; cache..., flux_nonconservative_temp_threaded,
6060
fhat_nonconservative_temp_threaded, phi_threaded)
6161
end

0 commit comments

Comments
 (0)