Merge pull request #4120 from akva2/zoltanparam_cleanup

ZoltanParams: some cleanup
This commit is contained in:
Markus Blatt 2022-09-19 10:45:11 +02:00 committed by GitHub
commit a1f27654c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 2 deletions

View File

@ -251,7 +251,13 @@ public:
EWOMS_REGISTER_PARAM(TypeTag, double, ZoltanImbalanceTol,
"Tolerable imbalance of the loadbalancing provided by Zoltan (default: 1.1).");
EWOMS_REGISTER_PARAM(TypeTag, std::string, ZoltanParams,
"Configuration of Zoltan partitioner. Valid options are: graph (default)), hypergrah or scotch. Alternatively, you can request a configuration to be read from a JSON file by giving the filename here, ending with '.json.'");
"Configuration of Zoltan partitioner. "
"Valid options are: graph, hypergraph or scotch. "
"Alternatively, you can request a configuration to be read "
"from a JSON file by giving the filename here, ending with '.json.' "
"See https://sandialabs.github.io/Zoltan/ug_html/ug.html "
"for available Zoltan options.");
EWOMS_HIDE_PARAM(TypeTag, ZoltanParams);
#endif
EWOMS_REGISTER_PARAM(TypeTag, bool, AllowDistributedWells,
"Allow the perforations of a well to be distributed to interior of multiple processes");

View File

@ -20,9 +20,13 @@
#include <config.h>
#include <opm/simulators/utils/SetupZoltanParams.hpp>
#include <opm/common/ErrorMacros.hpp>
#include <opm/common/OpmLog/OpmLog.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <boost/version.hpp>
#include <filesystem>
namespace Opm
{
@ -40,7 +44,11 @@ std::map<std::string,std::string> setupZoltanParams(const std::string& conf)
} else if (conf == "graph") {
result.emplace("LB_METHOD", "GRAPH");
result.emplace("GRAPH_PACKAGE", "PHG");
} else { // json file
} else if (conf.size() > 5 && conf.substr(conf.size() - 5, 5) == ".json") {
#if BOOST_VERSION / 100 % 1000 > 48
if ( !std::filesystem::exists(conf) ) {
OPM_THROW(std::invalid_argument, "JSON file " << conf << " does not exist.");
}
boost::property_tree::ptree tree;
try {
boost::property_tree::read_json(conf, tree);
@ -52,6 +60,16 @@ std::map<std::string,std::string> setupZoltanParams(const std::string& conf)
if (value)
result.insert_or_assign(node.first, *value);
}
#else
OPM_THROW(std::invalid_argument,
"--zoltan-params=file.json not supported with "
<< "boost version. Needs version > 1.48.");
#endif
} else {
// No valid configuration option found.
OPM_THROW(std::invalid_argument,
conf << " is not a valid setting for --zoltan-params."
<< " Please use graph, hypergraph or scotch");
}
return result;