Skip to content

Commit 32f8627

Browse files
committed
1) add FB for momenta so we can correctly do tangential interpolation in advection fluxes; 2) when doing SRD on rho and rhotheta, do it to the perturbational state not full state
1 parent 2b14ffe commit 32f8627

File tree

5 files changed

+49
-24
lines changed

5 files changed

+49
-24
lines changed

Source/EB/ERF_EBAux.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ define( [[maybe_unused]] int const& a_level,
3737

3838
const IntVect vdim(IntVect::TheDimensionVector(a_idim));
3939

40-
const BoxArray& grids = amrex::convert(a_grids, vdim);
40+
const BoxArray& my_grids = amrex::convert(a_grids, vdim);
4141

42-
m_cellflags = new FabArray<EBCellFlagFab>(grids, a_dmap, 1, a_ngrow[0], MFInfo(),
42+
m_cellflags = new FabArray<EBCellFlagFab>(my_grids, a_dmap, 1, a_ngrow[0], MFInfo(),
4343
DefaultFabFactory<EBCellFlagFab>());
4444

4545
// Set m_cellflags type to singlevalued
@@ -49,8 +49,8 @@ define( [[maybe_unused]] int const& a_level,
4949
fab.setType(FabType::singlevalued);
5050
}
5151

52-
m_volfrac = new MultiFab(grids, a_dmap, 1, a_ngrow[1], MFInfo(), FArrayBoxFactory());
53-
m_volcent = new MultiFab(grids, a_dmap, AMREX_SPACEDIM, a_ngrow[2], MFInfo(), FArrayBoxFactory());
52+
m_volfrac = new MultiFab(my_grids, a_dmap, 1, a_ngrow[1], MFInfo(), FArrayBoxFactory());
53+
m_volcent = new MultiFab(my_grids, a_dmap, AMREX_SPACEDIM, a_ngrow[2], MFInfo(), FArrayBoxFactory());
5454

5555
for (int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
5656
const BoxArray& faceba = amrex::convert(a_grids, IntVect::TheDimensionVector(idim));
@@ -63,9 +63,9 @@ define( [[maybe_unused]] int const& a_level,
6363
}
6464
}
6565

66-
m_bndryarea = new MultiFab(grids, a_dmap, 1, a_ngrow[2], MFInfo(), FArrayBoxFactory());
67-
m_bndrycent = new MultiFab(grids, a_dmap, AMREX_SPACEDIM, a_ngrow[2], MFInfo(), FArrayBoxFactory());
68-
m_bndrynorm = new MultiFab(grids, a_dmap, AMREX_SPACEDIM, a_ngrow[2], MFInfo(), FArrayBoxFactory());
66+
m_bndryarea = new MultiFab(my_grids, a_dmap, 1, a_ngrow[2], MFInfo(), FArrayBoxFactory());
67+
m_bndrycent = new MultiFab(my_grids, a_dmap, AMREX_SPACEDIM, a_ngrow[2], MFInfo(), FArrayBoxFactory());
68+
m_bndrynorm = new MultiFab(my_grids, a_dmap, AMREX_SPACEDIM, a_ngrow[2], MFInfo(), FArrayBoxFactory());
6969

7070
// Initialize with zeros
7171
m_volfrac->setVal(0.0);

Source/ERF_MakeNewArrays.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ ERF::init_stuff (int lev, const BoxArray& ba, const DistributionMapping& dm,
2929
// ********************************************************************************************
3030
// Base state holds r_0, pres_0, pi_0, th_0 (in that order)
3131
//
32-
// Here is where we set 3 ghost cells for the base state!
33-
//
32+
// Here is where we set the number of ghost cells for the base state!
3433
// ********************************************************************************************
35-
tmp_base_state.define(ba,dm,BaseState::num_comps,3);
34+
int ngb = (solverChoice.terrain_type == TerrainType::EB) ? 4 : 3;
35+
tmp_base_state.define(ba,dm,BaseState::num_comps,ngb);
3636
tmp_base_state.setVal(0.);
3737

3838
if (solverChoice.terrain_type == TerrainType::MovingFittedMesh) {

Source/TimeIntegration/ERF_MRI.H

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ public:
294294
// but we are using the "new" versions (in S_sum) of the velocities
295295
// (because we did update the fast variables in the substepping)
296296
// ****************************************************
297-
slow_rhs_post(*F_slow, S_old, S_new, *S_sum, time, old_time_stage, time_stage, nrk);
297+
slow_rhs_post(*F_slow, S_old, S_new, *S_sum, time, old_time_stage, time_stage, nrk);
298298
} // nrk
299299

300300
} else {

Source/TimeIntegration/ERF_SlowRhsPre.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,15 @@ void erf_slow_rhs_pre (int level, int finest_level,
159159
const Array<Real,AMREX_SPACEDIM> grav{0.0, 0.0, -solverChoice.gravity};
160160
const GpuArray<Real,AMREX_SPACEDIM> grav_gpu{grav[0], grav[1], grav[2]};
161161

162+
// **************************************************************************************
163+
// If doing advection with EB we need the extra values for tangential interpolation
164+
// **************************************************************************************
165+
if (solverChoice.terrain_type == TerrainType::EB) {
166+
S_data[IntVars::xmom].FillBoundary(geom.periodicity());
167+
S_data[IntVars::ymom].FillBoundary(geom.periodicity());
168+
S_data[IntVars::zmom].FillBoundary(geom.periodicity());
169+
}
170+
162171
// *****************************************************************************
163172
// Pre-computed quantities
164173
// *****************************************************************************

Source/TimeIntegration/ERF_TI_no_substep_fun.H

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -189,25 +189,42 @@
189189
for (int i = 0; i <= AMREX_SPACEDIM; ++i) {
190190
dUdt[i].setVal(0.0, 0, ncomp_fast[i], dUdt[i].nGrow());
191191
MultiFab::Copy(dUdt[i], F_slow[i], 0, 0, F_slow[i].nComp(), 0);
192-
dUdt[i].FillBoundary(fine_geom.periodicity());
193192
dUdt[i].setDomainBndry(1.234e10, 0, ncomp_fast[i], fine_geom);
193+
dUdt[i].FillBoundary(fine_geom.periodicity());
194194
}
195195

196196
BCRec const* bc_ptr_d = domain_bcs_type_d.data();
197+
IntVect ngv = S_old[IntVars::cons].nGrowVect();
198+
199+
MultiFab S_pert_cons(ba, dm, S_old[IntVars::cons].nComp(), ngv, MFInfo(), EBFactory(level));
200+
MultiFab rt0(ba, dm, 1, ngv, MFInfo(), EBFactory(level));
201+
202+
// Copy S_old into S_pert
203+
MultiFab::Copy(S_pert_cons, S_old[IntVars::cons],0,0,S_pert_cons.nComp(), ngv);
204+
205+
// Copy theta0 into rt0
206+
MultiFab::Copy(rt0,base_state[level],BaseState::th0_comp,0,1,ngv);
197207

198-
// Update F_slow by Redistribution.
208+
// Multiply theta0 by rho0 in rt0
209+
MultiFab::Multiply(rt0,base_state[level],BaseState::r0_comp,0,1,ngv);
199210

200-
redistribute_term ( ncomp_fast[IntVars::cons], fine_geom, F_slow[IntVars::cons], dUdt[IntVars::cons],
201-
S_old[IntVars::cons], EBFactory(level), bc_ptr_d, slow_dt);
202-
redistribute_term ( ncomp_fast[IntVars::xmom], fine_geom, F_slow[IntVars::xmom], dUdt[IntVars::xmom],
203-
S_old[IntVars::xmom], *(get_eb(level).get_u_const_factory()), bc_ptr_d, slow_dt, IntVars::xmom);
204-
redistribute_term ( ncomp_fast[IntVars::ymom], fine_geom, F_slow[IntVars::ymom], dUdt[IntVars::ymom],
205-
S_old[IntVars::ymom], *(get_eb(level).get_v_const_factory()), bc_ptr_d, slow_dt, IntVars::ymom);
206-
redistribute_term ( ncomp_fast[IntVars::zmom], fine_geom, F_slow[IntVars::zmom], dUdt[IntVars::zmom],
207-
S_old[IntVars::zmom], *(get_eb(level).get_w_const_factory()), bc_ptr_d, slow_dt, IntVars::zmom);
211+
MultiFab::Subtract(S_pert_cons, base_state[level], BaseState::r0_comp,0,1,ngv);
212+
MultiFab::Subtract(S_pert_cons, rt0 , 0,1,1,ngv);
208213

209-
// Update state using the updated F_slow. (NOTE: redistribute_term returns RHS not state variables.)
214+
// Update F_slow for perturbational fast quantites (rho - rho0) and (rho_theta - rho_theta_0)
215+
redistribute_term(ncomp_fast[IntVars::cons], fine_geom, F_slow[IntVars::cons], dUdt[IntVars::cons],
216+
S_pert_cons, EBFactory(level), bc_ptr_d, slow_dt);
210217

218+
// Update F_slow for momenta
219+
redistribute_term(ncomp_fast[IntVars::xmom], fine_geom, F_slow[IntVars::xmom], dUdt[IntVars::xmom],
220+
S_old[IntVars::xmom], *(get_eb(level).get_u_const_factory()), bc_ptr_d, slow_dt, IntVars::xmom);
221+
redistribute_term(ncomp_fast[IntVars::ymom], fine_geom, F_slow[IntVars::ymom], dUdt[IntVars::ymom],
222+
S_old[IntVars::ymom], *(get_eb(level).get_v_const_factory()), bc_ptr_d, slow_dt, IntVars::ymom);
223+
redistribute_term(ncomp_fast[IntVars::zmom], fine_geom, F_slow[IntVars::zmom], dUdt[IntVars::zmom],
224+
S_old[IntVars::zmom], *(get_eb(level).get_w_const_factory()), bc_ptr_d, slow_dt, IntVars::zmom);
225+
226+
227+
// Update state using the updated F_slow.
211228
for ( MFIter mfi(S_sum[IntVars::cons],TilingIfNotGPU()); mfi.isValid(); ++mfi)
212229
{
213230
const Box bx = mfi.tilebox();
@@ -270,12 +287,11 @@
270287
if (vfrac_w(i,j,k) > 0.0) {
271288
ssum[IntVars::zmom](i,j,k) = sold[IntVars::zmom](i,j,k)
272289
+ slow_dt * fslow[IntVars::zmom](i,j,k);
290+
273291
}
274292
});
275293
} // MFIter
276-
277294
} // EB
278-
279295
} // omp
280296

281297
// Even if we update all the conserved variables we don't need

0 commit comments

Comments
 (0)