Skip to content

Commit

Permalink
Avoid using the wrong grid by accident
Browse files Browse the repository at this point in the history
  • Loading branch information
dschwoerer committed Nov 29, 2024
1 parent 7032b8c commit 753bb34
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") ond 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!",
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 753bb34

Please sign in to comment.