Remove --linear-solver-configuration-file parameter.

This is now handled by passing a string to --linear-solver-configuration that
ends with ".json".
This commit is contained in:
Atgeirr Flø Rasmussen 2020-10-12 16:41:09 +02:00
parent 385880485a
commit f169cf90d8
2 changed files with 9 additions and 22 deletions

View File

@ -1,5 +1,5 @@
/*
Copyright 2015 SINTEF ICT, Applied Mathematics.
Copyright 2015, 2020 SINTEF Digital, Mathematics and Cybernetics.
Copyright 2015 IRIS AS
Copyright 2015 Dr. Blatt - HPC-Simulation-Software & Services
Copyright 2015 NTNU
@ -118,10 +118,6 @@ struct LinearSolverConfiguration {
using type = UndefinedProperty;
};
template<class TypeTag, class MyTypeTag>
struct LinearSolverConfigurationJsonFile {
using type = UndefinedProperty;
};
template<class TypeTag, class MyTypeTag>
struct GpuMode {
using type = UndefinedProperty;
};
@ -213,10 +209,6 @@ struct LinearSolverConfiguration<TypeTag, TTag::FlowIstlSolverParams> {
static constexpr auto value = "ilu0";
};
template<class TypeTag>
struct LinearSolverConfigurationJsonFile<TypeTag, TTag::FlowIstlSolverParams> {
static constexpr auto value = "none";
};
template<class TypeTag>
struct GpuMode<TypeTag, TTag::FlowIstlSolverParams> {
static constexpr auto value = "none";
};
@ -252,7 +244,6 @@ namespace Opm
bool ignoreConvergenceFailure_;
bool scale_linear_system_;
std::string linear_solver_configuration_;
std::string linear_solver_configuration_json_file_;
std::string gpu_mode_;
int bda_device_id_;
int opencl_platform_id_;
@ -280,7 +271,6 @@ namespace Opm
cpr_max_ell_iter_ = EWOMS_GET_PARAM(TypeTag, int, CprMaxEllIter);
cpr_reuse_setup_ = EWOMS_GET_PARAM(TypeTag, int, CprReuseSetup);
linear_solver_configuration_ = EWOMS_GET_PARAM(TypeTag, std::string, LinearSolverConfiguration);
linear_solver_configuration_json_file_ = EWOMS_GET_PARAM(TypeTag, std::string, LinearSolverConfigurationJsonFile);
gpu_mode_ = EWOMS_GET_PARAM(TypeTag, std::string, GpuMode);
bda_device_id_ = EWOMS_GET_PARAM(TypeTag, int, BdaDeviceId);
opencl_platform_id_ = EWOMS_GET_PARAM(TypeTag, int, OpenclPlatformId);
@ -304,8 +294,7 @@ namespace Opm
EWOMS_REGISTER_PARAM(TypeTag, bool, ScaleLinearSystem, "Scale linear system according to equation scale and primary variable types");
EWOMS_REGISTER_PARAM(TypeTag, int, CprMaxEllIter, "MaxIterations of the elliptic pressure part of the cpr solver");
EWOMS_REGISTER_PARAM(TypeTag, int, CprReuseSetup, "Reuse preconditioner setup. Valid options are 0: recreate the preconditioner for every linear solve, 1: recreate once every timestep, 2: recreate if last linear solve took more than 10 iterations, 3: never recreate");
EWOMS_REGISTER_PARAM(TypeTag, std::string, LinearSolverConfiguration, "Configuration of solver. Valid options are: ilu0 (default), cpr_quasiimpes, cpr_trueimpes or file (specified in LinearSolverConfigurationJsonFile) ");
EWOMS_REGISTER_PARAM(TypeTag, std::string, LinearSolverConfigurationJsonFile, "Filename of JSON configuration for flexible linear solver system.");
EWOMS_REGISTER_PARAM(TypeTag, std::string, LinearSolverConfiguration, "Configuration of solver. Valid options are: ilu0 (default), cpr (an alias for cpr_trueimpes), cpr_quasiimpes, cpr_trueimpes or amg. Alternatively, you can request a configuration to be read from a JSON file by giving the filename here, ending with '.json.'");
EWOMS_REGISTER_PARAM(TypeTag, std::string, GpuMode, "Use GPU cusparseSolver or openclSolver as the linear solver, usage: '--gpu-mode=[none|cusparse|opencl]'");
EWOMS_REGISTER_PARAM(TypeTag, int, BdaDeviceId, "Choose device ID for cusparseSolver or openclSolver, use 'nvidia-smi' or 'clinfo' to determine valid IDs");
EWOMS_REGISTER_PARAM(TypeTag, int, OpenclPlatformId, "Choose platform ID for openclSolver, use 'clinfo' to determine valid platform IDs");

View File

@ -39,21 +39,19 @@ setupPropertyTree(FlowLinearSolverParameters p) // Note: copying the parameters
std::string conf = p.linear_solver_configuration_;
// Get configuration from file.
if (conf == "file") {
if (conf.substr(conf.size() - 5, 5) == ".json") {
#if BOOST_VERSION / 100 % 1000 > 48
if (p.linear_solver_configuration_json_file_ == "none") {
OPM_THROW(std::invalid_argument,
"--linear-solver-configuration=file requires that a filename "
<< "is passed with "
<< "--linear-solver-configuration-json-file=filename.");
} else {
try {
boost::property_tree::ptree prm;
boost::property_tree::read_json(p.linear_solver_configuration_json_file_, prm);
boost::property_tree::read_json(conf, prm);
return prm;
}
catch (...) {
OPM_THROW(std::invalid_argument, "Failed reading linear solver configuration from JSON file " << conf);
}
#else
OPM_THROW(std::invalid_argument,
"--linear-solver-configuration=file not supported with "
"--linear-solver-configuration=file.json not supported with "
<< "boost version. Needs version > 1.48.");
#endif
}