FlowMainEbos: move parallel file merge code to separate compile unit

avoid some headers in simulator objects
This commit is contained in:
Arne Morten Kvarving
2023-02-28 12:41:36 +01:00
parent fe011bbd41
commit 143139c6ee
3 changed files with 70 additions and 25 deletions

View File

@@ -0,0 +1,58 @@
/*
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 <http://www.gnu.org/licenses/>.
*/
#include <config.h>
#include <opm/simulators/flow/FlowMainEbos.hpp>
#include <opm/common/utility/String.hpp>
#include <opm/simulators/utils/ParallelFileMerger.hpp>
#include <algorithm>
#include <string>
namespace Opm {
namespace detail {
void mergeParallelLogFiles(std::string_view output_dir,
std::string_view deckFilename,
bool enableLoggingFalloutWarning)
{
namespace fs = ::std::filesystem;
fs::path output_path(output_dir);
fs::path deck_filename(deckFilename);
std::string basename;
// Strip extension "." and ".DATA"
std::string extension = uppercase(deck_filename.extension().string());
if (extension == ".DATA" || extension == ".") {
basename = uppercase(deck_filename.stem().string());
} else {
basename = uppercase(deck_filename.filename().string());
}
std::for_each(fs::directory_iterator(output_path),
fs::directory_iterator(),
detail::ParallelFileMerger(output_path, basename,
enableLoggingFalloutWarning));
}
} // namespace detail
} // namespace Opm

View File

@@ -25,7 +25,6 @@
#include <opm/simulators/flow/ConvergenceOutputConfiguration.hpp>
#include <opm/simulators/flow/Banners.hpp>
#include <opm/simulators/flow/SimulatorFullyImplicitBlackoilEbos.hpp>
#include <opm/simulators/utils/ParallelFileMerger.hpp>
#include <opm/simulators/utils/moduleVersion.hpp>
#include <opm/simulators/utils/ParallelEclipseState.hpp>
#include <flow/flow_ebos_blackoil.hpp>
@@ -33,7 +32,6 @@
#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
#include <opm/input/eclipse/EclipseState/IOConfig/IOConfig.hpp>
#include <opm/input/eclipse/EclipseState/InitConfig/InitConfig.hpp>
#include <opm/common/utility/String.hpp>
#include <filesystem>
@@ -44,6 +42,7 @@
#endif
#include <memory>
#include <string_view>
namespace Opm::Properties {
@@ -77,8 +76,13 @@ struct OutputInterval<TypeTag, TTag::EclFlowProblem> {
} // namespace Opm::Properties
namespace Opm
{
namespace Opm {
namespace detail {
void mergeParallelLogFiles(std::string_view output_dir,
std::string_view deck_filename,
bool enableLoggingFalloutWarning);
}
class Deck;
@@ -379,8 +383,6 @@ namespace Opm
ThreadManager::init();
}
void mergeParallelLogFiles()
{
// force closing of all log files.
@@ -390,25 +392,9 @@ namespace Opm
return;
}
namespace fs = ::std::filesystem;
const std::string& output_dir = eclState().getIOConfig().getOutputDir();
fs::path output_path(output_dir);
fs::path deck_filename(EWOMS_GET_PARAM(TypeTag, std::string, EclDeckFileName));
std::string basename;
// Strip extension "." and ".DATA"
std::string extension = uppercase(deck_filename.extension().string());
if ( extension == ".DATA" || extension == "." )
{
basename = uppercase(deck_filename.stem().string());
}
else
{
basename = uppercase(deck_filename.filename().string());
}
std::for_each(fs::directory_iterator(output_path),
fs::directory_iterator(),
detail::ParallelFileMerger(output_path, basename,
EWOMS_GET_PARAM(TypeTag, bool, EnableLoggingFalloutWarning)));
detail::mergeParallelLogFiles(eclState().getIOConfig().getOutputDir(),
EWOMS_GET_PARAM(TypeTag, std::string, EclDeckFileName),
EWOMS_GET_PARAM(TypeTag, bool, EnableLoggingFalloutWarning));
}
void setupEbosSimulator()