Skip to content

Commit

Permalink
Merge pull request #3036 from boutproject/no-wrong-grid
Browse files Browse the repository at this point in the history
Avoid using the wrong grid by accident
  • Loading branch information
bendudson authored Dec 2, 2024
2 parents 733b780 + 658065f commit a3c3a50
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/mesh/mesh.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,16 @@ MeshFactory::ReturnType MeshFactory::create(const std::string& type, Options* op

if (options->isSet("file") or Options::root().isSet("grid")) {
// Specified mesh file
const auto grid_name =
(*options)["file"].withDefault(Options::root()["grid"].withDefault(""));
const auto grid_name1 = Options::root()["grid"].withDefault("");
const auto grid_name = (*options)["file"].withDefault(grid_name1);
if (options->isSet("file") and Options::root().isSet("grid")) {
if (grid_name1 != grid_name) {
throw BoutException(
"Mismatch in grid names - specified `{:s}` in grid and `{:s} in "
"mesh:file!\nPlease specify only one name or ensure they are the same!",
grid_name1, grid_name);
}
}
output << "\nGetting grid data from file " << grid_name << "\n";

// Create a grid file, using specified format if given
Expand Down

0 comments on commit a3c3a50

Please sign in to comment.