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
4 changes: 3 additions & 1 deletion Docs/sphinx_documentation/source/ProblemSetup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ Which of them a given ``probtype`` actually reads varies; see ``prob_init.cpp``.
+------------------------+--------------------------------------------------------------------+-------------+-----------+
| forcevort | Strength of the convected vortex (probtype 8) | Real | 6.0 |
+------------------------+--------------------------------------------------------------------+-------------+-----------+
| meanFlowDir | Direction of the mean flow the vortex is convected by (probtype 8) | Int | 0 |
| meanFlowDir | Direction of the mean flow the vortex is convected by (probtype 8).| Int | 0 |
| | 0 = no mean flow; +/-1, +/-2, +/-3 = mean flow along x, y, z; | | |
| | +/-4 = diagonal mean flow in the x-y plane. +/-3 requires 3D. | | |
+------------------------+--------------------------------------------------------------------+-------------+-----------+
| meanFlowMag | Magnitude of that mean flow (probtype 8) | Real | 0.0 |
+------------------------+--------------------------------------------------------------------+-------------+-----------+
Expand Down
21 changes: 15 additions & 6 deletions Source/NavierStokes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,17 @@ NavierStokes::Initialize_bcs ()
//
// Check for integer BC type specification in inputs file (older style)
//
if ( pp.contains("lo_bc") )
if ( pp.contains("lo_bc") || pp.contains("hi_bc") )
{
//
// The two are a pair: reading hi_bc only when lo_bc is present would
// silently drop a deck that gives just one of them.
//
if ( !pp.contains("lo_bc") || !pp.contains("hi_bc") )
{
amrex::Abort("NavierStokes::Initialize_bcs: ns.lo_bc and ns.hi_bc must be given together.");
}

Vector<int> lo_bc(AMREX_SPACEDIM), hi_bc(AMREX_SPACEDIM);
pp.getarr("lo_bc",lo_bc,0,AMREX_SPACEDIM);
pp.getarr("hi_bc",hi_bc,0,AMREX_SPACEDIM);
Expand Down Expand Up @@ -134,7 +143,7 @@ NavierStokes::Initialize_bcs ()
std::string bc_type = amrex::toLower(bc_type_in);

if (bc_type == "no_slip_wall" or bc_type == "nsw"
or phys_bc.data()[ori] == PhysBCType::noslipwall)
or (bc_type == "null" and phys_bc.data()[ori] == PhysBCType::noslipwall))
{
amrex::Print() << bcid <<" set to no-slip wall.\n";

Expand Down Expand Up @@ -165,7 +174,7 @@ NavierStokes::Initialize_bcs ()
// m_bc_velocity[ori] = {0.0, 0.0, 0.0};
}
else if (bc_type == "mass_inflow" or bc_type == "mi"
or phys_bc.data()[ori] == PhysBCType::inflow)
or (bc_type == "null" and phys_bc.data()[ori] == PhysBCType::inflow))
{
amrex::Print() << bcid << " set to mass inflow.\n";

Expand Down Expand Up @@ -199,7 +208,7 @@ NavierStokes::Initialize_bcs ()
// pbc.get("pressure", m_bc_pressure[ori]);
}
else if (bc_type == "pressure_outflow" or bc_type == "po"
or phys_bc.data()[ori] == PhysBCType::outflow)
or (bc_type == "null" and phys_bc.data()[ori] == PhysBCType::outflow))
{
amrex::Print() << bcid << " set to pressure outflow.\n";

Expand Down Expand Up @@ -869,8 +878,8 @@ NavierStokes::scalar_update (Real dt,
{
if (S_new.contains_nan(sigma,1,0))
{
Print() << "New scalar " << sigma << " contains Nans" << '\n';
exit(0);
amrex::Abort("NavierStokes::scalar_update(): new scalar component "
+ std::to_string(sigma) + " contains NaNs");
}
}
}
Expand Down
14 changes: 6 additions & 8 deletions Source/NavierStokesBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3572,8 +3572,8 @@ NavierStokesBase::velocity_update (Real dt)
{
if (S_new.contains_nan(sigma,1,0))
{
amrex::Print() << "New velocity " << sigma << " contains Nans" << '\n';
exit(0);
amrex::Abort("NavierStokesBase::velocity_update(): new velocity component "
+ std::to_string(sigma) + " contains NaNs");
}
}
}
Expand Down Expand Up @@ -4721,8 +4721,6 @@ NavierStokesBase::ComputeAofs ( MultiFab& advc, int a_comp, // Advection term "A
{
BL_PROFILE("NSB::ComputeAofs_kernel");

amrex::ignore_unused(do_fine_add);

// Need U_corr to be defined for sync.
AMREX_ASSERT( (is_sync && !U_corr.empty()) || !is_sync );

Expand Down Expand Up @@ -5270,17 +5268,17 @@ NavierStokesBase::ComputeAofs ( MultiFab& advc, int a_comp, // Advection term "A
Real sync_factor = do_crse_add ? 1.0 : -1.0;

// Update the flux registers when no EB
if ( do_reflux && (level < parent->finestLevel()) ) {
if ( do_reflux && do_crse_add && (level < parent->finestLevel()) ) {
getAdvFluxReg(level+1).CrseAdd(mfi,
{AMREX_D_DECL(&fx_fab,&fy_fab,&fz_fab)},
dxDp, sync_factor*dt, flux_comp, state_indx, ncomp, amrex::RunOn::Device);
} // do_reflux && level < finest_level
} // do_reflux && do_crse_add && level < finest_level

if ( do_reflux && (level > 0) ) {
if ( do_reflux && do_fine_add && (level > 0) ) {
advflux_reg->FineAdd(mfi,
{AMREX_D_DECL(&fx_fab,&fy_fab,&fz_fab)},
dxDp, sync_factor*dt, flux_comp, state_indx, ncomp, amrex::RunOn::Device);
} // do_reflux && (level > 0)
} // do_reflux && do_fine_add && (level > 0)
#endif
} // mfi
}
Expand Down
4 changes: 2 additions & 2 deletions Source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ main (int argc,
amrex::Abort("MUST SPECIFY a non-negative strt_time");
}

if (max_step < 0 && stop_time < 0)
if (max_step < 0 && stop_time < 0 && stop_interval <= 0.)
{
amrex::Abort("Exiting because neither max_step nor stop_time is non-negative.");
amrex::Abort("Exiting because none of max_step, stop_time or stop_interval is set.");
}

Amr* amrptr = new Amr(getLevelBld());
Expand Down
29 changes: 26 additions & 3 deletions Source/prob/prob_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -646,9 +646,22 @@ void NavierStokes::init_ConvectedVortex (Box const& vbx,
// amrex::Abort() cannot be called from within the device lambda below, so
// validate the mean flow direction here.
//
if ( IC.meanFlowDir < -3 || IC.meanFlowDir > 3 ) {
amrex::Abort("\n init_ConvectedVortex: prob.meanFlowDir must be 0 (no mean flow) or +/-1, +/-2, +/-3\n in the inputs file.");
if ( IC.meanFlowDir < -4 || IC.meanFlowDir > 4 ) {
amrex::Abort("\n init_ConvectedVortex: prob.meanFlowDir must be 0 (no mean flow),"
"\n +/-1, +/-2, +/-3 (mean flow along x, y, z) or +/-4 (diagonal in the x-y plane)"
"\n in the inputs file.");
}
#if (AMREX_SPACEDIM == 2)
//
// +/-4 is the non-axis-aligned option and works in 2D; +/-3 does not,
// since AMREX_D_TERM drops the z component and the mean flow would
// silently vanish.
//
if ( IC.meanFlowDir == 3 || IC.meanFlowDir == -3 ) {
amrex::Abort("\n init_ConvectedVortex: prob.meanFlowDir = +/-3 puts the mean flow along z"
"\n and requires 3D. Use +/-4 for a diagonal mean flow in the x-y plane.");
}
#endif

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The intent of meanFlowDir = 3 was as originally written, that is to create a mean flow that is not axis aligned. This problem is inherently 2D but can be run as pseudo 3D. I can see that meanFlowDir = 3 is confusing and suggest we could use 4 instead of 3.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks — you are right, and I had this backwards. I read the old case 3 as a typo because it was the only branch that was not single-component, and I did not consider that non-axis-aligned was the point. Sorry for removing it.

Adopted your numbering in ff09d46: +/-4 is now the diagonal, restored as the pre-PR case +/-3 body verbatim, and +/-3 is the z-aligned flow.

One extension to your suggestion, which I am happy to drop if you disagree: I kept this 2D guard, but narrowed it to +/-3 only. Now that +/-3 means z, AMREX_D_TERM still drops it in 2D and the mean flow would vanish silently. The message now points at +/-4:

init_ConvectedVortex: prob.meanFlowDir = +/-3 puts the mean flow along z
and requires 3D.  Use +/-4 for a diagonal mean flow in the x-y plane.

+/-4 itself works fine in 2D, so the pseudo-2D use you describe is unaffected.


amrex::ParallelFor(vbx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
{
Expand Down Expand Up @@ -691,11 +704,21 @@ void NavierStokes::init_ConvectedVortex (Box const& vbx,
vel(i,j,k,2) = w_vort);
break;
case 3 :
AMREX_D_TERM(vel(i,j,k,0) = u_vort;,
vel(i,j,k,1) = v_vort;,
vel(i,j,k,2) = IC.meanFlowMag + w_vort);
break;
case -3 :
AMREX_D_TERM(vel(i,j,k,0) = u_vort;,
vel(i,j,k,1) = v_vort;,
vel(i,j,k,2) = -IC.meanFlowMag + w_vort);
break;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
break;
break;
case 4 :
AMREX_D_TERM(vel(i,j,k,0) = IC.meanFlowMag + u_vort;,
vel(i,j,k,1) = IC.meanFlowMag + v_vort;,
vel(i,j,k,2) = w_vort);
break;
case -4 :
AMREX_D_TERM(vel(i,j,k,0) = -IC.meanFlowMag + u_vort;,
vel(i,j,k,1) = -IC.meanFlowMag + v_vort;,
vel(i,j,k,2) = w_vort);
break;

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applied in ff09d46, with case 4 / case -4 added after case -3 and before the case 0 / default fallthrough.

I applied it by hand rather than with the "commit suggestion" button: the suggested block has trailing whitespace after vel(i,j,k,2) = w_vort); on the case -4 line, and the repo's trailing_whitespaces style job would have failed on it.

Otherwise the body is your text unchanged, which also means it is character-identical to the pre-PR case +/-3.

case 4 : // diagonal in the x-y plane; |U| = meanFlowMag*sqrt(2)
AMREX_D_TERM(vel(i,j,k,0) = IC.meanFlowMag + u_vort;,
vel(i,j,k,1) = IC.meanFlowMag + v_vort;,
vel(i,j,k,2) = w_vort);
break;
case -3 :
case -4 :
AMREX_D_TERM(vel(i,j,k,0) = -IC.meanFlowMag + u_vort;,
vel(i,j,k,1) = -IC.meanFlowMag + v_vort;,
vel(i,j,k,2) = w_vort);
Expand Down
Loading