@@ -33,6 +33,8 @@ Castro::trace_plm(const Box& bx, const int idir,
33
33
// vbx is the valid box (no ghost cells)
34
34
35
35
const auto dx = geom.CellSizeArray ();
36
+ const auto problo = geom.ProbLoArray ();
37
+ const int coord = geom.Coord ();
36
38
37
39
const int * lo_bc = phys_bc.lo ();
38
40
const int * hi_bc = phys_bc.hi ();
@@ -43,8 +45,6 @@ Castro::trace_plm(const Box& bx, const int idir,
43
45
const auto domlo = geom.Domain ().loVect3d ();
44
46
const auto domhi = geom.Domain ().hiVect3d ();
45
47
46
- const Real dtdx = dt/dx[idir];
47
-
48
48
auto vlo = vbx.loVect3d ();
49
49
auto vhi = vbx.hiVect3d ();
50
50
@@ -100,6 +100,16 @@ Castro::trace_plm(const Box& bx, const int idir,
100
100
[=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
101
101
{
102
102
103
+ Real dtdL = dt / dx[idir];
104
+ Real dL = dx[idir];
105
+
106
+ // Want dt/(rdtheta) instead of dt/dtheta for 2d Spherical
107
+ if (coord == 2 && idir == 1 ) {
108
+ Real r = problo[0 ] + static_cast <Real>(i + 0 .5_rt) * dx[0 ];
109
+ dL = r * dx[1 ];
110
+ dtdL = dt / dL;
111
+ }
112
+
103
113
bool lo_bc_test = lo_symm && ((idir == 0 && i == domlo[0 ]) ||
104
114
(idir == 1 && j == domlo[1 ]) ||
105
115
(idir == 2 && k == domlo[2 ]));
@@ -166,7 +176,7 @@ Castro::trace_plm(const Box& bx, const int idir,
166
176
load_stencil (srcQ, idir, i, j, k, QUN, src);
167
177
168
178
Real dp = dq[IEIGN_P];
169
- pslope (trho, s, src, flat, lo_bc_test, hi_bc_test, dx[idir] , dp);
179
+ pslope (trho, s, src, flat, lo_bc_test, hi_bc_test, dL , dp);
170
180
dq[IEIGN_P] = dp;
171
181
172
182
}
@@ -185,7 +195,7 @@ Castro::trace_plm(const Box& bx, const int idir,
185
195
186
196
// construct the right state on the i interface
187
197
188
- Real ref_fac = 0 .5_rt*(1 .0_rt + dtdx *amrex::min (e[0 ], 0 .0_rt));
198
+ Real ref_fac = 0 .5_rt*(1 .0_rt + dtdL *amrex::min (e[0 ], 0 .0_rt));
189
199
Real rho_ref = rho - ref_fac*dq[IEIGN_RHO];
190
200
Real un_ref = un - ref_fac*dq[IEIGN_UN];
191
201
Real ut_ref = ut - ref_fac*dq[IEIGN_UT];
@@ -195,8 +205,8 @@ Castro::trace_plm(const Box& bx, const int idir,
195
205
196
206
// this is -(1/2) ( 1 + dt/dx lambda) (l . dq) r
197
207
Real trace_fac0 = 0 .0_rt; // FOURTH*dtdx*(e(1) - e(1))*(1.0_rt - sign(1.0_rt, e(1)))
198
- Real trace_fac1 = 0 .25_rt*dtdx *(e[0 ] - e[1 ])*(1 .0_rt - std::copysign (1 .0_rt, e[1 ]));
199
- Real trace_fac2 = 0 .25_rt*dtdx *(e[0 ] - e[2 ])*(1 .0_rt - std::copysign (1 .0_rt, e[2 ]));
208
+ Real trace_fac1 = 0 .25_rt*dtdL *(e[0 ] - e[1 ])*(1 .0_rt - std::copysign (1 .0_rt, e[1 ]));
209
+ Real trace_fac2 = 0 .25_rt*dtdL *(e[0 ] - e[2 ])*(1 .0_rt - std::copysign (1 .0_rt, e[2 ]));
200
210
201
211
Real apright = trace_fac2*alphap;
202
212
Real amright = trace_fac0*alpham;
@@ -230,16 +240,16 @@ Castro::trace_plm(const Box& bx, const int idir,
230
240
231
241
// now construct the left state on the i+1 interface
232
242
233
- ref_fac = 0 .5_rt*(1 .0_rt - dtdx *amrex::max (e[2 ], 0 .0_rt));
243
+ ref_fac = 0 .5_rt*(1 .0_rt - dtdL *amrex::max (e[2 ], 0 .0_rt));
234
244
rho_ref = rho + ref_fac*dq[IEIGN_RHO];
235
245
un_ref = un + ref_fac*dq[IEIGN_UN];
236
246
ut_ref = ut + ref_fac*dq[IEIGN_UT];
237
247
utt_ref = utt + ref_fac*dq[IEIGN_UTT];
238
248
p_ref = p + ref_fac*dq[IEIGN_P];
239
249
rhoe_ref = rhoe + ref_fac*dq[IEIGN_RE];
240
250
241
- trace_fac0 = 0 .25_rt*dtdx *(e[2 ] - e[0 ])*(1 .0_rt + std::copysign (1 .0_rt, e[0 ]));
242
- trace_fac1 = 0 .25_rt*dtdx *(e[2 ] - e[1 ])*(1 .0_rt + std::copysign (1 .0_rt, e[1 ]));
251
+ trace_fac0 = 0 .25_rt*dtdL *(e[2 ] - e[0 ])*(1 .0_rt + std::copysign (1 .0_rt, e[0 ]));
252
+ trace_fac1 = 0 .25_rt*dtdL *(e[2 ] - e[1 ])*(1 .0_rt + std::copysign (1 .0_rt, e[1 ]));
243
253
trace_fac2 = 0 .0_rt; // FOURTH*dtdx*(e(3) - e(3))*(1.0_rt + sign(1.0_rt, e(3)))
244
254
245
255
Real apleft = trace_fac2*alphap;
@@ -301,29 +311,42 @@ Castro::trace_plm(const Box& bx, const int idir,
301
311
}
302
312
303
313
#if (AMREX_SPACEDIM < 3)
304
- // geometry source terms -- these only apply to the x-states
305
- if (idir == 0 && dloga (i,j,k) != 0 .0_rt) {
306
- Real courn = dtdx*(cc + std::abs (un));
314
+ // geometry source terms
315
+ // these only apply to the x-states for cylindrical and spherical
316
+ // or y-states for spherical
317
+
318
+ if (dloga (i,j,k) != 0 .0_rt) {
319
+ Real courn = dtdL*(cc + std::abs (un));
307
320
Real eta = (1 .0_rt-courn)/(cc*dt*std::abs (dloga (i,j,k)));
308
321
Real dlogatmp = amrex::min (eta, 1 .0_rt)*dloga (i,j,k);
309
322
Real sourcr = -0 .5_rt*dt*rho*dlogatmp*un;
310
323
Real sourcp = sourcr*csq;
311
324
Real source = sourcp*enth;
312
325
313
- if (i <= vhi[0 ]) {
326
+ if (idir == 0 && i <= vhi[0 ]) {
314
327
qm (i+1 ,j,k,QRHO) += sourcr;
315
328
qm (i+1 ,j,k,QRHO) = amrex::max (qm (i+1 ,j,k,QRHO), lsmall_dens);
316
329
qm (i+1 ,j,k,QPRES) += sourcp;
317
330
qm (i+1 ,j,k,QREINT) += source;
318
331
}
319
332
320
- if (i >= vlo[0 ]) {
333
+ if (idir == 1 && j <= vhi[1 ]) {
334
+ qm (i,j+1 ,k,QRHO) += sourcr;
335
+ qm (i,j+1 ,k,QRHO) = amrex::max (qm (i,j+1 ,k,QRHO), lsmall_dens);
336
+ qm (i,j+1 ,k,QPRES) += sourcp;
337
+ qm (i,j+1 ,k,QREINT) += source;
338
+ }
339
+
340
+ if ((idir == 0 && i >= vlo[0 ]) ||
341
+ (idir == 1 && j >= vlo[1 ])) {
321
342
qp (i,j,k,QRHO) += sourcr;
322
343
qp (i,j,k,QRHO) = amrex::max (qp (i,j,k,QRHO), lsmall_dens);
323
344
qp (i,j,k,QPRES) += sourcp;
324
345
qp (i,j,k,QREINT) += source;
325
346
}
347
+
326
348
}
349
+
327
350
#endif
328
351
329
352
for (int ipassive = 0 ; ipassive < npassive; ipassive++) {
@@ -340,12 +363,12 @@ Castro::trace_plm(const Box& bx, const int idir,
340
363
(idir == 1 && j >= vlo[1 ]) ||
341
364
(idir == 2 && k >= vlo[2 ])) {
342
365
343
- Real spzero = un >= 0 .0_rt ? -1 .0_rt : un*dtdx ;
366
+ Real spzero = un >= 0 .0_rt ? -1 .0_rt : un*dtdL ;
344
367
qp (i,j,k,n) = s[i0] + 0 .5_rt*(-1 .0_rt - spzero)*dX;
345
368
}
346
369
347
370
// Left state
348
- Real spzero = un >= 0 .0_rt ? un*dtdx : 1 .0_rt;
371
+ Real spzero = un >= 0 .0_rt ? un*dtdL : 1 .0_rt;
349
372
Real acmpleft = 0 .5_rt*(1 .0_rt - spzero )*dX;
350
373
351
374
if (idir == 0 && i <= vhi[0 ]) {
0 commit comments