From fdb285c03a948cad57a4364ef4e7f2d0ff87db3b Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Fri, 1 Mar 2024 14:22:52 +0100 Subject: [PATCH] changed: rename FlowMain.cpp to FlowUtils.cpp and add a dedicated header. this way we don't need to pull in FlowMain.hpp for the prototypes, avoiding pulling in the entire simulator machinery just to build some simple utility functions. --- CMakeLists_files.cmake | 3 +- opm/simulators/flow/FlowMain.hpp | 23 ++-------- .../flow/{FlowMain.cpp => FlowUtils.cpp} | 19 +++++--- opm/simulators/flow/FlowUtils.hpp | 45 +++++++++++++++++++ 4 files changed, 64 insertions(+), 26 deletions(-) rename opm/simulators/flow/{FlowMain.cpp => FlowUtils.cpp} (94%) create mode 100644 opm/simulators/flow/FlowUtils.hpp diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index c1be9a96d..bbc17d26f 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -43,7 +43,7 @@ list (APPEND MAIN_SOURCE_FILES opm/simulators/flow/Banners.cpp opm/simulators/flow/ConvergenceOutputConfiguration.cpp opm/simulators/flow/ExtraConvergenceOutputThread.cpp - opm/simulators/flow/FlowMain.cpp + opm/simulators/flow/FlowUtils.cpp opm/simulators/flow/GenericOutputBlackoilModule.cpp opm/simulators/flow/InterRegFlows.cpp opm/simulators/flow/KeywordValidation.cpp @@ -452,6 +452,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/simulators/flow/DummyGradientCalculator.hpp opm/simulators/flow/ExtraConvergenceOutputThread.hpp opm/simulators/flow/FlowMain.hpp + opm/simulators/flow/FlowUtils.hpp opm/simulators/flow/FlowsData.hpp opm/simulators/flow/GenericOutputBlackoilModule.hpp opm/simulators/flow/InterRegFlows.hpp diff --git a/opm/simulators/flow/FlowMain.hpp b/opm/simulators/flow/FlowMain.hpp index 6aa050c57..908f94f11 100644 --- a/opm/simulators/flow/FlowMain.hpp +++ b/opm/simulators/flow/FlowMain.hpp @@ -22,15 +22,16 @@ #ifndef OPM_FLOW_MAIN_HEADER_INCLUDED #define OPM_FLOW_MAIN_HEADER_INCLUDED -#include -#include - #include #include #include #include +#include +#include +#include + #if HAVE_DUNE_FEM #include #else @@ -39,7 +40,6 @@ #include #include -#include namespace Opm::Properties { @@ -74,21 +74,6 @@ struct OutputInterval { } // namespace Opm::Properties namespace Opm { -namespace detail { - -void checkAllMPIProcesses(); - -void mergeParallelLogFiles(std::string_view output_dir, - std::string_view deck_filename, - bool enableLoggingFalloutWarning); - -void handleExtraConvergenceOutput(SimulatorReport& report, - std::string_view option, - std::string_view optionName, - std::string_view output_dir, - std::string_view base_name); - -} class Deck; diff --git a/opm/simulators/flow/FlowMain.cpp b/opm/simulators/flow/FlowUtils.cpp similarity index 94% rename from opm/simulators/flow/FlowMain.cpp rename to opm/simulators/flow/FlowUtils.cpp index 1a07dffe7..f12d7cfe3 100644 --- a/opm/simulators/flow/FlowMain.cpp +++ b/opm/simulators/flow/FlowUtils.cpp @@ -21,21 +21,29 @@ */ #include -#include +#include +#include #include #include - +#include #include +#if HAVE_MPI +#include +#endif + +#include + #include #include #include #include +#include +#include -namespace Opm { -namespace detail { +namespace Opm::detail { void mergeParallelLogFiles(std::string_view output_dir, std::string_view deckFilename, @@ -156,5 +164,4 @@ void checkAllMPIProcesses() #endif } -} // namespace detail -} // namespace Opm +} // namespace Opm::detail diff --git a/opm/simulators/flow/FlowUtils.hpp b/opm/simulators/flow/FlowUtils.hpp new file mode 100644 index 000000000..1e6bc0874 --- /dev/null +++ b/opm/simulators/flow/FlowUtils.hpp @@ -0,0 +1,45 @@ +/* + Copyright 2013, 2014, 2015 SINTEF ICT, Applied Mathematics. + Copyright 2014 Dr. Blatt - HPC-Simulation-Software & Services + Copyright 2015 IRIS AS + Copyright 2014 STATOIL ASA. + + This file is part of the Open Porous Media project (OPM). + + OPM is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OPM is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see . +*/ +#ifndef OPM_FLOW_UTILS_HEADER_INCLUDED +#define OPM_FLOW_UTILS_HEADER_INCLUDED + +#include + +namespace Opm { struct SimulatorReport; } + +namespace Opm::detail { + +void checkAllMPIProcesses(); + +void mergeParallelLogFiles(std::string_view output_dir, + std::string_view deck_filename, + bool enableLoggingFalloutWarning); + +void handleExtraConvergenceOutput(SimulatorReport& report, + std::string_view option, + std::string_view optionName, + std::string_view output_dir, + std::string_view base_name); + +} // namespace Opm::detail + +#endif // OPM_FLOW_UTILS_HEADER_INCLUDED