From f1c109099b1f01e043bc2fd8819000c702c4a611 Mon Sep 17 00:00:00 2001 From: "Dmitry Yu. Naumov" <github@naumov.de> Date: Fri, 13 Jul 2018 19:02:39 +0200 Subject: [PATCH] [PL] PV: Use findElementOrError() for mesh search. --- ProcessLib/ProcessVariable.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/ProcessLib/ProcessVariable.cpp b/ProcessLib/ProcessVariable.cpp index a135853d4c5..5b8b0563ed9 100644 --- a/ProcessLib/ProcessVariable.cpp +++ b/ProcessLib/ProcessVariable.cpp @@ -12,6 +12,7 @@ #include <utility> #include <logog/include/logog.hpp> +#include "BaseLib/Algorithm.h" #include "MeshGeoToolsLib/ConstructMeshesFromGeometries.h" #include "MeshLib/Mesh.h" #include "ProcessLib/BoundaryCondition/BoundaryCondition.h" @@ -69,19 +70,13 @@ MeshLib::Mesh const& findMeshInConfig( // // Find and extract mesh from the list of meshes. // - auto const mesh_it = std::find_if( - begin(meshes), end(meshes), [&mesh_name](auto const& mesh) { + auto const& mesh = *BaseLib::findElementOrError( + begin(meshes), end(meshes), + [&mesh_name](auto const& mesh) { assert(mesh != nullptr); return mesh->getName() == mesh_name; - }); - if (mesh_it == end(meshes)) - { - OGS_FATAL("Required mesh with name '%s' not found.", - mesh_name.c_str()); - } - - auto const& mesh = **mesh_it; - + }, + "Required mesh with name '" + mesh_name + "' not found."); DBUG("Found mesh '%s' with id %d.", mesh.getName().c_str(), mesh.getID()); return mesh; -- GitLab