Skip to content

Commit

Permalink
Merge pull request #638 from apbailey/master
Browse files Browse the repository at this point in the history
Throw fatal runtime error for asymmetric x2 bounds for 1D spherical-polar mesh
  • Loading branch information
felker authored Dec 7, 2024
2 parents 71da5c3 + 4638056 commit a94f18f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
6 changes: 3 additions & 3 deletions inputs/hydro/athinput.mignone_radial
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ ix1_bc = reflecting # inner-X1 boundary flag
ox1_bc = outflow # outer-X1 boundary flag
x1rat = 1.0 # non-uniform grid ratio

nx2 = 1 # Number of zones in X2-direction
x2min = 0.0 # minimum value of X2
x2max = 1.0 # maximum value of X2
nx2 = 1 # Number of zones in X2-direction
x2min = 1.0707963267948966 # minimum value of X2
x2max = 2.0707963267948966 # maximum value of X2
ix2_bc = periodic # inner-X2 boundary flag
ox2_bc = periodic # outer-X2 boundary flag

Expand Down
17 changes: 17 additions & 0 deletions src/coordinates/spherical_polar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,23 @@ void Coordinates::Initialize(ParameterInput *pin) {
ATHENA_ERROR(msg);
}

// x2 limits must be symmetric about PI/2 in 1D
if (pm->ndim == 1) {
Real dmax = pm->mesh_size.x2max - PI/2.0;
Real dmin = PI/2.0 - pm->mesh_size.x2min;
if (std::abs(dmax - dmin) > std::numeric_limits<Real>::epsilon()) {
std::stringstream msg;
msg << "### FATAL ERROR in BoundaryValues constructor" << std::endl
<< "1D spherical-like coordinates requires x2-limits to be symmetric about "
<< std::setprecision(std::numeric_limits<Real>::max_digits10 -1)
<< std::scientific << PI/2.0 << "\n"
<< "Current x2 domsin limits are: \n"
<< "x2min=" << pm->mesh_size.x2min << "\n"
<< "x2max=" << pm->mesh_size.x2max << std::endl;
ATHENA_ERROR(msg);
}
}

// initialize volume-averaged coordinates and spacing
// x1-direction: x1v = (\int r dV / \int dV) = d(r^4/4)/d(r^3/3)
for (int i=il-ng; i<=iu+ng; ++i) {
Expand Down

0 comments on commit a94f18f

Please sign in to comment.