mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge pull request #5578 from akva2/parametersystem_tu
ParameterSystem: add translation unit
This commit is contained in:
commit
9a0e39c1ad
@ -317,6 +317,14 @@ macro (sources_hook)
|
|||||||
include(opencl-source-provider)
|
include(opencl-source-provider)
|
||||||
list(APPEND opm-simulators_SOURCES ${PROJECT_BINARY_DIR}/clSources.cpp)
|
list(APPEND opm-simulators_SOURCES ${PROJECT_BINARY_DIR}/clSources.cpp)
|
||||||
endif()
|
endif()
|
||||||
|
if(QuadMath_FOUND)
|
||||||
|
get_target_property(qm_defs QuadMath::QuadMath INTERFACE_COMPILE_DEFINITIONS)
|
||||||
|
list(APPEND qm_defs HAVE_QUAD=1)
|
||||||
|
get_target_property(qm_options QuadMath::QuadMath INTERFACE_COMPILE_OPTIONS)
|
||||||
|
set_source_files_properties(opm/models/utils/parametersystem.cpp
|
||||||
|
PROPERTIES COMPILE_DEFINITIONS "${qm_defs}"
|
||||||
|
COMPILE_OPTIONS "${qm_options}")
|
||||||
|
endif()
|
||||||
endmacro (sources_hook)
|
endmacro (sources_hook)
|
||||||
|
|
||||||
macro (fortran_hook)
|
macro (fortran_hook)
|
||||||
|
@ -64,6 +64,7 @@ list (APPEND MAIN_SOURCE_FILES
|
|||||||
opm/models/parallel/mpiutil.cpp
|
opm/models/parallel/mpiutil.cpp
|
||||||
opm/models/parallel/tasklets.cpp
|
opm/models/parallel/tasklets.cpp
|
||||||
opm/models/parallel/threadmanager.cpp
|
opm/models/parallel/threadmanager.cpp
|
||||||
|
opm/models/utils/parametersystem.cpp
|
||||||
opm/models/utils/timer.cpp
|
opm/models/utils/timer.cpp
|
||||||
opm/simulators/flow/ActionHandler.cpp
|
opm/simulators/flow/ActionHandler.cpp
|
||||||
opm/simulators/flow/Banners.cpp
|
opm/simulators/flow/Banners.cpp
|
||||||
@ -711,7 +712,7 @@ list (APPEND PUBLIC_HEADER_FILES
|
|||||||
opm/models/utils/basicparameters.hh
|
opm/models/utils/basicparameters.hh
|
||||||
opm/models/utils/basicproperties.hh
|
opm/models/utils/basicproperties.hh
|
||||||
opm/models/utils/genericguard.hh
|
opm/models/utils/genericguard.hh
|
||||||
opm/models/utils/parametersystem.hh
|
opm/models/utils/parametersystem.hpp
|
||||||
opm/models/utils/pffgridvector.hh
|
opm/models/utils/pffgridvector.hh
|
||||||
opm/models/utils/prefetch.hh
|
opm/models/utils/prefetch.hh
|
||||||
opm/models/utils/propertysystem.hh
|
opm/models/utils/propertysystem.hh
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#include "flowexp.hpp"
|
#include "flowexp.hpp"
|
||||||
|
|
||||||
#include <opm/models/discretization/common/tpfalinearizer.hh>
|
#include <opm/models/discretization/common/tpfalinearizer.hh>
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
#include <opm/simulators/flow/Main.hpp>
|
#include <opm/simulators/flow/Main.hpp>
|
||||||
#include <opm/simulators/flow/FlowProblem.hpp>
|
#include <opm/simulators/flow/FlowProblem.hpp>
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
|
|
||||||
#include <opm/models/common/quantitycallbacks.hh>
|
#include <opm/models/common/quantitycallbacks.hh>
|
||||||
#include <opm/models/discretization/common/fvbaseextensivequantities.hh>
|
#include <opm/models/discretization/common/fvbaseextensivequantities.hh>
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
|
|
||||||
#include <opm/material/common/Valgrind.hpp>
|
#include <opm/material/common/Valgrind.hpp>
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
#define EWOMS_FV_BASE_FD_LOCAL_LINEARIZER_HH
|
#define EWOMS_FV_BASE_FD_LOCAL_LINEARIZER_HH
|
||||||
|
|
||||||
#include <opm/models/utils/propertysystem.hh>
|
#include <opm/models/utils/propertysystem.hh>
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
#include <opm/models/discretization/common/fvbaseproperties.hh>
|
#include <opm/models/discretization/common/fvbaseproperties.hh>
|
||||||
|
|
||||||
#include <opm/material/common/MathToolbox.hpp>
|
#include <opm/material/common/MathToolbox.hpp>
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
|
|
||||||
#include "fvbaseproperties.hh"
|
#include "fvbaseproperties.hh"
|
||||||
|
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
#include <opm/models/utils/alignedallocator.hh>
|
#include <opm/models/utils/alignedallocator.hh>
|
||||||
|
|
||||||
#include <opm/material/common/Valgrind.hpp>
|
#include <opm/material/common/Valgrind.hpp>
|
||||||
|
@ -37,11 +37,13 @@
|
|||||||
|
|
||||||
#include <dune/common/fvector.hh>
|
#include <dune/common/fvector.hh>
|
||||||
|
|
||||||
|
#include <functional>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
namespace Opm::Properties {
|
namespace Opm::Properties {
|
||||||
|
|
||||||
@ -268,7 +270,9 @@ public:
|
|||||||
* the next regular parameter. If this is less than 1, it indicated that the
|
* the next regular parameter. If this is less than 1, it indicated that the
|
||||||
* positional parameter was invalid.
|
* positional parameter was invalid.
|
||||||
*/
|
*/
|
||||||
static int handlePositionalParameter(std::set<std::string>&,
|
static int handlePositionalParameter(std::function<void(const std::string&,
|
||||||
|
const std::string&)>,
|
||||||
|
std::set<std::string>&,
|
||||||
std::string& errorMsg,
|
std::string& errorMsg,
|
||||||
int,
|
int,
|
||||||
const char** argv,
|
const char** argv,
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
#include <opm/models/io/baseoutputwriter.hh>
|
#include <opm/models/io/baseoutputwriter.hh>
|
||||||
|
|
||||||
#include <opm/models/utils/basicproperties.hh>
|
#include <opm/models/utils/basicproperties.hh>
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
#include <opm/models/utils/propertysystem.hh>
|
#include <opm/models/utils/propertysystem.hh>
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#define EWOMS_BASE_VANGUARD_HH
|
#define EWOMS_BASE_VANGUARD_HH
|
||||||
|
|
||||||
#include <opm/models/utils/basicproperties.hh>
|
#include <opm/models/utils/basicproperties.hh>
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
|
|
||||||
#include <dune/common/version.hh>
|
#include <dune/common/version.hh>
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#include <opm/models/utils/basicparameters.hh>
|
#include <opm/models/utils/basicparameters.hh>
|
||||||
#include <opm/models/utils/basicproperties.hh>
|
#include <opm/models/utils/basicproperties.hh>
|
||||||
#include <opm/models/utils/propertysystem.hh>
|
#include <opm/models/utils/propertysystem.hh>
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
|
|
||||||
#include <dune/grid/utility/structuredgridfactory.hh>
|
#include <dune/grid/utility/structuredgridfactory.hh>
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
#include <opm/models/io/basevanguard.hh>
|
#include <opm/models/io/basevanguard.hh>
|
||||||
#include <opm/models/utils/propertysystem.hh>
|
#include <opm/models/utils/propertysystem.hh>
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
|
|
||||||
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
#include <opm/models/utils/basicparameters.hh>
|
#include <opm/models/utils/basicparameters.hh>
|
||||||
#include <opm/models/utils/basicproperties.hh>
|
#include <opm/models/utils/basicproperties.hh>
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
#include <opm/models/utils/propertysystem.hh>
|
#include <opm/models/utils/propertysystem.hh>
|
||||||
|
|
||||||
#include <dune/grid/yaspgrid.hh>
|
#include <dune/grid/yaspgrid.hh>
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
#include <opm/models/io/baseoutputmodule.hh>
|
#include <opm/models/io/baseoutputmodule.hh>
|
||||||
#include <opm/models/io/vtkmultiwriter.hh>
|
#include <opm/models/io/vtkmultiwriter.hh>
|
||||||
|
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
#include <opm/models/utils/propertysystem.hh>
|
#include <opm/models/utils/propertysystem.hh>
|
||||||
|
|
||||||
namespace Opm::Parameters {
|
namespace Opm::Parameters {
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
#include <opm/models/io/baseoutputmodule.hh>
|
#include <opm/models/io/baseoutputmodule.hh>
|
||||||
#include <opm/models/io/vtkmultiwriter.hh>
|
#include <opm/models/io/vtkmultiwriter.hh>
|
||||||
|
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
#include <opm/models/utils/propertysystem.hh>
|
#include <opm/models/utils/propertysystem.hh>
|
||||||
|
|
||||||
namespace Opm::Parameters {
|
namespace Opm::Parameters {
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
|
|
||||||
#include <opm/models/discretization/common/fvbaseparameters.hh>
|
#include <opm/models/discretization/common/fvbaseparameters.hh>
|
||||||
|
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
#include <opm/models/utils/propertysystem.hh>
|
#include <opm/models/utils/propertysystem.hh>
|
||||||
|
|
||||||
namespace Opm::Parameters {
|
namespace Opm::Parameters {
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
#include <opm/models/io/baseoutputmodule.hh>
|
#include <opm/models/io/baseoutputmodule.hh>
|
||||||
#include <opm/models/io/vtkmultiwriter.hh>
|
#include <opm/models/io/vtkmultiwriter.hh>
|
||||||
|
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
#include <opm/models/utils/propertysystem.hh>
|
#include <opm/models/utils/propertysystem.hh>
|
||||||
|
|
||||||
namespace Opm::Properties::TTag {
|
namespace Opm::Properties::TTag {
|
||||||
|
@ -38,7 +38,7 @@
|
|||||||
#include <opm/models/io/baseoutputmodule.hh>
|
#include <opm/models/io/baseoutputmodule.hh>
|
||||||
#include <opm/models/io/vtkmultiwriter.hh>
|
#include <opm/models/io/vtkmultiwriter.hh>
|
||||||
|
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
#include <opm/models/utils/propertysystem.hh>
|
#include <opm/models/utils/propertysystem.hh>
|
||||||
|
|
||||||
namespace Opm::Parameters {
|
namespace Opm::Parameters {
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
#include <opm/models/io/baseoutputmodule.hh>
|
#include <opm/models/io/baseoutputmodule.hh>
|
||||||
#include <opm/models/io/vtkmultiwriter.hh>
|
#include <opm/models/io/vtkmultiwriter.hh>
|
||||||
|
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
#include <opm/models/utils/propertysystem.hh>
|
#include <opm/models/utils/propertysystem.hh>
|
||||||
|
|
||||||
namespace Opm::Parameters {
|
namespace Opm::Parameters {
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
#include <opm/models/io/vtkmultiwriter.hh>
|
#include <opm/models/io/vtkmultiwriter.hh>
|
||||||
|
|
||||||
#include <opm/models/utils/propertysystem.hh>
|
#include <opm/models/utils/propertysystem.hh>
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
|
|
||||||
namespace Opm::Parameters {
|
namespace Opm::Parameters {
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
#include <opm/models/io/vtkmultiwriter.hh>
|
#include <opm/models/io/vtkmultiwriter.hh>
|
||||||
|
|
||||||
#include <opm/models/utils/propertysystem.hh>
|
#include <opm/models/utils/propertysystem.hh>
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
|
|
||||||
#include <opm/models/discretization/common/fvbaseparameters.hh>
|
#include <opm/models/discretization/common/fvbaseparameters.hh>
|
||||||
|
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
#include <opm/models/utils/propertysystem.hh>
|
#include <opm/models/utils/propertysystem.hh>
|
||||||
|
|
||||||
namespace Opm::Parameters {
|
namespace Opm::Parameters {
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
#include <opm/models/io/baseoutputmodule.hh>
|
#include <opm/models/io/baseoutputmodule.hh>
|
||||||
#include <opm/models/io/vtkmultiwriter.hh>
|
#include <opm/models/io/vtkmultiwriter.hh>
|
||||||
|
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
#include <opm/models/utils/propertysystem.hh>
|
#include <opm/models/utils/propertysystem.hh>
|
||||||
|
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#include <opm/models/io/baseoutputmodule.hh>
|
#include <opm/models/io/baseoutputmodule.hh>
|
||||||
#include <opm/models/io/vtkmultiwriter.hh>
|
#include <opm/models/io/vtkmultiwriter.hh>
|
||||||
|
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
#include <opm/models/utils/propertysystem.hh>
|
#include <opm/models/utils/propertysystem.hh>
|
||||||
|
|
||||||
namespace Opm::Parameters {
|
namespace Opm::Parameters {
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#include <opm/models/io/baseoutputmodule.hh>
|
#include <opm/models/io/baseoutputmodule.hh>
|
||||||
#include <opm/models/io/vtkmultiwriter.hh>
|
#include <opm/models/io/vtkmultiwriter.hh>
|
||||||
|
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
#include <opm/models/utils/propertysystem.hh>
|
#include <opm/models/utils/propertysystem.hh>
|
||||||
|
|
||||||
namespace Opm::Parameters {
|
namespace Opm::Parameters {
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
#include <opm/models/io/baseoutputmodule.hh>
|
#include <opm/models/io/baseoutputmodule.hh>
|
||||||
#include <opm/models/io/vtkmultiwriter.hh>
|
#include <opm/models/io/vtkmultiwriter.hh>
|
||||||
|
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
#include <opm/models/utils/propertysystem.hh>
|
#include <opm/models/utils/propertysystem.hh>
|
||||||
|
|
||||||
namespace Opm::Parameters {
|
namespace Opm::Parameters {
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
#include <opm/models/io/baseoutputmodule.hh>
|
#include <opm/models/io/baseoutputmodule.hh>
|
||||||
#include <opm/models/io/vtkmultiwriter.hh>
|
#include <opm/models/io/vtkmultiwriter.hh>
|
||||||
|
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
#include <opm/models/utils/propertysystem.hh>
|
#include <opm/models/utils/propertysystem.hh>
|
||||||
|
|
||||||
namespace Opm::Parameters {
|
namespace Opm::Parameters {
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <opm/models/discretization/common/fvbaseparameters.hh>
|
#include <opm/models/discretization/common/fvbaseparameters.hh>
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
|
|
||||||
namespace Opm {
|
namespace Opm {
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#include <dune/common/parametertree.hh>
|
#include <dune/common/parametertree.hh>
|
||||||
|
|
||||||
#include <opm/models/utils/basicparameters.hh>
|
#include <opm/models/utils/basicparameters.hh>
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
#include <opm/models/utils/propertysystem.hh>
|
#include <opm/models/utils/propertysystem.hh>
|
||||||
|
|
||||||
#if HAVE_DUNE_FEM
|
#if HAVE_DUNE_FEM
|
||||||
|
File diff suppressed because it is too large
Load Diff
338
opm/models/utils/parametersystem.hpp
Normal file
338
opm/models/utils/parametersystem.hpp
Normal file
@ -0,0 +1,338 @@
|
|||||||
|
// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||||
|
// vi: set et ts=4 sw=4 sts=4:
|
||||||
|
/*
|
||||||
|
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 2 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/>.
|
||||||
|
|
||||||
|
Consult the COPYING file in the top-level source directory of this
|
||||||
|
module for the precise wording of the license and the list of
|
||||||
|
copyright holders.
|
||||||
|
*/
|
||||||
|
/*!
|
||||||
|
* \file
|
||||||
|
*
|
||||||
|
* \brief This file provides the infrastructure to retrieve run-time parameters
|
||||||
|
*
|
||||||
|
* Internally, runtime parameters are implemented using
|
||||||
|
* Dune::ParameterTree with the default value taken from the parameter
|
||||||
|
* definition.
|
||||||
|
*/
|
||||||
|
#ifndef OPM_PARAMETER_SYSTEM_HPP
|
||||||
|
#define OPM_PARAMETER_SYSTEM_HPP
|
||||||
|
|
||||||
|
#include <dune/common/classname.hh>
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
#include <functional>
|
||||||
|
#include <set>
|
||||||
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
#include <type_traits>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace Opm::Parameters {
|
||||||
|
|
||||||
|
namespace detail {
|
||||||
|
|
||||||
|
template <typename, class = void>
|
||||||
|
struct has_name : public std::false_type {};
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
struct has_name<T, std::void_t<decltype(std::declval<T>().name)>>
|
||||||
|
: public std::true_type {};
|
||||||
|
|
||||||
|
//! get the name data member of a parameter
|
||||||
|
template<class Parameter>
|
||||||
|
auto getParamName()
|
||||||
|
{
|
||||||
|
if constexpr (has_name<Parameter>::value) {
|
||||||
|
return Parameter::name;
|
||||||
|
} else {
|
||||||
|
std::string paramName = Dune::className<Parameter>();
|
||||||
|
paramName.replace(0, std::strlen("Opm::Parameters::"), "");
|
||||||
|
const auto pos = paramName.find_first_of('<');
|
||||||
|
if (pos != std::string::npos) {
|
||||||
|
paramName.erase(pos);
|
||||||
|
}
|
||||||
|
return paramName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//! \brief Private implementation.
|
||||||
|
template<class ParamType>
|
||||||
|
ParamType Get_(const std::string& paramName, ParamType defaultValue,
|
||||||
|
bool errorIfNotRegistered);
|
||||||
|
|
||||||
|
//! \brief Private implementation.
|
||||||
|
void Hide_(const std::string& paramName);
|
||||||
|
|
||||||
|
//! \brief Private implementation.
|
||||||
|
bool IsSet_(const std::string& paramName, bool errorIfNotRegistered);
|
||||||
|
|
||||||
|
//! \brief Private implementation.
|
||||||
|
void Register_(const std::string& paramName,
|
||||||
|
const std::string& paramTypeName,
|
||||||
|
const std::string& defaultValue,
|
||||||
|
const char* usageString);
|
||||||
|
|
||||||
|
//! \brief Private implementation.
|
||||||
|
void SetDefault_(const std::string& paramName,
|
||||||
|
const std::string& paramValue);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string breakLines(const std::string& msg,
|
||||||
|
int indentWidth,
|
||||||
|
int maxWidth);
|
||||||
|
|
||||||
|
int getTtyWidth();
|
||||||
|
|
||||||
|
//! \endcond
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \ingroup Parameter
|
||||||
|
* \brief Print a usage message for all run-time parameters.
|
||||||
|
*
|
||||||
|
* \param helpPreamble The string that is printed after the error message and before the
|
||||||
|
* list of parameters.
|
||||||
|
* \param errorMsg The error message to be printed, if any
|
||||||
|
* \param os The \c std::ostream which should be used.
|
||||||
|
*/
|
||||||
|
void printUsage(const std::string& helpPreamble,
|
||||||
|
std::ostream& os,
|
||||||
|
const std::string& errorMsg = "",
|
||||||
|
const bool showAll = false);
|
||||||
|
|
||||||
|
//! \brief Callback function for command line parsing.
|
||||||
|
using PositionalArgumentCallback = std::function<int(std::function<void(const std::string&,
|
||||||
|
const std::string&)>,
|
||||||
|
std::set<std::string>&,
|
||||||
|
std::string&,
|
||||||
|
int,
|
||||||
|
const char**,
|
||||||
|
int,
|
||||||
|
int)>;
|
||||||
|
/*!
|
||||||
|
* \ingroup Parameter
|
||||||
|
* \brief Parse the parameters provided on the command line.
|
||||||
|
*
|
||||||
|
* This function does some basic syntax checks.
|
||||||
|
*
|
||||||
|
* \param argc The number of parameters passed by the operating system to the
|
||||||
|
* main() function
|
||||||
|
* \param argv The array of strings passed by the operating system to the main()
|
||||||
|
* function
|
||||||
|
* \param helpPreamble If non-empty, the --help and -h parameters will be recognized and
|
||||||
|
* the content of the string will be printed before the list of
|
||||||
|
* command line parameters
|
||||||
|
* \return Empty string if everything worked out. Otherwise the thing that could
|
||||||
|
* not be read.
|
||||||
|
*/
|
||||||
|
std::string
|
||||||
|
parseCommandLineOptions(int argc,
|
||||||
|
const char **argv,
|
||||||
|
const PositionalArgumentCallback& posArgCallback,
|
||||||
|
const std::string& helpPreamble = "");
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \ingroup Parameter
|
||||||
|
* \brief Read the parameters from an INI-style file.
|
||||||
|
*
|
||||||
|
* This function does some basic syntax checks.
|
||||||
|
*/
|
||||||
|
void parseParameterFile(const std::string& fileName, bool overwrite = true);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \ingroup Parameter
|
||||||
|
* \brief Print values of the run-time parameters.
|
||||||
|
*
|
||||||
|
* \param os The \c std::ostream on which the message should be printed
|
||||||
|
*/
|
||||||
|
void printValues(std::ostream& os);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \ingroup Parameter
|
||||||
|
* \brief Print the list of unused run-time parameters.
|
||||||
|
*
|
||||||
|
* \param os The \c std::ostream on which the message should be printed
|
||||||
|
*
|
||||||
|
* \return true if something was printed
|
||||||
|
*/
|
||||||
|
bool printUnused(std::ostream& os);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \ingroup Parameter
|
||||||
|
*
|
||||||
|
* \brief Retrieve a runtime parameter.
|
||||||
|
*
|
||||||
|
* The default value is specified in the parameter struct.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
*
|
||||||
|
* \code
|
||||||
|
* // Retrieves value UpwindWeight, default
|
||||||
|
* // is taken from the property UpwindWeight
|
||||||
|
* ::Opm::Parameters::get<::Opm::Parameters::UpwindWeight>();
|
||||||
|
* \endcode
|
||||||
|
*/
|
||||||
|
template <class Param>
|
||||||
|
auto Get(bool errorIfNotRegistered = true)
|
||||||
|
{
|
||||||
|
using ParamType = std::conditional_t<std::is_same_v<decltype(Param::value),
|
||||||
|
const char* const>, std::string,
|
||||||
|
std::remove_const_t<decltype(Param::value)>>;
|
||||||
|
ParamType defaultValue = Param::value;
|
||||||
|
return detail::Get_(detail::getParamName<Param>(),
|
||||||
|
defaultValue, errorIfNotRegistered);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \ingroup Parameter
|
||||||
|
*
|
||||||
|
* \brief Set a runtime parameter.
|
||||||
|
*
|
||||||
|
* Override the default value specified.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
*
|
||||||
|
* \code
|
||||||
|
* // Set the value UpwindWeight
|
||||||
|
* ::Opm::Parameters::Set<::Opm::Parameters::UpwindWeight>(3.0);
|
||||||
|
* \endcode
|
||||||
|
*/
|
||||||
|
template <class Param>
|
||||||
|
void SetDefault(decltype(Param::value) new_value)
|
||||||
|
{
|
||||||
|
const std::string paramName = detail::getParamName<Param>();
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << new_value;
|
||||||
|
detail::SetDefault_(paramName, oss.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief A struct holding the key-value pair for a parameter.
|
||||||
|
*/
|
||||||
|
struct Parameter
|
||||||
|
{
|
||||||
|
Parameter(const std::string& k, const std::string& v)
|
||||||
|
: key(k), value(v)
|
||||||
|
{}
|
||||||
|
|
||||||
|
friend std::ostream& operator<<(std::ostream& os, const Parameter& param)
|
||||||
|
{
|
||||||
|
os << param.key << "=\"" << param.value << '"';
|
||||||
|
return os;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator==(const Parameter& setting) const
|
||||||
|
{
|
||||||
|
return setting.key == key
|
||||||
|
&& setting.value == value;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator !=(const Parameter& setting) const
|
||||||
|
{
|
||||||
|
return !(*this == setting);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string key, value;
|
||||||
|
};
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Retrieves the lists of parameters specified at runtime and their values.
|
||||||
|
*
|
||||||
|
* The two arguments besides the TypeTag are assumed to be STL containers which store
|
||||||
|
* std::pair<std::string, std::string>.
|
||||||
|
*/
|
||||||
|
void getLists(std::vector<Parameter>& usedParams,
|
||||||
|
std::vector<Parameter>& unusedParams);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Reset parameter system.
|
||||||
|
*/
|
||||||
|
void reset();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Returns true if a parameter has been specified at runtime, false
|
||||||
|
* otherwise.
|
||||||
|
*
|
||||||
|
* If the parameter in question has not been registered, this throws an exception.
|
||||||
|
*/
|
||||||
|
template <class Param>
|
||||||
|
bool IsSet(bool errorIfNotRegistered = true)
|
||||||
|
{
|
||||||
|
return detail::IsSet_(detail::getParamName<Param>(), errorIfNotRegistered);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \ingroup Parameter
|
||||||
|
*
|
||||||
|
* \brief Register a run-time parameter.
|
||||||
|
*
|
||||||
|
* In OPM, parameters can only be used after they have been
|
||||||
|
* registered.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
*
|
||||||
|
* \code
|
||||||
|
* // Registers a run-time parameter "UpwindWeight"
|
||||||
|
* and the description "Relative weight of the upwind node."
|
||||||
|
* Register<UpwindWeight>("Relative weight of the upwind node.");
|
||||||
|
* \endcode
|
||||||
|
*/
|
||||||
|
template <class Param>
|
||||||
|
void Register(const char* usageString)
|
||||||
|
{
|
||||||
|
const std::string paramName = detail::getParamName<Param>();
|
||||||
|
const auto defaultValue = Param::value;
|
||||||
|
using ParamType = std::conditional_t<std::is_same_v<decltype(defaultValue),
|
||||||
|
const char* const>, std::string,
|
||||||
|
std::remove_const_t<decltype(defaultValue)>>;
|
||||||
|
|
||||||
|
std::ostringstream oss;
|
||||||
|
oss << defaultValue;
|
||||||
|
detail::Register_(paramName, Dune::className<ParamType>(), oss.str(), usageString);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Indicate that a given parameter should not be mentioned in the help message
|
||||||
|
*
|
||||||
|
* This allows to deal with unused parameters
|
||||||
|
*/
|
||||||
|
template <class Param>
|
||||||
|
void Hide()
|
||||||
|
{
|
||||||
|
detail::Hide_(detail::getParamName<Param>());
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Query whether parameter registration is open or not.
|
||||||
|
* \return True if registration is open, false otherwise
|
||||||
|
*/
|
||||||
|
bool IsRegistrationOpen();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \brief Indicate that all parameters are registered for a given type tag.
|
||||||
|
*
|
||||||
|
* If registerParam is called after the invocation of
|
||||||
|
* \c endParamRegistration, a <tt>std::logic_error</tt> exception
|
||||||
|
* will be thrown.
|
||||||
|
*/
|
||||||
|
void endRegistration();
|
||||||
|
//! \endcond
|
||||||
|
|
||||||
|
} // namespace Opm::Parameters
|
||||||
|
|
||||||
|
#endif // OPM_PARAMETER_SYSTEM_HPP
|
@ -29,7 +29,7 @@
|
|||||||
#define EWOMS_SIMULATOR_HH
|
#define EWOMS_SIMULATOR_HH
|
||||||
|
|
||||||
#include <opm/models/io/restart.hh>
|
#include <opm/models/io/restart.hh>
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
|
|
||||||
#include <opm/models/utils/basicproperties.hh>
|
#include <opm/models/utils/basicproperties.hh>
|
||||||
#include <opm/models/utils/propertysystem.hh>
|
#include <opm/models/utils/propertysystem.hh>
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
// dune/common/densematrix.hh because of some c++ ideosyncrasies
|
// dune/common/densematrix.hh because of some c++ ideosyncrasies
|
||||||
#include <opm/material/densead/Evaluation.hpp>
|
#include <opm/material/densead/Evaluation.hpp>
|
||||||
|
|
||||||
#include "parametersystem.hh"
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
|
|
||||||
#include <opm/models/utils/simulator.hh>
|
#include <opm/models/utils/simulator.hh>
|
||||||
#include <opm/models/utils/timer.hpp>
|
#include <opm/models/utils/timer.hpp>
|
||||||
@ -131,8 +131,8 @@ static inline int setupParameters_(int argc,
|
|||||||
std::string s =
|
std::string s =
|
||||||
Parameters::parseCommandLineOptions(argc,
|
Parameters::parseCommandLineOptions(argc,
|
||||||
argv,
|
argv,
|
||||||
helpPreamble,
|
positionalParamCallback,
|
||||||
positionalParamCallback);
|
helpPreamble);
|
||||||
if (!s.empty())
|
if (!s.empty())
|
||||||
{
|
{
|
||||||
int status = 1;
|
int status = 1;
|
||||||
@ -161,7 +161,7 @@ static inline int setupParameters_(int argc,
|
|||||||
if (myRank == 0) {
|
if (myRank == 0) {
|
||||||
oss << "Parameter file \"" << paramFileName
|
oss << "Parameter file \"" << paramFileName
|
||||||
<< "\" does not exist or is not readable.";
|
<< "\" does not exist or is not readable.";
|
||||||
Parameters::printUsage(argv[0], oss.str());
|
Parameters::printUsage(argv[0], std::cerr, oss.str());
|
||||||
}
|
}
|
||||||
return /*status=*/1;
|
return /*status=*/1;
|
||||||
}
|
}
|
||||||
@ -171,8 +171,7 @@ static inline int setupParameters_(int argc,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// make sure that no unknown parameters are encountered
|
// make sure that no unknown parameters are encountered
|
||||||
using KeyValuePair = std::pair<std::string, std::string>;
|
using ParamList = std::vector<Parameters::Parameter>;
|
||||||
using ParamList = std::list<KeyValuePair>;
|
|
||||||
|
|
||||||
ParamList usedParams;
|
ParamList usedParams;
|
||||||
ParamList unusedParams;
|
ParamList unusedParams;
|
||||||
@ -188,7 +187,7 @@ static inline int setupParameters_(int argc,
|
|||||||
|
|
||||||
std::cerr << "\n";
|
std::cerr << "\n";
|
||||||
for (const auto& keyValue : unusedParams)
|
for (const auto& keyValue : unusedParams)
|
||||||
std::cerr << " " << keyValue.first << "=\"" << keyValue.second << "\"\n";
|
std::cerr << " " << keyValue << "\n";
|
||||||
std::cerr << "\n";
|
std::cerr << "\n";
|
||||||
|
|
||||||
std::cerr << "Use\n"
|
std::cerr << "Use\n"
|
||||||
@ -317,18 +316,20 @@ static inline int start(int argc, char **argv, bool registerParams=true)
|
|||||||
// read the initial time step and the end time
|
// read the initial time step and the end time
|
||||||
Scalar endTime = Parameters::Get<Parameters::EndTime<Scalar>>();
|
Scalar endTime = Parameters::Get<Parameters::EndTime<Scalar>>();
|
||||||
if (endTime < -1e50) {
|
if (endTime < -1e50) {
|
||||||
if (myRank == 0)
|
if (myRank == 0) {
|
||||||
Parameters::printUsage(argv[0],
|
Parameters::printUsage(argv[0], std::cerr,
|
||||||
"Mandatory parameter '--end-time' not specified!");
|
"Mandatory parameter '--end-time' not specified!");
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Scalar initialTimeStepSize = Parameters::Get<Parameters::InitialTimeStepSize<Scalar>>();
|
Scalar initialTimeStepSize = Parameters::Get<Parameters::InitialTimeStepSize<Scalar>>();
|
||||||
if (initialTimeStepSize < -1e50) {
|
if (initialTimeStepSize < -1e50) {
|
||||||
if (myRank == 0)
|
if (myRank == 0) {
|
||||||
Parameters::printUsage(argv[0],
|
Parameters::printUsage(argv[0], std::cerr,
|
||||||
"Mandatory parameter '--initial-time-step-size' "
|
"Mandatory parameter '--initial-time-step-size' "
|
||||||
"not specified!");
|
"not specified!");
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -340,9 +341,9 @@ static inline int start(int argc, char **argv, bool registerParams=true)
|
|||||||
#endif
|
#endif
|
||||||
const std::string briefDescription = Problem::briefDescription();
|
const std::string briefDescription = Problem::briefDescription();
|
||||||
if (!briefDescription.empty()) {
|
if (!briefDescription.empty()) {
|
||||||
std::string tmp = Parameters::breakLines_(briefDescription,
|
std::string tmp = Parameters::breakLines(briefDescription,
|
||||||
/*indentWidth=*/0,
|
/*indentWidth=*/0,
|
||||||
Parameters::getTtyWidth_());
|
Parameters::getTtyWidth());
|
||||||
std::cout << tmp << std::endl << std::endl;
|
std::cout << tmp << std::endl << std::endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -357,20 +358,20 @@ static inline int start(int argc, char **argv, bool registerParams=true)
|
|||||||
if (printParams) {
|
if (printParams) {
|
||||||
bool printSeparator = false;
|
bool printSeparator = false;
|
||||||
if (printParams == 1 || !isatty(fileno(stdout))) {
|
if (printParams == 1 || !isatty(fileno(stdout))) {
|
||||||
Parameters::printValues();
|
Parameters::printValues(std::cout);
|
||||||
printSeparator = true;
|
printSeparator = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
// always print the list of specified but unused parameters
|
// always print the list of specified but unused parameters
|
||||||
printSeparator =
|
printSeparator =
|
||||||
printSeparator ||
|
printSeparator ||
|
||||||
Parameters::printUnused();
|
Parameters::printUnused(std::cout);
|
||||||
if (printSeparator)
|
if (printSeparator)
|
||||||
std::cout << endParametersSeparator;
|
std::cout << endParametersSeparator;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
// always print the list of specified but unused parameters
|
// always print the list of specified but unused parameters
|
||||||
if (Parameters::printUnused())
|
if (Parameters::printUnused(std::cout))
|
||||||
std::cout << endParametersSeparator;
|
std::cout << endParametersSeparator;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
|
|
||||||
#include <opm/models/discretization/common/fvbaseparameters.hh>
|
#include <opm/models/discretization/common/fvbaseparameters.hh>
|
||||||
|
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
#include <opm/simulators/flow/DamarisParameters.hpp>
|
#include <opm/simulators/flow/DamarisParameters.hpp>
|
||||||
|
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
|
|
||||||
namespace Opm {
|
namespace Opm {
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
#include <opm/models/discretization/common/fvbaseparameters.hh>
|
#include <opm/models/discretization/common/fvbaseparameters.hh>
|
||||||
#include <opm/models/discretization/common/fvbaseproperties.hh>
|
#include <opm/models/discretization/common/fvbaseproperties.hh>
|
||||||
#include <opm/models/io/basevanguard.hh>
|
#include <opm/models/io/basevanguard.hh>
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
#include <opm/models/utils/propertysystem.hh>
|
#include <opm/models/utils/propertysystem.hh>
|
||||||
|
|
||||||
#include <opm/simulators/flow/BlackoilModelParameters.hpp>
|
#include <opm/simulators/flow/BlackoilModelParameters.hpp>
|
||||||
|
@ -52,7 +52,8 @@ class EclipseState;
|
|||||||
class Schedule;
|
class Schedule;
|
||||||
template<typename Grid, typename GridView> class LookUpData;
|
template<typename Grid, typename GridView> class LookUpData;
|
||||||
|
|
||||||
int eclPositionalParameter(Dune::ParameterTree& tree,
|
int eclPositionalParameter(std::function<void(const std::string&,
|
||||||
|
const std::string&)> addKey,
|
||||||
std::set<std::string>& seenParams,
|
std::set<std::string>& seenParams,
|
||||||
std::string& errorMsg,
|
std::string& errorMsg,
|
||||||
const char** argv,
|
const char** argv,
|
||||||
|
@ -45,7 +45,7 @@
|
|||||||
|
|
||||||
namespace Opm {
|
namespace Opm {
|
||||||
|
|
||||||
int eclPositionalParameter(Dune::ParameterTree& tree,
|
int eclPositionalParameter(std::function<void(const std::string&, const std::string&)> addKey,
|
||||||
std::set<std::string>& seenParams,
|
std::set<std::string>& seenParams,
|
||||||
std::string& errorMsg,
|
std::string& errorMsg,
|
||||||
const char** argv,
|
const char** argv,
|
||||||
@ -73,7 +73,7 @@ int eclPositionalParameter(Dune::ParameterTree& tree,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
tree["EclDeckFileName"] = argv[paramIdx];
|
addKey("EclDeckFileName", argv[paramIdx]);
|
||||||
seenParams.insert("EclDeckFileName");
|
seenParams.insert("EclDeckFileName");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -81,7 +81,7 @@
|
|||||||
|
|
||||||
#include <opm/input/eclipse/Parser/InputErrorAction.hpp>
|
#include <opm/input/eclipse/Parser/InputErrorAction.hpp>
|
||||||
|
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
|
|
||||||
#include <opm/simulators/flow/BlackoilModelParameters.hpp>
|
#include <opm/simulators/flow/BlackoilModelParameters.hpp>
|
||||||
#include <opm/simulators/utils/readDeck.hpp>
|
#include <opm/simulators/utils/readDeck.hpp>
|
||||||
|
@ -84,7 +84,7 @@ namespace Opm {
|
|||||||
// Read the command line parameters. Throws an exception if something goes wrong.
|
// Read the command line parameters. Throws an exception if something goes wrong.
|
||||||
static int setupParameters_(int argc, char** argv, Parallel::Communication comm)
|
static int setupParameters_(int argc, char** argv, Parallel::Communication comm)
|
||||||
{
|
{
|
||||||
if (!Parameters::MetaData::registrationOpen()) {
|
if (!Parameters::IsRegistrationOpen()) {
|
||||||
// We have already successfully run setupParameters_().
|
// We have already successfully run setupParameters_().
|
||||||
// For the dynamically chosen runs (as from the main flow
|
// For the dynamically chosen runs (as from the main flow
|
||||||
// executable) we must run this function again with the
|
// executable) we must run this function again with the
|
||||||
@ -150,7 +150,7 @@ namespace Opm {
|
|||||||
// deal with --print-parameters and unknown parameters.
|
// deal with --print-parameters and unknown parameters.
|
||||||
if (Parameters::Get<Parameters::PrintParameters>() == 1) {
|
if (Parameters::Get<Parameters::PrintParameters>() == 1) {
|
||||||
if (mpiRank == 0) {
|
if (mpiRank == 0) {
|
||||||
Parameters::printValues();
|
Parameters::printValues(std::cout);
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -228,14 +228,16 @@ public:
|
|||||||
/*!
|
/*!
|
||||||
* \copydoc FvBaseProblem::handlePositionalParameter
|
* \copydoc FvBaseProblem::handlePositionalParameter
|
||||||
*/
|
*/
|
||||||
static int handlePositionalParameter(std::set<std::string>& seenParams,
|
static int handlePositionalParameter(std::function<void(const std::string&,
|
||||||
|
const std::string&)> addKey,
|
||||||
|
std::set<std::string>& seenParams,
|
||||||
std::string& errorMsg,
|
std::string& errorMsg,
|
||||||
int,
|
int,
|
||||||
const char** argv,
|
const char** argv,
|
||||||
int paramIdx,
|
int paramIdx,
|
||||||
int)
|
int)
|
||||||
{
|
{
|
||||||
return eclPositionalParameter(Parameters::MetaData::tree(),
|
return eclPositionalParameter(addKey,
|
||||||
seenParams,
|
seenParams,
|
||||||
errorMsg,
|
errorMsg,
|
||||||
argv,
|
argv,
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
#include <opm/models/common/multiphasebaseparameters.hh>
|
#include <opm/models/common/multiphasebaseparameters.hh>
|
||||||
#include <opm/models/nonlinear/newtonmethodparameters.hh>
|
#include <opm/models/nonlinear/newtonmethodparameters.hh>
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
|
|
||||||
#include <opm/simulators/flow/EclWriter.hpp>
|
#include <opm/simulators/flow/EclWriter.hpp>
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
#include <opm/models/io/vtktemperaturemodule.hh>
|
#include <opm/models/io/vtktemperaturemodule.hh>
|
||||||
#include <opm/models/nonlinear/newtonmethodparameters.hh>
|
#include <opm/models/nonlinear/newtonmethodparameters.hh>
|
||||||
#include <opm/models/utils/basicparameters.hh>
|
#include <opm/models/utils/basicparameters.hh>
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
|
|
||||||
#include <opm/simulators/flow/ConvergenceOutputConfiguration.hpp>
|
#include <opm/simulators/flow/ConvergenceOutputConfiguration.hpp>
|
||||||
#include <opm/simulators/timestepping/SimulatorReport.hpp>
|
#include <opm/simulators/timestepping/SimulatorReport.hpp>
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
|
#include <opm/input/eclipse/EclipseState/EclipseState.hpp>
|
||||||
|
|
||||||
#include <opm/models/utils/propertysystem.hh>
|
#include <opm/models/utils/propertysystem.hh>
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
|
|
||||||
#include <opm/simulators/flow/Banners.hpp>
|
#include <opm/simulators/flow/Banners.hpp>
|
||||||
#include <opm/simulators/flow/FlowMain.hpp>
|
#include <opm/simulators/flow/FlowMain.hpp>
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
#include <opm/models/nonlinear/newtonmethodparameters.hh>
|
#include <opm/models/nonlinear/newtonmethodparameters.hh>
|
||||||
#include <opm/models/nonlinear/newtonmethodproperties.hh>
|
#include <opm/models/nonlinear/newtonmethodproperties.hh>
|
||||||
|
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
#include <opm/models/utils/propertysystem.hh>
|
#include <opm/models/utils/propertysystem.hh>
|
||||||
#include <opm/models/utils/basicproperties.hh>
|
#include <opm/models/utils/basicproperties.hh>
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@
|
|||||||
|
|
||||||
#include <opm/models/blackoil/blackoilproperties.hh>
|
#include <opm/models/blackoil/blackoilproperties.hh>
|
||||||
#include <opm/models/discretization/common/fvbaseproperties.hh>
|
#include <opm/models/discretization/common/fvbaseproperties.hh>
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
#include <opm/models/utils/propertysystem.hh>
|
#include <opm/models/utils/propertysystem.hh>
|
||||||
|
|
||||||
#include <opm/output/data/Cells.hpp>
|
#include <opm/output/data/Cells.hpp>
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
#include <opm/models/discretization/common/fvbaseparameters.hh>
|
#include <opm/models/discretization/common/fvbaseparameters.hh>
|
||||||
#include <opm/models/io/baseoutputmodule.hh>
|
#include <opm/models/io/baseoutputmodule.hh>
|
||||||
#include <opm/models/io/vtkmultiwriter.hh>
|
#include <opm/models/io/vtkmultiwriter.hh>
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
#include <opm/models/utils/propertysystem.hh>
|
#include <opm/models/utils/propertysystem.hh>
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
#include <opm/simulators/flow/Main.hpp>
|
#include <opm/simulators/flow/Main.hpp>
|
||||||
#include <opm/simulators/flow/FlowMain.hpp>
|
#include <opm/simulators/flow/FlowMain.hpp>
|
||||||
#include <opm/models/utils/propertysystem.hh>
|
#include <opm/models/utils/propertysystem.hh>
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
#include <opm/simulators/flow/python/Pybind11Exporter.hpp>
|
#include <opm/simulators/flow/python/Pybind11Exporter.hpp>
|
||||||
#include <opm/simulators/flow/python/PyFluidState.hpp>
|
#include <opm/simulators/flow/python/PyFluidState.hpp>
|
||||||
#include <opm/simulators/flow/python/PyMaterialState.hpp>
|
#include <opm/simulators/flow/python/PyMaterialState.hpp>
|
||||||
@ -32,6 +32,7 @@
|
|||||||
#include <opm/input/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
|
#include <opm/input/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
|
||||||
|
|
||||||
namespace Opm::Pybind {
|
namespace Opm::Pybind {
|
||||||
|
|
||||||
class PyBlackOilSimulator
|
class PyBlackOilSimulator
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#include <opm/simulators/linalg/FlowLinearSolverParameters.hpp>
|
#include <opm/simulators/linalg/FlowLinearSolverParameters.hpp>
|
||||||
#include <opm/simulators/linalg/linalgparameters.hh>
|
#include <opm/simulators/linalg/linalgparameters.hh>
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
|
|
||||||
namespace Opm {
|
namespace Opm {
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
#include <opm/models/discretization/common/fvbaseproperties.hh>
|
#include <opm/models/discretization/common/fvbaseproperties.hh>
|
||||||
#include <opm/models/common/multiphasebaseproperties.hh>
|
#include <opm/models/common/multiphasebaseproperties.hh>
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
#include <opm/models/utils/propertysystem.hh>
|
#include <opm/models/utils/propertysystem.hh>
|
||||||
#include <opm/simulators/flow/BlackoilModelParameters.hpp>
|
#include <opm/simulators/flow/BlackoilModelParameters.hpp>
|
||||||
#include <opm/simulators/flow/FlowBaseVanguard.hpp>
|
#include <opm/simulators/flow/FlowBaseVanguard.hpp>
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
#include <dune/common/version.hh>
|
#include <dune/common/version.hh>
|
||||||
|
|
||||||
#include <opm/models/utils/propertysystem.hh>
|
#include <opm/models/utils/propertysystem.hh>
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
|
|
||||||
#include <opm/simulators/linalg/linalgparameters.hh>
|
#include <opm/simulators/linalg/linalgparameters.hh>
|
||||||
#include <opm/simulators/linalg/linalgproperties.hh>
|
#include <opm/simulators/linalg/linalgproperties.hh>
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
#include <dune/istl/solvers.hh>
|
#include <dune/istl/solvers.hh>
|
||||||
|
|
||||||
#include <opm/models/utils/propertysystem.hh>
|
#include <opm/models/utils/propertysystem.hh>
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
|
|
||||||
#include <opm/simulators/linalg/linalgparameters.hh>
|
#include <opm/simulators/linalg/linalgparameters.hh>
|
||||||
#include <opm/simulators/linalg/linalgproperties.hh>
|
#include <opm/simulators/linalg/linalgproperties.hh>
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
|
|
||||||
#include <opm/models/utils/genericguard.hh>
|
#include <opm/models/utils/genericguard.hh>
|
||||||
#include <opm/models/utils/propertysystem.hh>
|
#include <opm/models/utils/propertysystem.hh>
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
|
|
||||||
#include <opm/simulators/linalg/istlpreconditionerwrappers.hh>
|
#include <opm/simulators/linalg/istlpreconditionerwrappers.hh>
|
||||||
#include <opm/simulators/linalg/istlsparsematrixadapter.hh>
|
#include <opm/simulators/linalg/istlsparsematrixadapter.hh>
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
#include <opm/input/eclipse/Schedule/Tuning.hpp>
|
#include <opm/input/eclipse/Schedule/Tuning.hpp>
|
||||||
|
|
||||||
#include <opm/models/utils/basicproperties.hh>
|
#include <opm/models/utils/basicproperties.hh>
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
#include <opm/models/utils/propertysystem.hh>
|
#include <opm/models/utils/propertysystem.hh>
|
||||||
|
|
||||||
#include <opm/simulators/timestepping/AdaptiveSimulatorTimer.hpp>
|
#include <opm/simulators/timestepping/AdaptiveSimulatorTimer.hpp>
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
|
|
||||||
#include <opm/simulators/timestepping/EclTimeSteppingParams.hpp>
|
#include <opm/simulators/timestepping/EclTimeSteppingParams.hpp>
|
||||||
|
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
|
|
||||||
namespace Opm {
|
namespace Opm {
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
#ifndef OPM_DAMARISKEYWORDS_HEADER_INCLUDED
|
#ifndef OPM_DAMARISKEYWORDS_HEADER_INCLUDED
|
||||||
#define OPM_DAMARISKEYWORDS_HEADER_INCLUDED
|
#define OPM_DAMARISKEYWORDS_HEADER_INCLUDED
|
||||||
|
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
|
|
||||||
#include <opm/simulators/flow/DamarisParameters.hpp>
|
#include <opm/simulators/flow/DamarisParameters.hpp>
|
||||||
#include <opm/simulators/utils/ParallelCommunication.hpp>
|
#include <opm/simulators/utils/ParallelCommunication.hpp>
|
||||||
|
@ -21,7 +21,7 @@
|
|||||||
#define OPM_GASLIFT_SINGLE_WELL_HEADER_INCLUDED
|
#define OPM_GASLIFT_SINGLE_WELL_HEADER_INCLUDED
|
||||||
|
|
||||||
#include <opm/models/utils/propertysystem.hh>
|
#include <opm/models/utils/propertysystem.hh>
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
#include <opm/models/discretization/common/fvbaseproperties.hh>
|
#include <opm/models/discretization/common/fvbaseproperties.hh>
|
||||||
#include <opm/simulators/wells/GasLiftSingleWellGeneric.hpp>
|
#include <opm/simulators/wells/GasLiftSingleWellGeneric.hpp>
|
||||||
#include <opm/simulators/wells/GasLiftGroupInfo.hpp>
|
#include <opm/simulators/wells/GasLiftGroupInfo.hpp>
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#define BOOST_TEST_MODULE Glift1
|
#define BOOST_TEST_MODULE Glift1
|
||||||
|
|
||||||
#include <opm/models/utils/propertysystem.hh>
|
#include <opm/models/utils/propertysystem.hh>
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
#include <opm/models/utils/start.hh>
|
#include <opm/models/utils/start.hh>
|
||||||
|
|
||||||
#include <opm/input/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
|
#include <opm/input/eclipse/EclipseState/SummaryConfig/SummaryConfig.hpp>
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#include <opm/models/utils/parametersystem.hh>
|
#include <opm/models/utils/parametersystem.hpp>
|
||||||
|
|
||||||
#define BOOST_TEST_MODULE ParameterSystemTest
|
#define BOOST_TEST_MODULE ParameterSystemTest
|
||||||
#include <boost/test/unit_test.hpp>
|
#include <boost/test/unit_test.hpp>
|
||||||
@ -41,35 +41,6 @@ struct SimpleParamBoolN2
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
class Setting
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Setting(const std::string& k, const std::string& v)
|
|
||||||
: key(k), value(v)
|
|
||||||
{}
|
|
||||||
|
|
||||||
friend std::ostream& operator<<(std::ostream& os, const Setting& setting)
|
|
||||||
{
|
|
||||||
os << setting.key << "=" << setting.value << '\n';
|
|
||||||
return os;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator==(const Setting& setting) const
|
|
||||||
{
|
|
||||||
return setting.key == key
|
|
||||||
&& setting.value == value;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator !=(const Setting& setting) const
|
|
||||||
{
|
|
||||||
return !(*this == setting);
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::string key;
|
|
||||||
std::string value;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Fixture
|
struct Fixture
|
||||||
{
|
{
|
||||||
Fixture()
|
Fixture()
|
||||||
@ -107,8 +78,21 @@ BOOST_FIXTURE_TEST_CASE(GetLists, Fixture)
|
|||||||
"--unused-param=foo",
|
"--unused-param=foo",
|
||||||
};
|
};
|
||||||
|
|
||||||
Opm::Parameters::parseCommandLineOptions(5, argv, "",
|
auto noPositional = [](std::function<void(const std::string&,
|
||||||
Opm::Parameters::noPositionalParameters_);
|
const std::string&)>,
|
||||||
|
std::set<std::string>&,
|
||||||
|
std::string&,
|
||||||
|
int,
|
||||||
|
const char**,
|
||||||
|
int,
|
||||||
|
int) -> int
|
||||||
|
{
|
||||||
|
assert("Should not be here!");
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Opm::Parameters::parseCommandLineOptions(5, argv, noPositional);
|
||||||
|
|
||||||
BOOST_CHECK_EQUAL(Opm::Parameters::IsSet<Opm::Parameters::SimpleParamBool>(), true);
|
BOOST_CHECK_EQUAL(Opm::Parameters::IsSet<Opm::Parameters::SimpleParamBool>(), true);
|
||||||
BOOST_CHECK_EQUAL(Opm::Parameters::IsSet<Opm::Parameters::SimpleParamFloat>(), true);
|
BOOST_CHECK_EQUAL(Opm::Parameters::IsSet<Opm::Parameters::SimpleParamFloat>(), true);
|
||||||
@ -117,7 +101,7 @@ BOOST_FIXTURE_TEST_CASE(GetLists, Fixture)
|
|||||||
BOOST_CHECK_EQUAL(Opm::Parameters::IsSet<Opm::Parameters::SimpleParamDouble>(), false);
|
BOOST_CHECK_EQUAL(Opm::Parameters::IsSet<Opm::Parameters::SimpleParamDouble>(), false);
|
||||||
BOOST_CHECK_EQUAL(Opm::Parameters::IsSet<Opm::Parameters::SimpleParamInt>(), false);
|
BOOST_CHECK_EQUAL(Opm::Parameters::IsSet<Opm::Parameters::SimpleParamInt>(), false);
|
||||||
|
|
||||||
using SettingMap = std::vector<Setting>;
|
using SettingMap = std::vector<Opm::Parameters::Parameter>;
|
||||||
|
|
||||||
const SettingMap set_ref = {
|
const SettingMap set_ref = {
|
||||||
{"SimpleParamBool", "true"},
|
{"SimpleParamBool", "true"},
|
||||||
@ -153,7 +137,7 @@ BOOST_FIXTURE_TEST_CASE(ParseParameterFile, Fixture)
|
|||||||
BOOST_FIXTURE_TEST_CASE(PrintUsage, Fixture)
|
BOOST_FIXTURE_TEST_CASE(PrintUsage, Fixture)
|
||||||
{
|
{
|
||||||
std::stringstream usage;
|
std::stringstream usage;
|
||||||
Opm::Parameters::printUsage("", "", usage);
|
Opm::Parameters::printUsage("", usage);
|
||||||
BOOST_CHECK_EQUAL(trimString(usage.str()),
|
BOOST_CHECK_EQUAL(trimString(usage.str()),
|
||||||
trimString(R"(
|
trimString(R"(
|
||||||
Recognized options:
|
Recognized options:
|
||||||
@ -168,7 +152,7 @@ Recognized options:
|
|||||||
BOOST_FIXTURE_TEST_CASE(PrintUsageAll, Fixture)
|
BOOST_FIXTURE_TEST_CASE(PrintUsageAll, Fixture)
|
||||||
{
|
{
|
||||||
std::stringstream usage;
|
std::stringstream usage;
|
||||||
Opm::Parameters::printUsage("===foobar===", "", usage, true);
|
Opm::Parameters::printUsage("===foobar===", usage, "", true);
|
||||||
BOOST_CHECK_EQUAL(trimString(usage.str()),
|
BOOST_CHECK_EQUAL(trimString(usage.str()),
|
||||||
trimString(R"(===foobar===
|
trimString(R"(===foobar===
|
||||||
Recognized options:
|
Recognized options:
|
||||||
|
Loading…
Reference in New Issue
Block a user