Skip to content

Commit

Permalink
Slopez Race Condition Fix (#402)
Browse files Browse the repository at this point in the history
fix race condition in slopez for 4th order case near physical boundaries
update the treatment to match slopex and slopey cases which recompute
slopes intead of relying on neighboring slopes which may not have been
computed yet on a GPU
  • Loading branch information
ajnonaka authored Dec 7, 2023
1 parent 80c3e1a commit ffd3793
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,47 @@
variables minimum value maximum value
velx -69379.106064 69727.434216
vely -50178.472393 162983.57857
magvel 0.058876198888 162990.70574
momentum 159043.32129 2.2240885011e+14
magvel 0.058876197198 162990.70574
momentum 159043.31672 2.2240885011e+14
vort -0.066372521336 0.066767477487
rho 2701317.753 5501056735
rhoh 3.2011875688e+23 1.7545655512e+28
h 1.1850466508e+17 3.1895063725e+18
rhoX(C12) 810395.3259 1650317020.5
rhoX(O16) 1890922.4271 3850739714.5
rhoX(Mg24) 2.701317753e-24 221.89260649
rhoX(Mg24) 2.701317753e-24 221.89239446
X(C12) 0.29999989289 0.3
X(O16) 0.7 0.7
X(Mg24) 1e-30 1.0710848116e-07
X(Mg24) 1e-30 1.0710837882e-07
abar 14.545454545 14.54545549
omegadot(C12) -1.4173265938e-05 9.9296309988e-14
omegadot(O16) -5.9577785993e-13 3.9718523995e-13
omegadot(Mg24) -4.515473392e-26 1.4173265895e-05
omegadot(Mg24) -4.515473392e-26 1.4173265903e-05
Hnuc 0 7.938420473e+12
tfromp 16727067.413 686993354.61
tfromh 16727067.413 686993221.88
deltap -7.4771335795e+18 1.1443033126e+19
deltap -7.4771224469e+18 1.1443033126e+19
deltaT -8.0825118397e-06 2.6373031805e-06
Pi -1.1560937501e+23 1.0613576031e+23
pioverp0 -0.00013503348925 0.00016017384341
Pi -1.1560937499e+23 1.0613576032e+23
pioverp0 -0.00013503348923 0.00016017384343
p0pluspi 1.1878354865e+23 4.6908062299e+27
gpix -1.1344430106e+16 1.1287350216e+16
gpiy -1.1484175696e+16 2.7687724676e+16
gpiy -1.1484175696e+16 2.7687724675e+16
rhopert -3804600.1096 192531.7145
rhohpert -2.083177552e+24 1.0714116853e+23
tpert -12194479.902 240499771.15
rho0 2701317.753 5501056735
rhoh0 3.2011875698e+23 1.7545655512e+28
h0 1.1850466524e+17 3.1895063725e+18
p0 1.1878857264e+23 4.6908021446e+27
MachNumber 2.2764666381e-10 0.00019226694581
deltagamma -3.057506013e-05 0.0005974112677
MachNumber 2.2764665727e-10 0.00019226694581
deltagamma -3.0575060129e-05 0.0005974112677
entropy 13130474.995 61536481.496
entropypert -0.006991029308 0.13157121617
S -7.8659088534e-17 4.8986667856e-06
S -7.8659088534e-17 4.8986667857e-06
w0x 0 0
w0y -3.572126146e-08 7.5376596039
divw0 -9.315577374e-10 4.7258871201e-07
w0y -3.5721235058e-08 7.5376596038
divw0 -9.3155772233e-10 4.7258871201e-07
thermal 0 0
conductivity 0 0
sponge 0.98894855525 1
Expand Down
16 changes: 13 additions & 3 deletions Source/MaestroSlopes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,12 +537,17 @@ void Maestro::Slopez(const Box& bx, Array4<Real> const s,

} else if (k == klo + 1) {
// Recalculate the slope at lo(2)+1 using the revised dzl
Real del = -16.0 / 15.0 * s(i, j, k - 2, n) +
0.5 * s(i, j, k - 1, n) +
2.0 / 3.0 * s(i, j, k, n) -
0.1 * s(i, j, k + 1, n);
dmin = 2.0 * (s(i, j, k - 1, n) - s(i, j, k - 2, n));
dpls = 2.0 * (s(i, j, k, n) - s(i, j, k - 1, n));
Real slim = amrex::min(amrex::Math::abs(dpls),
amrex::Math::abs(dmin));
slim = dpls * dmin > 0.0 ? slim : 0.0;
dzl = slz(i, j, k - 1, n);
Real sflag = amrex::Math::copysign(1.0, del);
dzl = sflag * amrex::min(slim, amrex::Math::abs(del));
ds = 4.0 / 3.0 * dcen - (dzr + dzl) / 6.0;
slz(i, j, k, n) =
dflag * amrex::min(amrex::Math::abs(ds), dlim);
Expand All @@ -568,12 +573,17 @@ void Maestro::Slopez(const Box& bx, Array4<Real> const s,

} else if (k == khi - 1) {
// Recalculate the slope at lo(3)+1 using the revised dzr
Real del = -(-16.0 / 15.0 * s(i, j, k + 2, n) +
0.5 * s(i, j, k + 1, n) +
2.0 / 3.0 * s(i, j, k, n) -
0.1 * s(i, j, k - 1, n));
dmin = 2.0 * (s(i, j, k + 1, n) - s(i, j, k, n));
dpls = 2.0 * (s(i, j, k + 2, n) - s(i, j, k + 1, n));
Real slim = amrex::min(amrex::Math::abs(dpls),
amrex::Math::abs(dmin));
slim = dpls * dmin > 0.0 ? slim : 0.0;
dzr = slz(i, j, k + 1, n);
Real sflag = amrex::Math::copysign(1.0, del);
dzr = sflag * amrex::min(slim, amrex::Math::abs(del));
ds = 4.0 / 3.0 * dcen - (dzl + dzr) / 6.0;
slz(i, j, k, n) =
dflag * amrex::min(amrex::Math::abs(ds), dlim);
Expand All @@ -582,4 +592,4 @@ void Maestro::Slopez(const Box& bx, Array4<Real> const s,
});
}
}
#endif
#endif

0 comments on commit ffd3793

Please sign in to comment.