Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Source/Diffusion.H
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ public:
const amrex::MultiFab& rho_half,
int rho_flag,
const amrex::MultiFab* const* beta,
const amrex::MultiFab* betaCC,
int betaComp = 0,
bool update_fluxreg = true);

Expand All @@ -127,6 +128,7 @@ public:
const amrex::MultiFab& rho_half,
int rho_flag,
const amrex::MultiFab* const* beta,
const amrex::MultiFab* betaCC,
int betaComp,
bool update_fluxreg);

Expand Down
51 changes: 31 additions & 20 deletions Source/Diffusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,14 @@ Diffusion::diffuse_scalar (const Vector<MultiFab*>& S_old,
}
opn.setCoarseFineBC(Solnc.get(), cratio[0]);
}
else if (level > 0) {
//
// No coarse data supplied, but this is a level > 0 solve, so
// we still must tell MLMG the true refinement ratio for the
// homogeneous Dirichlet coarse-fine boundary condition.
//
opn.setCoarseFineBC(nullptr, cratio[0]);
}
MultiFab::Copy(Soln,*S_old[0],sigma,0,nComp,ng);
if (rho_flag == 2) {
#ifdef AMREX_USE_OMP
Expand Down Expand Up @@ -517,6 +525,9 @@ Diffusion::diffuse_scalar (const Vector<MultiFab*>& S_old,
}
opnp1.setCoarseFineBC(Solnc.get(), cratio[0]);
}
else if (level > 0) {
opnp1.setCoarseFineBC(nullptr, cratio[0]);
}
#ifdef AMREX_USE_OMP
#pragma omp parallel if (Gpu::notInLaunchRegion())
#endif
Expand Down Expand Up @@ -847,7 +858,6 @@ Diffusion::diffuse_tensor_velocity (Real dt,
// const Real tol_abs = 0.0;
// cribbing from scalar
const Real tol_rel = visc_tol;
const Real tol_abs = get_scaled_abs_tol(Rhs, visc_tol);

LPInfo info;
info.setAgglomeration(agglomeration);
Expand Down Expand Up @@ -889,10 +899,10 @@ Diffusion::diffuse_tensor_velocity (Real dt,
tensorop.setLevelBC(0, &Soln);
}

Real rhsscale = 1.0;
{
MultiFab acoef;
std::pair<Real,Real> scalars;
Real rhsscale = 1.0;
const MultiFab& rho = (rho_flag == 1) ? rho_half : navier_stokes->get_new_data(State_Type);
const int rho_comp = (rho_flag == 1) ? 0 : Density;
computeAlpha(acoef, scalars, a, b,
Expand All @@ -901,6 +911,12 @@ Diffusion::diffuse_tensor_velocity (Real dt,
tensorop.setScalars(scalars.first, scalars.second);
tensorop.setACoeffs(0, acoef);
}
//
// computeAlpha scaled the operator scalars by rhsscale; the RHS must be
// scaled to match (cf. diffuse_scalar and diffuse_Ssync).
//
Rhs.mult(rhsscale,0,AMREX_SPACEDIM);
const Real tol_abs = get_scaled_abs_tol(Rhs, visc_tol);

#ifdef AMREX_USE_EB
setViscosity(tensorop, betanp1, betaComp, *betanp1CC);
Expand Down Expand Up @@ -966,6 +982,7 @@ Diffusion::diffuse_Vsync (MultiFab& Vsync,
const MultiFab& rho_half,
int rho_flag,
const MultiFab* const* beta,
const MultiFab* betaCC,
int betaComp,
bool update_fluxreg)
{
Expand All @@ -979,7 +996,7 @@ Diffusion::diffuse_Vsync (MultiFab& Vsync,
AMREX_ASSERT(beta[d]->min(0,0) >= 0.0);
#endif

diffuse_tensor_Vsync(Vsync,dt,be_cn_theta,rho_half,rho_flag,beta,betaComp,update_fluxreg);
diffuse_tensor_Vsync(Vsync,dt,be_cn_theta,rho_half,rho_flag,beta,betaCC,betaComp,update_fluxreg);
//
// applyBC has put "incorrect" values in the ghost cells
// outside external Dirichlet boundaries. Reset these to zero
Expand Down Expand Up @@ -1017,8 +1034,9 @@ Diffusion::diffuse_tensor_Vsync (MultiFab& Vsync,
Real be_cn_theta,
const MultiFab& rho_half,
int rho_flag,
const MultiFab* const* /*beta*/,
int /*betaComp*/,
const MultiFab* const* beta,
const MultiFab* betaCC,
int betaComp,
bool update_fluxreg)
{
AMREX_ASSERT(rho_flag == 1 || rho_flag == 3);
Expand All @@ -1045,7 +1063,9 @@ Diffusion::diffuse_tensor_Vsync (MultiFab& Vsync,
{
const Box& bx = mfi.tilebox();
auto const& rhs = Rhs.array(mfi);
auto const& rho = (rho_flag == 1) ? rho_half.array(mfi) : navier_stokes->get_old_data(State_Type).array(mfi,Density);
// NOTE: must use the new-time density here to match the acoef built
// below and mac_sync's normalization of Vsync by rho^{n+1}.
auto const& rho = (rho_flag == 1) ? rho_half.array(mfi) : navier_stokes->get_new_data(State_Type).array(mfi,Density);

amrex::ParallelFor(bx, [rhs, rho]
AMREX_GPU_DEVICE (int i, int j, int k) noexcept
Expand Down Expand Up @@ -1113,22 +1133,13 @@ Diffusion::diffuse_tensor_Vsync (MultiFab& Vsync,
tensorop.setACoeffs(0, acoef);
}

{
FluxBoxes fb_bcoef;
MultiFab** face_bcoef = nullptr;
face_bcoef = fb_bcoef.define(navier_stokes);
for (int dir=0; dir<AMREX_SPACEDIM; dir++) {
face_bcoef[dir]->setVal(1.0);
}

#ifdef AMREX_USE_EB
MultiFab bcoefCC(grids,dmap,1,0,MFInfo(),navier_stokes->Factory());
bcoefCC.setVal(1.0);
setViscosity(tensorop, face_bcoef, 0, bcoefCC);
AMREX_ALWAYS_ASSERT(betaCC != nullptr);
setViscosity(tensorop, beta, betaComp, *betaCC);
#else
setViscosity(tensorop, face_bcoef, 0);
amrex::ignore_unused(betaCC);
setViscosity(tensorop, beta, betaComp);
#endif
}

MLMG mlmg(tensorop);
if (max_iter > 0) {
Expand All @@ -1144,7 +1155,7 @@ Diffusion::diffuse_tensor_Vsync (MultiFab& Vsync,
mlmg.setMaxFmgIter(max_fmg_iter);
mlmg.setVerbose(verbose);

Rhs.mult(rhsscale,0,1);
Rhs.mult(rhsscale,0,AMREX_SPACEDIM);

mlmg.setFinalFillBC(true);
mlmg.solve({&Soln}, {&Rhs}, tol_rel, tol_abs);
Expand Down
8 changes: 7 additions & 1 deletion Source/NS_LES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,13 @@ NavierStokesBase::calc_mut_LES(MultiFab* mu_LES[AMREX_SPACEDIM], const Real time
Real smag = 0;
for (int i_symij = 0; i_symij < dim_fluxes; ++i_symij)
{
Real symij = src(i,j,k,i_symij) + src(i,j,k,i_symij);
// compVelGrad stores du_m/dx_n in component AMREX_SPACEDIM*n+m,
// so the transpose of flat index c is
// (c%AMREX_SPACEDIM)*AMREX_SPACEDIM + c/AMREX_SPACEDIM. Pairing
// each component with its transpose gives symij = 2*S_mn, so
// smag below is 2*S:S and mu_t = (Cs*dx)^2*sqrt(2 S_ij S_ij).
int i_symji = (i_symij%AMREX_SPACEDIM)*AMREX_SPACEDIM + i_symij/AMREX_SPACEDIM;
Real symij = src(i,j,k,i_symij) + src(i,j,k,i_symji);
smag += symij * symij;
}

Expand Down
10 changes: 10 additions & 0 deletions Source/NS_average.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ NavierStokesBase::time_average(amrex::Real& a_time_avg, amrex::Real& a_time_av
{
MultiFab& Sstate = get_new_data(State_Type);
MultiFab& Savg = get_new_data(Average_Type);
//
// Old data may not have been allocated yet, e.g. when this is called from
// post_init and no advance has taken place (ns.init_iter <= 0).
// Zero is the right seed: the kernel below copies S_avg back into
// S_avg_old on every sample, so both time levels agree by construction.
//
if (! state[Average_Type].hasOldData()) {
state[Average_Type].allocOldData();
state[Average_Type].oldData().setVal(0.);
}
MultiFab& Savg_old = get_old_data(Average_Type);

#ifdef _OPENMP
Expand Down
4 changes: 3 additions & 1 deletion Source/NavierStokes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1561,7 +1561,9 @@ NavierStokes::mac_sync ()
loc_viscn = fb_viscn.define(this);
getViscosity(loc_viscn, viscTime);

diffusion->diffuse_Vsync(Vsync,dt,be_cn_theta,Rh,rho_flag,loc_viscn,0);
// viscn_cc holds the cell-centered viscosity at prevTime; needed by
// MLEBTensorOp::setEBShearViscosity in EB builds.
diffusion->diffuse_Vsync(Vsync,dt,be_cn_theta,Rh,rho_flag,loc_viscn,viscn_cc,0);
}

FluxBoxes fb_SC;
Expand Down
6 changes: 6 additions & 0 deletions Source/NavierStokesBase.H
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,12 @@ public:
static amrex::Vector<amrex::Real> time_avg;
static amrex::Vector<amrex::Real> time_avg_fluct;
static amrex::Vector<amrex::Real> dt_avg;
//
// Grow time_avg/time_avg_fluct/dt_avg so that every level up to
// a_finest_level has an entry. New entries are zero-filled; existing
// accumulations are preserved.
//
static void grow_avg_vectors (int a_finest_level);
static int avg_interval;
static int compute_fluctuations;
//
Expand Down
Loading
Loading