From 4d607e52b803f0b0de734f70a3e0d179c2262cee Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Mon, 13 Jan 2020 11:39:02 -0600 Subject: [PATCH] Setting id appropriately for new unstructured mesh. --- src/mesh.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/mesh.cpp b/src/mesh.cpp index 063c3a9047..0840d0144b 100644 --- a/src/mesh.cpp +++ b/src/mesh.cpp @@ -1310,7 +1310,12 @@ extern "C" int openmc_add_unstrucutred_mesh(const char filename[], return OPENMC_E_INVALID_ARGUMENT; } - *mesh_id = model::meshes.back()->id_; + int id = 0; + for (const auto& m : model::meshes) { id = std::max(m->id_, id); } + + id += 1; + model::meshes.back()->id_ = id; + *mesh_id = id; return 0; }