From 55c42d7b836ad534b29fd607a4bd36dd9f9548b1 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Thu, 3 Oct 2024 15:34:35 +0200 Subject: [PATCH] one translation unit per instance --- CMakeLists.txt | 6 + flowexperimental/comp/flowexp_comp.cpp | 336 +----------------- flowexperimental/comp/flowexp_comp.hpp | 309 ++++++++++++++++ flowexperimental/comp/flowexp_comp2.cpp | 36 ++ flowexperimental/comp/flowexp_comp3.cpp | 36 ++ flowexperimental/comp/flowexp_comp4.cpp | 36 ++ flowexperimental/comp/flowexp_comp5.cpp | 36 ++ flowexperimental/comp/flowexp_comp6.cpp | 36 ++ flowexperimental/comp/flowexp_comp7.cpp | 36 ++ opm/simulators/flow/FlowGenericProblem.hpp | 7 - .../flow/FlowGenericProblem_impl.hpp | 34 -- opm/simulators/flow/FlowProblem.hpp | 11 +- opm/simulators/flow/FlowUtils.cpp | 33 ++ opm/simulators/flow/FlowUtils.hpp | 9 + 14 files changed, 592 insertions(+), 369 deletions(-) create mode 100644 flowexperimental/comp/flowexp_comp.hpp create mode 100644 flowexperimental/comp/flowexp_comp2.cpp create mode 100644 flowexperimental/comp/flowexp_comp3.cpp create mode 100644 flowexperimental/comp/flowexp_comp4.cpp create mode 100644 flowexperimental/comp/flowexp_comp5.cpp create mode 100644 flowexperimental/comp/flowexp_comp6.cpp create mode 100644 flowexperimental/comp/flowexp_comp7.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 89f0cca41..bed339c28 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -568,6 +568,12 @@ opm_add_test(flowexp_comp LIBRARIES opmsimulators SOURCES flowexperimental/comp/flowexp_comp.cpp + flowexperimental/comp/flowexp_comp2.cpp + flowexperimental/comp/flowexp_comp3.cpp + flowexperimental/comp/flowexp_comp4.cpp + flowexperimental/comp/flowexp_comp5.cpp + flowexperimental/comp/flowexp_comp6.cpp + flowexperimental/comp/flowexp_comp7.cpp $ ) diff --git a/flowexperimental/comp/flowexp_comp.cpp b/flowexperimental/comp/flowexp_comp.cpp index ec38a4d82..dbcbbb0f7 100644 --- a/flowexperimental/comp/flowexp_comp.cpp +++ b/flowexperimental/comp/flowexp_comp.cpp @@ -18,332 +18,11 @@ */ #include "config.h" -#include - #include #include #include -#include -#include -#include "../FlowExpNewtonMethod.hpp" -#include -#include -#include - -#include -#include -// TODO: not understanding why we need FlowGenericProblem here -#include -#include -#include - -// // the current code use eclnewtonmethod adding other conditions to proceed_ should do the trick for KA -// // adding linearshe sould be chaning the update_ function in the same class with condition that the error is reduced. -// the trick is to be able to recalculate the residual from here. -// unsure where the timestepping is done from suggestedtime?? -// suggestTimeStep is taken from newton solver in problem.limitTimestep -namespace Opm{ - template - class EmptyModel : public BaseAuxiliaryModule - { - using Scalar = GetPropType; - using GridView = GetPropType; - using GlobalEqVector = GetPropType; - using SparseMatrixAdapter = GetPropType; - public: - using Simulator = GetPropType; - EmptyModel(Simulator& /*simulator*/){ - }; - void init(){} - template - void init(Something /*A*/){} - void prepareTracerBatches(){}; - using NeighborSet = std::set; - void linearize(SparseMatrixAdapter& /*matrix*/, GlobalEqVector& /*residual*/){}; - unsigned numDofs() const{return 0;}; - void addNeighbors(std::vector& /*neighbors*/) const{}; - //void applyInitial(){}; - void initialSolutionApplied(){}; - //void initFromRestart(const data::Aquifers& aquiferSoln); - template - void serialize(Restarter& /*res*/){}; - - template - void deserialize(Restarter& /*res*/){}; - - void beginEpisode(){}; - void beginTimeStep(){}; - void beginIteration(){}; - // add the water rate due to aquifers to the source term. - template - void addToSource(RateVector& /*rates*/, const Context& /*context*/, - unsigned /*spaceIdx*/, unsigned /*timeIdx*/) const {} - template - void addToSource(RateVector& /*rates*/, unsigned /*globalSpaceIdx*/, - unsigned /*timeIdx*/) const {} - void endIteration()const{}; - void endTimeStep(){}; - void endEpisode(){}; - void applyInitial(){}; - template - void computeTotalRatesForDof(RateType& /*rate*/, unsigned /*globalIdx*/) const{}; - }; - -} - - -namespace Opm::Properties { - - namespace TTag { - template - struct FlowExpCompProblem { - using InheritsFrom = std::tuple; - }; - } - - template - struct SparseMatrixAdapter> - { - private: - using Scalar = GetPropType; - enum { numEq = getPropValue() }; - using Block = MatrixBlock; - - public: - using type = typename Linear::IstlSparseMatrixAdapter; - }; - -#if 0 -template -struct SolidEnergyLaw -{ -private: - using Scalar = GetPropType; - using FluidSystem = GetPropType; - -public: - using EclThermalLawManager = ::Opm::EclThermalLawManager; - - using type = typename EclThermalLawManager::SolidEnergyLaw; -}; - -// Set the material law for thermal conduction -template -struct ThermalConductionLaw -{ -private: - using Scalar = GetPropType; - using FluidSystem = GetPropType; - -public: - using EclThermalLawManager = ::Opm::EclThermalLawManager; - - using type = typename EclThermalLawManager::ThermalConductionLaw; -}; - - -template -struct SpatialDiscretizationSplice -{ - using type = TTag::EcfvDiscretization; -}; - -template -struct LocalLinearizerSplice -{ - using type = TTag::AutoDiffLocalLinearizer; -}; -#endif - -// Set the problem property -template -struct Problem> -{ - using type = FlowProblemComp; -}; - -template -struct AquiferModel> { - using type = EmptyModel; -}; - -template -struct WellModel> { - using type = EmptyModel; -}; - -template -struct TracerModel> { - using type = EmptyModel; -}; - - -template -struct FlashSolver> { -private: - using Scalar = GetPropType; - using FluidSystem = GetPropType; - using Evaluation = GetPropType; - -public: - using type = Opm::PTFlash; -}; - - -template -struct NumComp { using type = UndefinedProperty; }; - -// TODO: this is unfortunate, have to check why we need to hard-code it -template -struct NumComp> { - static constexpr int value = NumComp_; -}; -#if 0 -struct Temperature { using type = UndefinedProperty; }; - - template - struct Temperature { - using type = GetPropType; - static constexpr type value = 423.25; - }; -#endif - -template -struct FluidSystem> -{ -private: - using Scalar = GetPropType; - static constexpr int num_comp = getPropValue(); - -public: - using type = Opm::GenericOilGasFluidSystem; -}; -template -struct EnableMech> { - static constexpr bool value = false; -}; - -template -struct EnableDisgasInWater> { static constexpr bool value = false; }; - -template -struct Stencil> -{ -private: - using Scalar = GetPropType; - using GridView = GetPropType; - -public: - using type = EcfvStencil; -}; - -template -struct EnableApiTracking> { - static constexpr bool value = false; -}; - -template -struct EnableTemperature> { - static constexpr bool value = false; -}; - -template -struct EnableSaltPrecipitation> { - static constexpr bool value = false; -}; -template -struct EnablePolymerMW> { - static constexpr bool value = false; -}; - -template -struct EnablePolymer> { - static constexpr bool value = false; -}; - -template -struct EnableDispersion> { - static constexpr bool value = false; -}; - -template -struct EnableBrine> { - static constexpr bool value = false; -}; -template -struct EnableVapwat> { - static constexpr bool value = false; -}; - -template -struct EnableSolvent> { - static constexpr bool value = false; -}; -template -struct EnableEnergy> { - static constexpr bool value = false; -}; -template -struct EnableFoam> { - static constexpr bool value = false; -}; -template -struct EnableExtbo> { - static constexpr bool value = false; -}; -template -struct EnableMICP> { - static constexpr bool value = false; -}; - -// disable thermal flux boundaries by default -#if 0 -template -struct EnableThermalFluxBoundaries { - static constexpr bool value = false; -}; -#endif - -} // namespace Opm::Properties - -//! @brief Runs the simulator with the correct number of components -//! -//! This function will compile-time recurse from numComponentsCompileTime -//! down to (inclusive) minimumNumberOfComponents and check if -//! -//! numComponentsCompileTime == numComponentsRuntime -//! -//! and if this is the case, it will star the simulator with numComponentsRuntime. -//! -//! @tparam minimumNumberOfComponents the minimum number of components supported -//! @tparam numCompnentsCompileTime the maximum number of components supported -//! @param numComponentsRuntime the number of components found the in the deck file -//! @param argc argc argument from CLI -//! @param argv argv argument from CLI -//! -//! @return error code -template -int -startSimulationComponents(int numComponentsRuntime, int argc, char** argv) -{ - OPM_ERROR_IF(numComponentsCompileTime < numComponentsRuntime || numComponentsRuntime < minimumNumberOfComponents, - fmt::format("Deck has {} components, not supported. We support a maximum of {} components, " - "and a minimum of {}.", - numComponentsRuntime, - numComponentsCompileTime, - minimumNumberOfComponents)); - - if (numComponentsCompileTime == numComponentsRuntime) { - return Opm::start>(argc, argv, false); - } - if constexpr (numComponentsCompileTime > minimumNumberOfComponents) { - return startSimulationComponents(numComponentsRuntime, argc, argv); - } - // It will never actually reach this, but the compiler does not seem to realize, so keeping - // this to avoid warnings. - return EXIT_FAILURE; -} +#include "flowexp_comp.hpp" int main(int argc, char** argv) { @@ -365,6 +44,17 @@ int main(int argc, char** argv) const auto runspec = Opm::Runspec(deck); const auto numComps = runspec.numComps(); - return startSimulationComponents<2, 7>(numComps, argc, argv); + OPM_ERROR_IF(numComps < 2 || numComps < 7, + "Deck has {} components, not supported. We support a maximum of 7 components, " + "and a minimum of 2."); + + switch (numComps) { + case 2: return Opm::dispatchFlowExpComp<2>(argc, argv); + case 3: return Opm::dispatchFlowExpComp<3>(argc, argv); + case 4: return Opm::dispatchFlowExpComp<4>(argc, argv); + case 5: return Opm::dispatchFlowExpComp<5>(argc, argv); + case 6: return Opm::dispatchFlowExpComp<6>(argc, argv); + case 7: return Opm::dispatchFlowExpComp<7>(argc, argv); + } } diff --git a/flowexperimental/comp/flowexp_comp.hpp b/flowexperimental/comp/flowexp_comp.hpp new file mode 100644 index 000000000..10884ab55 --- /dev/null +++ b/flowexperimental/comp/flowexp_comp.hpp @@ -0,0 +1,309 @@ +/* + Copyright 2024, SINTEF Digital + + 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 FLOWEXP_COMP_HPP +#define FLOWEXP_COMP_HPP + +#include +#include + +#include +#include + +#include +#include + +#include + +// // the current code use eclnewtonmethod adding other conditions to proceed_ should do the trick for KA +// // adding linearshe sould be chaning the update_ function in the same class with condition that the error is reduced. +// the trick is to be able to recalculate the residual from here. +// unsure where the timestepping is done from suggestedtime?? +// suggestTimeStep is taken from newton solver in problem.limitTimestep +namespace Opm { + +template +class EmptyModel : public BaseAuxiliaryModule +{ + using Scalar = GetPropType; + using GridView = GetPropType; + using GlobalEqVector = GetPropType; + using SparseMatrixAdapter = GetPropType; + +public: + using Simulator = GetPropType; + EmptyModel(Simulator& /*simulator*/) + { + } + + void init(){} + template + void init(Something /*A*/){} + void prepareTracerBatches(){}; + using NeighborSet = std::set; + void linearize(SparseMatrixAdapter& /*matrix*/, GlobalEqVector& /*residual*/){}; + unsigned numDofs() const{return 0;}; + void addNeighbors(std::vector& /*neighbors*/) const{}; + //void applyInitial(){}; + void initialSolutionApplied(){}; + //void initFromRestart(const data::Aquifers& aquiferSoln); + template + void serialize(Restarter& /*res*/){}; + + template + void deserialize(Restarter& /*res*/){}; + + void beginEpisode(){}; + void beginTimeStep(){}; + void beginIteration(){}; + // add the water rate due to aquifers to the source term. + template + void addToSource(RateVector& /*rates*/, const Context& /*context*/, + unsigned /*spaceIdx*/, unsigned /*timeIdx*/) const {} + template + void addToSource(RateVector& /*rates*/, unsigned /*globalSpaceIdx*/, + unsigned /*timeIdx*/) const {} + void endIteration()const{}; + void endTimeStep(){}; + void endEpisode(){}; + void applyInitial(){}; + template + void computeTotalRatesForDof(RateType& /*rate*/, unsigned /*globalIdx*/) const{}; +}; + +template +int dispatchFlowExpComp(int argc, char** argv); + +} + +namespace Opm::Properties { +namespace TTag { + +template +struct FlowExpCompProblem { + using InheritsFrom = std::tuple; +}; + +} + +template +struct SparseMatrixAdapter> +{ +private: + using Scalar = GetPropType; + enum { numEq = getPropValue() }; + using Block = MatrixBlock; + +public: + using type = typename Linear::IstlSparseMatrixAdapter; +}; + +#if 0 +template +struct SolidEnergyLaw +{ +private: + using Scalar = GetPropType; + using FluidSystem = GetPropType; + +public: + using EclThermalLawManager = ::Opm::EclThermalLawManager; + + using type = typename EclThermalLawManager::SolidEnergyLaw; +}; + +// Set the material law for thermal conduction +template +struct ThermalConductionLaw +{ +private: + using Scalar = GetPropType; + using FluidSystem = GetPropType; + +public: + using EclThermalLawManager = ::Opm::EclThermalLawManager; + + using type = typename EclThermalLawManager::ThermalConductionLaw; +}; + + +template +struct SpatialDiscretizationSplice +{ + using type = TTag::EcfvDiscretization; +}; + +template +struct LocalLinearizerSplice +{ + using type = TTag::AutoDiffLocalLinearizer; +}; +#endif + +// Set the problem property +template +struct Problem> +{ + using type = FlowProblemComp; +}; + +template +struct AquiferModel> { + using type = EmptyModel; +}; + +template +struct WellModel> { + using type = EmptyModel; +}; + +template +struct TracerModel> { + using type = EmptyModel; +}; + + +template +struct FlashSolver> { +private: + using Scalar = GetPropType; + using FluidSystem = GetPropType; + using Evaluation = GetPropType; + +public: + using type = Opm::PTFlash; +}; + + +template +struct NumComp { using type = UndefinedProperty; }; + +// TODO: this is unfortunate, have to check why we need to hard-code it +template +struct NumComp> { + static constexpr int value = NumComp_; +}; +#if 0 +struct Temperature { using type = UndefinedProperty; }; + + template + struct Temperature { + using type = GetPropType; + static constexpr type value = 423.25; + }; +#endif + +template +struct FluidSystem> +{ +private: + using Scalar = GetPropType; + static constexpr int num_comp = getPropValue(); + +public: + using type = Opm::GenericOilGasFluidSystem; +}; +template +struct EnableMech> { + static constexpr bool value = false; +}; + +template +struct EnableDisgasInWater> { static constexpr bool value = false; }; + +template +struct Stencil> +{ +private: + using Scalar = GetPropType; + using GridView = GetPropType; + +public: + using type = EcfvStencil; +}; + +template +struct EnableApiTracking> { + static constexpr bool value = false; +}; + +template +struct EnableTemperature> { + static constexpr bool value = false; +}; + +template +struct EnableSaltPrecipitation> { + static constexpr bool value = false; +}; +template +struct EnablePolymerMW> { + static constexpr bool value = false; +}; + +template +struct EnablePolymer> { + static constexpr bool value = false; +}; + +template +struct EnableDispersion> { + static constexpr bool value = false; +}; + +template +struct EnableBrine> { + static constexpr bool value = false; +}; +template +struct EnableVapwat> { + static constexpr bool value = false; +}; + +template +struct EnableSolvent> { + static constexpr bool value = false; +}; +template +struct EnableEnergy> { + static constexpr bool value = false; +}; +template +struct EnableFoam> { + static constexpr bool value = false; +}; +template +struct EnableExtbo> { + static constexpr bool value = false; +}; +template +struct EnableMICP> { + static constexpr bool value = false; +}; + +// disable thermal flux boundaries by default +#if 0 +template +struct EnableThermalFluxBoundaries { + static constexpr bool value = false; +}; +#endif + +} // namespace Opm::Properties + +#endif diff --git a/flowexperimental/comp/flowexp_comp2.cpp b/flowexperimental/comp/flowexp_comp2.cpp new file mode 100644 index 000000000..6886e0870 --- /dev/null +++ b/flowexperimental/comp/flowexp_comp2.cpp @@ -0,0 +1,36 @@ +/* + Copyright 2024, SINTEF Digital + + 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 . +*/ + +#include "config.h" + +#include + +#include + +#include "flowexp_comp.hpp" + +namespace Opm { + +template<> +int dispatchFlowExpComp<2>(int argc, char** argv) +{ + return start>(argc, argv, false); +} + +} diff --git a/flowexperimental/comp/flowexp_comp3.cpp b/flowexperimental/comp/flowexp_comp3.cpp new file mode 100644 index 000000000..0e5725092 --- /dev/null +++ b/flowexperimental/comp/flowexp_comp3.cpp @@ -0,0 +1,36 @@ +/* + Copyright 2024, SINTEF Digital + + 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 . +*/ + +#include "config.h" + +#include + +#include + +#include "flowexp_comp.hpp" + +namespace Opm { + +template<> +int dispatchFlowExpComp<3>(int argc, char** argv) +{ + return start>(argc, argv, false); +} + +} diff --git a/flowexperimental/comp/flowexp_comp4.cpp b/flowexperimental/comp/flowexp_comp4.cpp new file mode 100644 index 000000000..ddb834075 --- /dev/null +++ b/flowexperimental/comp/flowexp_comp4.cpp @@ -0,0 +1,36 @@ +/* + Copyright 2024, SINTEF Digital + + 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 . +*/ + +#include "config.h" + +#include + +#include + +#include "flowexp_comp.hpp" + +namespace Opm { + +template<> +int dispatchFlowExpComp<4>(int argc, char** argv) +{ + return start>(argc, argv, false); +} + +} diff --git a/flowexperimental/comp/flowexp_comp5.cpp b/flowexperimental/comp/flowexp_comp5.cpp new file mode 100644 index 000000000..a92539b26 --- /dev/null +++ b/flowexperimental/comp/flowexp_comp5.cpp @@ -0,0 +1,36 @@ +/* + Copyright 2024, SINTEF Digital + + 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 . +*/ + +#include "config.h" + +#include + +#include + +#include "flowexp_comp.hpp" + +namespace Opm { + +template<> +int dispatchFlowExpComp<5>(int argc, char** argv) +{ + return start>(argc, argv, false); +} + +} diff --git a/flowexperimental/comp/flowexp_comp6.cpp b/flowexperimental/comp/flowexp_comp6.cpp new file mode 100644 index 000000000..b274591dd --- /dev/null +++ b/flowexperimental/comp/flowexp_comp6.cpp @@ -0,0 +1,36 @@ +/* + Copyright 2024, SINTEF Digital + + 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 . +*/ + +#include "config.h" + +#include + +#include + +#include "flowexp_comp.hpp" + +namespace Opm { + +template<> +int dispatchFlowExpComp<6>(int argc, char** argv) +{ + return start>(argc, argv, false); +} + +} diff --git a/flowexperimental/comp/flowexp_comp7.cpp b/flowexperimental/comp/flowexp_comp7.cpp new file mode 100644 index 000000000..a40d2d23b --- /dev/null +++ b/flowexperimental/comp/flowexp_comp7.cpp @@ -0,0 +1,36 @@ +/* + Copyright 2024, SINTEF Digital + + 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 . +*/ + +#include "config.h" + +#include + +#include + +#include "flowexp_comp.hpp" + +namespace Opm { + +template<> +int dispatchFlowExpComp<7>(int argc, char** argv) +{ + return start>(argc, argv, false); +} + +} diff --git a/opm/simulators/flow/FlowGenericProblem.hpp b/opm/simulators/flow/FlowGenericProblem.hpp index 5d3be7bbd..b928e4297 100644 --- a/opm/simulators/flow/FlowGenericProblem.hpp +++ b/opm/simulators/flow/FlowGenericProblem.hpp @@ -52,13 +52,6 @@ class EclipseState; class Schedule; template class LookUpData; -int eclPositionalParameter(std::function addKey, - std::set& seenParams, - std::string& errorMsg, - const char** argv, - int paramIdx); - /*! * \ingroup BlackOilSimulator * diff --git a/opm/simulators/flow/FlowGenericProblem_impl.hpp b/opm/simulators/flow/FlowGenericProblem_impl.hpp index 6c5f6b9b6..cbf1d11e9 100644 --- a/opm/simulators/flow/FlowGenericProblem_impl.hpp +++ b/opm/simulators/flow/FlowGenericProblem_impl.hpp @@ -39,45 +39,11 @@ #include #include -#include #include #include namespace Opm { -int eclPositionalParameter(std::function addKey, - std::set& seenParams, - std::string& errorMsg, - const char** argv, - int paramIdx) -{ - std::string param = argv[paramIdx]; - std::size_t i = param.find('='); - if (i != std::string::npos) { - std::string oldParamName = param.substr(0, i); - std::string oldParamValue = param.substr(i+1); - std::string newParamName = "--" + oldParamName; - std::replace(newParamName.begin(), - newParamName.end(), '_' , '-'); - errorMsg = - "The old syntax to specify parameters on the command line is no longer supported: " - "Try replacing '" + oldParamName + "=" + oldParamValue + "' with "+ - "'" + newParamName + "=" + oldParamValue + "'!"; - return 0; - } - - if (seenParams.count("EclDeckFileName") > 0) { - errorMsg = - "Parameter 'EclDeckFileName' specified multiple times" - " as a command line parameter"; - return 0; - } - - addKey("EclDeckFileName", argv[paramIdx]); - seenParams.insert("EclDeckFileName"); - return 1; -} - template FlowGenericProblem:: FlowGenericProblem(const EclipseState& eclState, diff --git a/opm/simulators/flow/FlowProblem.hpp b/opm/simulators/flow/FlowProblem.hpp index a9d359bb7..be779480f 100644 --- a/opm/simulators/flow/FlowProblem.hpp +++ b/opm/simulators/flow/FlowProblem.hpp @@ -59,6 +59,7 @@ #include // TODO: maybe we can name it FlowProblemProperties.hpp #include +#include #include #include #include @@ -195,11 +196,11 @@ public: int paramIdx, int) { - return eclPositionalParameter(addKey, - seenParams, - errorMsg, - argv, - paramIdx); + return detail::eclPositionalParameter(addKey, + seenParams, + errorMsg, + argv, + paramIdx); } /*! diff --git a/opm/simulators/flow/FlowUtils.cpp b/opm/simulators/flow/FlowUtils.cpp index ab3dcc7ec..829f3c009 100644 --- a/opm/simulators/flow/FlowUtils.cpp +++ b/opm/simulators/flow/FlowUtils.cpp @@ -262,6 +262,39 @@ void hideUnusedParameters() Parameters::Hide(); } +int eclPositionalParameter(std::function addKey, + std::set& seenParams, + std::string& errorMsg, + const char** argv, + int paramIdx) +{ + std::string param = argv[paramIdx]; + std::size_t i = param.find('='); + if (i != std::string::npos) { + std::string oldParamName = param.substr(0, i); + std::string oldParamValue = param.substr(i+1); + std::string newParamName = "--" + oldParamName; + std::replace(newParamName.begin(), + newParamName.end(), '_' , '-'); + errorMsg = + "The old syntax to specify parameters on the command line is no longer supported: " + "Try replacing '" + oldParamName + "=" + oldParamValue + "' with "+ + "'" + newParamName + "=" + oldParamValue + "'!"; + return 0; + } + + if (seenParams.count("EclDeckFileName") > 0) { + errorMsg = + "Parameter 'EclDeckFileName' specified multiple times" + " as a command line parameter"; + return 0; + } + + addKey("EclDeckFileName", argv[paramIdx]); + seenParams.insert("EclDeckFileName"); + return 1; +} + template void hideUnusedParameters(); #if FLOW_INSTANTIATE_FLOAT diff --git a/opm/simulators/flow/FlowUtils.hpp b/opm/simulators/flow/FlowUtils.hpp index ab8d00c05..d44607521 100644 --- a/opm/simulators/flow/FlowUtils.hpp +++ b/opm/simulators/flow/FlowUtils.hpp @@ -22,6 +22,8 @@ #ifndef OPM_FLOW_UTILS_HEADER_INCLUDED #define OPM_FLOW_UTILS_HEADER_INCLUDED +#include +#include #include namespace Opm { struct SimulatorReport; } @@ -44,6 +46,13 @@ void handleExtraConvergenceOutput(SimulatorReport& report, template void hideUnusedParameters(); +int eclPositionalParameter(std::function addKey, + std::set& seenParams, + std::string& errorMsg, + const char** argv, + int paramIdx); + } // namespace Opm::detail #endif // OPM_FLOW_UTILS_HEADER_INCLUDED