From 02d0f8cc63e29b846b44eafd0e732f4f649a5277 Mon Sep 17 00:00:00 2001 From: David Landa Marban Date: Thu, 11 Sep 2025 17:49:41 +0200 Subject: [PATCH 1/2] BIOFILM effects for gas-water systems --- CMakeLists.txt | 2 +- CMakeLists_files.cmake | 16 +- flow/flow_biofilm.cpp | 124 ++++ flow/flow_biofilm.hpp | 27 + flow/flow_biofilm_main.cpp | 21 + flow/flow_gasoil.cpp | 2 +- flow/flow_gasoil_energy.cpp | 2 +- flow/flow_gasoildiffuse.cpp | 2 +- flow/flow_gaswater.cpp | 2 +- flow/flow_gaswater_brine.cpp | 2 +- flow/flow_gaswater_dissolution.cpp | 2 +- flow/flow_gaswater_dissolution_diffuse.cpp | 2 +- flow/flow_gaswater_energy.cpp | 2 +- flow/flow_gaswater_saltprec_energy.cpp | 2 +- flow/flow_gaswater_saltprec_vapwat.cpp | 2 +- flow/flow_gaswater_solvent.cpp | 2 +- flow/flow_micp.cpp | 7 +- flow/flow_oilwater.cpp | 2 +- flow/flow_oilwater_brine.cpp | 2 +- flow/flow_oilwater_polymer.cpp | 2 +- flow/flow_oilwater_polymer_injectivity.cpp | 2 +- flow/flow_onephase.cpp | 2 +- flow/flow_onephase_energy.cpp | 2 +- ...BlackOilIntensiveQuantitiesGlobalIndex.hpp | 8 +- flowexperimental/comp/flowexp_comp.hpp | 2 +- .../blackoil/blackoilbioeffectsmodules.hh | 666 ++++++++++++++++++ .../blackoil/blackoilbioeffectsparams.cpp | 182 +++++ ...arams.hpp => blackoilbioeffectsparams.hpp} | 51 +- .../blackoil/blackoilboundaryratevector.hh | 2 +- .../blackoil/blackoildiffusionmodule.hh | 154 ++-- .../blackoil/blackoildispersionmodule.hh | 105 ++- .../blackoil/blackoilextensivequantities.hh | 4 +- .../blackoil/blackoilintensivequantities.hh | 49 +- opm/models/blackoil/blackoillocalresidual.hh | 15 +- .../blackoil/blackoillocalresidualtpfa.hh | 40 +- opm/models/blackoil/blackoilmicpmodules.hh | 542 -------------- opm/models/blackoil/blackoilmicpparams.cpp | 146 ---- opm/models/blackoil/blackoilmodel.hh | 14 +- opm/models/blackoil/blackoilnewtonmethod.hpp | 32 +- .../blackoil/blackoilonephaseindices.hh | 14 +- .../blackoil/blackoilprimaryvariables.hh | 39 +- opm/models/blackoil/blackoilproperties.hh | 4 +- opm/models/blackoil/blackoilratevector.hh | 9 +- .../blackoil/blackoiltwophaseindices.hh | 78 +- .../blackoilvariableandequationindices.hh | 77 +- .../discretization/common/tpfalinearizer.hh | 17 +- ...le.hpp => vtkblackoilbioeffectsmodule.hpp} | 111 ++- ...ms.cpp => vtkblackoilbioeffectsparams.cpp} | 32 +- ...ms.hpp => vtkblackoilbioeffectsparams.hpp} | 16 +- opm/models/ptflash/flashindices.hh | 3 + ...PContainer.cpp => BioeffectsContainer.cpp} | 114 +-- ...PContainer.hpp => BioeffectsContainer.hpp} | 41 +- opm/simulators/flow/BlackoilModel.hpp | 3 +- .../flow/BlackoilModelProperties.hpp | 2 +- opm/simulators/flow/BlackoilModel_impl.hpp | 42 +- opm/simulators/flow/CpGridVanguard.hpp | 8 +- .../flow/FlowBaseProblemProperties.hpp | 2 +- opm/simulators/flow/FlowGenericProblem.hpp | 5 +- .../flow/FlowGenericProblem_impl.hpp | 65 +- opm/simulators/flow/FlowProblem.hpp | 7 +- opm/simulators/flow/FlowProblemBlackoil.hpp | 38 +- .../flow/GenericOutputBlackoilModule.cpp | 21 +- .../flow/GenericOutputBlackoilModule.hpp | 12 +- opm/simulators/flow/Main.hpp | 10 + opm/simulators/flow/MainDispatchDynamic.cpp | 23 + opm/simulators/flow/OutputBlackoilModule.hpp | 48 +- .../flow/OutputCompositionalModule.hpp | 2 +- .../flow/SimulatorFullyImplicitBlackoil.hpp | 3 +- opm/simulators/flow/SolutionContainers.cpp | 12 +- opm/simulators/flow/SolutionContainers.hpp | 6 +- opm/simulators/utils/ComponentName.cpp | 5 + .../utils/InstantiationIndicesMacros.hpp | 1 + opm/simulators/wells/BlackoilWellModel.hpp | 4 +- opm/simulators/wells/StandardWell.hpp | 3 +- .../wells/StandardWellConnections.cpp | 27 +- .../wells/StandardWellConnections.hpp | 5 + opm/simulators/wells/StandardWell_impl.hpp | 57 +- opm/simulators/wells/WellInterface.hpp | 3 +- opm/simulators/wells/WellState.cpp | 16 +- python/simulators/PyGasWaterSimulator.cpp | 16 +- regressionTests.cmake | 8 + 81 files changed, 1904 insertions(+), 1348 deletions(-) create mode 100644 flow/flow_biofilm.cpp create mode 100644 flow/flow_biofilm.hpp create mode 100644 flow/flow_biofilm_main.cpp create mode 100644 opm/models/blackoil/blackoilbioeffectsmodules.hh create mode 100644 opm/models/blackoil/blackoilbioeffectsparams.cpp rename opm/models/blackoil/{blackoilmicpparams.hpp => blackoilbioeffectsparams.hpp} (54%) delete mode 100644 opm/models/blackoil/blackoilmicpmodules.hh delete mode 100644 opm/models/blackoil/blackoilmicpparams.cpp rename opm/models/io/{vtkblackoilmicpmodule.hpp => vtkblackoilbioeffectsmodule.hpp} (64%) rename opm/models/io/{vtkblackoilmicpparams.cpp => vtkblackoilbioeffectsparams.cpp} (59%) rename opm/models/io/{vtkblackoilmicpparams.hpp => vtkblackoilbioeffectsparams.hpp} (82%) rename opm/simulators/flow/{MICPContainer.cpp => BioeffectsContainer.cpp} (54%) rename opm/simulators/flow/{MICPContainer.hpp => BioeffectsContainer.hpp} (60%) diff --git a/CMakeLists.txt b/CMakeLists.txt index de430e9a783..94c52f196be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -577,7 +577,7 @@ set(FLOW_MODELS blackoil brine energy extbo foam gasoil gaswater gasoil_energy brine_saltprecipitation gaswater_saltprec_vapwat gaswater_saltprec_energy brine_precsalt_vapwat blackoil_legacyassembly gasoildiffuse gaswater_dissolution - gaswater_dissolution_diffuse gaswater_energy gaswater_solvent) + gaswater_dissolution_diffuse gaswater_energy gaswater_solvent biofilm) set(FLOW_VARIANT_MODELS brine_energy onephase onephase_energy) set(FLOW_TGTS) diff --git a/CMakeLists_files.cmake b/CMakeLists_files.cmake index f88979eab4f..d7d5a5be8e1 100644 --- a/CMakeLists_files.cmake +++ b/CMakeLists_files.cmake @@ -77,15 +77,15 @@ list (APPEND MAIN_SOURCE_FILES flowexperimental/FIBlackOilModelNoCache.hpp flowexperimental/flowexp.hpp flowexperimental/FlowExpNewtonMethod.hpp + opm/models/blackoil/blackoilbioeffectsparams.cpp opm/models/blackoil/blackoilbrineparams.cpp opm/models/blackoil/blackoilextboparams.cpp opm/models/blackoil/blackoilfoamparams.cpp - opm/models/blackoil/blackoilmicpparams.cpp opm/models/blackoil/blackoilnewtonmethodparams.cpp opm/models/blackoil/blackoilpolymerparams.cpp opm/models/blackoil/blackoilsolventparams.cpp + opm/models/io/vtkblackoilbioeffectsparams.cpp opm/models/io/vtkblackoilenergyparams.cpp - opm/models/io/vtkblackoilmicpparams.cpp opm/models/io/vtkblackoilpolymerparams.cpp opm/models/io/vtkblackoilparams.cpp opm/models/io/vtkblackoilsolventparams.cpp @@ -108,6 +108,7 @@ list (APPEND MAIN_SOURCE_FILES opm/models/utils/timer.cpp opm/simulators/flow/ActionHandler.cpp opm/simulators/flow/Banners.cpp + opm/simulators/flow/BioeffectsContainer.cpp opm/simulators/flow/BlackoilModelParameters.cpp opm/simulators/flow/BlackoilModelConvergenceMonitor.cpp opm/simulators/flow/CollectDataOnIORank.cpp @@ -131,7 +132,6 @@ list (APPEND MAIN_SOURCE_FILES opm/simulators/flow/LogOutputHelper.cpp opm/simulators/flow/Main.cpp opm/simulators/flow/MechContainer.cpp - opm/simulators/flow/MICPContainer.cpp opm/simulators/flow/MixingRateControls.cpp opm/simulators/flow/NlddReporting.cpp opm/simulators/flow/NonlinearSolver.cpp @@ -668,6 +668,8 @@ list (APPEND TEST_DATA_FILES # originally generated with the command: # find opm -name '*.h*' -a ! -name '*-pch.hpp' -printf '\t%p\n' | sort list (APPEND PUBLIC_HEADER_FILES + opm/models/blackoil/blackoilbioeffectsmodules.hh + opm/models/blackoil/blackoilbioeffectsparams.hpp opm/models/blackoil/blackoilboundaryratevector.hh opm/models/blackoil/blackoilbrinemodules.hh opm/models/blackoil/blackoilbrineparams.hpp @@ -685,8 +687,6 @@ list (APPEND PUBLIC_HEADER_FILES opm/models/blackoil/blackoilintensivequantities.hh opm/models/blackoil/blackoillocalresidual.hh opm/models/blackoil/blackoillocalresidualtpfa.hh - opm/models/blackoil/blackoilmicpmodules.hh - opm/models/blackoil/blackoilmicpparams.hpp opm/models/blackoil/blackoilmodel.hh opm/models/blackoil/blackoilnewtonmethod.hpp opm/models/blackoil/blackoilnewtonmethodparams.hpp @@ -783,10 +783,10 @@ list (APPEND PUBLIC_HEADER_FILES opm/models/io/simplexvanguard.hh opm/models/io/structuredgridvanguard.hh opm/models/io/unstructuredgridvanguard.hh + opm/models/io/vtkblackoilbioeffectsmodule.hpp + opm/models/io/vtkblackoilbioeffectsparams.hpp opm/models/io/vtkblackoilenergymodule.hpp opm/models/io/vtkblackoilenergyparams.hpp - opm/models/io/vtkblackoilmicpmodule.hpp - opm/models/io/vtkblackoilmicpparams.hpp opm/models/io/vtkblackoilmodule.hpp opm/models/io/vtkblackoilparams.hpp opm/models/io/vtkblackoilpolymermodule.hpp @@ -883,6 +883,7 @@ list (APPEND PUBLIC_HEADER_FILES opm/simulators/flow/AluGridVanguard.hpp opm/simulators/flow/Banners.hpp opm/simulators/flow/BaseAquiferModel.hpp + opm/simulators/flow/BioeffectsContainer.hpp opm/simulators/flow/BlackoilModel.hpp opm/simulators/flow/BlackoilModel_impl.hpp opm/simulators/flow/BlackoilModelConvergenceMonitor.hpp @@ -932,7 +933,6 @@ list (APPEND PUBLIC_HEADER_FILES opm/simulators/flow/LogOutputHelper.hpp opm/simulators/flow/Main.hpp opm/simulators/flow/MechContainer.hpp - opm/simulators/flow/MICPContainer.hpp opm/simulators/flow/MixingRateControls.hpp opm/simulators/flow/NewTranFluxModule.hpp opm/simulators/flow/NlddReporting.hpp diff --git a/flow/flow_biofilm.cpp b/flow/flow_biofilm.cpp new file mode 100644 index 00000000000..08fb20df17c --- /dev/null +++ b/flow/flow_biofilm.cpp @@ -0,0 +1,124 @@ +/* + 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" + +// Define making clear that the simulator supports AMG +#define FLOW_SUPPORT_AMG 1 + +#include + +#include +#include +#include +#include + +#include +#include +#include + +namespace Opm { +/*! + * \brief Two-phase (gas+water) flow problem including biofilm effects (one transported + * quantity: suspended microbes and one solid phase: biofilm). + */ +namespace Properties { +namespace TTag { +struct FlowBiofilmProblem { + using InheritsFrom = std::tuple; +}; +} + +template +struct EnableBioeffects { + static constexpr bool value = true; +}; + +template +struct EnableDiffusion { + static constexpr bool value = true; +}; + +template +struct EnableDispersion { + static constexpr bool value = true; +}; + +template +struct EnableDisgasInWater { + static constexpr bool value = true; +}; + +template +struct EnableVapwat { + static constexpr bool value = true; +}; + +template +struct Linearizer { using type = TpfaLinearizer; }; +template +struct LocalResidual { using type = BlackOilLocalResidualTPFA; }; + +//! The indices required by the model +template +struct Indices +{ +private: + // it is unfortunately not possible to simply use 'TypeTag' here because this leads + // to cyclic definitions of some properties. if this happens the compiler error + // messages unfortunately are *really* confusing and not really helpful. + using BaseTypeTag = TTag::FlowProblem; + using FluidSystem = GetPropType; + +public: + using type = BlackOilTwoPhaseIndices(), + getPropValue(), + getPropValue(), + getPropValue(), + getPropValue(), + getPropValue(), + /*PVOffset=*/0, + /*disabledCompIdx=*/FluidSystem::oilCompIdx, + 2>; //Two biocomponents (suspended microbes and biofilm) +}; +}} + +namespace Opm { + + +// ----------------- Main program ----------------- +int flowBiofilmMain(int argc, char** argv, bool outputCout, bool outputFiles) +{ + // we always want to use the default locale, and thus spare us the trouble + // with incorrect locale settings. + resetLocale(); + + FlowMain + mainfunc {argc, argv, outputCout, outputFiles} ; + return mainfunc.execute(); +} + +int flowBiofilmMainStandalone(int argc, char** argv) +{ + using TypeTag = Properties::TTag::FlowBiofilmProblem; + auto mainObject = std::make_unique(argc, argv); + auto ret = mainObject->runStatic(); + // Destruct mainObject as the destructor calls MPI_Finalize! + mainObject.reset(); + return ret; +} + +} // namespace Opm diff --git a/flow/flow_biofilm.hpp b/flow/flow_biofilm.hpp new file mode 100644 index 00000000000..71b7727784c --- /dev/null +++ b/flow/flow_biofilm.hpp @@ -0,0 +1,27 @@ +/* + 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 FLOW_BIOFILM_HPP +#define FLOW_BIOFILM_HPP + +namespace Opm { + +//! \brief Main function used in flow binary. +int flowBiofilmMain(int argc, char** argv, bool outputCout, bool outputFiles); + +//! \brief Main function used in flow_biofilm binary. +int flowBiofilmMainStandalone(int argc, char** argv); + +} + +#endif // FLOW_BIOFILM_HPP diff --git a/flow/flow_biofilm_main.cpp b/flow/flow_biofilm_main.cpp new file mode 100644 index 00000000000..9faf25d76f5 --- /dev/null +++ b/flow/flow_biofilm_main.cpp @@ -0,0 +1,21 @@ +/* + 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 + + +int main(int argc, char** argv) +{ + return Opm::flowBiofilmMainStandalone(argc, argv); +} diff --git a/flow/flow_gasoil.cpp b/flow/flow_gasoil.cpp index d3006447696..252957a7e87 100644 --- a/flow/flow_gasoil.cpp +++ b/flow/flow_gasoil.cpp @@ -65,7 +65,7 @@ struct Indices getPropValue(), /*PVOffset=*/0, /*disabledCompIdx=*/FluidSystem::waterCompIdx, - getPropValue()>; + getPropValue()>; }; }} diff --git a/flow/flow_gasoil_energy.cpp b/flow/flow_gasoil_energy.cpp index 52f1e69245a..88c773dbca1 100644 --- a/flow/flow_gasoil_energy.cpp +++ b/flow/flow_gasoil_energy.cpp @@ -55,7 +55,7 @@ struct Indices getPropValue(), /*PVOffset=*/0, /*disabledCompIdx=*/FluidSystem::waterCompIdx, - getPropValue()>; + getPropValue()>; }; template struct EnableEnergy { diff --git a/flow/flow_gasoildiffuse.cpp b/flow/flow_gasoildiffuse.cpp index 91a4c2604c1..99429e09194 100644 --- a/flow/flow_gasoildiffuse.cpp +++ b/flow/flow_gasoildiffuse.cpp @@ -67,7 +67,7 @@ struct Indices getPropValue(), /*PVOffset=*/0, /*disabledCompIdx=*/FluidSystem::waterCompIdx, - getPropValue()>; + getPropValue()>; }; }} diff --git a/flow/flow_gaswater.cpp b/flow/flow_gaswater.cpp index 1e2f9c06487..eb98ba7d958 100644 --- a/flow/flow_gaswater.cpp +++ b/flow/flow_gaswater.cpp @@ -63,7 +63,7 @@ struct Indices getPropValue(), /*PVOffset=*/0, /*disabledCompIdx=*/FluidSystem::oilCompIdx, - getPropValue()>; + getPropValue()>; }; }} diff --git a/flow/flow_gaswater_brine.cpp b/flow/flow_gaswater_brine.cpp index c3ba120a362..bdd12e7b0b7 100644 --- a/flow/flow_gaswater_brine.cpp +++ b/flow/flow_gaswater_brine.cpp @@ -64,7 +64,7 @@ struct Indices getPropValue(), /*PVOffset=*/0, /*disabledCompIdx=*/FluidSystem::oilCompIdx, - getPropValue()>; + getPropValue()>; }; }} diff --git a/flow/flow_gaswater_dissolution.cpp b/flow/flow_gaswater_dissolution.cpp index f4a8f4b27ea..954a75dbac3 100644 --- a/flow/flow_gaswater_dissolution.cpp +++ b/flow/flow_gaswater_dissolution.cpp @@ -78,7 +78,7 @@ struct Indices getPropValue(), /*PVOffset=*/0, /*disabledCompIdx=*/FluidSystem::oilCompIdx, - getPropValue()>; + getPropValue()>; }; }} diff --git a/flow/flow_gaswater_dissolution_diffuse.cpp b/flow/flow_gaswater_dissolution_diffuse.cpp index 52f3de8240c..19e7fcd46ba 100644 --- a/flow/flow_gaswater_dissolution_diffuse.cpp +++ b/flow/flow_gaswater_dissolution_diffuse.cpp @@ -81,7 +81,7 @@ struct Indices getPropValue(), /*PVOffset=*/0, /*disabledCompIdx=*/FluidSystem::oilCompIdx, - getPropValue()>; + getPropValue()>; }; }} diff --git a/flow/flow_gaswater_energy.cpp b/flow/flow_gaswater_energy.cpp index c7c59fbf595..8cdbd85d898 100644 --- a/flow/flow_gaswater_energy.cpp +++ b/flow/flow_gaswater_energy.cpp @@ -86,7 +86,7 @@ struct Indices getPropValue(), /*PVOffset=*/0, /*disabledCompIdx=*/FluidSystem::oilCompIdx, - getPropValue()>; + getPropValue()>; }; }} diff --git a/flow/flow_gaswater_saltprec_energy.cpp b/flow/flow_gaswater_saltprec_energy.cpp index cefa98ad488..c9f58c23d64 100644 --- a/flow/flow_gaswater_saltprec_energy.cpp +++ b/flow/flow_gaswater_saltprec_energy.cpp @@ -77,7 +77,7 @@ struct Indices getPropValue(), /*PVOffset=*/0, /*disabledCompIdx=*/FluidSystem::oilCompIdx, - getPropValue()>; + getPropValue()>; }; }} diff --git a/flow/flow_gaswater_saltprec_vapwat.cpp b/flow/flow_gaswater_saltprec_vapwat.cpp index 36f10b94199..2fd1c1244e9 100644 --- a/flow/flow_gaswater_saltprec_vapwat.cpp +++ b/flow/flow_gaswater_saltprec_vapwat.cpp @@ -72,7 +72,7 @@ struct Indices getPropValue(), /*PVOffset=*/0, /*disabledCompIdx=*/FluidSystem::oilCompIdx, - getPropValue()>; + getPropValue()>; }; }} diff --git a/flow/flow_gaswater_solvent.cpp b/flow/flow_gaswater_solvent.cpp index 8128be8c550..31eafe750d5 100644 --- a/flow/flow_gaswater_solvent.cpp +++ b/flow/flow_gaswater_solvent.cpp @@ -61,7 +61,7 @@ struct Indices getPropValue(), /*PVOffset=*/0, /*disabledCompIdx=*/FluidSystem::oilCompIdx, - getPropValue()>; + getPropValue()>; }; }} diff --git a/flow/flow_micp.cpp b/flow/flow_micp.cpp index 48edcd0bb69..f746da2c4df 100644 --- a/flow/flow_micp.cpp +++ b/flow/flow_micp.cpp @@ -29,6 +29,11 @@ #include namespace Opm { +/*! + * \brief Single-phase (water) flow problem including microbially induced calcite precipitation (MICP) + * effects (three transported quantities: suspended microbes, oxygen, and urea, and two solid phases: + * biofilm and calcite). + */ namespace Properties { namespace TTag { struct FlowMICPProblem { @@ -36,7 +41,7 @@ struct FlowMICPProblem { }; } template -struct EnableMICP { +struct EnableBioeffects { static constexpr bool value = true; }; template diff --git a/flow/flow_oilwater.cpp b/flow/flow_oilwater.cpp index b7b05a93827..84283b30dfb 100644 --- a/flow/flow_oilwater.cpp +++ b/flow/flow_oilwater.cpp @@ -66,7 +66,7 @@ struct Indices getPropValue(), /*PVOffset=*/0, /*disabledCompIdx=*/FluidSystem::gasCompIdx, - getPropValue()>; + getPropValue()>; }; }} diff --git a/flow/flow_oilwater_brine.cpp b/flow/flow_oilwater_brine.cpp index a3ab7aa4cbe..e794bafca6c 100644 --- a/flow/flow_oilwater_brine.cpp +++ b/flow/flow_oilwater_brine.cpp @@ -56,7 +56,7 @@ struct Indices getPropValue(), /*PVOffset=*/0, /*disabledCompIdx=*/FluidSystem::gasCompIdx, - getPropValue()>; + getPropValue()>; }; }} diff --git a/flow/flow_oilwater_polymer.cpp b/flow/flow_oilwater_polymer.cpp index 4fc5abeecc2..36266375138 100644 --- a/flow/flow_oilwater_polymer.cpp +++ b/flow/flow_oilwater_polymer.cpp @@ -56,7 +56,7 @@ struct Indices getPropValue(), /*PVOffset=*/0, /*disabledCompIdx=*/FluidSystem::gasCompIdx, - getPropValue()>; + getPropValue()>; }; }} diff --git a/flow/flow_oilwater_polymer_injectivity.cpp b/flow/flow_oilwater_polymer_injectivity.cpp index 3d970d287c5..ca716397d72 100644 --- a/flow/flow_oilwater_polymer_injectivity.cpp +++ b/flow/flow_oilwater_polymer_injectivity.cpp @@ -63,7 +63,7 @@ struct Indices getPropValue(), /*PVOffset=*/0, /*disabledCompIdx=*/FluidSystem::gasCompIdx, - getPropValue()>; + getPropValue()>; }; }} diff --git a/flow/flow_onephase.cpp b/flow/flow_onephase.cpp index 903f4105ed7..c418bf6bb63 100644 --- a/flow/flow_onephase.cpp +++ b/flow/flow_onephase.cpp @@ -63,7 +63,7 @@ struct Indices getPropValue(), /*PVOffset=*/0, /*enabledCompIdx=*/FluidSystem::waterCompIdx, - getPropValue()>; + getPropValue()>; }; } // namespace Opm::Properties diff --git a/flow/flow_onephase_energy.cpp b/flow/flow_onephase_energy.cpp index fbc8326551c..f0205fcec2b 100644 --- a/flow/flow_onephase_energy.cpp +++ b/flow/flow_onephase_energy.cpp @@ -58,7 +58,7 @@ struct Indices getPropValue(), /*PVOffset=*/0, /*enebledCompIdx=*/FluidSystem::waterCompIdx, - getPropValue()>; + getPropValue()>; }; } // namespace Opm::Properties diff --git a/flowexperimental/BlackOilIntensiveQuantitiesGlobalIndex.hpp b/flowexperimental/BlackOilIntensiveQuantitiesGlobalIndex.hpp index f8419fe269a..ca12bef7f9d 100644 --- a/flowexperimental/BlackOilIntensiveQuantitiesGlobalIndex.hpp +++ b/flowexperimental/BlackOilIntensiveQuantitiesGlobalIndex.hpp @@ -48,7 +48,7 @@ #include #include #include -#include +#include #include #include @@ -79,7 +79,7 @@ class BlackOilIntensiveQuantitiesGlobalIndex , public BlackOilFoamIntensiveQuantities()> , public BlackOilBrineIntensiveQuantities()> , public BlackOilEnergyIntensiveQuantitiesGlobalIndex()> - , public BlackOilMICPIntensiveQuantities()> + , public BlackOilBioeffectsIntensiveQuantities()> , public BlackOilConvectiveMixingIntensiveQuantities()> { using ParentType = GetPropType; @@ -107,7 +107,7 @@ class BlackOilIntensiveQuantitiesGlobalIndex enum { enableEnergy = getPropValue() }; enum { enableDiffusion = getPropValue() }; enum { enableConvectiveMixing = getPropValue() }; - enum { enableMICP = getPropValue() }; + enum { enableBioeffects = getPropValue() }; enum { numPhases = getPropValue() }; enum { numComponents = getPropValue() }; enum { waterCompIdx = FluidSystem::waterCompIdx }; @@ -530,7 +530,7 @@ class BlackOilIntensiveQuantitiesGlobalIndex friend BlackOilEnergyIntensiveQuantitiesGlobalIndex; friend BlackOilFoamIntensiveQuantities; friend BlackOilBrineIntensiveQuantities; - friend BlackOilMICPIntensiveQuantities; + friend BlackOilBioeffectsIntensiveQuantities; Implementation& asImp_() { return *static_cast(this); } diff --git a/flowexperimental/comp/flowexp_comp.hpp b/flowexperimental/comp/flowexp_comp.hpp index 9316c083f33..ab3fe327ffb 100644 --- a/flowexperimental/comp/flowexp_comp.hpp +++ b/flowexperimental/comp/flowexp_comp.hpp @@ -257,7 +257,7 @@ struct EnableExtbo> { static constexpr bool value = false; }; template -struct EnableMICP> { +struct EnableBioeffects> { static constexpr bool value = false; }; diff --git a/opm/models/blackoil/blackoilbioeffectsmodules.hh b/opm/models/blackoil/blackoilbioeffectsmodules.hh new file mode 100644 index 00000000000..2c4b425a2cc --- /dev/null +++ b/opm/models/blackoil/blackoilbioeffectsmodules.hh @@ -0,0 +1,666 @@ +// -*- 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 . + + 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 Contains the classes required to extend the black-oil model by bioeffects. + */ +#ifndef OPM_BLACK_OIL_BIOEFFECTS_MODULE_HH +#define OPM_BLACK_OIL_BIOEFFECTS_MODULE_HH + +#include + +#include +#include + +#include + +#include +#include +#include +#include + +namespace Opm { +/*! + * \ingroup BlackOil + * \brief Contains the high level supplements required to extend the black oil + * model by bioeffects. + * + * The two implemented model extensions are MICP and biofilm effects in + * underground storage. For details on the mathematical models, refer to the + * OPM Flow manual. + * + * I) MICP (Microbially Induced Calcite Precipitation) + * MICP is a novel and sustainable technology that leverages biochemical + * processes to form barriers through calcium carbonate cementation. This + * approach shows promise for sealing leakage zones in geological formations. + * + * The conceptual model includes the following key mechanisms: + * - Suspended microbes attach to pore walls, forming biofilm. + * - A growth solution is introduced to stimulate biofilm development. + * - The biofilm utilizes a cementation solution to produce calcite. + * - Calcite precipitates reduce pore space, thereby decreasing rock + * permeability. + * + * This implementation considers a single-phase (water) system with the + * following primary variables: + * - Pressure of the water phase + * - Concentration of suspended microbes + * - Concentration of oxygen + * - Concentration of urea + * - Volume fraction of biofilm + * - Volume fraction of calcite + * + * II) Biofilm effects in underground applications (e.g., hydrogen storage) + * + * Biofilm-related effects in subsurface applications such as hydrogen + * storage include reduced injectivity and hydrogen loss. The conceptual + * model includes the following mechanisms: + * + * - Biofilm is present in the storage site prior to injection. + * - The biofilm consumes injected hydrogen/CO2, leading to clogging + * effects. + * + * This implementation considers a two-phase (gas + water) system with the + * following primary variables: + * - Pressure of the gas phase + * - Water saturation / dissolved gas in water + * - Concentration of suspended microbes + * - Volume fraction of biofilm + */ +template ()> +class BlackOilBioeffectsModule +{ + using Scalar = GetPropType; + using Evaluation = GetPropType; + using PrimaryVariables = GetPropType; + using IntensiveQuantities = GetPropType; + using ExtensiveQuantities = GetPropType; + using ElementContext = GetPropType; + using FluidSystem = GetPropType; + using Model = GetPropType; + using Simulator = GetPropType; + using EqVector = GetPropType; + using RateVector = GetPropType; + using Indices = GetPropType; + using Problem = GetPropType; + + using Toolbox = MathToolbox; + + using TabulatedFunction = typename BlackOilBioeffectsParams::TabulatedFunction; + + enum { waterCompIdx = FluidSystem::waterCompIdx }; + enum { gasCompIdx = FluidSystem::gasCompIdx }; + + static constexpr unsigned microbialConcentrationIdx = Indices::microbialConcentrationIdx; + static constexpr unsigned oxygenConcentrationIdx = Indices::oxygenConcentrationIdx; + static constexpr unsigned ureaConcentrationIdx = Indices::ureaConcentrationIdx; + static constexpr unsigned biofilmConcentrationIdx = Indices::biofilmConcentrationIdx; + static constexpr unsigned calciteConcentrationIdx = Indices::calciteConcentrationIdx; + static constexpr unsigned contiMicrobialEqIdx = Indices::contiMicrobialEqIdx; + static constexpr unsigned contiOxygenEqIdx = Indices::contiOxygenEqIdx; + static constexpr unsigned contiUreaEqIdx = Indices::contiUreaEqIdx; + static constexpr unsigned contiBiofilmEqIdx = Indices::contiBiofilmEqIdx; + static constexpr unsigned contiCalciteEqIdx = Indices::contiCalciteEqIdx; + static constexpr unsigned waterPhaseIdx = FluidSystem::waterPhaseIdx; + + static constexpr unsigned enableBioeffects = enableBioeffectsV; + static constexpr bool enableMICP = Indices::enableMICP; + + static constexpr unsigned numEq = getPropValue(); + +public: + //! \brief Set parameters. + static void setParams(BlackOilBioeffectsParams&& params) + { + params_ = params; + } + + /*! + * \brief Register all run-time parameters for the black-oil bioeffects module. + */ + static void registerParameters() + { + if constexpr (enableBioeffects) + VtkBlackOilBioeffectsModule::registerParameters(); + } + + /*! + * \brief Register all bioeffects specific VTK and ECL output modules. + */ + static void registerOutputModules(Model& model, + Simulator& simulator) + { + if constexpr (enableBioeffects) + model.addOutputModule(std::make_unique>(simulator)); + } + + static bool eqApplies(unsigned eqIdx) + { + if constexpr (enableBioeffects) + if constexpr (enableMICP) + return eqIdx == contiMicrobialEqIdx || eqIdx == contiOxygenEqIdx || eqIdx == contiUreaEqIdx + || eqIdx == contiBiofilmEqIdx || eqIdx == contiCalciteEqIdx; + else + return eqIdx == contiMicrobialEqIdx || eqIdx == contiBiofilmEqIdx; + else + return false; + } + + static Scalar eqWeight([[maybe_unused]] unsigned eqIdx) + { + assert(eqApplies(eqIdx)); + + // TODO: it may be beneficial to chose this differently. + return static_cast(1.0); + } + + // must be called after water storage is computed + template + static void addStorage(Dune::FieldVector& storage, + const IntensiveQuantities& intQuants) + { + if constexpr (enableBioeffects) { + const auto& fs = intQuants.fluidState(); + LhsEval surfaceVolumeWater = Toolbox::template decay(fs.saturation(waterPhaseIdx)) * + Toolbox::template decay(fs.invB(waterPhaseIdx)) * + Toolbox::template decay(intQuants.porosity()); + // avoid singular matrix if no water is present + surfaceVolumeWater = max(surfaceVolumeWater, 1e-10); + // suspended microbes in water phase + const LhsEval accumulationMicrobes = surfaceVolumeWater * Toolbox::template decay(intQuants.microbialConcentration()); + storage[contiMicrobialEqIdx] += accumulationMicrobes; + // biofilm + const LhsEval accumulationBiofilm = Toolbox::template decay(intQuants.biofilmConcentration()); + storage[contiBiofilmEqIdx] += accumulationBiofilm; + if constexpr (enableMICP) { + // oxygen in water phase + const LhsEval accumulationOxygen = surfaceVolumeWater * Toolbox::template decay(intQuants.oxygenConcentration()); + storage[contiOxygenEqIdx] += accumulationOxygen; + // urea in water phase (applying the scaling factor for the urea equation) + const LhsEval accumulationUrea = surfaceVolumeWater * Toolbox::template decay(intQuants.ureaConcentration()); + storage[contiUreaEqIdx] += accumulationUrea; + storage[contiUreaEqIdx] *= getPropValue(); + // calcite + const LhsEval accumulationCalcite = Toolbox::template decay(intQuants.calciteConcentration()); + storage[contiCalciteEqIdx] += accumulationCalcite; + } + } + } + + template + static void addBioeffectsFluxes_(RateVector& flux, + unsigned phaseIdx, + const Eval& volumeFlux, + const IntensiveQuantities& upFs) + { + if (phaseIdx == waterPhaseIdx) { + if constexpr (enableBioeffects) { + flux[contiMicrobialEqIdx] = + decay(upFs.microbialConcentration()) + * volumeFlux; + if constexpr (enableMICP) { + flux[contiOxygenEqIdx] = + decay(upFs.oxygenConcentration()) + * volumeFlux; + flux[contiUreaEqIdx] = + decay(upFs.ureaConcentration()) + * volumeFlux; + } + } + } + } + + // since the urea concentration can be much larger than 1, then we apply a scaling factor + static void applyScaling(RateVector& flux) + { + if constexpr (enableMICP) { + flux[contiUreaEqIdx] *= getPropValue(); + } + } + + static void computeFlux([[maybe_unused]] RateVector& flux, + [[maybe_unused]] const ElementContext& elemCtx, + [[maybe_unused]] unsigned scvfIdx, + [[maybe_unused]] unsigned timeIdx) + { + if constexpr (enableBioeffects) { + const auto& extQuants = elemCtx.extensiveQuantities(scvfIdx, timeIdx); + unsigned focusIdx = elemCtx.focusDofIndex(); + unsigned upIdx = extQuants.upstreamIndex(waterPhaseIdx); + flux[contiMicrobialEqIdx] = 0.0; + if constexpr (enableMICP) { + flux[contiOxygenEqIdx] = 0.0; + flux[contiUreaEqIdx] = 0.0; + } + if (upIdx == focusIdx) + addBioeffectsFluxes_(flux, elemCtx, scvfIdx, timeIdx); + else + addBioeffectsFluxes_(flux, elemCtx, scvfIdx, timeIdx); + } + } + + template + static void addBioeffectsFluxes_(RateVector& flux, + const ElementContext& elemCtx, + unsigned scvfIdx, + unsigned timeIdx) + { + const auto& extQuants = elemCtx.extensiveQuantities(scvfIdx, timeIdx); + unsigned upIdx = extQuants.upstreamIndex(waterPhaseIdx); + const auto& up = elemCtx.intensiveQuantities(upIdx, timeIdx); + const auto& fs = up.fluidState(); + const auto& volFlux = extQuants.volumeFlux(waterPhaseIdx); + addBioeffectsFluxes_(flux, volFlux, fs); + } + + static void addSource(RateVector& source, + const Problem& problem, + const IntensiveQuantities& intQuants, + unsigned globalSpaceIdex) + { + if constexpr (enableBioeffects) { + const auto b = intQuants.fluidState().invB(waterPhaseIdx); + unsigned satnumIdx = problem.satnumRegionIndex(globalSpaceIdex); + Scalar rho_b = densityBiofilm(satnumIdx); + Scalar k_d = microbialDeathRate(satnumIdx); + Scalar mu = maximumGrowthRate(satnumIdx); + Scalar k_n = halfVelocityGrowth(satnumIdx); + Scalar Y = yieldGrowthCoefficient(satnumIdx); + Scalar k_a = microbialAttachmentRate(satnumIdx); + Scalar k_str = detachmentRate(satnumIdx); + Scalar eta = detachmentExponent(satnumIdx); + const auto& velocityInf = problem.model().linearizer().getVelocityInfo(); + auto velocityInfos = velocityInf[globalSpaceIdex]; + Scalar normVelocityCell = + std::accumulate(velocityInfos.begin(), velocityInfos.end(), 0.0, + [](const auto acc, const auto& info) + { return max(acc, std::abs(info.velocity[waterPhaseIdx])); }); + if constexpr (enableMICP) { + Scalar rho_c = densityCalcite(satnumIdx); + Scalar k_u = halfVelocityUrea(satnumIdx); + Scalar mu_u = maximumUreaUtilization(satnumIdx); + Scalar F = oxygenConsumptionFactor(satnumIdx); + Scalar Y_uc = yieldUreaToCalciteCoefficient(satnumIdx); + + // compute Monod terms (the negative region is replaced by a straight line) + // Schäfer et al (1998) https://doi.org/10.1016/S0169-7722(97)00060-0 + Evaluation k_g = mu * intQuants.oxygenConcentration() / (k_n + intQuants.oxygenConcentration()); + Evaluation k_c = mu_u * intQuants.ureaConcentration() / (k_u + intQuants.ureaConcentration()); + if (intQuants.oxygenConcentration() < 0) { + k_g = mu * intQuants.oxygenConcentration() / k_n; + } + if (intQuants.ureaConcentration() < 0) { + k_c = mu_u * intQuants.ureaConcentration() / k_u; + } + + // compute the processes + // see https://doi.org/10.1016/j.ijggc.2021.103256 for the MICP processes in the model + source[Indices::contiMicrobialEqIdx] += intQuants.microbialConcentration() * intQuants.porosity() * + b * (Y * k_g - k_d - k_a) + + rho_b * intQuants.biofilmConcentration() * k_str * pow(normVelocityCell / intQuants.porosity(), eta); + + source[Indices::contiOxygenEqIdx] -= (intQuants.microbialConcentration() * intQuants.porosity() * + b + rho_b * intQuants.biofilmConcentration()) * F * k_g; + + source[Indices::contiUreaEqIdx] -= rho_b * intQuants.biofilmConcentration() * k_c; + + source[Indices::contiBiofilmEqIdx] += intQuants.biofilmConcentration() * (Y * k_g - k_d - + k_str * pow(normVelocityCell / intQuants.porosity(), eta) - Y_uc * (rho_b / rho_c) * + intQuants.biofilmConcentration() * k_c / (intQuants.porosity() + + intQuants.biofilmConcentration())) + k_a * intQuants.microbialConcentration() * + intQuants.porosity() * b / rho_b; + + source[Indices::contiCalciteEqIdx] += (rho_b / rho_c) * intQuants.biofilmConcentration() * Y_uc * k_c; + + // since the urea concentration can be much larger than 1, then we apply a scaling factor + source[Indices::contiUreaEqIdx] *= getPropValue(); + } + else { + const Scalar normVelocityCellG = + std::accumulate(velocityInfos.begin(), velocityInfos.end(), 0.0, + [](const auto acc, const auto& info) + { return max(acc, std::abs(info.velocity[1])); }); + normVelocityCell = max(normVelocityCellG, normVelocityCell); + // convert Rsw to concentration to use in source term + const auto& fs = intQuants.fluidState(); + const auto& Sw = fs.saturation(waterPhaseIdx); + const auto& Rsw = fs.Rsw(); + const auto& rhow = fs.density(waterPhaseIdx); + unsigned pvtRegionIndex = fs.pvtRegionIndex(); + + const auto& xG = RswToMassFraction(pvtRegionIndex, Rsw); + + // get porosity, biofilm concentration, and gas density for convenience + const Evaluation& poro = intQuants.porosity(); + Scalar rho_gRef = FluidSystem::referenceDensity(FluidSystem::gasPhaseIdx, pvtRegionIndex); + + // calculate biofilm growth rate + Evaluation k_g = mu * (xG * rhow * poro * Sw / (xG * rhow * poro * Sw + k_n)); + if (xG < 0) { + k_g = mu * (xG * rhow * poro * Sw / k_n); + } + + // compute source terms + // decay, detachment, and attachment rate of suspended microbes + source[contiMicrobialEqIdx] += Sw * intQuants.microbialConcentration() * intQuants.porosity() * b + * (- k_a - k_d) + + intQuants.biofilmConcentration() * rho_b * k_str + * pow(normVelocityCell / intQuants.porosity(), eta); + // biofilm growth and decay rate + source[contiBiofilmEqIdx] += (k_g - k_d - k_str * pow(normVelocityCell / intQuants.porosity(), eta)) + * intQuants.biofilmConcentration() + + k_a * Sw * intQuants.microbialConcentration() * intQuants.porosity() * b / rho_b; + + // biofilm consumption of dissolved gas is proportional to biofilm growth rate + unsigned activeGasCompIdx = FluidSystem::canonicalToActiveCompIdx(gasCompIdx); + source[activeGasCompIdx] -= intQuants.biofilmConcentration() * rho_b * k_g / (Y * rho_gRef); + } + } + } + + static void addSource([[maybe_unused]] RateVector& source, + [[maybe_unused]] const ElementContext& elemCtx, + [[maybe_unused]] unsigned dofIdx, + [[maybe_unused]] unsigned timeIdx) + { + if constexpr (enableMICP) { + const auto& problem = elemCtx.problem(); + const auto& intQuants = elemCtx.intensiveQuantities(dofIdx, timeIdx); + addSource(source, problem, intQuants, dofIdx); + } + } + + static const Scalar densityBiofilm(unsigned satnumRegionIdx) + { + return params_.densityBiofilm_[satnumRegionIdx]; + } + + static const Scalar densityCalcite(unsigned satnumRegionIdx) + { + return params_.densityCalcite_[satnumRegionIdx]; + } + + static const Scalar detachmentRate(unsigned satnumRegionIdx) + { + return params_.detachmentRate_[satnumRegionIdx]; + } + + static const Scalar detachmentExponent(unsigned satnumRegionIdx) + { + return params_.detachmentExponent_[satnumRegionIdx]; + } + + static const Scalar halfVelocityGrowth(unsigned satnumRegionIdx) + { + return params_.halfVelocityGrowth_[satnumRegionIdx]; + } + + static const Scalar halfVelocityUrea(unsigned satnumRegionIdx) + { + return params_.halfVelocityUrea_[satnumRegionIdx]; + } + + static const Scalar maximumGrowthRate(unsigned satnumRegionIdx) + { + return params_.maximumGrowthRate_[satnumRegionIdx]; + } + + static const Scalar maximumUreaUtilization(unsigned satnumRegionIdx) + { + return params_.maximumUreaUtilization_[satnumRegionIdx]; + } + + static const Scalar microbialAttachmentRate(unsigned satnumRegionIdx) + { + return params_.microbialAttachmentRate_[satnumRegionIdx]; + } + + static const Scalar microbialDeathRate(unsigned satnumRegionIdx) + { + return params_.microbialDeathRate_[satnumRegionIdx]; + } + + static const Scalar oxygenConsumptionFactor(unsigned satnumRegionIdx) + { + return params_.oxygenConsumptionFactor_[satnumRegionIdx]; + } + + static const Scalar yieldGrowthCoefficient(unsigned satnumRegionIdx) + { + return params_.yieldGrowthCoefficient_[satnumRegionIdx]; + } + + static const Scalar yieldUreaToCalciteCoefficient(unsigned satnumRegionIdx) + { + return params_.yieldUreaToCalciteCoefficient_[satnumRegionIdx]; + } + + static const Scalar bioDiffCoefficient(unsigned pvtRegionIdx, unsigned compIdx) + { + return params_.bioDiffCoefficient_[pvtRegionIdx][compIdx]; + } + + static const TabulatedFunction& permfactTable(const ElementContext& elemCtx, + unsigned scvIdx, + unsigned timeIdx) + { + unsigned satnumRegionIdx = elemCtx.problem().satnumRegionIndex(elemCtx, scvIdx, timeIdx); + return params_.permfactTable_[satnumRegionIdx]; + } + + static const TabulatedFunction& permfactTable(unsigned satnumRegionIdx) + { + return params_.permfactTable_[satnumRegionIdx]; + } + + static const TabulatedFunction& pcfactTable(unsigned satnumRegionIdx) + { + return params_.pcfactTable_[satnumRegionIdx]; + } + + static bool hasPcfactTables() + { + if constexpr (enableBioeffects && !enableMICP) { + return !params_.pcfactTable_.empty(); + } + else { + return false; + } + } + +private: + static BlackOilBioeffectsParams params_; + + static Evaluation RswToMassFraction(unsigned regionIdx, const Evaluation& Rsw) { + Scalar rho_wRef = FluidSystem::referenceDensity(FluidSystem::waterPhaseIdx, regionIdx); + Scalar rho_gRef = FluidSystem::referenceDensity(FluidSystem::gasPhaseIdx, regionIdx); + + const Evaluation rho_oG = Rsw * rho_gRef; + + return rho_oG / (rho_wRef + rho_oG); + } +}; + + +template +BlackOilBioeffectsParams::Scalar> +BlackOilBioeffectsModule::params_; + +/*! + * \ingroup BlackOil + * \class Opm::BlackOilBioeffectsIntensiveQuantities + * + * \brief Provides the volumetric quantities required for the equations needed by the + * bioeffects extension of the black-oil model. + */ +template ()> +class BlackOilBioeffectsIntensiveQuantities +{ + using Implementation = GetPropType; + + using Scalar = GetPropType; + using Evaluation = GetPropType; + using PrimaryVariables = GetPropType; + using FluidSystem = GetPropType; + using Indices = GetPropType; + using ElementContext = GetPropType; + + using BioeffectsModule = BlackOilBioeffectsModule; + + static constexpr int microbialConcentrationIdx = Indices::microbialConcentrationIdx; + static constexpr int oxygenConcentrationIdx = Indices::oxygenConcentrationIdx; + static constexpr int ureaConcentrationIdx = Indices::ureaConcentrationIdx; + static constexpr int biofilmConcentrationIdx = Indices::biofilmConcentrationIdx; + static constexpr int calciteConcentrationIdx = Indices::calciteConcentrationIdx; + static constexpr int temperatureIdx = Indices::temperatureIdx; + static constexpr int waterPhaseIdx = FluidSystem::waterPhaseIdx; + static constexpr bool enableMICP = Indices::enableMICP; + +public: + + /*! + * \brief Update the intensive properties needed to handle bioeffects from the + * primary variables + * + */ + void bioeffectsPropertiesUpdate_(const ElementContext& elemCtx, + unsigned dofIdx, + unsigned timeIdx) + { + const auto linearizationType = elemCtx.linearizationType(); + const PrimaryVariables& priVars = elemCtx.primaryVars(dofIdx, timeIdx); + const Scalar referencePorosity_ = elemCtx.problem().referencePorosity(dofIdx, timeIdx); + unsigned satnumRegionIdx = elemCtx.problem().satnumRegionIndex(elemCtx, dofIdx, timeIdx); + + microbialConcentration_ = priVars.makeEvaluation(microbialConcentrationIdx, timeIdx, linearizationType); + biofilmConcentration_ = priVars.makeEvaluation(biofilmConcentrationIdx, timeIdx, linearizationType); + biofilmMass_ = biofilmConcentration_ * BioeffectsModule::densityBiofilm(satnumRegionIdx); + calciteConcentration_ = 0.0; + if constexpr (enableMICP) { + oxygenConcentration_ = priVars.makeEvaluation(oxygenConcentrationIdx, timeIdx, linearizationType); + ureaConcentration_ = priVars.makeEvaluation(ureaConcentrationIdx, timeIdx, linearizationType); + calciteConcentration_ = priVars.makeEvaluation(calciteConcentrationIdx, timeIdx, linearizationType); + calciteMass_ = calciteConcentration_ * BioeffectsModule::densityCalcite(satnumRegionIdx); + } + const Evaluation poroFact = min(1.0 - (biofilmConcentration_ + calciteConcentration_) / + (referencePorosity_), 1.0); //phi/phi_0 + + const auto& permfactTable = BioeffectsModule::permfactTable(satnumRegionIdx); + permFactor_ = permfactTable.eval(poroFact, /*extrapolation=*/true); + } + + const Evaluation& microbialConcentration() const + { return microbialConcentration_; } + + const Evaluation& oxygenConcentration() const + { return oxygenConcentration_; } + + const Evaluation& ureaConcentration() const + { return ureaConcentration_; } + + const Evaluation& biofilmConcentration() const + { return biofilmConcentration_; } + + const Evaluation& calciteConcentration() const + { return calciteConcentration_; } + + const Evaluation biofilmMass() const + { return biofilmMass_; } + + const Evaluation calciteMass() const + { return calciteMass_; } + + const Evaluation& permFactor() const + { return permFactor_; } + +protected: + Evaluation microbialConcentration_; + Evaluation oxygenConcentration_; + Evaluation ureaConcentration_; + Evaluation biofilmConcentration_; + Evaluation calciteConcentration_; + Evaluation biofilmMass_; + Evaluation calciteMass_; + Evaluation permFactor_; + Evaluation pcFactor_; + +}; + +template +class BlackOilBioeffectsIntensiveQuantities +{ + using Evaluation = GetPropType; + using ElementContext = GetPropType; + using Scalar = GetPropType; + +public: + void bioeffectsPropertiesUpdate_(const ElementContext&, + unsigned, + unsigned) + {} + + const Evaluation& microbialConcentration() const + { throw std::logic_error("microbialConcentration() called but MICP is disabled"); } + + const Evaluation& oxygenConcentration() const + { throw std::logic_error("oxygenConcentration() called but MICP is disabled"); } + + const Evaluation& ureaConcentration() const + { throw std::logic_error("ureaConcentration() called but MICP is disabled"); } + + const Evaluation& biofilmConcentration() const + { throw std::logic_error("biofilmConcentration() called but biofilm/MICP is disabled"); } + + const Evaluation& calciteConcentration() const + { throw std::logic_error("calciteConcentration() called but MICP is disabled"); } + + const Evaluation& biofilmMass() const + { throw std::logic_error("biofilmMass() called but biofilm/MICP is disabled"); } + + const Evaluation& calciteMass() const + { throw std::logic_error("calciteMass() called but MICP is disabled"); } + + const Evaluation& permFactor() const + { throw std::logic_error("permFactor() called but biofilm/MICP is disabled"); } +}; + +/*! + * \ingroup BlackOil + * \class Opm::BlackOilBioeffectsExtensiveQuantities + * + * \brief Provides the bioeffects specific extensive quantities to the generic black-oil + * module's extensive quantities. + */ +template ()> +class BlackOilBioeffectsExtensiveQuantities +{ + using Implementation = GetPropType; +}; + +template +class BlackOilBioeffectsExtensiveQuantities{}; + +} // namespace Opm + +#endif diff --git a/opm/models/blackoil/blackoilbioeffectsparams.cpp b/opm/models/blackoil/blackoilbioeffectsparams.cpp new file mode 100644 index 00000000000..20ffd44ae33 --- /dev/null +++ b/opm/models/blackoil/blackoilbioeffectsparams.cpp @@ -0,0 +1,182 @@ +// -*- 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 . + + 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. +*/ + +#include +#include + +#if HAVE_ECL_INPUT +#include +#include +#include +#include +#include +#include +#include +#endif + +#include +#include +#include + +namespace Opm { + +#if HAVE_ECL_INPUT +template +template +void BlackOilBioeffectsParams:: +initFromState(const EclipseState& eclState) +{ + // some sanity checks: + // if biofilm is enabled, the BIOFILM keyword must be present, + // if biofilm is disabled the keyword must not be present, + // if MICP is enabled, the MICP keyword must be present, and + // if MICP is disabled the keyword must not be present + if constexpr (enableBioeffects) { + if constexpr (enableMICP) { + if (!eclState.runspec().micp()) { + throw std::runtime_error("Non-trivial MICP treatment requested at compile time, but " + "the deck does not contain the MICP keyword"); + } + } + else { + if (!eclState.runspec().biof()) { + throw std::runtime_error("Non-trivial Biofilm effects requested at compile time, but " + "the deck does not contain the BIOFILM keyword"); + } + } + } + else { + if (eclState.runspec().biof()) { + throw std::runtime_error("Biofilm effects disabled at compile time, but the deck " + "contains the BIOFILM keyword"); + } + else if (eclState.runspec().micp()) { + throw std::runtime_error("MICP treatment disabled at compile time, but the deck " + "contains the MICP keyword"); + } + } + + if (!eclState.runspec().micp() && !eclState.runspec().biof()) + return; // bioeffects are supposed to be disabled + + const auto& tableManager = eclState.getTableManager(); + unsigned numSatRegions = tableManager.getTabdims().getNumSatTables(); + unsigned numPvtRegions = tableManager.getTabdims().getNumPVTTables(); + + // initialize the objects which deal with the bioparameters + const TableContainer& biofilmTables = tableManager.getBiofilmTables(); + if (biofilmTables.empty()) { + if constexpr (enableMICP) { + throw std::runtime_error("MICP requires the BIOFPARA keyword"); + } + else { + throw std::runtime_error("BIOFILM requires the BIOFPARA keyword"); + } + } + densityBiofilm_.resize(numSatRegions); + microbialDeathRate_.resize(numSatRegions); + maximumGrowthRate_.resize(numSatRegions); + halfVelocityGrowth_.resize(numSatRegions); + yieldGrowthCoefficient_.resize(numSatRegions); + detachmentRate_.resize(numSatRegions); + detachmentExponent_.resize(numSatRegions); + microbialAttachmentRate_.resize(numSatRegions); + if constexpr (enableMICP) { + densityCalcite_.resize(numSatRegions); + halfVelocityUrea_.resize(numSatRegions); + maximumUreaUtilization_.resize(numSatRegions); + oxygenConsumptionFactor_.resize(numSatRegions); + yieldUreaToCalciteCoefficient_.resize(numSatRegions); + } + for (unsigned stnRegionIdx = 0; stnRegionIdx < numSatRegions; ++stnRegionIdx) { + const BiofilmTable& biofilmTable = biofilmTables.getTable(stnRegionIdx); + densityBiofilm_[stnRegionIdx] = biofilmTable.getDensityBiofilm().front(); + microbialDeathRate_[stnRegionIdx] = biofilmTable.getMicrobialDeathRate().front(); + maximumGrowthRate_[stnRegionIdx] = biofilmTable.getMaximumGrowthRate().front(); + halfVelocityGrowth_[stnRegionIdx] = biofilmTable.getHalfVelocityGrowth().front(); + yieldGrowthCoefficient_[stnRegionIdx] = biofilmTable.getYieldGrowthCoefficient().front(); + detachmentRate_[stnRegionIdx] = biofilmTable.getDetachmentRate().front(); + detachmentExponent_[stnRegionIdx] = biofilmTable.getDetachmentExponent().front(); + microbialAttachmentRate_[stnRegionIdx] = biofilmTable.getMicrobialAttachmentRate().front(); + if constexpr (enableMICP) { + densityCalcite_[stnRegionIdx] = biofilmTable.getDensityCalcite().front(); + halfVelocityUrea_[stnRegionIdx] = biofilmTable.getHalfVelocityUrea().front(); + maximumUreaUtilization_[stnRegionIdx] = biofilmTable.getMaximumUreaUtilization().front(); + oxygenConsumptionFactor_[stnRegionIdx] = biofilmTable.getOxygenConsumptionFactor().front(); + yieldUreaToCalciteCoefficient_[stnRegionIdx] = biofilmTable.getYieldUreaToCalciteCoefficient().front(); + } + } + + const TableContainer& diffMICPTables = tableManager.getDiffMICPTables(); + bioDiffCoefficient_.resize(numPvtRegions); + for (unsigned pvtRegionIdx = 0; pvtRegionIdx < numPvtRegions; ++pvtRegionIdx) { + bioDiffCoefficient_[pvtRegionIdx].resize(BlackOilBioeffectsParams::numDiffCoef, 0.0); + if (!diffMICPTables.empty()) { + const DiffMICPTable& diffMICPTable = diffMICPTables.getTable(pvtRegionIdx); + bioDiffCoefficient_[pvtRegionIdx][BlackOilBioeffectsParams::micrDiffIdx] = diffMICPTable.getMicrobialDiffusion().front(); + bioDiffCoefficient_[pvtRegionIdx][BlackOilBioeffectsParams::oxygDiffIdx] = diffMICPTable.getOxygenDiffusion().front(); + bioDiffCoefficient_[pvtRegionIdx][BlackOilBioeffectsParams::ureaDiffIdx] = diffMICPTable.getUreaDiffusion().front(); + } + } + + if constexpr (!enableMICP) { + const TableContainer& pcfactTables = tableManager.getPcfactTables(); + if (!pcfactTables.empty()) { + pcfactTable_.resize(numSatRegions); + for (size_t i = 0; i < pcfactTables.size(); ++i) { + const PcfactTable& pcfactTable = pcfactTables.getTable(i); + pcfactTable_[i].setXYContainers(pcfactTable.getPorosityChangeColumn(), pcfactTable.getPcMultiplierColumn()); + } + } + } + + const TableContainer& permfactTables = tableManager.getPermfactTables(); + if (permfactTables.empty()) { + if constexpr (enableMICP) { + throw std::runtime_error("MICP requires the PERMFACT keyword"); + } + else { + throw std::runtime_error("BIOFILM requires the PERMFACT keyword"); + } + } + permfactTable_.resize(numSatRegions); + for (std::size_t i = 0; i < permfactTables.size(); ++i) { + const PermfactTable& permfactTable = permfactTables.getTable(i); + permfactTable_[i].setXYContainers(permfactTable.getPorosityChangeColumn(), permfactTable.getPermeabilityMultiplierColumn()); + } +} +#endif + +#define INSTANTIATE_TYPE(T) \ + template struct BlackOilBioeffectsParams; \ + template void BlackOilBioeffectsParams::initFromState(const EclipseState&); \ + template void BlackOilBioeffectsParams::initFromState(const EclipseState&); \ + template void BlackOilBioeffectsParams::initFromState(const EclipseState&); + +INSTANTIATE_TYPE(double) + +#if FLOW_INSTANTIATE_FLOAT +INSTANTIATE_TYPE(float) +#endif + +} // namespace Opm diff --git a/opm/models/blackoil/blackoilmicpparams.hpp b/opm/models/blackoil/blackoilbioeffectsparams.hpp similarity index 54% rename from opm/models/blackoil/blackoilmicpparams.hpp rename to opm/models/blackoil/blackoilbioeffectsparams.hpp index 02a8c8643f1..b8e4343379a 100644 --- a/opm/models/blackoil/blackoilmicpparams.hpp +++ b/opm/models/blackoil/blackoilbioeffectsparams.hpp @@ -23,10 +23,10 @@ /*! * \file * - * \brief Contains the parameters required to extend the black-oil model by MICP. + * \brief Contains the parameters required to extend the black-oil model by bioeffects. */ -#ifndef OPM_BLACK_OIL_MICP_PARAMS_HPP -#define OPM_BLACK_OIL_MICP_PARAMS_HPP +#ifndef OPM_BLACK_OIL_BIOEFFECTS_PARAMS_HPP +#define OPM_BLACK_OIL_BIOEFFECTS_PARAMS_HPP #include @@ -38,37 +38,42 @@ namespace Opm { class EclipseState; #endif -//! \brief Struct holding the parameters for the BlackOilMICPModule class. +//! \brief Struct holding the parameters for the BlackOilBioeffectsModule class. template -struct BlackOilMICPParams +struct BlackOilBioeffectsParams { #if HAVE_ECL_INPUT - template + template void initFromState(const EclipseState& eclState); #endif using TabulatedFunction = Tabulated1DFunction; + enum { numDiffCoef = 3 }; + enum { micrDiffIdx = 0 }; + enum { oxygDiffIdx = 1 }; + enum { ureaDiffIdx = 2 }; + std::vector permfactTable_; + std::vector pcfactTable_; - std::vector densityBiofilm_; - std::vector densityCalcite_; - std::vector detachmentRate_; - std::vector detachmentExponent_; - std::vector halfVelocityOxygen_; - std::vector halfVelocityUrea_; - std::vector maximumGrowthRate_; - std::vector maximumUreaUtilization_; - std::vector microbialAttachmentRate_; - std::vector microbialDeathRate_; - std::vector oxygenConsumptionFactor_; - std::vector yieldGrowthCoefficient_; - std::vector yieldUreaToCalciteCoefficient_; - std::vector microbialDiffusion_; - std::vector oxygenDiffusion_; - std::vector ureaDiffusion_; + std::vector densityBiofilm_{}; + std::vector densityCalcite_{}; + std::vector detachmentRate_{}; + std::vector detachmentExponent_{}; + std::vector halfVelocityGrowth_{}; + std::vector halfVelocityUrea_{}; + std::vector maximumGrowthRate_{}; + std::vector maximumUreaUtilization_{}; + std::vector microbialAttachmentRate_{}; + std::vector microbialDeathRate_{}; + std::vector oxygenConsumptionFactor_{}; + std::vector yieldGrowthCoefficient_{}; + std::vector yieldUreaToCalciteCoefficient_{}; + + std::vector> bioDiffCoefficient_{}; }; } // namespace Opm -#endif // OPM_BLACK_OIL_MICP_PARAMS_HPP +#endif // OPM_BLACK_OIL_BIOEFFECTS_PARAMS_HPP diff --git a/opm/models/blackoil/blackoilboundaryratevector.hh b/opm/models/blackoil/blackoilboundaryratevector.hh index 4929c855939..781dc44d60d 100644 --- a/opm/models/blackoil/blackoilboundaryratevector.hh +++ b/opm/models/blackoil/blackoilboundaryratevector.hh @@ -64,7 +64,7 @@ class BlackOilBoundaryRateVector : public GetPropType() }; - enum { enableMICP = getPropValue() }; + enum { enableMICP = Indices::enableMICP }; static constexpr bool blackoilConserveSurfaceVolume = getPropValue(); diff --git a/opm/models/blackoil/blackoildiffusionmodule.hh b/opm/models/blackoil/blackoildiffusionmodule.hh index c213c00c3a0..08ccde15a85 100644 --- a/opm/models/blackoil/blackoildiffusionmodule.hh +++ b/opm/models/blackoil/blackoildiffusionmodule.hh @@ -32,7 +32,7 @@ #include -#include +#include #include #include @@ -101,12 +101,15 @@ class BlackOilDiffusionModule using FluidSystem = GetPropType; using Indices = GetPropType; using IntensiveQuantities = GetPropType; + using BioeffectsModule = BlackOilBioeffectsModule; + using BioeffectsParams = BlackOilBioeffectsParams; enum { numPhases = FluidSystem::numPhases }; enum { numComponents = FluidSystem::numComponents }; enum { conti0EqIdx = Indices::conti0EqIdx }; - enum { enableMICP = getPropValue() }; + enum { enableBioeffects = getPropValue() }; + enum { enableMICP = Indices::enableMICP }; static constexpr unsigned contiMicrobialEqIdx = Indices::contiMicrobialEqIdx; static constexpr unsigned contiOxygenEqIdx = Indices::contiOxygenEqIdx; @@ -171,6 +174,10 @@ public: const auto& diffusivity = extQuants.diffusivity(); const auto& effectiveDiffusionCoefficient = extQuants.effectiveDiffusionCoefficient(); addDiffusiveFlux(flux, inIq, exIq, diffusivity, effectiveDiffusionCoefficient); + if constexpr(enableBioeffects) { + const auto& effectiveBioDiffCoefficient = extQuants.effectiveBioDiffCoefficient(); + addBioDiffFlux(flux, inIq, exIq, diffusivity, effectiveBioDiffCoefficient); + } } template @@ -182,32 +189,9 @@ public: { const auto& inFs = inIq.fluidState(); const auto& exFs = exIq.fluidState(); + unsigned pvtRegionIndex = inFs.pvtRegionIndex(); Evaluation diffR = 0.0; - if constexpr (enableMICP) { - // The diffusion coefficients are given for mass concentrations - const Evaluation bAvg = (inFs.invB(waterPhaseIdx) + Toolbox::value(exFs.invB(waterPhaseIdx))) / 2; - diffR = inIq.microbialConcentration() - Toolbox::value(exIq.microbialConcentration()); - flux[contiMicrobialEqIdx] += - bAvg * - diffR * - diffusivity * - effectiveDiffusionCoefficient[waterPhaseIdx][contiMicrobialEqIdx - 1]; - diffR = inIq.oxygenConcentration() - Toolbox::value(exIq.oxygenConcentration()); - flux[contiOxygenEqIdx] += - bAvg * - diffR * - diffusivity * - effectiveDiffusionCoefficient[waterPhaseIdx][contiOxygenEqIdx - 1]; - diffR = inIq.ureaConcentration() - Toolbox::value(exIq.ureaConcentration()); - flux[contiUreaEqIdx] += - bAvg * - diffR * - diffusivity * - effectiveDiffusionCoefficient[waterPhaseIdx][contiUreaEqIdx - 1]; - return; - } - const unsigned pvtRegionIndex = inFs.pvtRegionIndex(); for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { if (!FluidSystem::phaseIsActive(phaseIdx)) { continue; @@ -284,6 +268,42 @@ public: } } + template + static void addBioDiffFlux(RateVector& flux, + const IntensiveQuantities& inIq, + const IntensiveQuantities& exIq, + const Evaluation& diffusivity, + const EvaluationArray& effectiveBioDiffCoefficient) + { + const auto& inFs = inIq.fluidState(); + const auto& exFs = exIq.fluidState(); + Evaluation diffR = 0.0; + + // The diffusion coefficients are given for mass concentrations + Evaluation bAvg = (inFs.saturation(waterPhaseIdx) * inFs.invB(waterPhaseIdx) + + Toolbox::value(exFs.saturation(waterPhaseIdx)) * Toolbox::value(exFs.invB(waterPhaseIdx))) / 2; + diffR = inIq.microbialConcentration() - Toolbox::value(exIq.microbialConcentration()); + flux[contiMicrobialEqIdx] += + bAvg + * diffR + * diffusivity + * effectiveBioDiffCoefficient[BioeffectsParams::micrDiffIdx]; + if constexpr(enableMICP) { + diffR = inIq.oxygenConcentration() - Toolbox::value(exIq.oxygenConcentration()); + flux[contiOxygenEqIdx] += + bAvg + * diffR + * diffusivity + * effectiveBioDiffCoefficient[BioeffectsParams::oxygDiffIdx]; + diffR = inIq.ureaConcentration() - Toolbox::value(exIq.ureaConcentration()); + flux[contiUreaEqIdx] += + bAvg + * diffR + * diffusivity + * effectiveBioDiffCoefficient[BioeffectsParams::ureaDiffIdx]; + } + } + private: static Scalar toFractionGasOil (unsigned regionIdx) { @@ -386,11 +406,14 @@ class BlackOilDiffusionIntensiveQuantities using ElementContext = GetPropType; using FluidSystem = GetPropType; using IntensiveQuantities = GetPropType; - using MICPModule = BlackOilMICPModule; + using Indices = GetPropType; + using BioeffectsModule = BlackOilBioeffectsModule; enum { numPhases = FluidSystem::numPhases }; enum { numComponents = FluidSystem::numComponents }; - enum { enableMICP = getPropValue() }; + enum { enableBioeffects = getPropValue() }; + enum { enableMICP = Indices::enableMICP }; + enum { numBioInWat = Indices::numBioInWat }; static constexpr unsigned waterPhaseIdx = FluidSystem::waterPhaseIdx; @@ -445,6 +468,27 @@ public: } } + /*! + * \brief Returns the molecular diffusion coefficient for a + * biocomponent in the water phase. + */ + Evaluation bioDiffCoefficient(unsigned compIdx) const + { return bioDiffCoefficient_[compIdx]; } + + /*! + * \brief Returns the effective molecular diffusion coefficient of + * the porous medium for a biocomponent in the water phase. + */ + Evaluation effectiveBioDiffCoefficient(unsigned compIdx) const + { + // TODO add a run-time parameter to enable tortuosity + static bool enableTortuosity = false; + if (enableTortuosity) + return tortuosity_[waterPhaseIdx] * bioDiffCoefficient_[compIdx]; + + return bioDiffCoefficient_[compIdx]; + } + protected: /*! * \brief Update the quantities required to calculate diffusive @@ -473,14 +517,6 @@ protected: { using Toolbox = MathToolbox; - if constexpr (enableMICP) { - const unsigned pvtRegionIndex = intQuants.fluidState().pvtRegionIndex(); - diffusionCoefficient_[waterPhaseIdx][0] = MICPModule::microbialDiffusion(pvtRegionIndex); - diffusionCoefficient_[waterPhaseIdx][1] = MICPModule::oxygenDiffusion(pvtRegionIndex); - diffusionCoefficient_[waterPhaseIdx][2] = MICPModule::ureaDiffusion(pvtRegionIndex); - return; - } - for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { if (!FluidSystem::phaseIsActive(phaseIdx)) { continue; @@ -513,11 +549,20 @@ protected: compIdx); } } + + if constexpr(enableBioeffects) { + unsigned pvtRegionIndex = intQuants.pvtRegionIndex(); + for (unsigned compIdx = 0; compIdx < numBioInWat; ++compIdx) { + bioDiffCoefficient_[compIdx] = + BioeffectsModule::bioDiffCoefficient(pvtRegionIndex, compIdx); + } + } } private: std::array tortuosity_{}; std::array, numPhases> diffusionCoefficient_{}; + std::array bioDiffCoefficient_{}; }; /*! @@ -595,11 +640,14 @@ class BlackOilDiffusionExtensiveQuantities using FluidSystem = GetPropType; using Toolbox = MathToolbox; using IntensiveQuantities = GetPropType; + using Indices = GetPropType; enum { dimWorld = GridView::dimensionworld }; enum { numPhases = getPropValue() }; enum { numComponents = getPropValue() }; - enum { enableMICP = getPropValue() }; + enum { enableBioeffects = getPropValue() }; + enum { enableMICP = Indices::enableMICP }; + enum { numBioInWat = Indices::numBioInWat }; static constexpr unsigned waterPhaseIdx = FluidSystem::waterPhaseIdx; @@ -632,6 +680,9 @@ protected: diffusivity_ = diff / faceArea; update(effectiveDiffusionCoefficient_, intQuantsInside, intQuantsOutside); Valgrind::CheckDefined(diffusivity_); + if constexpr(enableBioeffects) { + updateBio(effectiveBioDiffCoefficient_, intQuantsInside, intQuantsOutside); + } } public: @@ -642,15 +693,6 @@ public: // opm-models expects per area flux // use the arithmetic average for the effective // diffusion coefficients. - if constexpr(enableMICP) { - for (unsigned compIdx = 0; compIdx < numComponents; ++compIdx) { - effectiveDiffusionCoefficient[waterPhaseIdx][compIdx] = - 0.5 * (intQuantsInside.effectiveDiffusionCoefficient(waterPhaseIdx, compIdx) + - intQuantsOutside.effectiveDiffusionCoefficient(waterPhaseIdx, compIdx)); - } - return; - } - for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { if (!FluidSystem::phaseIsActive(phaseIdx)) { continue; @@ -668,6 +710,18 @@ public: } } + static void updateBio(std::array& effectiveBioDiffCoefficient, + const IntensiveQuantities& intQuantsInside, + const IntensiveQuantities& intQuantsOutside) { + + for (unsigned compIdx = 0; compIdx < numBioInWat; ++compIdx) { + effectiveBioDiffCoefficient[compIdx] = + 0.5 * (intQuantsInside.effectiveBioDiffCoefficient(compIdx) + + intQuantsOutside.effectiveBioDiffCoefficient(compIdx)); + Valgrind::CheckDefined(effectiveBioDiffCoefficient[compIdx]); + } + } + protected: template void updateBoundary_(const Context&, @@ -701,9 +755,17 @@ public: const auto& effectiveDiffusionCoefficient() const { return effectiveDiffusionCoefficient_; } + const Evaluation& effectiveBioDiffCoefficient(unsigned compIdx) const + { return effectiveBioDiffCoefficient_[compIdx]; } + + const auto& effectiveBioDiffCoefficient() const{ + return effectiveBioDiffCoefficient_; + } + private: Scalar diffusivity_; EvaluationArray effectiveDiffusionCoefficient_; + std::array effectiveBioDiffCoefficient_; }; } // namespace Opm diff --git a/opm/models/blackoil/blackoildispersionmodule.hh b/opm/models/blackoil/blackoildispersionmodule.hh index c47c75dd715..bd9c4bd32c3 100644 --- a/opm/models/blackoil/blackoildispersionmodule.hh +++ b/opm/models/blackoil/blackoildispersionmodule.hh @@ -124,7 +124,8 @@ class BlackOilDispersionModule enum { numComponents = FluidSystem::numComponents }; enum { conti0EqIdx = Indices::conti0EqIdx }; enum { enableDispersion = getPropValue() }; - enum { enableMICP = getPropValue() }; + enum { enableBioeffects = getPropValue() }; + enum { enableMICP = Indices::enableMICP }; static constexpr unsigned contiMicrobialEqIdx = Indices::contiMicrobialEqIdx; static constexpr unsigned contiOxygenEqIdx = Indices::contiOxygenEqIdx; @@ -201,28 +202,30 @@ public: const auto& inFs = inIq.fluidState(); const auto& exFs = exIq.fluidState(); Evaluation diffR = 0.0; - if constexpr(enableMICP) { + if constexpr(enableBioeffects) { // The dispersion coefficients are given for mass concentrations const Evaluation bAvg = (inFs.invB(waterPhaseIdx) + Toolbox::value(exFs.invB(waterPhaseIdx))) / 2; diffR = inIq.microbialConcentration() - Toolbox::value(exIq.microbialConcentration()); flux[contiMicrobialEqIdx] += - bAvg * - normVelocityAvg[waterPhaseIdx] * - dispersivity * - diffR; - diffR = inIq.oxygenConcentration() - Toolbox::value(exIq.oxygenConcentration()); - flux[contiOxygenEqIdx] += - bAvg * - normVelocityAvg[waterPhaseIdx] * - dispersivity * - diffR; - diffR = inIq.ureaConcentration() - Toolbox::value(exIq.ureaConcentration()); - flux[contiUreaEqIdx] += - bAvg * - normVelocityAvg[waterPhaseIdx] * - dispersivity * - diffR; - return; + bAvg + * normVelocityAvg[waterPhaseIdx] + * dispersivity + * diffR; + if constexpr(enableMICP) { + diffR = inIq.oxygenConcentration() - Toolbox::value(exIq.oxygenConcentration()); + flux[contiOxygenEqIdx] += + bAvg + * normVelocityAvg[waterPhaseIdx] + * dispersivity + * diffR; + diffR = inIq.ureaConcentration() - Toolbox::value(exIq.ureaConcentration()); + flux[contiUreaEqIdx] += + bAvg + * normVelocityAvg[waterPhaseIdx] + * dispersivity + * diffR; + return; + } } unsigned pvtRegionIndex = inFs.pvtRegionIndex(); @@ -249,21 +252,14 @@ public: bAvg /= 2; Evaluation convFactor = 1.0; - if (FluidSystem::enableDissolvedGas() && - FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx) && - phaseIdx == FluidSystem::oilPhaseIdx) - { + if (FluidSystem::enableDissolvedGas() && FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx) && phaseIdx == FluidSystem::oilPhaseIdx) { const Evaluation rsAvg = (inFs.Rs() + Toolbox::value(exFs.Rs())) / 2; convFactor = 1.0 / (toMassFractionGasOil(pvtRegionIndex) + rsAvg); diffR = inFs.Rs() - Toolbox::value(exFs.Rs()); } - if (FluidSystem::enableVaporizedOil() && - FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx) && - phaseIdx == FluidSystem::gasPhaseIdx) - { + if (FluidSystem::enableVaporizedOil() && FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx) && phaseIdx == FluidSystem::gasPhaseIdx) { const Evaluation rvAvg = (inFs.Rv() + Toolbox::value(exFs.Rv())) / 2; - convFactor = toMassFractionGasOil(pvtRegionIndex) / - (1.0 + rvAvg * toMassFractionGasOil(pvtRegionIndex)); + convFactor = toMassFractionGasOil(pvtRegionIndex) / (1.0 + rvAvg*toMassFractionGasOil(pvtRegionIndex)); diffR = inFs.Rv() - Toolbox::value(exFs.Rv()); } if (FluidSystem::enableDissolvedGasInWater() && phaseIdx == FluidSystem::waterPhaseIdx) { @@ -273,8 +269,7 @@ public: } if (FluidSystem::enableVaporizedWater() && phaseIdx == FluidSystem::gasPhaseIdx) { const Evaluation rvAvg = (inFs.Rvw() + Toolbox::value(exFs.Rvw())) / 2; - convFactor = toMassFractionGasWater(pvtRegionIndex) / - (1.0 + rvAvg * toMassFractionGasWater(pvtRegionIndex)); + convFactor = toMassFractionGasWater(pvtRegionIndex)/ (1.0 + rvAvg*toMassFractionGasWater(pvtRegionIndex)); diffR = inFs.Rvw() - Toolbox::value(exFs.Rvw()); } @@ -282,34 +277,32 @@ public: const unsigned solventCompIdx = FluidSystem::solventComponentIndex(phaseIdx); const unsigned activeSolventCompIdx = FluidSystem::canonicalToActiveCompIdx(solventCompIdx); flux[conti0EqIdx + activeSolventCompIdx] += - -bAvg * - normVelocityAvg[phaseIdx] * - convFactor * - dispersivity * - diffR; + - bAvg + * normVelocityAvg[phaseIdx] + * convFactor + * dispersivity + * diffR; // mass flux of solute component const unsigned soluteCompIdx = FluidSystem::soluteComponentIndex(phaseIdx); const unsigned activeSoluteCompIdx = FluidSystem::canonicalToActiveCompIdx(soluteCompIdx); flux[conti0EqIdx + activeSoluteCompIdx] += - bAvg * - normVelocityAvg[phaseIdx] * - convFactor * - dispersivity * - diffR; + bAvg + * normVelocityAvg[phaseIdx] + * convFactor + * dispersivity + * diffR; } } private: - static Scalar toMassFractionGasOil (unsigned regionIdx) - { + + static Scalar toMassFractionGasOil (unsigned regionIdx) { const Scalar rhoO = FluidSystem::referenceDensity(FluidSystem::oilPhaseIdx, regionIdx); const Scalar rhoG = FluidSystem::referenceDensity(FluidSystem::gasPhaseIdx, regionIdx); return rhoO / rhoG; } - - static Scalar toMassFractionGasWater (unsigned regionIdx) - { + static Scalar toMassFractionGasWater (unsigned regionIdx) { const Scalar rhoW = FluidSystem::referenceDensity(FluidSystem::waterPhaseIdx, regionIdx); const Scalar rhoG = FluidSystem::referenceDensity(FluidSystem::gasPhaseIdx, regionIdx); return rhoW / rhoG; @@ -386,7 +379,9 @@ public: * \brief Returns the max. norm of the filter velocity of the cell. */ Scalar normVelocityCell(unsigned phaseIdx) const - { return normVelocityCell_[phaseIdx]; } + { + return normVelocityCell_[phaseIdx]; + } protected: /*! @@ -420,7 +415,7 @@ protected: for (const auto& velocityInfo : velocityInfos) { for (unsigned i = 0; i < phaseIdxs.size(); ++i) { if (FluidSystem::phaseIsActive(phaseIdxs[i])) { - normVelocityCell_[phaseIdxs[i]] = max( normVelocityCell_[phaseIdxs[i]], + normVelocityCell_[phaseIdxs[i]] = std::max(normVelocityCell_[phaseIdxs[i]], std::abs(velocityInfo.velocity[conti0EqIdx + FluidSystem::canonicalToActiveCompIdx(compIdxs[i])])); } @@ -429,7 +424,7 @@ protected: } private: - std::array normVelocityCell_{}; + Scalar normVelocityCell_[numPhases]; }; /*! @@ -484,7 +479,7 @@ public: * \brief The dispersivity the face. * */ - Scalar dispersivity() const + const Scalar& dispersivity() const { throw std::logic_error("The method dispersivity() does not " "make sense if dispersion is disabled."); @@ -497,11 +492,12 @@ public: * \copydoc Doxygen::phaseIdxParam * \copydoc Doxygen::compIdxParam */ - Scalar normVelocityAvg(unsigned) const + const Scalar& normVelocityAvg(unsigned) const { throw std::logic_error("The method normVelocityAvg() " "does not make sense if dispersion is disabled."); } + }; /*! @@ -524,9 +520,8 @@ class BlackOilDispersionExtensiveQuantities using DimVector = Dune::FieldVector; using DimEvalVector = Dune::FieldVector; - public: - using ScalarArray = std::array; + using ScalarArray = Scalar[numPhases]; static void update(ScalarArray& normVelocityAvg, const IntensiveQuantities& intQuantsInside, const IntensiveQuantities& intQuantsOutside) @@ -569,7 +564,7 @@ public: * \copydoc Doxygen::phaseIdxParam * \copydoc Doxygen::compIdxParam */ - Scalar dispersivity() const + const Scalar& dispersivity() const { return dispersivity_; } /*! @@ -579,7 +574,7 @@ public: * \copydoc Doxygen::phaseIdxParam * \copydoc Doxygen::compIdxParam */ - Scalar normVelocityAvg(unsigned phaseIdx) const + const Scalar& normVelocityAvg(unsigned phaseIdx) const { return normVelocityAvg_[phaseIdx]; } const auto& normVelocityAvg() const diff --git a/opm/models/blackoil/blackoilextensivequantities.hh b/opm/models/blackoil/blackoilextensivequantities.hh index 2e016f1bbfc..cf8c4df2f7f 100644 --- a/opm/models/blackoil/blackoilextensivequantities.hh +++ b/opm/models/blackoil/blackoilextensivequantities.hh @@ -28,11 +28,11 @@ #ifndef EWOMS_BLACK_OIL_EXTENSIVE_QUANTITIES_HH #define EWOMS_BLACK_OIL_EXTENSIVE_QUANTITIES_HH +#include #include #include #include #include -#include #include namespace Opm { @@ -55,7 +55,7 @@ class BlackOilExtensiveQuantities , public BlackOilPolymerExtensiveQuantities()> , public BlackOilEnergyExtensiveQuantities()> , public BlackOilDiffusionExtensiveQuantities()> - , public BlackOilMICPExtensiveQuantities()> + , public BlackOilBioeffectsExtensiveQuantities()> { using MultiPhaseParent = MultiPhaseBaseExtensiveQuantities; diff --git a/opm/models/blackoil/blackoilintensivequantities.hh b/opm/models/blackoil/blackoilintensivequantities.hh index 1e139e57596..3e0894c0b50 100644 --- a/opm/models/blackoil/blackoilintensivequantities.hh +++ b/opm/models/blackoil/blackoilintensivequantities.hh @@ -37,6 +37,7 @@ #include #include +#include #include #include #include @@ -44,7 +45,6 @@ #include #include #include -#include #include #include #include @@ -80,7 +80,7 @@ class BlackOilIntensiveQuantities , public BlackOilFoamIntensiveQuantities()> , public BlackOilBrineIntensiveQuantities()> , public BlackOilEnergyIntensiveQuantities()> - , public BlackOilMICPIntensiveQuantities()> + , public BlackOilBioeffectsIntensiveQuantities()> , public BlackOilConvectiveMixingIntensiveQuantities()> { using ParentType = GetPropType; @@ -110,7 +110,8 @@ class BlackOilIntensiveQuantities enum { enableDiffusion = getPropValue() }; enum { enableDispersion = getPropValue() }; enum { enableConvectiveMixing = getPropValue() }; - enum { enableMICP = getPropValue() }; + enum { enableBioeffects = getPropValue() }; + enum { enableMICP = Indices::enableMICP }; enum { numPhases = getPropValue() }; enum { numComponents = getPropValue() }; enum { waterCompIdx = FluidSystem::waterCompIdx }; @@ -136,7 +137,8 @@ class BlackOilIntensiveQuantities using DirectionalMobilityPtr = Utility::CopyablePtr>; using BrineModule = BlackOilBrineModule; using BrineIntQua = BlackOilBrineIntensiveQuantities; - using MICPIntQua = BlackOilMICPIntensiveQuantities; + using BioeffectsModule = BlackOilBioeffectsModule; + using BioeffectsIntQua = BlackOilBioeffectsIntensiveQuantities; public: using FluidState = BlackOilFluidState(pC, materialParams, fluidState_); - // scaling the capillary pressure due to salt precipitation + // scaling the capillary pressure due to porosity changes if constexpr (enableBrine) { if (BrineModule::hasPcfactTables() && priVars.primaryVarsMeaningBrine() == PrimaryVariables::BrineMeaning::Sp) @@ -306,6 +308,20 @@ public: } } } + else if constexpr (enableBioeffects) { + if (BioeffectsModule::hasPcfactTables() && referencePorosity_ > 0) { + unsigned satnumRegionIdx = problem.satnumRegionIndex(globalSpaceIdx); + const Evaluation Sb = priVars.makeEvaluation(Indices::biofilmConcentrationIdx, timeIdx); + const Evaluation porosityFactor = min(1.0 - Sb/referencePorosity_, 1.0); //phi/phi_0 + const auto& pcfactTable = BioeffectsModule::pcfactTable(satnumRegionIdx); + const Evaluation pcFactor = pcfactTable.eval(porosityFactor, /*extrapolation=*/true); + for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { + if (FluidSystem::phaseIsActive(phaseIdx)) { + pC[phaseIdx] *= pcFactor; + } + } + } + } // oil is the reference phase for pressure if (priVars.primaryVarsMeaningPressure() == PrimaryVariables::PressureMeaning::Pg) { @@ -562,13 +578,14 @@ public: // deal with water induced rock compaction porosity_ *= problem.template rockCompPoroMultiplier(*this, globalSpaceIdx); - // deal with MICP - if constexpr (enableMICP) { + // deal with bioeffects (minimum porosity of 1e-8 to prevent numerical issues) + if constexpr (enableBioeffects) { const Evaluation biofilm_ = priVars.makeEvaluation(Indices::biofilmConcentrationIdx, timeIdx, linearizationType); - const Evaluation calcite_ = priVars.makeEvaluation(Indices::calciteConcentrationIdx, - timeIdx, linearizationType); - // minimum porosity of 1e-8 to prevent numerical issues + Evaluation calcite_ = 0.0; + if constexpr (enableMICP) { + calcite_ = priVars.makeEvaluation(Indices::calciteConcentrationIdx, timeIdx, linearizationType); + } porosity_ -= min(biofilm_ + calcite_, referencePorosity_ - 1e-8); } @@ -629,8 +646,8 @@ public: if constexpr (enableFoam) { asImp_().foamPropertiesUpdate_(elemCtx, dofIdx, timeIdx); } - if constexpr (enableMICP) { - asImp_().MICPPropertiesUpdate_(elemCtx, dofIdx, timeIdx); + if constexpr (enableBioeffects) { + asImp_().bioeffectsPropertiesUpdate_(elemCtx, dofIdx, timeIdx); } if constexpr (enableBrine) { asImp_().saltPropertiesUpdate_(elemCtx, dofIdx, timeIdx); @@ -793,14 +810,14 @@ public: const Evaluation& permFactor() const { - if constexpr (enableMICP) { - return MICPIntQua::permFactor(); + if constexpr (enableBioeffects) { + return BioeffectsIntQua::permFactor(); } else if constexpr (enableSaltPrecipitation) { return BrineIntQua::permFactor(); } else { - throw std::logic_error("permFactor() called but salt precipitation or MICP are disabled"); + throw std::logic_error("permFactor() called but salt precipitation or bioeffects are disabled"); } } @@ -811,7 +828,7 @@ private: friend BlackOilEnergyIntensiveQuantities; friend BlackOilFoamIntensiveQuantities; friend BlackOilBrineIntensiveQuantities; - friend BlackOilMICPIntensiveQuantities; + friend BlackOilBioeffectsIntensiveQuantities; Implementation& asImp_() { return *static_cast(this); } diff --git a/opm/models/blackoil/blackoillocalresidual.hh b/opm/models/blackoil/blackoillocalresidual.hh index bb2a908f2bb..d50c2c939c0 100644 --- a/opm/models/blackoil/blackoillocalresidual.hh +++ b/opm/models/blackoil/blackoillocalresidual.hh @@ -31,13 +31,13 @@ #include #include +#include #include #include #include #include #include #include -#include #include #include #include @@ -96,7 +96,7 @@ class BlackOilLocalResidual : public GetPropType; using BrineModule = BlackOilBrineModule; using DiffusionModule = BlackOilDiffusionModule; - using MICPModule = BlackOilMICPModule; + using BioeffectsModule = BlackOilBioeffectsModule; using ConvectiveMixingModule = BlackOilConvectiveMixingModule; public: @@ -192,8 +192,8 @@ public: // deal with salt (if present) BrineModule::addStorage(storage, intQuants); - // deal with micp (if present) - MICPModule::addStorage(storage, intQuants); + // deal with bioeffects (if present) + BioeffectsModule::addStorage(storage, intQuants); } /*! @@ -243,9 +243,10 @@ public: // deal with salt (if present) BrineModule::computeFlux(flux, elemCtx, scvfIdx, timeIdx); - // deal with micp (if present) - MICPModule::computeFlux(flux, elemCtx, scvfIdx, timeIdx); + // deal with bioeffects (if present) + BioeffectsModule::computeFlux(flux, elemCtx, scvfIdx, timeIdx); + // deal with diffusion (if present) DiffusionModule::addDiffusiveFlux(flux, elemCtx, scvfIdx, timeIdx); // deal with convective mixing (if enabled) @@ -264,7 +265,7 @@ public: elemCtx.problem().source(source, elemCtx, dofIdx, timeIdx); // deal with MICP (if present) - MICPModule::addSource(source, elemCtx, dofIdx, timeIdx); + BioeffectsModule::addSource(source, elemCtx, dofIdx, timeIdx); // scale the source term of the energy equation if constexpr (enableEnergy) { diff --git a/opm/models/blackoil/blackoillocalresidualtpfa.hh b/opm/models/blackoil/blackoillocalresidualtpfa.hh index 924a255958c..5787e20ed1f 100644 --- a/opm/models/blackoil/blackoillocalresidualtpfa.hh +++ b/opm/models/blackoil/blackoillocalresidualtpfa.hh @@ -35,6 +35,7 @@ #include #include +#include #include #include #include @@ -42,7 +43,6 @@ #include #include #include -#include #include #include #include @@ -106,7 +106,8 @@ class BlackOilLocalResidualTPFA : public GetPropType(); static constexpr bool enableDispersion = getPropValue(); static constexpr bool enableConvectiveMixing = getPropValue(); - static constexpr bool enableMICP = getPropValue(); + static constexpr bool enableBioeffects = getPropValue(); + static constexpr bool enableMICP = Indices::enableMICP; using SolventModule = BlackOilSolventModule; using ExtboModule = BlackOilExtboModule; @@ -119,7 +120,7 @@ class BlackOilLocalResidualTPFA : public GetPropType; - using MICPModule = BlackOilMICPModule; + using BioeffectsModule = BlackOilBioeffectsModule; using Toolbox = MathToolbox; @@ -232,8 +233,8 @@ public: // deal with salt (if present) BrineModule::addStorage(storage, intQuants); - // deal with micp (if present) - MICPModule::addStorage(storage, intQuants); + // deal with bioeffects (if present) + BioeffectsModule::addStorage(storage, intQuants); } /*! @@ -386,7 +387,7 @@ public: // Use arithmetic average (more accurate with harmonic, but that requires recomputing the transmissbility) Evaluation transMult = (intQuantsIn.rockCompTransMultiplier() + Toolbox::value(intQuantsEx.rockCompTransMultiplier())) / 2; - if constexpr (enableMICP) { + if constexpr (enableBioeffects) { transMult *= (intQuantsIn.permFactor() + Toolbox::value(intQuantsEx.permFactor())) / 2; } Evaluation darcyFlux; @@ -413,9 +414,9 @@ public: EnergyModule::template addPhaseEnthalpyFluxes_(flux, phaseIdx, darcyFlux, up.fluidState()); } - if constexpr (enableMICP) { - MICPModule::template - addMICPFluxes_(flux, darcyFlux, intQuantsIn); + if constexpr (enableBioeffects) { + BioeffectsModule::template addBioeffectsFluxes_ + (flux, phaseIdx, darcyFlux, up); } } else { const auto& invB = getInvB_(up.fluidState(), phaseIdx, pvtRegionIdx); @@ -425,12 +426,11 @@ public: EnergyModule::template addPhaseEnthalpyFluxes_(flux,phaseIdx,darcyFlux, up.fluidState()); } - if constexpr (enableMICP) { - MICPModule::template - addMICPFluxes_(flux, darcyFlux, intQuantsEx); + if constexpr (enableBioeffects) { + BioeffectsModule::template addBioeffectsFluxes_ + (flux, phaseIdx, darcyFlux, up); } } - } // deal with solvents (if present) @@ -524,7 +524,7 @@ public: // apply the scaling for the urea equation in MICP if constexpr (enableMICP) { - MICPModule::applyScaling(flux); + BioeffectsModule::applyScaling(flux); } } @@ -718,8 +718,8 @@ public: // retrieve the source term intrinsic to the problem problem.source(source, globalSpaceIdex, timeIdx); - // deal with MICP (if present) - MICPModule::addSource(source, problem, insideIntQuants, globalSpaceIdex); + // deal with bioeffects (if present) + BioeffectsModule::addSource(source, problem, insideIntQuants, globalSpaceIdex); // scale the source term of the energy equation if constexpr (enableEnergy) { @@ -736,8 +736,8 @@ public: source = 0.0; problem.addToSourceDense(source, globalSpaceIdex, timeIdx); - // deal with MICP (if present) - MICPModule::addSource(source, problem, insideIntQuants, globalSpaceIdex); + // deal with bioeffects (if present) + BioeffectsModule::addSource(source, problem, insideIntQuants, globalSpaceIdex); // scale the source term of the energy equation if constexpr (enableEnergy) { @@ -757,8 +757,8 @@ public: // retrieve the source term intrinsic to the problem elemCtx.problem().source(source, elemCtx, dofIdx, timeIdx); - // deal with MICP (if present) - MICPModule::addSource(source, elemCtx, dofIdx, timeIdx); + // deal with bioeffects (if present) + BioeffectsModule::addSource(source, elemCtx, dofIdx, timeIdx); // scale the source term of the energy equation if constexpr (enableEnergy) { diff --git a/opm/models/blackoil/blackoilmicpmodules.hh b/opm/models/blackoil/blackoilmicpmodules.hh deleted file mode 100644 index 6f4385f43b2..00000000000 --- a/opm/models/blackoil/blackoilmicpmodules.hh +++ /dev/null @@ -1,542 +0,0 @@ -// -*- 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 . - - 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 Contains the classes required to extend the black-oil model by MICP. - */ -#ifndef OPM_BLACK_OIL_MICP_MODULE_HH -#define OPM_BLACK_OIL_MICP_MODULE_HH - -#include - -#include - -#include -#include - -#include - -#include -#include -#include -#include - -namespace Opm { - -/*! - * \ingroup BlackOil - * \brief Contains the high level supplements required to extend the black oil - * model by MICP. - */ -template ()> -class BlackOilMICPModule -{ - using Scalar = GetPropType; - using Evaluation = GetPropType; - using PrimaryVariables = GetPropType; - using IntensiveQuantities = GetPropType; - using ExtensiveQuantities = GetPropType; - using ElementContext = GetPropType; - using FluidSystem = GetPropType; - using Model = GetPropType; - using Simulator = GetPropType; - using EqVector = GetPropType; - using RateVector = GetPropType; - using Indices = GetPropType; - using Problem = GetPropType; - - using Toolbox = MathToolbox; - - using TabulatedFunction = typename BlackOilMICPParams::TabulatedFunction; - - enum { waterCompIdx = FluidSystem::waterCompIdx }; - - static constexpr unsigned microbialConcentrationIdx = Indices::microbialConcentrationIdx; - static constexpr unsigned oxygenConcentrationIdx = Indices::oxygenConcentrationIdx; - static constexpr unsigned ureaConcentrationIdx = Indices::ureaConcentrationIdx; - static constexpr unsigned biofilmConcentrationIdx = Indices::biofilmConcentrationIdx; - static constexpr unsigned calciteConcentrationIdx = Indices::calciteConcentrationIdx; - static constexpr unsigned contiMicrobialEqIdx = Indices::contiMicrobialEqIdx; - static constexpr unsigned contiOxygenEqIdx = Indices::contiOxygenEqIdx; - static constexpr unsigned contiUreaEqIdx = Indices::contiUreaEqIdx; - static constexpr unsigned contiBiofilmEqIdx = Indices::contiBiofilmEqIdx; - static constexpr unsigned contiCalciteEqIdx = Indices::contiCalciteEqIdx; - static constexpr unsigned waterPhaseIdx = FluidSystem::waterPhaseIdx; - - static constexpr unsigned enableMICP = enableMICPV; - - static constexpr unsigned numEq = getPropValue(); - -public: - //! \brief Set parameters. - static void setParams(BlackOilMICPParams&& params) - { - params_ = params; - } - - /*! - * \brief Register all run-time parameters for the black-oil MICP module. - */ - static void registerParameters() - { - if constexpr (enableMICP) { - VtkBlackOilMICPModule::registerParameters(); - } - } - - /*! - * \brief Register all MICP specific VTK and ECL output modules. - */ - static void registerOutputModules(Model& model, - Simulator& simulator) - { - if constexpr (enableMICP) { - model.addOutputModule(std::make_unique>(simulator)); - } - } - - static bool eqApplies(unsigned eqIdx) - { - if constexpr (enableMICP) { - return - eqIdx == contiMicrobialEqIdx - || eqIdx == contiOxygenEqIdx - || eqIdx == contiUreaEqIdx - || eqIdx == contiBiofilmEqIdx - || eqIdx == contiCalciteEqIdx; - } - else { - return false; - } - } - - static Scalar eqWeight([[maybe_unused]] unsigned eqIdx) - { - assert(eqApplies(eqIdx)); - - // TODO: it may be beneficial to chose this differently. - return static_cast(1.0); - } - - // must be called after water storage is computed - template - static void addStorage(Dune::FieldVector& storage, - const IntensiveQuantities& intQuants) - { - if constexpr (enableMICP) { - const auto& fs = intQuants.fluidState(); - - // avoid singular matrix if no water is present - const LhsEval surfaceVolumeWater = - max(Toolbox::template decay(fs.invB(waterPhaseIdx)) * - Toolbox::template decay(intQuants.porosity()), - 1e-10); - - // suspended microbes in water phase - const LhsEval massMicrobes = surfaceVolumeWater * - Toolbox::template decay(intQuants.microbialConcentration()); - const LhsEval accumulationMicrobes = massMicrobes; - storage[contiMicrobialEqIdx] += accumulationMicrobes; - - // oxygen in water phase - const LhsEval massOxygen = surfaceVolumeWater * - Toolbox::template decay(intQuants.oxygenConcentration()); - const LhsEval accumulationOxygen = massOxygen; - storage[contiOxygenEqIdx] += accumulationOxygen; - - // urea in water phase (applying the scaling factor for the urea equation) - const LhsEval massUrea = surfaceVolumeWater * - Toolbox::template decay(intQuants.ureaConcentration()); - const LhsEval accumulationUrea = massUrea; - storage[contiUreaEqIdx] += accumulationUrea; - storage[contiUreaEqIdx] *= getPropValue(); - - // biofilm - const LhsEval massBiofilm = Toolbox::template decay(intQuants.biofilmConcentration()); - const LhsEval accumulationBiofilm = massBiofilm; - storage[contiBiofilmEqIdx] += accumulationBiofilm; - - // calcite - const LhsEval massCalcite = Toolbox::template decay(intQuants.calciteConcentration()); - const LhsEval accumulationCalcite = massCalcite; - storage[contiCalciteEqIdx] += accumulationCalcite; - } - } - - template - static void addMICPFluxes_(RateVector& flux, - const Eval& volumeFlux, - const IntensiveQuantities& upFs) - { - if constexpr (enableMICP) { - flux[contiMicrobialEqIdx] += decay(upFs.microbialConcentration()) * volumeFlux; - flux[contiOxygenEqIdx] += decay(upFs.oxygenConcentration()) * volumeFlux; - flux[contiUreaEqIdx] += decay(upFs.ureaConcentration()) * volumeFlux; - } - } - - // since the urea concentration can be much larger than 1, then we apply a scaling factor - static void applyScaling(RateVector& flux) - { - if constexpr (enableMICP) { - flux[contiUreaEqIdx] *= getPropValue(); - } - } - - static void computeFlux([[maybe_unused]] RateVector& flux, - [[maybe_unused]] const ElementContext& elemCtx, - [[maybe_unused]] unsigned scvfIdx, - [[maybe_unused]] unsigned timeIdx) - { - if constexpr (enableMICP) { - flux[contiMicrobialEqIdx] = 0.0; - flux[contiOxygenEqIdx] = 0.0; - flux[contiUreaEqIdx] = 0.0; - const auto& extQuants = elemCtx.extensiveQuantities(scvfIdx, timeIdx); - const unsigned focusIdx = elemCtx.focusDofIndex(); - const unsigned upIdx = extQuants.upstreamIndex(waterPhaseIdx); - if (upIdx == focusIdx) { - addMICPFluxes_(flux, elemCtx, scvfIdx, timeIdx); - } - else { - addMICPFluxes_(flux, elemCtx, scvfIdx, timeIdx); - } - } - } - - template - static void addMICPFluxes_(RateVector& flux, - const ElementContext& elemCtx, - unsigned scvfIdx, - unsigned timeIdx) - { - const auto& extQuants = elemCtx.extensiveQuantities(scvfIdx, timeIdx); - const unsigned upIdx = extQuants.upstreamIndex(waterPhaseIdx); - const auto& up = elemCtx.intensiveQuantities(upIdx, timeIdx); - const auto& fs = up.fluidState(); - const auto& volFlux = extQuants.volumeFlux(waterPhaseIdx); - addMICPFluxes_(flux, volFlux, fs); - } - - // see https://doi.org/10.1016/j.ijggc.2021.103256 for the MICP processes in the model - static void addSource(RateVector& source, - const Problem& problem, - const IntensiveQuantities& intQuants, - unsigned globalSpaceIdex) - { - if constexpr (enableMICP) { - const auto& velocityInf = problem.model().linearizer().getVelocityInfo(); - const auto& velocityInfos = velocityInf[globalSpaceIdex]; - const Scalar normVelocityCell = - std::accumulate(velocityInfos.begin(), velocityInfos.end(), 0.0, - [](const auto acc, const auto& info) - { return max(acc, std::abs(info.velocity[waterPhaseIdx])); }); - - // get the model parameters - const auto b = intQuants.fluidState().invB(waterPhaseIdx); - const unsigned satnumIdx = problem.satnumRegionIndex(globalSpaceIdex); - const Scalar k_a = microbialAttachmentRate(satnumIdx); - const Scalar k_d = microbialDeathRate(satnumIdx); - const Scalar rho_b = densityBiofilm(satnumIdx); - const Scalar rho_c = densityCalcite(satnumIdx); - const Scalar k_str = detachmentRate(satnumIdx); - const Scalar eta = detachmentExponent(satnumIdx); - const Scalar k_o = halfVelocityOxygen(satnumIdx); - const Scalar k_u = halfVelocityUrea(satnumIdx); - const Scalar mu = maximumGrowthRate(satnumIdx); - const Scalar mu_u = maximumUreaUtilization(satnumIdx); - const Scalar Y_sb = yieldGrowthCoefficient(satnumIdx); - const Scalar F = oxygenConsumptionFactor(satnumIdx); - const Scalar Y_uc = yieldUreaToCalciteCoefficient(satnumIdx); - - // compute Monod terms (the negative region is replaced by a straight line) - // Schäfer et al (1998) https://doi.org/10.1016/S0169-7722(97)00060-0 - const Evaluation k_g = - intQuants.oxygenConcentration() < 0 - ? mu * intQuants.oxygenConcentration() / k_o - : mu * intQuants.oxygenConcentration() / (k_o + intQuants.oxygenConcentration()); - const Evaluation k_c = - intQuants.ureaConcentration() < 0 - ? mu_u * intQuants.ureaConcentration() / k_u - : mu_u * intQuants.ureaConcentration() / (k_u + intQuants.ureaConcentration()); - - // compute the processes - source[Indices::contiMicrobialEqIdx] += intQuants.microbialConcentration() * intQuants.porosity() * - b * (Y_sb * k_g - k_d - k_a) + - rho_b * intQuants.biofilmConcentration() * k_str * pow(normVelocityCell, eta); - - source[Indices::contiOxygenEqIdx] -= (intQuants.microbialConcentration() * intQuants.porosity() * - b + rho_b * intQuants.biofilmConcentration()) * F * k_g; - - source[Indices::contiUreaEqIdx] -= rho_b * intQuants.biofilmConcentration() * k_c; - - source[Indices::contiBiofilmEqIdx] += intQuants.biofilmConcentration() * (Y_sb * k_g - k_d - - k_str * pow(normVelocityCell, eta) - Y_uc * (rho_b / rho_c) * - intQuants.biofilmConcentration() * k_c / (intQuants.porosity() + - intQuants.biofilmConcentration())) + k_a * intQuants.microbialConcentration() * - intQuants.porosity() * b / rho_b; - - source[Indices::contiCalciteEqIdx] += (rho_b / rho_c) * intQuants.biofilmConcentration() * Y_uc * k_c; - - // since the urea concentration can be much larger than 1, then we apply a scaling factor - source[Indices::contiUreaEqIdx] *= getPropValue(); - } - } - - static void addSource([[maybe_unused]] RateVector& source, - [[maybe_unused]] const ElementContext& elemCtx, - [[maybe_unused]] unsigned dofIdx, - [[maybe_unused]] unsigned timeIdx) - { - if constexpr (enableMICP) { - const auto& problem = elemCtx.problem(); - const auto& intQuants = elemCtx.intensiveQuantities(dofIdx, timeIdx); - addSource(source, problem, intQuants, dofIdx); - } - } - - static Scalar densityBiofilm(unsigned satnumRegionIdx) - { return params_.densityBiofilm_[satnumRegionIdx]; } - - static Scalar densityCalcite(unsigned satnumRegionIdx) - { return params_.densityCalcite_[satnumRegionIdx]; } - - static Scalar detachmentRate(unsigned satnumRegionIdx) - { return params_.detachmentRate_[satnumRegionIdx]; } - - static Scalar detachmentExponent(unsigned satnumRegionIdx) - { return params_.detachmentExponent_[satnumRegionIdx]; } - - static Scalar halfVelocityOxygen(unsigned satnumRegionIdx) - { return params_.halfVelocityOxygen_[satnumRegionIdx]; } - - static Scalar halfVelocityUrea(unsigned satnumRegionIdx) - { return params_.halfVelocityUrea_[satnumRegionIdx]; } - - static Scalar maximumGrowthRate(unsigned satnumRegionIdx) - { return params_.maximumGrowthRate_[satnumRegionIdx]; } - - static Scalar maximumUreaUtilization(unsigned satnumRegionIdx) - { return params_.maximumUreaUtilization_[satnumRegionIdx]; } - - static Scalar microbialAttachmentRate(unsigned satnumRegionIdx) - { return params_.microbialAttachmentRate_[satnumRegionIdx]; } - - static Scalar microbialDeathRate(unsigned satnumRegionIdx) - { return params_.microbialDeathRate_[satnumRegionIdx]; } - - static Scalar oxygenConsumptionFactor(unsigned satnumRegionIdx) - { return params_.oxygenConsumptionFactor_[satnumRegionIdx]; } - - static Scalar yieldGrowthCoefficient(unsigned satnumRegionIdx) - { return params_.yieldGrowthCoefficient_[satnumRegionIdx]; } - - static Scalar yieldUreaToCalciteCoefficient(unsigned satnumRegionIdx) - { return params_.yieldUreaToCalciteCoefficient_[satnumRegionIdx]; } - - static Scalar microbialDiffusion(unsigned pvtRegionIdx) - { return params_.microbialDiffusion_[pvtRegionIdx]; } - - static Scalar oxygenDiffusion(unsigned pvtRegionIdx) - { return params_.oxygenDiffusion_[pvtRegionIdx]; } - - static Scalar ureaDiffusion(unsigned pvtRegionIdx) - { return params_.ureaDiffusion_[pvtRegionIdx]; } - - static const TabulatedFunction& permfactTable(const ElementContext& elemCtx, - unsigned scvIdx, - unsigned timeIdx) - { - const unsigned satnumRegionIdx = elemCtx.problem().satnumRegionIndex(elemCtx, scvIdx, timeIdx); - return params_.permfactTable_[satnumRegionIdx]; - } - - static const TabulatedFunction& permfactTable(unsigned satnumRegionIdx) - { return params_.permfactTable_[satnumRegionIdx]; } - -private: - static BlackOilMICPParams params_; -}; - -template -BlackOilMICPParams::Scalar> -BlackOilMICPModule::params_; - -template -class BlackOilMICPIntensiveQuantities; - -/*! - * \ingroup BlackOil - * \class Opm::BlackOilMICPIntensiveQuantities - * - * \brief Provides the volumetric quantities required for the equations needed by the - * MICP extension of the black-oil model. - */ -template -class BlackOilMICPIntensiveQuantities -{ - using Implementation = GetPropType; - - using Scalar = GetPropType; - using Evaluation = GetPropType; - using PrimaryVariables = GetPropType; - using FluidSystem = GetPropType; - using Indices = GetPropType; - using ElementContext = GetPropType; - - using MICPModule = BlackOilMICPModule; - - static constexpr int microbialConcentrationIdx = Indices::microbialConcentrationIdx; - static constexpr int oxygenConcentrationIdx = Indices::oxygenConcentrationIdx; - static constexpr int ureaConcentrationIdx = Indices::ureaConcentrationIdx; - static constexpr int biofilmConcentrationIdx = Indices::biofilmConcentrationIdx; - static constexpr int calciteConcentrationIdx = Indices::calciteConcentrationIdx; - static constexpr int waterPhaseIdx = FluidSystem::waterPhaseIdx; - -public: - /*! - * \brief Update the intensive properties needed to handle MICP from the - * primary variables - * - */ - void MICPPropertiesUpdate_(const ElementContext& elemCtx, - unsigned dofIdx, - unsigned timeIdx) - { - const auto linearizationType = elemCtx.linearizationType(); - const PrimaryVariables& priVars = elemCtx.primaryVars(dofIdx, timeIdx); - const Scalar referencePorosity_ = elemCtx.problem().referencePorosity(dofIdx, timeIdx); - - microbialConcentration_ = priVars.makeEvaluation(microbialConcentrationIdx, timeIdx, linearizationType); - oxygenConcentration_ = priVars.makeEvaluation(oxygenConcentrationIdx, timeIdx, linearizationType); - ureaConcentration_ = priVars.makeEvaluation(ureaConcentrationIdx, timeIdx, linearizationType); - biofilmConcentration_ = priVars.makeEvaluation(biofilmConcentrationIdx, timeIdx, linearizationType); - calciteConcentration_ = priVars.makeEvaluation(calciteConcentrationIdx, timeIdx, linearizationType); - - const Evaluation porosityFactor = min(1.0 - (biofilmConcentration_ + calciteConcentration_) / - (referencePorosity_ + 1e-8), - 1.0); // phi / phi_0 - const unsigned satnumRegionIdx = elemCtx.problem().satnumRegionIndex(elemCtx, dofIdx, timeIdx); - const auto& permfactTable = MICPModule::permfactTable(satnumRegionIdx); - permFactor_ = permfactTable.eval(porosityFactor, /*extrapolation=*/true); - - biofilmMass_ = referencePorosity_*biofilmConcentration_*MICPModule::densityBiofilm(satnumRegionIdx); - calciteMass_ = referencePorosity_*calciteConcentration_*MICPModule::densityCalcite(satnumRegionIdx); - } - - const Evaluation& microbialConcentration() const - { return microbialConcentration_; } - - const Evaluation& oxygenConcentration() const - { return oxygenConcentration_; } - - const Evaluation& ureaConcentration() const - { return ureaConcentration_; } - - const Evaluation& biofilmConcentration() const - { return biofilmConcentration_; } - - const Evaluation& calciteConcentration() const - { return calciteConcentration_; } - - const Evaluation biofilmMass() const - { return biofilmMass_; } - - const Evaluation calciteMass() const - { return calciteMass_; } - - const Evaluation& permFactor() const - { return permFactor_; } - -protected: - Evaluation microbialConcentration_; - Evaluation oxygenConcentration_; - Evaluation ureaConcentration_; - Evaluation biofilmConcentration_; - Evaluation calciteConcentration_; - Evaluation biofilmMass_; - Evaluation calciteMass_; - Evaluation permFactor_; -}; - -template -class BlackOilMICPIntensiveQuantities -{ - using Evaluation = GetPropType; - using ElementContext = GetPropType; - using Scalar = GetPropType; - -public: - void MICPPropertiesUpdate_(const ElementContext&, - unsigned, - unsigned) - {} - - const Evaluation& microbialConcentration() const - { throw std::logic_error("microbialConcentration() called but MICP is disabled"); } - - const Evaluation& oxygenConcentration() const - { throw std::logic_error("oxygenConcentration() called but MICP is disabled"); } - - const Evaluation& ureaConcentration() const - { throw std::logic_error("ureaConcentration() called but MICP is disabled"); } - - const Evaluation& biofilmConcentration() const - { throw std::logic_error("biofilmConcentration() called but MICP is disabled"); } - - const Evaluation& calciteConcentration() const - { throw std::logic_error("calciteConcentration() called but MICP is disabled"); } - - const Evaluation& biofilmMass() const - { throw std::logic_error("biofilmMass() called but MICP is disabled"); } - - const Evaluation& calciteMass() const - { throw std::logic_error("calciteMass() called but MICP is disabled"); } - - const Evaluation& permFactor() const - { throw std::logic_error("permFactor() called but MICP is disabled"); } -}; - -template -class BlackOilMICPExtensiveQuantities; - -/*! - * \ingroup BlackOil - * \class Opm::BlackOilMICPExtensiveQuantities - * - * \brief Provides the MICP specific extensive quantities to the generic black-oil - * module's extensive quantities. - */ -template -class BlackOilMICPExtensiveQuantities -{ - using Implementation = GetPropType; -}; - -template -class BlackOilMICPExtensiveQuantities{}; - -} // namespace Opm - -#endif diff --git a/opm/models/blackoil/blackoilmicpparams.cpp b/opm/models/blackoil/blackoilmicpparams.cpp deleted file mode 100644 index fd6c2da7de8..00000000000 --- a/opm/models/blackoil/blackoilmicpparams.cpp +++ /dev/null @@ -1,146 +0,0 @@ -// -*- 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 . - - 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. -*/ - -#include -#include - -#if HAVE_ECL_INPUT -#include -#include -#include -#include -#include -#include -#endif - -#include -#include -#include - -namespace Opm { - -#if HAVE_ECL_INPUT -template -template -void BlackOilMICPParams:: -initFromState(const EclipseState& eclState) -{ - // some sanity checks: if MICP is enabled, the MICP keyword must be - // present, if MICP is disabled the keyword must not be present. - if constexpr (enableMICP) { - if (!eclState.runspec().micp()) { - throw std::runtime_error("Non-trivial MICP treatment requested at compile time, but " - "the deck does not contain the MICP keyword"); - } - } - else { - if (eclState.runspec().micp()) { - throw std::runtime_error("MICP treatment disabled at compile time, but the deck " - "contains the MICP keyword"); - } - } - - if (!eclState.runspec().micp()) - return; // MICP treatment is supposed to be disabled*/ - - const auto& tableManager = eclState.getTableManager(); - unsigned numSatRegions = tableManager.getTabdims().getNumSatTables(); - unsigned numPvtRegions = tableManager.getTabdims().getNumPVTTables(); - - // initialize the objects which deal with the MICP parameters - const TableContainer& biofilmTables = tableManager.getBiofilmTables(); - if (biofilmTables.empty()) { - throw std::runtime_error("MICP requires the BIOFPARA keyword"); - } - densityBiofilm_.resize(numSatRegions); - densityCalcite_.resize(numSatRegions); - detachmentRate_.resize(numSatRegions); - detachmentExponent_.resize(numSatRegions); - halfVelocityOxygen_.resize(numSatRegions); - halfVelocityUrea_.resize(numSatRegions); - maximumGrowthRate_.resize(numSatRegions); - maximumUreaUtilization_.resize(numSatRegions); - microbialAttachmentRate_.resize(numSatRegions); - microbialDeathRate_.resize(numSatRegions); - oxygenConsumptionFactor_.resize(numSatRegions); - yieldGrowthCoefficient_.resize(numSatRegions); - yieldUreaToCalciteCoefficient_.resize(numSatRegions); - for (unsigned stnRegionIdx = 0; stnRegionIdx < numSatRegions; ++stnRegionIdx) { - const BiofilmTable& biofilmTable = biofilmTables.getTable(stnRegionIdx); - densityBiofilm_[stnRegionIdx] = biofilmTable.getDensityBiofilm().front(); - densityCalcite_[stnRegionIdx] = biofilmTable.getDensityCalcite().front(); - detachmentRate_[stnRegionIdx] = biofilmTable.getDetachmentRate().front(); - detachmentExponent_[stnRegionIdx] = biofilmTable.getDetachmentExponent().front(); - halfVelocityOxygen_[stnRegionIdx] = biofilmTable.getHalfVelocityOxygen().front(); - halfVelocityUrea_[stnRegionIdx] = biofilmTable.getHalfVelocityUrea().front(); - maximumGrowthRate_[stnRegionIdx] = biofilmTable.getMaximumGrowthRate().front(); - maximumUreaUtilization_[stnRegionIdx] = biofilmTable.getMaximumUreaUtilization().front(); - microbialAttachmentRate_[stnRegionIdx] = biofilmTable.getMicrobialAttachmentRate().front(); - microbialDeathRate_[stnRegionIdx] = biofilmTable.getMicrobialDeathRate().front(); - oxygenConsumptionFactor_[stnRegionIdx] = biofilmTable.getOxygenConsumptionFactor().front(); - yieldGrowthCoefficient_[stnRegionIdx] = biofilmTable.getYieldGrowthCoefficient().front(); - yieldUreaToCalciteCoefficient_[stnRegionIdx] = biofilmTable.getYieldUreaToCalciteCoefficient().front(); - } - - const TableContainer& diffMICPTables = tableManager.getDiffMICPTables(); - microbialDiffusion_.resize(numPvtRegions); - oxygenDiffusion_.resize(numPvtRegions); - ureaDiffusion_.resize(numPvtRegions); - for (unsigned pvtRegionIdx = 0; pvtRegionIdx < numPvtRegions; ++pvtRegionIdx) { - if (!diffMICPTables.empty()) { - const DiffMICPTable& diffMICPTable = diffMICPTables.getTable(pvtRegionIdx); - microbialDiffusion_[pvtRegionIdx] = diffMICPTable.getMicrobialDiffusion().front(); - oxygenDiffusion_[pvtRegionIdx] = diffMICPTable.getOxygenDiffusion().front(); - ureaDiffusion_[pvtRegionIdx] = diffMICPTable.getUreaDiffusion().front(); - } - else { - microbialDiffusion_[pvtRegionIdx] = 0.0; - oxygenDiffusion_[pvtRegionIdx] = 0.0; - ureaDiffusion_[pvtRegionIdx] = 0.0; - } - } - - const TableContainer& permfactTables = tableManager.getPermfactTables(); - if (permfactTables.empty()) { - throw std::runtime_error("MICP requires the PERMFACT keyword"); - } - permfactTable_.resize(numSatRegions); - for (std::size_t i = 0; i < permfactTables.size(); ++i) { - const PermfactTable& permfactTable = permfactTables.getTable(i); - permfactTable_[i].setXYContainers(permfactTable.getPorosityChangeColumn(), permfactTable.getPermeabilityMultiplierColumn()); - } -} -#endif - -#define INSTANTIATE_TYPE(T) \ - template struct BlackOilMICPParams; \ - template void BlackOilMICPParams::initFromState(const EclipseState&); \ - template void BlackOilMICPParams::initFromState(const EclipseState&); - -INSTANTIATE_TYPE(double) - -#if FLOW_INSTANTIATE_FLOAT -INSTANTIATE_TYPE(float) -#endif - -} // namespace Opm diff --git a/opm/models/blackoil/blackoilmodel.hh b/opm/models/blackoil/blackoilmodel.hh index 5135171d9d6..60e7e7619aa 100644 --- a/opm/models/blackoil/blackoilmodel.hh +++ b/opm/models/blackoil/blackoilmodel.hh @@ -32,6 +32,7 @@ #include +#include #include #include #include @@ -43,7 +44,6 @@ #include #include #include -#include #include #include #include @@ -147,7 +147,7 @@ struct Indices getPropValue(), getPropValue(), /*PVOffset=*/0, - getPropValue()>; + getPropValue()>; }; //! Set the fluid system to the black-oil fluid system by default @@ -198,7 +198,7 @@ struct EnableSaltPrecipitation { static constexpr bool value = false; }; template -struct EnableMICP +struct EnableBioeffects { static constexpr bool value = false; }; //! By default, the blackoil model is isothermal and does not conserve energy @@ -215,7 +215,7 @@ template struct EnableDiffusion { static constexpr bool value = false; }; -//! disable disperison by default +//! disable dispersion by default template struct EnableDispersion { static constexpr bool value = false; }; @@ -363,7 +363,7 @@ private: using EnergyModule = BlackOilEnergyModule; using DiffusionModule = BlackOilDiffusionModule; using DispersionModule = BlackOilDispersionModule; - using MICPModule = BlackOilMICPModule; + using BioeffectsModule = BlackOilBioeffectsModule; public: using LocalResidual = GetPropType; @@ -386,7 +386,7 @@ public: PolymerModule::registerParameters(); EnergyModule::registerParameters(); DiffusionModule::registerParameters(); - MICPModule::registerParameters(); + BioeffectsModule::registerParameters(); // register runtime parameters of the VTK output modules VtkBlackOilModule::registerParameters(); @@ -675,7 +675,7 @@ protected: SolventModule::registerOutputModules(asImp_(), this->simulator_); PolymerModule::registerOutputModules(asImp_(), this->simulator_); EnergyModule::registerOutputModules(asImp_(), this->simulator_); - MICPModule::registerOutputModules(asImp_(), this->simulator_); + BioeffectsModule::registerOutputModules(asImp_(), this->simulator_); this->addOutputModule(std::make_unique>(this->simulator_)); this->addOutputModule(std::make_unique>(this->simulator_)); diff --git a/opm/models/blackoil/blackoilnewtonmethod.hpp b/opm/models/blackoil/blackoilnewtonmethod.hpp index 3b96e54d459..184b418dd0a 100644 --- a/opm/models/blackoil/blackoilnewtonmethod.hpp +++ b/opm/models/blackoil/blackoilnewtonmethod.hpp @@ -30,9 +30,9 @@ #include -#include -#include +#include #include +#include #include @@ -69,7 +69,7 @@ class BlackOilNewtonMethod : public GetPropType; using Scalar = GetPropType; using Linearizer = GetPropType; - using MICPModule = BlackOilMICPModule; + using BioeffectsModule = BlackOilBioeffectsModule; static const unsigned numEq = getPropValue(); static constexpr bool enableSaltPrecipitation = getPropValue(); @@ -211,7 +211,8 @@ class BlackOilNewtonMethod : public GetPropType= 0; static constexpr bool enableFoam = Indices::foamConcentrationIdx >= 0; static constexpr bool enableBrine = Indices::saltConcentrationIdx >= 0; - static constexpr bool enableMICP = Indices::microbialConcentrationIdx >= 0; + static constexpr bool enableBioeffects = Indices::biofilmConcentrationIdx >= 0; + static constexpr bool enableMICP = Indices::enableMICP; currentValue.checkDefined(); Valgrind::CheckDefined(update); @@ -392,25 +393,26 @@ class BlackOilNewtonMethod : public GetPropTypeproblem().referencePorosity(globalDofIdx, 0) - 1e-8); } - if (pvIdx == Indices::calciteConcentrationIdx) { - nextValue[pvIdx] = std::clamp(nextValue[pvIdx], - Scalar{0.0}, - this->problem().referencePorosity(globalDofIdx, 0) - 1e-8); + if constexpr (enableMICP) { + if (pvIdx == Indices::oxygenConcentrationIdx) { + nextValue[pvIdx] = std::max(nextValue[pvIdx], Scalar{0.0}); + } + if (pvIdx == Indices::ureaConcentrationIdx) { + nextValue[pvIdx] = std::max(nextValue[pvIdx], Scalar{0.0}); + } + if (pvIdx == Indices::calciteConcentrationIdx) { + nextValue[pvIdx] = std::clamp(nextValue[pvIdx], Scalar{0.0}, + this->problem().referencePorosity(globalDofIdx, 0) - 1e-8); + } } } } diff --git a/opm/models/blackoil/blackoilonephaseindices.hh b/opm/models/blackoil/blackoilonephaseindices.hh index 94170fedadf..726836b1212 100644 --- a/opm/models/blackoil/blackoilonephaseindices.hh +++ b/opm/models/blackoil/blackoilonephaseindices.hh @@ -47,7 +47,7 @@ template + unsigned numBioCompV> struct BlackOilOnePhaseIndices { //! Is phase enabled or not @@ -67,8 +67,11 @@ struct BlackOilOnePhaseIndices //! Shall energy be conserved? static constexpr bool enableEnergy = numEnergyV > 0; - //! Is MICP involved? - static constexpr bool enableMICP = numMICPsV > 0; + //! Is MICP involved? (microbes, oxygen, urea, biofilm, and calcite) + static constexpr bool enableMICP = numBioCompV == 5; + + //! Biofilm effects on co2/h2store only for two phase indices + static constexpr bool enableBiofilm = false; //! Number of solvent components to be considered static constexpr int numSolvents = enableSolvent ? numSolventsV : 0; @@ -92,7 +95,10 @@ struct BlackOilOnePhaseIndices static constexpr int numPhases = 1; //! Number of MICP components to be considered - static constexpr int numMICPs = enableMICP ? numMICPsV : 0; + static constexpr int numMICPs = enableMICP ? numBioCompV : 0; + + //! Number of biocomponents in the water phase + static constexpr int numBioInWat = enableMICP ? 3 : 0; //! The number of equations static constexpr int numEq = numPhases + numSolvents + numExtbos + numPolymers + diff --git a/opm/models/blackoil/blackoilprimaryvariables.hh b/opm/models/blackoil/blackoilprimaryvariables.hh index da0f6c6ee7d..2f962c4da84 100644 --- a/opm/models/blackoil/blackoilprimaryvariables.hh +++ b/opm/models/blackoil/blackoilprimaryvariables.hh @@ -31,6 +31,7 @@ #include #include +#include #include #include #include @@ -108,7 +109,8 @@ class BlackOilPrimaryVariables : public FvBasePrimaryVariables enum { enableVapwat = getPropValue() }; enum { enableEnergy = getPropValue() }; enum { enableTemperature = getPropValue() }; - enum { enableMICP = getPropValue() }; + enum { enableBioeffects = getPropValue() }; + enum { enableMICP = Indices::enableMICP }; enum { gasCompIdx = FluidSystem::gasCompIdx }; enum { waterCompIdx = FluidSystem::waterCompIdx }; enum { oilCompIdx = FluidSystem::oilCompIdx }; @@ -119,6 +121,7 @@ class BlackOilPrimaryVariables : public FvBasePrimaryVariables using ExtboModule = BlackOilExtboModule; using EnergyModule = BlackOilEnergyModule; using BrineModule = BlackOilBrineModule; + using BioeffectsModule = BlackOilBioeffectsModule; static_assert(numPhases == 3, "The black-oil model assumes three phases!"); static_assert(numComponents == 3, "The black-oil model assumes three components!"); @@ -585,15 +588,25 @@ public: return changed; } - if (BrineModule::hasPcfactTables() && primaryVarsMeaningBrine() == BrineMeaning::Sp) { - const unsigned satnumRegionIdx = problem.satnumRegionIndex(globalDofIdx); - const Scalar Sp = saltConcentration_(); - const Scalar porosityFactor = std::min(1.0 - Sp, 1.0); //phi/phi_0 - const auto& pcfactTable = BrineModule::pcfactTable(satnumRegionIdx); - pcFactor_ = pcfactTable.eval(porosityFactor, /*extrapolation=*/true); + pcFactor_ = 1.0; + if constexpr (enableBrine) { + if (BrineModule::hasPcfactTables() && primaryVarsMeaningBrine() == BrineMeaning::Sp) { + unsigned satnumRegionIdx = problem.satnumRegionIndex(globalDofIdx); + Scalar Sp = saltConcentration_(); + Scalar porosityFactor = std::min(1.0 - Sp, 1.0); //phi/phi_0 + const auto& pcfactTable = BrineModule::pcfactTable(satnumRegionIdx); + pcFactor_ = pcfactTable.eval(porosityFactor, /*extrapolation=*/true); + } } - else { - pcFactor_ = 1.0; + else if constexpr (enableBioeffects) { + if (BioeffectsModule::hasPcfactTables() && problem.referencePorosity(globalDofIdx, 0) > 0) { + unsigned satnumRegionIdx = problem.satnumRegionIndex(globalDofIdx); + Scalar Sb = biofilmConcentration_() / + problem.referencePorosity(globalDofIdx, 0); + Scalar porosityFactor = std::min(1.0 - Sb, 1.0); //phi/phi_0 + const auto& pcfactTable = BioeffectsModule::pcfactTable(satnumRegionIdx); + pcFactor_ = pcfactTable.eval(porosityFactor, /*extrapolation=*/true); + } } switch (primaryVarsMeaningWater()) { @@ -974,6 +987,14 @@ private: } } + Scalar biofilmConcentration_() const + { + if constexpr (enableBioeffects) + return (*this)[Indices::biofilmConcentrationIdx]; + else + return 0.0; + } + Scalar temperature_(const Problem& problem, [[maybe_unused]] unsigned globalDofIdx) const { if constexpr (enableEnergy) { diff --git a/opm/models/blackoil/blackoilproperties.hh b/opm/models/blackoil/blackoilproperties.hh index ef5a333504d..94b33d8704e 100644 --- a/opm/models/blackoil/blackoilproperties.hh +++ b/opm/models/blackoil/blackoilproperties.hh @@ -78,9 +78,9 @@ struct EnableVapwat { using type = UndefinedProperty; }; template struct EnableDisgasInWater { using type = UndefinedProperty; }; -//! Enable the ECL-blackoil extension for MICP. +//! Enable the ECL-blackoil extension for bioeffects (biofilm/MICP) template -struct EnableMICP { using type = UndefinedProperty; }; +struct EnableBioeffects { using type = UndefinedProperty; }; //! Allow the spatial and temporal domains to exhibit non-constant temperature //! in the black-oil model diff --git a/opm/models/blackoil/blackoilratevector.hh b/opm/models/blackoil/blackoilratevector.hh index 15136ce3ec2..afeb9bdb668 100644 --- a/opm/models/blackoil/blackoilratevector.hh +++ b/opm/models/blackoil/blackoilratevector.hh @@ -34,9 +34,9 @@ #include #include +#include #include #include -#include #include #include #include @@ -69,7 +69,6 @@ class BlackOilRateVector using PolymerModule = BlackOilPolymerModule; using FoamModule = BlackOilFoamModule; using BrineModule = BlackOilBrineModule; - using MICPModule = BlackOilMICPModule; enum { numEq = getPropValue() }; enum { numComponents = getPropValue() }; @@ -81,7 +80,7 @@ class BlackOilRateVector enum { enablePolymerMolarWeight = getPropValue() }; enum { enableFoam = getPropValue() }; enum { enableBrine = getPropValue() }; - enum { enableMICP = getPropValue() }; + enum { enableBioeffects = getPropValue() }; using Toolbox = MathToolbox; using ParentType = Dune::FieldVector; @@ -162,8 +161,8 @@ public: throw std::logic_error("setMolarRate() not implemented for salt water"); } - if constexpr (enableMICP) { - throw std::logic_error("setMolarRate() not implemented for MICP"); + if constexpr (enableBioeffects) { + throw std::logic_error("setMolarRate() not implemented for bioeffects (biofilm/MICP)"); } // convert to "surface volume" if requested diff --git a/opm/models/blackoil/blackoiltwophaseindices.hh b/opm/models/blackoil/blackoiltwophaseindices.hh index ada2d1d72df..f0136d4f7f2 100644 --- a/opm/models/blackoil/blackoiltwophaseindices.hh +++ b/opm/models/blackoil/blackoiltwophaseindices.hh @@ -47,7 +47,7 @@ template + unsigned numBioCompV> struct BlackOilTwoPhaseIndices { //! Is phase enabled or not @@ -67,8 +67,11 @@ struct BlackOilTwoPhaseIndices //! Shall energy be conserved? static constexpr bool enableEnergy = numEnergyV > 0; - //! Is MICP involved? - static constexpr bool enableMICP = numMICPsV > 0; + //! MICP only available for one phase indices + static constexpr bool enableMICP = false; + + //! Are biofilms involved? + static constexpr bool enableBiofilm = numBioCompV > 0; //! Number of solvent components to be considered static constexpr int numSolvents = enableSolvent ? numSolventsV : 0; @@ -88,15 +91,18 @@ struct BlackOilTwoPhaseIndices //! Number of salt equations to be considered static constexpr int numBrine = enableBrine? 1 : 0; + //! Number of biofilm equations to be considered + static constexpr int numBioComp = enableBiofilm ? numBioCompV : 0; + + //! Number of biocomponents in the water phase + static constexpr int numBioInWat = enableBiofilm ? 1 : 0; + //! The number of fluid phases static constexpr int numPhases = 2; - //! Number of MICP components to be considered - static constexpr int numMICPs = enableMICP ? numMICPsV : 0; - //! The number of equations static constexpr int numEq = numPhases + numSolvents + numExtbos + numPolymers + - numEnergy + numFoam + numBrine + numMICPs; + numEnergy + numFoam + numBrine + numBioComp; ////////////////////////////// // Primary variable indices @@ -144,37 +150,30 @@ struct BlackOilTwoPhaseIndices static constexpr int polymerMoleWeightIdx = numPolymers > 1 ? polymerConcentrationIdx + 1 : -1000; - //! Index of the primary variable for the first MICP component + //! Index of the primary variable for the first microbial component static constexpr int microbialConcentrationIdx = - enableMICP ? PVOffset + numPhases + numSolvents : -1000; + enableBiofilm ? PVOffset + numPhases + numSolvents : -1000; - //! Index of the primary variable for the second MICP component - static constexpr int oxygenConcentrationIdx = - numMICPs > 1 ? microbialConcentrationIdx + 1 : -1000; - - //! Index of the primary variable for the third MICP component - static constexpr int ureaConcentrationIdx = - numMICPs > 2 ? oxygenConcentrationIdx + 1 : -1000; - - //! Index of the primary variable for the fourth MICP component + //! Index of the primary variable for the biofilm component static constexpr int biofilmConcentrationIdx = - numMICPs > 3 ? ureaConcentrationIdx + 1 : -1000; + enableBiofilm ? PVOffset + numPhases + numSolvents + 1 : -1000; - //! Index of the primary variable for the fifth MICP component - static constexpr int calciteConcentrationIdx = - numMICPs > 4 ? biofilmConcentrationIdx + 1 : -1000; + //! MICP only available for one phase indices + static constexpr int oxygenConcentrationIdx = -1000; + static constexpr int ureaConcentrationIdx = -1000; + static constexpr int calciteConcentrationIdx = -1000; //! Index of the primary variable for the foam static constexpr int foamConcentrationIdx = - enableFoam ? PVOffset + numPhases + numSolvents + numPolymers + numMICPs : -1000; + enableFoam ? PVOffset + numPhases + numSolvents + numPolymers + numBioComp : -1000; //! Index of the primary variable for the salt static constexpr int saltConcentrationIdx = - enableBrine ? PVOffset + numPhases + numSolvents + numPolymers + numMICPs + numFoam : -1000; + enableBrine ? PVOffset + numPhases + numSolvents + numPolymers + numBioComp + numFoam : -1000; //! Index of the primary variable for temperature static constexpr int temperatureIdx = - enableEnergy ? PVOffset + numPhases + numSolvents + numExtbos + numPolymers + numMICPs + numFoam + numBrine : - 1000; + enableEnergy ? PVOffset + numPhases + numSolvents + numExtbos + numPolymers + numBioComp + numFoam + numBrine : - 1000; ////////////////////// // Equation indices @@ -200,37 +199,30 @@ struct BlackOilTwoPhaseIndices static constexpr int contiPolymerMWEqIdx = numPolymers > 1 ? contiPolymerEqIdx + 1 : -1000; - //! Index of the continuity equation for the first MICP component + //! Index of the continuity equation for the first microbial component static constexpr int contiMicrobialEqIdx = - enableMICP ? PVOffset + numPhases + numSolvents : -1000; - - //! Index of the continuity equation for the second MICP component - static constexpr int contiOxygenEqIdx = - numMICPs > 1 ? contiMicrobialEqIdx + 1 : -1000; - - //! Index of the continuity equation for the third MICP component - static constexpr int contiUreaEqIdx = - numMICPs > 2 ? contiOxygenEqIdx + 1 : -1000; + enableBiofilm ? PVOffset + numPhases + numSolvents : -1000; - //! Index of the continuity equation for the fourth MICP component + //! Index of the continuity equation for the biofilm component static constexpr int contiBiofilmEqIdx = - numMICPs > 3 ? contiUreaEqIdx + 1 : -1000; + enableBiofilm ? PVOffset + numPhases + numSolvents + 1 : -1000; - //! Index of the continuity equation for the fifth MICP component - static constexpr int contiCalciteEqIdx = - numMICPs > 4 ? contiBiofilmEqIdx + 1 : -1000; + //! MICP only available for one phase indices + static constexpr int contiOxygenEqIdx = -1000; + static constexpr int contiUreaEqIdx = -1000; + static constexpr int contiCalciteEqIdx = -1000; //! Index of the continuity equation for the foam component static constexpr int contiFoamEqIdx = - enableFoam ? PVOffset + numPhases + numSolvents + numPolymers + numMICPs : -1000; + enableFoam ? PVOffset + numPhases + numSolvents + numPolymers + numBioComp : -1000; //! Index of the continuity equation for the salt component static constexpr int contiBrineEqIdx = - enableBrine ? PVOffset + numPhases + numSolvents + numPolymers + numMICPs + numFoam : -1000; + enableBrine ? PVOffset + numPhases + numSolvents + numPolymers + numBioComp + numFoam : -1000; //! Index of the continuity equation for energy static constexpr int contiEnergyEqIdx = - enableEnergy ? PVOffset + numPhases + numSolvents + numExtbos + numPolymers + numMICPs + numFoam + numBrine: -1000; + enableEnergy ? PVOffset + numPhases + numSolvents + numExtbos + numPolymers + numBioComp + numFoam + numBrine: -1000; }; } // namespace Opm diff --git a/opm/models/blackoil/blackoilvariableandequationindices.hh b/opm/models/blackoil/blackoilvariableandequationindices.hh index 0fc1a20fea7..20040f211d0 100644 --- a/opm/models/blackoil/blackoilvariableandequationindices.hh +++ b/opm/models/blackoil/blackoilvariableandequationindices.hh @@ -42,7 +42,7 @@ template + unsigned numBioCompV> struct BlackOilVariableAndEquationIndices { //! Number of phases active at all times @@ -65,8 +65,10 @@ struct BlackOilVariableAndEquationIndices //! Shall energy be conserved? static constexpr bool enableEnergy = numEnergyV > 0; - //! Is MICP involved? - static constexpr bool enableMICP = numMICPsV > 0; + //! No bioeffects for three phase indices + static constexpr bool enableMICP = false; + static constexpr bool enableBiofilm = false; + static constexpr int numBioInWat = 0; //! Number of solvent components to be considered static constexpr int numSolvents = enableSolvent ? numSolventsV : 0; @@ -86,12 +88,9 @@ struct BlackOilVariableAndEquationIndices //! Number of salt equations to be considered static constexpr int numBrine = enableBrine? 1 : 0; - //! Number of MICP components to be considered - static constexpr int numMICPs = enableMICP ? numMICPsV : 0; - //! The number of equations static constexpr int numEq = numPhases + numSolvents + numExtbos + numPolymers + - numEnergy + numFoam + numBrine + numMICPs; + numEnergy + numFoam + numBrine; //////// // Primary variable indices @@ -139,37 +138,24 @@ struct BlackOilVariableAndEquationIndices static constexpr int polymerMoleWeightIdx = numPolymers > 1 ? polymerConcentrationIdx + 1 : -1000; - //! Index of the primary variable for the first MICP component - static constexpr int microbialConcentrationIdx = - enableMICP ? PVOffset + numPhases + numSolvents : -1000; - - //! Index of the primary variable for the second MICP component - static constexpr int oxygenConcentrationIdx = - numMICPs > 1 ? microbialConcentrationIdx + 1 : -1000; - - //! Index of the primary variable for the third MICP component - static constexpr int ureaConcentrationIdx = - numMICPs > 2 ? oxygenConcentrationIdx + 1 : -1000; - - //! Index of the primary variable for the fourth MICP component - static constexpr int biofilmConcentrationIdx = - numMICPs > 3 ? ureaConcentrationIdx + 1 : -1000; - - //! Index of the primary variable for the fifth MICP component - static constexpr int calciteConcentrationIdx = - numMICPs > 4 ? biofilmConcentrationIdx + 1 : -1000; + //! No bioeffects for three phase indices + static constexpr int microbialConcentrationIdx = -1000; + static constexpr int oxygenConcentrationIdx = -1000; + static constexpr int ureaConcentrationIdx = -1000; + static constexpr int biofilmConcentrationIdx = -1000; + static constexpr int calciteConcentrationIdx = -1000; //! Index of the primary variable for the foam static constexpr int foamConcentrationIdx = - enableFoam ? PVOffset + numPhases + numSolvents + numExtbos + numPolymers + numMICPs : -1000; + enableFoam ? PVOffset + numPhases + numSolvents + numExtbos + numPolymers : -1000; //! Index of the primary variable for the brine static constexpr int saltConcentrationIdx = - enableBrine ? PVOffset + numPhases + numSolvents + numExtbos + numExtbos + numPolymers + numMICPs + numFoam : -1000; + enableBrine ? PVOffset + numPhases + numSolvents + numExtbos + numExtbos + numPolymers + numFoam : -1000; //! Index of the primary variable for temperature static constexpr int temperatureIdx = - enableEnergy ? PVOffset + numPhases + numSolvents + numExtbos + numPolymers + numMICPs + numFoam + numBrine : - 1000; + enableEnergy ? PVOffset + numPhases + numSolvents + numExtbos + numPolymers + numFoam + numBrine : - 1000; //////// @@ -195,38 +181,25 @@ struct BlackOilVariableAndEquationIndices //! Index of the continuity equation for the second polymer component (molecular weight) static constexpr int contiPolymerMWEqIdx = numPolymers > 1 ? contiPolymerEqIdx + 1 : -1000; - - //! Index of the continuity equation for the first MICP component - static constexpr int contiMicrobialEqIdx = - enableMICP ? PVOffset + numPhases + numSolvents + numExtbos : -1000; - - //! Index of the continuity equation for the second MICP component - static constexpr int contiOxygenEqIdx = - numMICPs > 1 ? contiMicrobialEqIdx + 1 : -1000; - - //! Index of the continuity equation for the third MICP component - static constexpr int contiUreaEqIdx = - numMICPs > 2 ? contiOxygenEqIdx + 1 : -1000; - - //! Index of the continuity equation for the fourth MICP component - static constexpr int contiBiofilmEqIdx = - numMICPs > 3 ? contiUreaEqIdx + 1 : -1000; - - //! Index of the continuity equation for the fifth MICP component - static constexpr int contiCalciteEqIdx = - numMICPs > 4 ? contiBiofilmEqIdx + 1 : -1000; + + //! No bioeffects for three phase indices + static constexpr int contiMicrobialEqIdx = -1000; + static constexpr int contiOxygenEqIdx = -1000; + static constexpr int contiUreaEqIdx = -1000; + static constexpr int contiBiofilmEqIdx = -1000; + static constexpr int contiCalciteEqIdx = -1000; //! Index of the continuity equation for the foam component static constexpr int contiFoamEqIdx = - enableFoam ? PVOffset + numPhases + numSolvents + numExtbos + numPolymers + numMICPs : -1000; + enableFoam ? PVOffset + numPhases + numSolvents + numExtbos + numPolymers : -1000; //! Index of the continuity equation for the salt water component static constexpr int contiBrineEqIdx = - enableBrine ? PVOffset + numPhases + numSolvents + numExtbos + numPolymers + numMICPs + numFoam : -1000; + enableBrine ? PVOffset + numPhases + numSolvents + numExtbos + numPolymers + numFoam : -1000; //! Index of the continuity equation for energy static constexpr int contiEnergyEqIdx = - enableEnergy ? PVOffset + numPhases + numSolvents + numExtbos + numPolymers + numMICPs + numFoam + numBrine: -1000; + enableEnergy ? PVOffset + numPhases + numSolvents + numExtbos + numPolymers + numFoam + numBrine: -1000; }; } // namespace Opm diff --git a/opm/models/discretization/common/tpfalinearizer.hh b/opm/models/discretization/common/tpfalinearizer.hh index b567a1316cb..9940366b135 100644 --- a/opm/models/discretization/common/tpfalinearizer.hh +++ b/opm/models/discretization/common/tpfalinearizer.hh @@ -100,6 +100,7 @@ class TpfaLinearizer using Stencil = GetPropType; using LocalResidual = GetPropType; using IntensiveQuantities = GetPropType; + using Indices = GetPropType; using Element = typename GridView::template Codim<0>::Entity; using ElementIterator = typename GridView::template Codim<0>::Iterator; @@ -119,7 +120,7 @@ class TpfaLinearizer static constexpr bool enableEnergy = getPropValue(); static constexpr bool enableDiffusion = getPropValue(); static constexpr bool enableDispersion = getPropValue(); - static constexpr bool enableMICP = getPropValue(); + static const bool enableBioeffects = getPropValue(); // copying the linearizer is not a good idea TpfaLinearizer(const TpfaLinearizer&) = delete; @@ -546,7 +547,7 @@ private: simulator_().problem().eclWriter().outputModule().getFlows().hasBlockFlows(); const bool anyFlores = simulator_().problem().eclWriter().outputModule().getFlows().anyFlores(); const bool dispersionActive = simulator_().vanguard().eclState().getSimulationConfig().rock_config().dispersion(); - if (((!anyFlows || !flowsInfo_.empty()) && (!anyFlores || !floresInfo_.empty())) && (!dispersionActive && !enableMICP)) { + if (((!anyFlows || !flowsInfo_.empty()) && (!anyFlores || !floresInfo_.empty())) && (!dispersionActive && !enableBioeffects)) { return; } const auto& model = model_(); @@ -572,7 +573,7 @@ private: if (anyFlores) { floresInfo_.reserve(numCells, 6 * numCells); } - if (dispersionActive || enableMICP) { + if (dispersionActive || enableBioeffects) { velocityInfo_.reserve(numCells, 6 * numCells); } @@ -618,7 +619,7 @@ private: if (anyFlores) { floresInfo_.appendRow(loc_flinfo.begin(), loc_flinfo.end()); } - if (dispersionActive || enableMICP) { + if (dispersionActive || enableBioeffects) { velocityInfo_.appendRow(loc_vlinfo.begin(), loc_vlinfo.end()); } } @@ -673,7 +674,7 @@ public: adres = 0.0; darcyFlux = 0.0; const IntensiveQuantities& intQuantsEx = model_().intensiveQuantities(globJ, /*timeIdx*/ 0); - LocalResidual::computeFlux(adres,darcyFlux, globI, globJ, intQuantsIn, + LocalResidual::computeFlux(adres, darcyFlux, globI, globJ, intQuantsIn, intQuantsEx, nbInfo.res_nbinfo, problem_().moduleParams()); adres *= nbInfo.res_nbinfo.faceArea; if (enableFlows) { @@ -764,10 +765,10 @@ private: adres = 0.0; darcyFlux = 0.0; const IntensiveQuantities& intQuantsEx = model_().intensiveQuantities(globJ, /*timeIdx*/ 0); - LocalResidual::computeFlux(adres,darcyFlux, globI, globJ, intQuantsIn, intQuantsEx, - nbInfo.res_nbinfo, problem_().moduleParams()); + LocalResidual::computeFlux(adres, darcyFlux, globI, globJ, intQuantsIn, intQuantsEx, + nbInfo.res_nbinfo, problem_().moduleParams()); adres *= nbInfo.res_nbinfo.faceArea; - if (dispersionActive || enableMICP) { + if (dispersionActive || enableBioeffects) { for (unsigned phaseIdx = 0; phaseIdx < numEq; ++phaseIdx) { velocityInfo_[globI][loc].velocity[phaseIdx] = darcyFlux[phaseIdx].value() / nbInfo.res_nbinfo.faceArea; diff --git a/opm/models/io/vtkblackoilmicpmodule.hpp b/opm/models/io/vtkblackoilbioeffectsmodule.hpp similarity index 64% rename from opm/models/io/vtkblackoilmicpmodule.hpp rename to opm/models/io/vtkblackoilbioeffectsmodule.hpp index 58a20cf9850..d424a7c851e 100644 --- a/opm/models/io/vtkblackoilmicpmodule.hpp +++ b/opm/models/io/vtkblackoilbioeffectsmodule.hpp @@ -22,10 +22,10 @@ */ /*! * \file - * \copydoc Opm::VtkBlackOilMICPModule + * \copydoc Opm::VtkBlackOilBioeffectsModule */ -#ifndef OPM_VTK_BLACK_OIL_MICP_MODULE_HPP -#define OPM_VTK_BLACK_OIL_MICP_MODULE_HPP +#ifndef OPM_VTK_BLACK_OIL_BIOEFFECTS_MODULE_HPP +#define OPM_VTK_BLACK_OIL_BIOEFFECTS_MODULE_HPP #include @@ -36,21 +36,20 @@ #include #include -#include +#include #include #include #include namespace Opm { - /*! * \ingroup Vtk * - * \brief VTK output module for the MICP model's related quantities. + * \brief VTK output module for the Bioeffect model's related quantities. */ template -class VtkBlackOilMICPModule : public BaseOutputModule +class VtkBlackOilBioeffectsModule : public BaseOutputModule { using ParentType = BaseOutputModule; @@ -59,21 +58,23 @@ class VtkBlackOilMICPModule : public BaseOutputModule using Scalar = GetPropType; using Evaluation = GetPropType; using ElementContext = GetPropType; + using Indices = GetPropType; static constexpr auto vtkFormat = getPropValue(); using VtkMultiWriter = ::Opm::VtkMultiWriter; - enum { enableMICP = getPropValue() }; + enum { enableBioeffects = getPropValue() }; + enum { enableMICP = Indices::enableMICP }; using BufferType = typename ParentType::BufferType; using ScalarBuffer = typename ParentType::ScalarBuffer; public: - explicit VtkBlackOilMICPModule(const Simulator& simulator) + explicit VtkBlackOilBioeffectsModule(const Simulator& simulator) : ParentType(simulator) { - if constexpr (enableMICP) { - params_.read(); + if constexpr (enableBioeffects) { + params_.read(enableMICP); } } @@ -83,8 +84,8 @@ class VtkBlackOilMICPModule : public BaseOutputModule */ static void registerParameters() { - if constexpr (enableMICP) { - VtkBlackoilMICPParams::registerParameters(); + if constexpr (enableBioeffects) { + VtkBlackOilBioeffectsParams::registerParameters(enableMICP); } } @@ -94,7 +95,7 @@ class VtkBlackOilMICPModule : public BaseOutputModule */ void allocBuffers() override { - if constexpr (enableMICP) { + if constexpr (enableBioeffects) { if (!Parameters::Get()) { return; } @@ -102,17 +103,19 @@ class VtkBlackOilMICPModule : public BaseOutputModule if (params_.microbialConcentrationOutput_) { this->resizeScalarBuffer_(microbialConcentration_, BufferType::Dof); } - if (params_.oxygenConcentrationOutput_) { - this->resizeScalarBuffer_(oxygenConcentration_, BufferType::Dof); - } - if (params_.ureaConcentrationOutput_) { - this->resizeScalarBuffer_(ureaConcentration_, BufferType::Dof); - } if (params_.biofilmConcentrationOutput_) { this->resizeScalarBuffer_(biofilmConcentration_, BufferType::Dof); } - if (params_.calciteConcentrationOutput_) { - this->resizeScalarBuffer_(calciteConcentration_, BufferType::Dof); + if constexpr (enableMICP) { + if (params_.oxygenConcentrationOutput_) { + this->resizeScalarBuffer_(oxygenConcentration_, BufferType::Dof); + } + if (params_.ureaConcentrationOutput_) { + this->resizeScalarBuffer_(ureaConcentration_, BufferType::Dof); + } + if (params_.calciteConcentrationOutput_) { + this->resizeScalarBuffer_(calciteConcentration_, BufferType::Dof); + } } } } @@ -123,7 +126,7 @@ class VtkBlackOilMICPModule : public BaseOutputModule */ void processElement(const ElementContext& elemCtx) override { - if constexpr (enableMICP) { + if constexpr (enableBioeffects) { if (!Parameters::Get()) { return; } @@ -136,25 +139,23 @@ class VtkBlackOilMICPModule : public BaseOutputModule microbialConcentration_[globalDofIdx] = scalarValue(intQuants.microbialConcentration()); } - - if (params_.oxygenConcentrationOutput_) { - oxygenConcentration_[globalDofIdx] = - scalarValue(intQuants.oxygenConcentration()); - } - - if (params_.ureaConcentrationOutput_) { - ureaConcentration_[globalDofIdx] = - scalarValue(intQuants.ureaConcentration()); - } - if (params_.biofilmConcentrationOutput_) { biofilmConcentration_[globalDofIdx] = scalarValue(intQuants.biofilmConcentration()); } - - if (params_.calciteConcentrationOutput_) { - calciteConcentration_[globalDofIdx] = - scalarValue(intQuants.calciteConcentration()); + if constexpr (enableMICP) { + if (params_.oxygenConcentrationOutput_) { + oxygenConcentration_[globalDofIdx] = + scalarValue(intQuants.oxygenConcentration()); + } + if (params_.ureaConcentrationOutput_) { + ureaConcentration_[globalDofIdx] = + scalarValue(intQuants.ureaConcentration()); + } + if (params_.calciteConcentrationOutput_) { + calciteConcentration_[globalDofIdx] = + scalarValue(intQuants.calciteConcentration()); + } } } } @@ -165,7 +166,7 @@ class VtkBlackOilMICPModule : public BaseOutputModule */ void commitBuffers(BaseOutputWriter& baseWriter) override { - if constexpr (enableMICP) { + if constexpr (enableBioeffects) { if (!dynamic_cast(&baseWriter)) { return; } @@ -174,31 +175,29 @@ class VtkBlackOilMICPModule : public BaseOutputModule this->commitScalarBuffer_(baseWriter, "microbial concentration", microbialConcentration_, BufferType::Dof); } - - if (params_.oxygenConcentrationOutput_) { - this->commitScalarBuffer_(baseWriter, "oxygen concentration", - oxygenConcentration_, BufferType::Dof); - } - - if (params_.ureaConcentrationOutput_) { - this->commitScalarBuffer_(baseWriter, "urea concentration", - ureaConcentration_, BufferType::Dof); - } - if (params_.biofilmConcentrationOutput_) { this->commitScalarBuffer_(baseWriter, "biofilm fraction", biofilmConcentration_, BufferType::Dof); } - - if (params_.calciteConcentrationOutput_) { - this->commitScalarBuffer_(baseWriter, "calcite fraction", - calciteConcentration_, BufferType::Dof); + if constexpr (enableMICP) { + if (params_.oxygenConcentrationOutput_) { + this->commitScalarBuffer_(baseWriter, "oxygen concentration", + oxygenConcentration_, BufferType::Dof); + } + if (params_.ureaConcentrationOutput_) { + this->commitScalarBuffer_(baseWriter, "urea concentration", + ureaConcentration_, BufferType::Dof); + } + if (params_.calciteConcentrationOutput_) { + this->commitScalarBuffer_(baseWriter, "calcite fraction", + calciteConcentration_, BufferType::Dof); + } } } } private: - VtkBlackoilMICPParams params_{}; + VtkBlackOilBioeffectsParams params_{}; ScalarBuffer microbialConcentration_{}; ScalarBuffer oxygenConcentration_{}; ScalarBuffer ureaConcentration_{}; @@ -208,4 +207,4 @@ class VtkBlackOilMICPModule : public BaseOutputModule } // namespace Opm -#endif // OPM_VTK_BLACKOIL_MICP_MODULE_HPP +#endif // OPM_VTK_BLACK_OIL_BIOEFFECTS_MODULE_HPP diff --git a/opm/models/io/vtkblackoilmicpparams.cpp b/opm/models/io/vtkblackoilbioeffectsparams.cpp similarity index 59% rename from opm/models/io/vtkblackoilmicpparams.cpp rename to opm/models/io/vtkblackoilbioeffectsparams.cpp index ca67f2b187b..559e302968d 100644 --- a/opm/models/io/vtkblackoilmicpparams.cpp +++ b/opm/models/io/vtkblackoilbioeffectsparams.cpp @@ -22,36 +22,40 @@ */ #include -#include +#include #include namespace Opm { -void VtkBlackoilMICPParams::registerParameters() +void VtkBlackOilBioeffectsParams::registerParameters(const bool isMICP) { Parameters::Register ("Include the concentration of the microbial component in the water phase " "in the VTK output files"); - Parameters::Register - ("Include the concentration of the oxygen component in the water phase " - "in the VTK output files"); - Parameters::Register - ("Include the concentration of the urea component in the water phase " - "in the VTK output files"); Parameters::Register ("Include the biofilm volume fraction in the VTK output files"); - Parameters::Register - ("Include the calcite volume fraction in the VTK output files"); + if (isMICP) { + Parameters::Register + ("Include the concentration of the oxygen component in the water phase " + "in the VTK output files"); + Parameters::Register + ("Include the concentration of the urea component in the water phase " + "in the VTK output files"); + Parameters::Register + ("Include the calcite volume fraction in the VTK output files"); + } } -void VtkBlackoilMICPParams::read() +void VtkBlackOilBioeffectsParams::read(const bool isMICP) { microbialConcentrationOutput_ = Parameters::Get(); - oxygenConcentrationOutput_ = Parameters::Get(); - ureaConcentrationOutput_ = Parameters::Get(); biofilmConcentrationOutput_ = Parameters::Get(); - calciteConcentrationOutput_ = Parameters::Get(); + if (isMICP) { + oxygenConcentrationOutput_ = Parameters::Get(); + ureaConcentrationOutput_ = Parameters::Get(); + calciteConcentrationOutput_ = Parameters::Get(); + } } } // namespace Opm diff --git a/opm/models/io/vtkblackoilmicpparams.hpp b/opm/models/io/vtkblackoilbioeffectsparams.hpp similarity index 82% rename from opm/models/io/vtkblackoilmicpparams.hpp rename to opm/models/io/vtkblackoilbioeffectsparams.hpp index 71f6ae308e3..78dcc16233d 100644 --- a/opm/models/io/vtkblackoilmicpparams.hpp +++ b/opm/models/io/vtkblackoilbioeffectsparams.hpp @@ -22,10 +22,10 @@ */ /*! * \file - * \copydoc Opm::VtkBlackOilMICPModule + * \copydoc Opm::VtkBlackOilBioeffectsModule */ -#ifndef OPM_VTK_BLACK_OIL_MICP_PARAMS_HPP -#define OPM_VTK_BLACK_OIL_MICP_PARAMS_HPP +#ifndef OPM_VTK_BLACK_OIL_BIOEFFECTS_PARAMS_HPP +#define OPM_VTK_BLACK_OIL_BIOEFFECTS_PARAMS_HPP namespace Opm::Parameters { @@ -41,15 +41,15 @@ struct VtkWriteCalciteConcentration { static constexpr bool value = true; }; namespace Opm { /*! - * \brief Struct holding the parameters for VtkBlackoilMICPModule. + * \brief Struct holding the parameters for VtkBlackOilBioeffectsModule. */ -struct VtkBlackoilMICPParams +struct VtkBlackOilBioeffectsParams { //! \brief Registers the parameters in parameter system. - static void registerParameters(); + static void registerParameters(const bool isMICP); //! \brief Reads the parameter values from the parameter system. - void read(); + void read(const bool isMICP); bool microbialConcentrationOutput_; bool oxygenConcentrationOutput_; @@ -60,4 +60,4 @@ struct VtkBlackoilMICPParams } // namespace Opm -#endif // OPM_VTK_BLACKOIL_MICP_PARAMS_HPP +#endif // OPM_VTK_BLACK_OIL_BIOEFFECTS_PARAMS_HPP diff --git a/opm/models/ptflash/flashindices.hh b/opm/models/ptflash/flashindices.hh index 2a2d90e6e62..cb0a67964d4 100644 --- a/opm/models/ptflash/flashindices.hh +++ b/opm/models/ptflash/flashindices.hh @@ -80,6 +80,9 @@ public: //! Index of the mass conservation equation for the first //! component. static constexpr int conti0EqIdx = PVOffset; + + //! MICP implementation is an extension of the black-oil model + static constexpr bool enableMICP = false; }; } // namespace Opm diff --git a/opm/simulators/flow/MICPContainer.cpp b/opm/simulators/flow/BioeffectsContainer.cpp similarity index 54% rename from opm/simulators/flow/MICPContainer.cpp rename to opm/simulators/flow/BioeffectsContainer.cpp index 4f851ce46ac..25db9407524 100644 --- a/opm/simulators/flow/MICPContainer.cpp +++ b/opm/simulators/flow/BioeffectsContainer.cpp @@ -21,7 +21,7 @@ */ #include -#include +#include #include @@ -37,37 +37,44 @@ namespace Opm { template -void MICPContainer:: -allocate(const unsigned bufferSize) +void BioeffectsContainer:: +allocate(const unsigned bufferSize, const bool isMICP) { cMicrobes_.resize(bufferSize, 0.0); - cOxygen_.resize(bufferSize, 0.0); - cUrea_.resize(bufferSize, 0.0); cBiofilm_.resize(bufferSize, 0.0); - cCalcite_.resize(bufferSize, 0.0); - + if (isMICP) { + cOxygen_.resize(bufferSize, 0.0); + cUrea_.resize(bufferSize, 0.0); + cCalcite_.resize(bufferSize, 0.0); + } allocated_ = true; } template -void MICPContainer:: +void BioeffectsContainer:: assign(const unsigned globalDofIdx, - const Scalar microbialConcentration, const Scalar oxygenConcentration, const Scalar ureaConcentration, - const Scalar biofilmConcentration, const Scalar calciteConcentration) { - cMicrobes_[globalDofIdx] = microbialConcentration; cOxygen_[globalDofIdx] = oxygenConcentration; cUrea_[globalDofIdx] = ureaConcentration; - cBiofilm_[globalDofIdx] = biofilmConcentration; cCalcite_[globalDofIdx] = calciteConcentration; } template -MICPSolutionContainer -MICPContainer:: +void BioeffectsContainer:: +assign(const unsigned globalDofIdx, + const Scalar microbialConcentration, + const Scalar biofilmConcentration) +{ + cMicrobes_[globalDofIdx] = microbialConcentration; + cBiofilm_[globalDofIdx] = biofilmConcentration; +} + +template +BioeffectsSolutionContainer +BioeffectsContainer:: getSolution() const { return { @@ -80,8 +87,8 @@ getSolution() const } template -void MICPContainer:: -outputRestart(data::Solution& sol) +void BioeffectsContainer:: +outputRestart(data::Solution& sol, const bool isMICP) { if (!this->allocated_) { return; @@ -90,33 +97,42 @@ outputRestart(data::Solution& sol) using DataEntry = std::tuple&>; - auto solutionVectors = std::array { - DataEntry{"BIOFILM", UnitSystem::measure::identity, cBiofilm_}, - DataEntry{"CALCITE", UnitSystem::measure::identity, cCalcite_}, - DataEntry{"MICROBES", UnitSystem::measure::density, cMicrobes_}, - DataEntry{"OXYGEN", UnitSystem::measure::density, cOxygen_}, - DataEntry{"UREA", UnitSystem::measure::density, cUrea_}, - }; + auto insert = [&sol](auto& entry) - std::for_each(solutionVectors.begin(), solutionVectors.end(), - [&sol](auto& entry) - { - if (!std::get<2>(entry).empty()) { - sol.insert(std::get(entry), - std::get(entry), - std::move(std::get<2>(entry)), - data::TargetType::RESTART_OPM_EXTENDED); - } - }); + { + if (!std::get<2>(entry).empty()) { + sol.insert(std::get(entry), + std::get(entry), + std::move(std::get<2>(entry)), + data::TargetType::RESTART_OPM_EXTENDED); + } + }; + + auto solutionMicrobes = DataEntry{"MICROBES", UnitSystem::measure::density, cMicrobes_}; + insert(solutionMicrobes); + auto solutionBiofilm = DataEntry{"BIOFILM", UnitSystem::measure::identity, cBiofilm_}; + insert(solutionBiofilm); + + if (isMICP) { + auto solutionVectors = std::array { + DataEntry{"CALCITE", UnitSystem::measure::identity, cCalcite_}, + DataEntry{"OXYGEN", UnitSystem::measure::density, cOxygen_}, + DataEntry{"UREA", UnitSystem::measure::density, cUrea_}, + }; + std::for_each(solutionVectors.begin(), solutionVectors.end(), + [&insert](auto& entry) + { insert(entry); }); + } allocated_ = false; } template -void MICPContainer:: +void BioeffectsContainer:: readRestart(const unsigned globalDofIdx, const unsigned elemIdx, - const data::Solution& sol) + const data::Solution& sol, + const bool isMICP) { if (this->allocated_) { return; @@ -131,23 +147,25 @@ readRestart(const unsigned globalDofIdx, } }; - const auto fields = std::array{ - std::pair{"BIOFILM", &cBiofilm_}, - std::pair{"CALCITE", &cCalcite_}, - std::pair{"MICROBES", &cMicrobes_}, - std::pair{"OXYGEN", &cOxygen_}, - std::pair{"UREA", &cUrea_}, - }; - - std::for_each(fields.begin(), fields.end(), - [&assign](const auto& p) - { assign(p.first, *p.second); }); + assign("MICROBES", *&cMicrobes_); + assign("BIOFILM", *&cBiofilm_); + + if (isMICP) { + const auto fields = std::array{ + std::pair{"OXYGEN", &cOxygen_}, + std::pair{"UREA", &cUrea_}, + std::pair{"CALCITE", &cCalcite_}, + }; + std::for_each(fields.begin(), fields.end(), + [&assign](const auto& p) + { assign(p.first, *p.second); }); + } } -template class MICPContainer; +template class BioeffectsContainer; #if FLOW_INSTANTIATE_FLOAT -template class MICPContainer; +template class BioeffectsContainer; #endif } // namespace Opm diff --git a/opm/simulators/flow/MICPContainer.hpp b/opm/simulators/flow/BioeffectsContainer.hpp similarity index 60% rename from opm/simulators/flow/MICPContainer.hpp rename to opm/simulators/flow/BioeffectsContainer.hpp index 8d863e45ae8..fb00f6de131 100644 --- a/opm/simulators/flow/MICPContainer.hpp +++ b/opm/simulators/flow/BioeffectsContainer.hpp @@ -23,51 +23,54 @@ * \file * \copydoc Opm::OutputBlackOilModule */ -#ifndef OPM_MICP_CONTAINER_HPP -#define OPM_MICP_CONTAINER_HPP +#ifndef OPM_BIOEFFECTS_CONTAINER_HPP +#define OPM_BIOEFFECTS_CONTAINER_HPP #include namespace Opm { namespace data { class Solution; } -template struct MICPSolutionContainer; +template struct BioeffectsSolutionContainer; template -class MICPContainer +class BioeffectsContainer { using ScalarBuffer = std::vector; public: - void allocate(const unsigned bufferSize); + void allocate(const unsigned bufferSize, const bool isMICP); void assign(const unsigned globalDofIdx, - const Scalar microbialConcentration, - const Scalar oxygenConcentration, - const Scalar ureaConcentration, - const Scalar biofilmConcentration, - const Scalar calciteConcentration); + const Scalar oxygenConcentration, + const Scalar ureaConcentration, + const Scalar calciteConcentration); - MICPSolutionContainer getSolution() const; + void assign(const unsigned globalDofIdx, + const Scalar microbialConcentration, + const Scalar biofilmConcentration); + + BioeffectsSolutionContainer getSolution() const; - void outputRestart(data::Solution& sol); + void outputRestart(data::Solution& sol, const bool isMICP); void readRestart(const unsigned globalDofIdx, const unsigned elemIdx, - const data::Solution& sol); + const data::Solution& sol, + const bool isMICP); bool allocated() const { return allocated_; } private: bool allocated_ = false; - ScalarBuffer cMicrobes_; - ScalarBuffer cOxygen_; - ScalarBuffer cUrea_; - ScalarBuffer cBiofilm_; - ScalarBuffer cCalcite_; + ScalarBuffer cMicrobes_{}; + ScalarBuffer cOxygen_{}; + ScalarBuffer cUrea_{}; + ScalarBuffer cBiofilm_{}; + ScalarBuffer cCalcite_{}; }; } // namespace Opm -#endif // OPM_MICP_CONTAINER_HPP +#endif // OPM_BIOEFFECTS_CONTAINER_HPP diff --git a/opm/simulators/flow/BlackoilModel.hpp b/opm/simulators/flow/BlackoilModel.hpp index 097fa16bc56..8dcfecb30c8 100644 --- a/opm/simulators/flow/BlackoilModel.hpp +++ b/opm/simulators/flow/BlackoilModel.hpp @@ -326,7 +326,8 @@ class BlackoilModel static constexpr bool has_energy_ = getPropValue(); static constexpr bool has_foam_ = getPropValue(); static constexpr bool has_brine_ = getPropValue(); - static constexpr bool has_micp_ = getPropValue(); + static constexpr bool has_bioeffects_ = getPropValue(); + static constexpr bool has_micp_ = Indices::enableMICP; ModelParameters param_; SimulatorReportSingle failureReport_; diff --git a/opm/simulators/flow/BlackoilModelProperties.hpp b/opm/simulators/flow/BlackoilModelProperties.hpp index 6fa005653c9..9cb2ecac217 100644 --- a/opm/simulators/flow/BlackoilModelProperties.hpp +++ b/opm/simulators/flow/BlackoilModelProperties.hpp @@ -86,7 +86,7 @@ struct EnableSaltPrecipitation { static constexpr bool value = false; }; template -struct EnableMICP +struct EnableBioeffects { static constexpr bool value = false; }; template diff --git a/opm/simulators/flow/BlackoilModel_impl.hpp b/opm/simulators/flow/BlackoilModel_impl.hpp index 3a45028667c..bd77f1357ef 100644 --- a/opm/simulators/flow/BlackoilModel_impl.hpp +++ b/opm/simulators/flow/BlackoilModel_impl.hpp @@ -1168,32 +1168,34 @@ getMaxCoeff(const unsigned cell_idx, std::abs(R2) / pvValue); } - if constexpr (has_micp_) { + if constexpr (has_bioeffects_) { B_avg[contiMicrobialEqIdx] += 1.0 / fs.invB(FluidSystem::waterPhaseIdx).value(); const auto R1 = modelResid[cell_idx][contiMicrobialEqIdx]; R_sum[contiMicrobialEqIdx] += R1; maxCoeff[contiMicrobialEqIdx] = std::max(maxCoeff[contiMicrobialEqIdx], - std::abs(R1) / pvValue); - B_avg[contiOxygenEqIdx] += 1.0 / fs.invB(FluidSystem::waterPhaseIdx).value(); - const auto R2 = modelResid[cell_idx][contiOxygenEqIdx]; - R_sum[contiOxygenEqIdx] += R2; - maxCoeff[contiOxygenEqIdx] = std::max(maxCoeff[contiOxygenEqIdx], - std::abs(R2) / pvValue); - B_avg[contiUreaEqIdx] += 1.0 / fs.invB(FluidSystem::waterPhaseIdx).value(); - const auto R3 = modelResid[cell_idx][contiUreaEqIdx]; - R_sum[contiUreaEqIdx] += R3; - maxCoeff[contiUreaEqIdx] = std::max(maxCoeff[contiUreaEqIdx], - std::abs(R3) / pvValue); + std::abs(R1) / pvValue); B_avg[contiBiofilmEqIdx] += 1.0 / fs.invB(FluidSystem::waterPhaseIdx).value(); - const auto R4 = modelResid[cell_idx][contiBiofilmEqIdx]; - R_sum[contiBiofilmEqIdx] += R4; + const auto R2 = modelResid[cell_idx][contiBiofilmEqIdx]; + R_sum[contiBiofilmEqIdx] += R2; maxCoeff[contiBiofilmEqIdx] = std::max(maxCoeff[contiBiofilmEqIdx], - std::abs(R4) / pvValue); - B_avg[contiCalciteEqIdx] += 1.0 / fs.invB(FluidSystem::waterPhaseIdx).value(); - const auto R5 = modelResid[cell_idx][contiCalciteEqIdx]; - R_sum[contiCalciteEqIdx] += R5; - maxCoeff[contiCalciteEqIdx] = std::max(maxCoeff[contiCalciteEqIdx], - std::abs(R5) / pvValue); + std::abs(R2) / pvValue); + if constexpr (has_micp_) { + B_avg[contiOxygenEqIdx] += 1.0 / fs.invB(FluidSystem::waterPhaseIdx).value(); + const auto R3 = modelResid[cell_idx][contiOxygenEqIdx]; + R_sum[contiOxygenEqIdx] += R3; + maxCoeff[contiOxygenEqIdx] = std::max(maxCoeff[contiOxygenEqIdx], + std::abs(R3) / pvValue); + B_avg[contiUreaEqIdx] += 1.0 / fs.invB(FluidSystem::waterPhaseIdx).value(); + const auto R4 = modelResid[cell_idx][contiUreaEqIdx]; + R_sum[contiUreaEqIdx] += R4; + maxCoeff[contiUreaEqIdx] = std::max(maxCoeff[contiUreaEqIdx], + std::abs(R4) / pvValue); + B_avg[contiCalciteEqIdx] += 1.0 / fs.invB(FluidSystem::waterPhaseIdx).value(); + const auto R5 = modelResid[cell_idx][contiCalciteEqIdx]; + R_sum[contiCalciteEqIdx] += R5; + maxCoeff[contiCalciteEqIdx] = std::max(maxCoeff[contiCalciteEqIdx], + std::abs(R5) / pvValue); + } } } diff --git a/opm/simulators/flow/CpGridVanguard.hpp b/opm/simulators/flow/CpGridVanguard.hpp index e9244531101..974d8a9fda7 100644 --- a/opm/simulators/flow/CpGridVanguard.hpp +++ b/opm/simulators/flow/CpGridVanguard.hpp @@ -155,11 +155,17 @@ class CpGridVanguard : public FlowBaseVanguard } if (runspec.micp()) { - if (getPropValue() == false) { + if (getPropValue() == false) { throw std::runtime_error("Input specifies MICP while simulator has it disabled"); } } + if (runspec.biof()) { + if (getPropValue() == false) { + throw std::runtime_error("Input specifies Biofilm while simulator has it disabled"); + } + } + if (phases.active(Phase::BRINE)) { if (getPropValue() == false) { throw std::runtime_error("Input specifies Brine while simulator has it disabled"); diff --git a/opm/simulators/flow/FlowBaseProblemProperties.hpp b/opm/simulators/flow/FlowBaseProblemProperties.hpp index 396d07aab2b..f20c1dcbf9d 100644 --- a/opm/simulators/flow/FlowBaseProblemProperties.hpp +++ b/opm/simulators/flow/FlowBaseProblemProperties.hpp @@ -226,7 +226,7 @@ struct EnableExtbo { static constexpr bool value = false; }; template -struct EnableMICP +struct EnableBioeffects { static constexpr bool value = false; }; // disable thermal flux boundaries by default diff --git a/opm/simulators/flow/FlowGenericProblem.hpp b/opm/simulators/flow/FlowGenericProblem.hpp index cbb6308a111..c9f426cef8d 100644 --- a/opm/simulators/flow/FlowGenericProblem.hpp +++ b/opm/simulators/flow/FlowGenericProblem.hpp @@ -265,7 +265,7 @@ class FlowGenericProblem serializer(overburdenPressure_); serializer(solventSaturation_); serializer(solventRsw_); - serializer(micp_); + serializer(bioeffects_); } protected: @@ -304,6 +304,7 @@ class FlowGenericProblem bool enableSolvent, bool enablePolymer, bool enablePolymerMolarWeight, + bool enableBioeffects, bool enableMICP); void updatePvtnum_(); @@ -338,7 +339,7 @@ class FlowGenericProblem std::vector overburdenPressure_; std::vector solventSaturation_; std::vector solventRsw_; - MICPSolutionContainer micp_; + BioeffectsSolutionContainer bioeffects_; // time stepping parameters bool enableTuning_; diff --git a/opm/simulators/flow/FlowGenericProblem_impl.hpp b/opm/simulators/flow/FlowGenericProblem_impl.hpp index 93c6af5f557..f413e80d71f 100644 --- a/opm/simulators/flow/FlowGenericProblem_impl.hpp +++ b/opm/simulators/flow/FlowGenericProblem_impl.hpp @@ -103,7 +103,7 @@ serializationTestObject(const EclipseState& eclState, result.solventSaturation_ = {15.0}; result.solventRsw_ = {18.0}; result.polymer_ = PolymerSolutionContainer::serializationTestObject(); - result.micp_ = MICPSolutionContainer::serializationTestObject(); + result.bioeffects_ = BioeffectsSolutionContainer::serializationTestObject(); return result; } @@ -483,6 +483,7 @@ readBlackoilExtentionsInitialConditions_(std::size_t numDof, bool enableSolvent, bool enablePolymer, bool enablePolymerMolarWeight, + bool enableBioeffects, bool enableMICP) { auto getArray = [](const std::vector& input) @@ -520,31 +521,33 @@ readBlackoilExtentionsInitialConditions_(std::size_t numDof, } } - if (enableMICP) { + if (enableBioeffects) { if (eclState_.fieldProps().has_double("SMICR")) { - micp_.microbialConcentration = getArray(eclState_.fieldProps().get_double("SMICR")); + bioeffects_.microbialConcentration = getArray(eclState_.fieldProps().get_double("SMICR")); } else { - micp_.microbialConcentration.resize(numDof, 0.0); - } - if (eclState_.fieldProps().has_double("SOXYG")) { - micp_.oxygenConcentration = getArray(eclState_.fieldProps().get_double("SOXYG")); - } else { - micp_.oxygenConcentration.resize(numDof, 0.0); - } - if (eclState_.fieldProps().has_double("SUREA")) { - micp_.ureaConcentration = getArray(eclState_.fieldProps().get_double("SUREA")); - } else { - micp_.ureaConcentration.resize(numDof, 0.0); + bioeffects_.microbialConcentration.resize(numDof, 0.0); } if (eclState_.fieldProps().has_double("SBIOF")) { - micp_.biofilmConcentration = getArray(eclState_.fieldProps().get_double("SBIOF")); + bioeffects_.biofilmConcentration = getArray(eclState_.fieldProps().get_double("SBIOF")); } else { - micp_.biofilmConcentration.resize(numDof, 0.0); + bioeffects_.biofilmConcentration.resize(numDof, 0.0); } - if (eclState_.fieldProps().has_double("SCALC")) { - micp_.calciteConcentration = getArray(eclState_.fieldProps().get_double("SCALC")); - } else { - micp_.calciteConcentration.resize(numDof, 0.0); + if (enableMICP) { + if (eclState_.fieldProps().has_double("SOXYG")) { + bioeffects_.oxygenConcentration = getArray(eclState_.fieldProps().get_double("SOXYG")); + } else { + bioeffects_.oxygenConcentration.resize(numDof, 0.0); + } + if (eclState_.fieldProps().has_double("SUREA")) { + bioeffects_.ureaConcentration = getArray(eclState_.fieldProps().get_double("SUREA")); + } else { + bioeffects_.ureaConcentration.resize(numDof, 0.0); + } + if (eclState_.fieldProps().has_double("SCALC")) { + bioeffects_.calciteConcentration = getArray(eclState_.fieldProps().get_double("SCALC")); + } else { + bioeffects_.calciteConcentration.resize(numDof, 0.0); + } } } } @@ -635,11 +638,11 @@ typename FlowGenericProblem::Scalar FlowGenericProblem:: microbialConcentration(unsigned elemIdx) const { - if (micp_.microbialConcentration.empty()) { + if (bioeffects_.microbialConcentration.empty()) { return 0; } - return micp_.microbialConcentration[elemIdx]; + return bioeffects_.microbialConcentration[elemIdx]; } template @@ -647,11 +650,11 @@ typename FlowGenericProblem::Scalar FlowGenericProblem:: oxygenConcentration(unsigned elemIdx) const { - if (micp_.oxygenConcentration.empty()) { + if (bioeffects_.oxygenConcentration.empty()) { return 0; } - return micp_.oxygenConcentration[elemIdx]; + return bioeffects_.oxygenConcentration[elemIdx]; } template @@ -659,11 +662,11 @@ typename FlowGenericProblem::Scalar FlowGenericProblem:: ureaConcentration(unsigned elemIdx) const { - if (micp_.ureaConcentration.empty()) { + if (bioeffects_.ureaConcentration.empty()) { return 0; } - return micp_.ureaConcentration[elemIdx]; + return bioeffects_.ureaConcentration[elemIdx]; } template @@ -671,11 +674,11 @@ typename FlowGenericProblem::Scalar FlowGenericProblem:: biofilmConcentration(unsigned elemIdx) const { - if (micp_.biofilmConcentration.empty()) { + if (bioeffects_.biofilmConcentration.empty()) { return 0; } - return micp_.biofilmConcentration[elemIdx]; + return bioeffects_.biofilmConcentration[elemIdx]; } template @@ -683,11 +686,11 @@ typename FlowGenericProblem::Scalar FlowGenericProblem:: calciteConcentration(unsigned elemIdx) const { - if (micp_.calciteConcentration.empty()) { + if (bioeffects_.calciteConcentration.empty()) { return 0; } - return micp_.calciteConcentration[elemIdx]; + return bioeffects_.calciteConcentration[elemIdx]; } template @@ -752,7 +755,7 @@ operator==(const FlowGenericProblem& rhs) const this->solventSaturation_ == rhs.solventSaturation_ && this->solventRsw_ == rhs.solventRsw_ && this->polymer_ == rhs.polymer_ && - this->micp_ == rhs.micp_; + this->bioeffects_ == rhs.bioeffects_; } } // namespace Opm diff --git a/opm/simulators/flow/FlowProblem.hpp b/opm/simulators/flow/FlowProblem.hpp index d0467a1ff08..77bd24ec6dd 100644 --- a/opm/simulators/flow/FlowProblem.hpp +++ b/opm/simulators/flow/FlowProblem.hpp @@ -105,6 +105,7 @@ class FlowProblem : public GetPropType using GlobalEqVector = GetPropType; using EqVector = GetPropType; using Vanguard = GetPropType; + using Indices = GetPropType; // Grid and world dimension enum { dim = GridView::dimension }; @@ -115,15 +116,16 @@ class FlowProblem : public GetPropType enum { numPhases = FluidSystem::numPhases }; enum { numComponents = FluidSystem::numComponents }; - enum { enableConvectiveMixing = getPropValue() }; + enum { enableBioeffects = getPropValue() }; enum { enableBrine = getPropValue() }; + enum { enableConvectiveMixing = getPropValue() }; enum { enableDiffusion = getPropValue() }; enum { enableDispersion = getPropValue() }; enum { enableEnergy = getPropValue() }; enum { enableExperiments = getPropValue() }; enum { enableExtbo = getPropValue() }; enum { enableFoam = getPropValue() }; - enum { enableMICP = getPropValue() }; + enum { enableMICP = Indices::enableMICP }; enum { enablePolymer = getPropValue() }; enum { enablePolymerMolarWeight = getPropValue() }; enum { enableSaltPrecipitation = getPropValue() }; @@ -154,7 +156,6 @@ class FlowProblem : public GetPropType using MaterialLaw = GetPropType; using DofMapper = GetPropType; using Evaluation = GetPropType; - using Indices = GetPropType; using IntensiveQuantities = GetPropType; using WellModel = GetPropType; using AquiferModel = GetPropType; diff --git a/opm/simulators/flow/FlowProblemBlackoil.hpp b/opm/simulators/flow/FlowProblemBlackoil.hpp index 845fd741da9..cf698d6169c 100644 --- a/opm/simulators/flow/FlowProblemBlackoil.hpp +++ b/opm/simulators/flow/FlowProblemBlackoil.hpp @@ -99,8 +99,9 @@ class FlowProblemBlackoil : public FlowProblem using FlowProblemType::numComponents; // TODO: potentially some cleaning up depending on the usage later here - using FlowProblemType::enableConvectiveMixing; + using FlowProblemType::enableBioeffects; using FlowProblemType::enableBrine; + using FlowProblemType::enableConvectiveMixing; using FlowProblemType::enableDiffusion; using FlowProblemType::enableDispersion; using FlowProblemType::enableEnergy; @@ -142,7 +143,7 @@ class FlowProblemBlackoil : public FlowProblem using FoamModule = BlackOilFoamModule; using BrineModule = BlackOilBrineModule; using ExtboModule = BlackOilExtboModule; - using MICPModule = BlackOilMICPModule; + using BioeffectsModule = BlackOilBioeffectsModule; using DispersionModule = BlackOilDispersionModule; using DiffusionModule = BlackOilDiffusionModule; using ConvectiveMixingModule = BlackOilConvectiveMixingModule; @@ -209,9 +210,9 @@ class FlowProblemBlackoil : public FlowProblem foamParams.template initFromState(vanguard.eclState()); FoamModule::setParams(std::move(foamParams)); - BlackOilMICPParams micpParams; - micpParams.template initFromState(vanguard.eclState()); - MICPModule::setParams(std::move(micpParams)); + BlackOilBioeffectsParams bioeffectsParams; + bioeffectsParams.template initFromState(vanguard.eclState()); + BioeffectsModule::setParams(std::move(bioeffectsParams)); BlackOilPolymerParams polymerParams; polymerParams.template initFromState(vanguard.eclState()); @@ -710,7 +711,7 @@ class FlowProblemBlackoil : public FlowProblem const auto& permfactTable = BrineModule::permfactTable(tableIdx); return permfactTable.eval(porosityFactor, /*extrapolation=*/true); } - else if constexpr (enableMICP) { + else if constexpr (enableBioeffects) { return intQuants.permFactor().value(); } else { @@ -928,12 +929,14 @@ class FlowProblemBlackoil : public FlowProblem } } - if constexpr (enableMICP){ - values[Indices::microbialConcentrationIdx] = this->micp_.microbialConcentration[globalDofIdx]; - values[Indices::oxygenConcentrationIdx]= this->micp_.oxygenConcentration[globalDofIdx]; - values[Indices::ureaConcentrationIdx]= this->micp_.ureaConcentration[globalDofIdx]; - values[Indices::calciteConcentrationIdx]= this->micp_.calciteConcentration[globalDofIdx]; - values[Indices::biofilmConcentrationIdx]= this->micp_.biofilmConcentration[globalDofIdx]; + if constexpr (enableBioeffects) { + values[Indices::microbialConcentrationIdx] = this->bioeffects_.microbialConcentration[globalDofIdx]; + values[Indices::biofilmConcentrationIdx]= this->bioeffects_.biofilmConcentration[globalDofIdx]; + if constexpr (enableMICP) { + values[Indices::oxygenConcentrationIdx]= this->bioeffects_.oxygenConcentration[globalDofIdx]; + values[Indices::ureaConcentrationIdx]= this->bioeffects_.ureaConcentration[globalDofIdx]; + values[Indices::calciteConcentrationIdx]= this->bioeffects_.calciteConcentration[globalDofIdx]; + } } values.checkDefined(); @@ -1021,15 +1024,15 @@ class FlowProblemBlackoil : public FlowProblem this->polymer_.moleWeight.resize(numElems, 0.0); } - if constexpr (enableMICP) { - this->micp_.resize(numElems); + if constexpr (enableBioeffects) { + this->bioeffects_.resize(numElems); } // Initialize mixing controls before trying to set any lastRx valuesx this->mixControls_.init(numElems, restart_step, eclState.runspec().tabdims().getNumPVTTables()); - if constexpr (enableMICP) { - this->micp_ = this->eclWriter_->outputModule().getMICP().getSolution(); + if constexpr (enableBioeffects) { + this->bioeffects_ = this->eclWriter_->outputModule().getBioeffects().getSolution(); } for (std::size_t elemIdx = 0; elemIdx < numElems; ++elemIdx) { @@ -1523,11 +1526,12 @@ class FlowProblemBlackoil : public FlowProblem { FlowProblemType::readInitialCondition_(); - if constexpr (enableSolvent || enablePolymer || enablePolymerMolarWeight || enableMICP) + if constexpr (enableSolvent || enablePolymer || enablePolymerMolarWeight || enableBioeffects) this->readBlackoilExtentionsInitialConditions_(this->model().numGridDof(), enableSolvent, enablePolymer, enablePolymerMolarWeight, + enableBioeffects, enableMICP); } diff --git a/opm/simulators/flow/GenericOutputBlackoilModule.cpp b/opm/simulators/flow/GenericOutputBlackoilModule.cpp index 3c143ec3c39..a488a7701f5 100644 --- a/opm/simulators/flow/GenericOutputBlackoilModule.cpp +++ b/opm/simulators/flow/GenericOutputBlackoilModule.cpp @@ -136,7 +136,7 @@ GenericOutputBlackoilModule(const EclipseState& eclState, bool enableBrine, bool enableSaltPrecipitation, bool enableExtbo, - bool enableMICP) + bool enableBioeffects) : eclState_(eclState) , schedule_(schedule) , summaryState_(summaryState) @@ -154,7 +154,7 @@ GenericOutputBlackoilModule(const EclipseState& eclState, , enableBrine_(enableBrine) , enableSaltPrecipitation_(enableSaltPrecipitation) , enableExtbo_(enableExtbo) - , enableMICP_(enableMICP) + , enableBioeffects_(enableBioeffects) , flowsC_(schedule, summaryConfig) , rftC_(eclState_, schedule_, [this](const std::string& wname) { return this->isOwnedByCurrentRank(wname); }, @@ -402,8 +402,9 @@ assignToSolution(data::Solution& sol) this->flowsC_.outputRestart(sol); - if (this->micpC_.allocated()) { - this->micpC_.outputRestart(sol); + if (this->bioeffectsC_.allocated()) { + // Biofilms for gas-water systems; MICP only for water systems + this->bioeffectsC_.outputRestart(sol, !FluidSystem::phaseIsActive(gasPhaseIdx)); } for (auto& array : extendedSolutionArrays) { @@ -571,8 +572,9 @@ setRestart(const data::Solution& sol, [&assign](const auto& p) { assign(p.first, *p.second); }); - if (this->micpC_.allocated()) { - this->micpC_.readRestart(globalDofIndex, elemIdx, sol); + if (this->bioeffectsC_.allocated()) { + // Biofilms for gas-water systems; MICP only for water systems + this->bioeffectsC_.readRestart(globalDofIndex, elemIdx, sol, !FluidSystem::phaseIsActive(gasPhaseIdx)); } } @@ -762,7 +764,7 @@ doAllocBuffers(const unsigned bufferSize, Entry{&cFoam_, "", enableFoam_}, Entry{&cSalt_, "", enableBrine_}, Entry{&pSalt_, "", enableSaltPrecipitation_}, - Entry{&permFact_, "", enableSaltPrecipitation_ || enableMICP_}, + Entry{&permFact_, "", enableSaltPrecipitation_ || enableBioeffects_}, Entry{&soMax_, "", oilvap.getType() == OilVapP::VAPPARS}, Entry{&soMax_, "", hysteresisConfig && hysteresisConfig->enableNonWettingHysteresis() && @@ -936,8 +938,9 @@ doAllocBuffers(const unsigned bufferSize, extboC_.allocate(bufferSize); } - if (enableMICP_) { - this->micpC_.allocate(bufferSize); + if (enableBioeffects_) { + // Biofilms for gas-water systems; MICP only for water systems + this->bioeffectsC_.allocate(bufferSize, !FluidSystem::phaseIsActive(gasPhaseIdx)); } // tracers diff --git a/opm/simulators/flow/GenericOutputBlackoilModule.hpp b/opm/simulators/flow/GenericOutputBlackoilModule.hpp index ab091194352..a50fd41df4c 100644 --- a/opm/simulators/flow/GenericOutputBlackoilModule.hpp +++ b/opm/simulators/flow/GenericOutputBlackoilModule.hpp @@ -32,13 +32,13 @@ #include #include +#include #include #include #include #include #include #include -#include #include #include #include @@ -201,8 +201,8 @@ class GenericOutputBlackoilModule { const std::vector& getFluidPressure() const { return fluidPressure_; } - const MICPContainer& getMICP() const - { return this->micpC_; } + const BioeffectsContainer& getBioeffects() const + { return this->bioeffectsC_; } const FlowsContainer& getFlows() const { return this->flowsC_; } @@ -286,7 +286,7 @@ class GenericOutputBlackoilModule { bool enableBrine, bool enableSaltPrecipitation, bool enableExtbo, - bool enableMICP); + bool enableBioeffects); void doAllocBuffers(unsigned bufferSize, unsigned reportStepNum, @@ -353,7 +353,7 @@ class GenericOutputBlackoilModule { bool enableBrine_{false}; bool enableSaltPrecipitation_{false}; bool enableExtbo_{false}; - bool enableMICP_{false}; + bool enableBioeffects_{false}; bool forceDisableFipOutput_{false}; bool forceDisableFipresvOutput_{false}; @@ -409,7 +409,7 @@ class GenericOutputBlackoilModule { ScalarBuffer minimumOilPressure_; ScalarBuffer saturatedOilFormationVolumeFactor_; ScalarBuffer rockCompTransMultiplier_; - MICPContainer micpC_; + BioeffectsContainer bioeffectsC_; ScalarBuffer pcgw_; ScalarBuffer pcow_; ScalarBuffer pcog_; diff --git a/opm/simulators/flow/Main.hpp b/opm/simulators/flow/Main.hpp index c7610e7f515..2c62a72c401 100644 --- a/opm/simulators/flow/Main.hpp +++ b/opm/simulators/flow/Main.hpp @@ -401,6 +401,16 @@ class Main /// \return Simulation's status/exit code. int runTwoPhase(const Phases& phases); + /// Run a simulation with Biofilm effects. + /// + /// Called from dispatchDynamic_() + /// + /// \param[in] phases Run's active phases. Needed to determine whether + /// or not the run's phase setup is supported. + /// + /// \return Simulation's status/exit code. + int runBiofilm(const Phases& phases); + /// Run a simulation with polymers. /// /// Called from dispatchDynamic_() diff --git a/opm/simulators/flow/MainDispatchDynamic.cpp b/opm/simulators/flow/MainDispatchDynamic.cpp index 1ce90d343a5..ece545659c2 100644 --- a/opm/simulators/flow/MainDispatchDynamic.cpp +++ b/opm/simulators/flow/MainDispatchDynamic.cpp @@ -24,6 +24,7 @@ #include +#include #include #include #include @@ -89,6 +90,11 @@ int Opm::Main::dispatchDynamic_() return this->runWaterOnlyEnergy(phases); } + // Biofilm case + else if (rspec.biof()) { + return this->runBiofilm(phases); + } + // Twophase cases else if (phases.size() == 2 && !thermal) { return this->runTwoPhase(phases); @@ -220,6 +226,23 @@ int Opm::Main::runTwoPhase(const Phases& phases) } } + +int Opm::Main::runBiofilm(const Phases& phases) + { + if (!(phases.active(Phase::WATER) && phases.active(Phase::GAS)) || (phases.size() != 2)) { + if (outputCout_) { + std::cerr << "Biofilm option can only be used for two-phase water/gas " + << "model (i.e. in combination with WATER and GAS)." << std::endl; + } + + return EXIT_FAILURE; + } + return flowBiofilmMain(this->argc_, + this->argv_, + this->outputCout_, + this->outputFiles_); + } + int Opm::Main::runPolymer(const Phases& phases) { if (! phases.active(Phase::WATER)) { diff --git a/opm/simulators/flow/OutputBlackoilModule.hpp b/opm/simulators/flow/OutputBlackoilModule.hpp index 1421800f4f5..68f170c0fee 100644 --- a/opm/simulators/flow/OutputBlackoilModule.hpp +++ b/opm/simulators/flow/OutputBlackoilModule.hpp @@ -114,7 +114,8 @@ class OutputBlackOilModule : public GenericOutputBlackoilModule() }; - enum { enableMICP = getPropValue() }; + enum { enableBioeffects = getPropValue() }; + enum { enableMICP = Indices::enableMICP }; enum { enableVapwat = getPropValue() }; enum { enableDisgasInWater = getPropValue() }; enum { enableDissolvedGas = Indices::compositionSwitchIdx >= 0 }; @@ -149,7 +150,7 @@ class OutputBlackOilModule : public GenericOutputBlackoilModule(), getPropValue(), getPropValue(), - getPropValue()) + getPropValue()) , simulator_(simulator) , collectOnIORank_(collectOnIORank) { @@ -935,22 +936,25 @@ class OutputBlackOilModule : public GenericOutputBlackoilModuleupdateCO2InWater(globalDofIdx, pv, fs); } - if constexpr(enableMICP) { - const auto surfVolWat = pv * getValue(fs.invB(waterPhaseIdx)); + if constexpr(enableBioeffects) { + const auto surfVolWat = pv * getValue(fs.saturation(waterPhaseIdx)) * + getValue(fs.invB(waterPhaseIdx)); if (this->fipC_.hasMicrobialMass()) { this->updateMicrobialMass(globalDofIdx, intQuants, surfVolWat); } - if (this->fipC_.hasOxygenMass()) { - this->updateOxygenMass(globalDofIdx, intQuants, surfVolWat); - } - if (this->fipC_.hasUreaMass()) { - this->updateUreaMass(globalDofIdx, intQuants, surfVolWat); - } if (this->fipC_.hasBiofilmMass()) { this->updateBiofilmMass(globalDofIdx, intQuants, totVolume); } - if (this->fipC_.hasCalciteMass()) { - this->updateCalciteMass(globalDofIdx, intQuants, totVolume); + if constexpr(enableMICP) { + if (this->fipC_.hasOxygenMass()) { + this->updateOxygenMass(globalDofIdx, intQuants, surfVolWat); + } + if (this->fipC_.hasUreaMass()) { + this->updateUreaMass(globalDofIdx, intQuants, surfVolWat); + } + if (this->fipC_.hasCalciteMass()) { + this->updateCalciteMass(globalDofIdx, intQuants, totVolume); + } } } @@ -1582,15 +1586,18 @@ class OutputBlackOilModule : public GenericOutputBlackoilModuleextboC_.allocated() }, - Entry{[&micpC = this->micpC_](const Context& ectx) + Entry{[&bioeffectsC = this->bioeffectsC_](const Context& ectx) { - micpC.assign(ectx.globalDofIdx, - ectx.intQuants.microbialConcentration().value(), - ectx.intQuants.oxygenConcentration().value(), - ectx.intQuants.ureaConcentration().value(), - ectx.intQuants.biofilmConcentration().value(), - ectx.intQuants.calciteConcentration().value()); - }, this->micpC_.allocated() + bioeffectsC.assign(ectx.globalDofIdx, + ectx.intQuants.microbialConcentration().value(), + ectx.intQuants.biofilmConcentration().value()); + if (Indices::enableMICP) { + bioeffectsC.assign(ectx.globalDofIdx, + ectx.intQuants.oxygenConcentration().value(), + ectx.intQuants.ureaConcentration().value(), + ectx.intQuants.calciteConcentration().value()); + } + }, this->bioeffectsC_.allocated() }, Entry{[&rftC = this->rftC_, &vanguard = this->simulator_.vanguard()](const Context& ectx) @@ -2121,6 +2128,7 @@ class OutputBlackOilModule : public GenericOutputBlackoilModulesimulator_.model()](const Context& ectx) { return getValue(ectx.intQuants.microbialConcentration()) * + getValue(ectx.fs.saturation(waterPhaseIdx)) * getValue(ectx.intQuants.porosity()) * model.dofTotalVolume(ectx.globalDofIdx); } diff --git a/opm/simulators/flow/OutputCompositionalModule.hpp b/opm/simulators/flow/OutputCompositionalModule.hpp index 3874bae7a07..27f25b55e5a 100644 --- a/opm/simulators/flow/OutputCompositionalModule.hpp +++ b/opm/simulators/flow/OutputCompositionalModule.hpp @@ -111,7 +111,7 @@ class OutputCompositionalModule : public GenericOutputBlackoilModule(), getPropValue(), getPropValue(), - getPropValue()) + getPropValue()) , simulator_(simulator) { for (auto& region_pair : this->regions_) { diff --git a/opm/simulators/flow/SimulatorFullyImplicitBlackoil.hpp b/opm/simulators/flow/SimulatorFullyImplicitBlackoil.hpp index e08c3f4964f..f60eab18021 100644 --- a/opm/simulators/flow/SimulatorFullyImplicitBlackoil.hpp +++ b/opm/simulators/flow/SimulatorFullyImplicitBlackoil.hpp @@ -108,8 +108,7 @@ class SimulatorFullyImplicitBlackoil : private SerializableSim using TimeStepper = AdaptiveTimeStepping; using PolymerModule = BlackOilPolymerModule; - using MICPModule = BlackOilMICPModule; - + using BioeffectsModule = BlackOilBioeffectsModule; using Solver = NonlinearSolver; using ModelParameters = typename Model::ModelParameters; diff --git a/opm/simulators/flow/SolutionContainers.cpp b/opm/simulators/flow/SolutionContainers.cpp index 4a4e0520d7d..1a11d61286e 100644 --- a/opm/simulators/flow/SolutionContainers.cpp +++ b/opm/simulators/flow/SolutionContainers.cpp @@ -49,8 +49,8 @@ operator==(const PolymerSolutionContainer& rhs) const } template -MICPSolutionContainer -MICPSolutionContainer::serializationTestObject() +BioeffectsSolutionContainer +BioeffectsSolutionContainer::serializationTestObject() { return {{16.0}, {17.0}, @@ -60,7 +60,7 @@ MICPSolutionContainer::serializationTestObject() } template -void MICPSolutionContainer::resize(const unsigned numElems) +void BioeffectsSolutionContainer::resize(const unsigned numElems) { microbialConcentration.resize(numElems, 0.0); oxygenConcentration.resize(numElems, 0.0); @@ -70,8 +70,8 @@ void MICPSolutionContainer::resize(const unsigned numElems) } template -bool MICPSolutionContainer:: -operator==(const MICPSolutionContainer& rhs) const +bool BioeffectsSolutionContainer:: +operator==(const BioeffectsSolutionContainer& rhs) const { return this->microbialConcentration == rhs.microbialConcentration && this->oxygenConcentration == rhs.oxygenConcentration && @@ -82,7 +82,7 @@ operator==(const MICPSolutionContainer& rhs) const #define INSTANTIATE_TYPE(T) \ template struct PolymerSolutionContainer; \ - template struct MICPSolutionContainer; + template struct BioeffectsSolutionContainer; INSTANTIATE_TYPE(double) diff --git a/opm/simulators/flow/SolutionContainers.hpp b/opm/simulators/flow/SolutionContainers.hpp index f32e03dbcc7..bb24076d3af 100644 --- a/opm/simulators/flow/SolutionContainers.hpp +++ b/opm/simulators/flow/SolutionContainers.hpp @@ -54,14 +54,14 @@ struct PolymerSolutionContainer { //! \brief Struct holding MICP extension data. template -struct MICPSolutionContainer { +struct BioeffectsSolutionContainer { std::vector microbialConcentration; std::vector oxygenConcentration; std::vector ureaConcentration; std::vector biofilmConcentration; std::vector calciteConcentration; - static MICPSolutionContainer serializationTestObject(); + static BioeffectsSolutionContainer serializationTestObject(); //! \brief Resize vectors and zero initialize. void resize(const unsigned numElems); @@ -76,7 +76,7 @@ struct MICPSolutionContainer { serializer(calciteConcentration); } - bool operator==(const MICPSolutionContainer& rhs) const; + bool operator==(const BioeffectsSolutionContainer& rhs) const; }; } // namespace Opm diff --git a/opm/simulators/utils/ComponentName.cpp b/opm/simulators/utils/ComponentName.cpp index edb361f0780..b4a8fba7635 100644 --- a/opm/simulators/utils/ComponentName.cpp +++ b/opm/simulators/utils/ComponentName.cpp @@ -84,6 +84,11 @@ ComponentName::ComponentName() names_[Indices::biofilmConcentrationIdx] = "Biofilm"; names_[Indices::calciteConcentrationIdx] = "Calcite"; } + + if constexpr (Indices::enableBiofilm) { + names_[Indices::microbialConcentrationIdx] = "Microbes"; + names_[Indices::biofilmConcentrationIdx] = "Biofilm"; + } } diff --git a/opm/simulators/utils/InstantiationIndicesMacros.hpp b/opm/simulators/utils/InstantiationIndicesMacros.hpp index 3cfa5249865..f6c12a409e4 100644 --- a/opm/simulators/utils/InstantiationIndicesMacros.hpp +++ b/opm/simulators/utils/InstantiationIndicesMacros.hpp @@ -77,6 +77,7 @@ INSTANTIATE_CLASS(CLASS,T,BlackOilTwoPhaseIndices<0u,0u,0u,1u,false,false,0u,0u,0u>) \ INSTANTIATE_CLASS(CLASS,T,BlackOilTwoPhaseIndices<0u,0u,0u,1u,false,true,0u,0u,0u>) \ INSTANTIATE_CLASS(CLASS,T,BlackOilTwoPhaseIndices<1u,0u,0u,0u,false,false,0u,0u,0u>) \ + INSTANTIATE_CLASS(CLASS,T,BlackOilTwoPhaseIndices<0u,0u,0u,0u,false,false,0u,0u,2u>) \ INSTANTIATE_CLASS(CLASS,T,BlackOilVariableAndEquationIndices<0u,0u,0u,0u,false,false,0u,0u>) \ INSTANTIATE_CLASS(CLASS,T,BlackOilVariableAndEquationIndices<0u,0u,0u,0u,true,false,0u,0u>) \ INSTANTIATE_CLASS(CLASS,T,BlackOilVariableAndEquationIndices<0u,0u,0u,0u,false,true,0u,0u>) \ diff --git a/opm/simulators/wells/BlackoilWellModel.hpp b/opm/simulators/wells/BlackoilWellModel.hpp index c8691c94bd2..558262c5448 100644 --- a/opm/simulators/wells/BlackoilWellModel.hpp +++ b/opm/simulators/wells/BlackoilWellModel.hpp @@ -125,7 +125,7 @@ template class WellContributions; static constexpr bool has_solvent_ = getPropValue(); static constexpr bool has_polymer_ = getPropValue(); static constexpr bool has_energy_ = getPropValue(); - static constexpr bool has_micp_ = getPropValue(); + static constexpr bool has_micp_ = Indices::enableMICP; // TODO: where we should put these types, WellInterface or Well Model? // or there is some other strategy, like TypeTag @@ -133,7 +133,7 @@ template class WellContributions; using BVector = Dune::BlockVector; using PolymerModule = BlackOilPolymerModule; - using MICPModule = BlackOilMICPModule; + using BioeffectsModule = BlackOilBioeffectsModule; // For the conversion between the surface volume rate and reservoir voidage rate using RateConverterType = RateConverter:: diff --git a/opm/simulators/wells/StandardWell.hpp b/opm/simulators/wells/StandardWell.hpp index daa8b1b64e4..4417f60935d 100644 --- a/opm/simulators/wells/StandardWell.hpp +++ b/opm/simulators/wells/StandardWell.hpp @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include @@ -85,6 +85,7 @@ namespace Opm using Base::has_foam; using Base::has_brine; using Base::has_energy; + using Base::has_bioeffects; using Base::has_micp; using PolymerModule = BlackOilPolymerModule; diff --git a/opm/simulators/wells/StandardWellConnections.cpp b/opm/simulators/wells/StandardWellConnections.cpp index ee489180c14..ac481516837 100644 --- a/opm/simulators/wells/StandardWellConnections.cpp +++ b/opm/simulators/wells/StandardWellConnections.cpp @@ -721,9 +721,9 @@ template typename StandardWellConnections::Eval StandardWellConnections:: connectionRateFoam(const std::vector& cq_s, - const std::variant& foamConcentration, - const Phase transportPhase, - DeferredLogger& deferred_logger) const + const std::variant& foamConcentration, + const Phase transportPhase, + DeferredLogger& deferred_logger) const { // TODO: the application of well efficiency factor has not been tested with an example yet auto getFoamTransportIdx = [&deferred_logger,transportPhase] { @@ -756,6 +756,27 @@ connectionRateFoam(const std::vector& cq_s, return well_.restrictEval(cq_s_foam); } +template +typename StandardWellConnections::Eval +StandardWellConnections:: +connectionRateBioeffects(Scalar& rate, + const Scalar vap_wat_rate, + const std::vector& cq_s, + const std::variant& microbialConcentration) const +{ + // TODO: the application of well efficiency factor has not been tested with an example yet + const unsigned waterCompIdx = FluidSystem::canonicalToActiveCompIdx(FluidSystem::waterCompIdx); + // Correction microbial rate; evaporated water does not contain microbes + EvalWell cq_s_bm = cq_s[waterCompIdx] - vap_wat_rate; + cq_s_bm *= std::get(microbialConcentration); + + // Note. Efficiency factor is handled in the output layer + rate = cq_s_bm.value(); + + cq_s_bm *= well_.wellEfficiencyFactor(); + return well_.restrictEval(cq_s_bm); +} + template std::tuple::Eval, typename StandardWellConnections::Eval, diff --git a/opm/simulators/wells/StandardWellConnections.hpp b/opm/simulators/wells/StandardWellConnections.hpp index 1edc5e75d18..24a532d60c1 100644 --- a/opm/simulators/wells/StandardWellConnections.hpp +++ b/opm/simulators/wells/StandardWellConnections.hpp @@ -124,6 +124,11 @@ class StandardWellConnections const std::vector& cq_s, const std::variant& polymerConcentration) const; + Eval connectionRateBioeffects(Scalar& rate, + const Scalar vap_wat_rate, + const std::vector& cq_s, + const std::variant& microbialConcentration) const; + std::tuple connectionRatesMICP(Scalar& rate_m, Scalar& rate_o, diff --git a/opm/simulators/wells/StandardWell_impl.hpp b/opm/simulators/wells/StandardWell_impl.hpp index 47667c6841a..431c79c37f1 100644 --- a/opm/simulators/wells/StandardWell_impl.hpp +++ b/opm/simulators/wells/StandardWell_impl.hpp @@ -607,29 +607,40 @@ namespace Opm saltConcentration); } - if constexpr (has_micp) { + if constexpr (has_bioeffects) { std::variant microbialConcentration; - std::variant oxygenConcentration; - std::variant ureaConcentration; - if (this->isInjector()) { - microbialConcentration = this->wmicrobes(); - oxygenConcentration = this->woxygen(); - ureaConcentration = this->wurea(); - } else { - microbialConcentration = this->extendEval(intQuants.microbialConcentration()); - oxygenConcentration = this->extendEval(intQuants.oxygenConcentration()); - ureaConcentration = this->extendEval(intQuants.ureaConcentration()); - } - std::tie(connectionRates[perf][Indices::contiMicrobialEqIdx], - connectionRates[perf][Indices::contiOxygenEqIdx], - connectionRates[perf][Indices::contiUreaEqIdx]) = - this->connections_.connectionRatesMICP(perf_data.microbial_rates[perf], - perf_data.oxygen_rates[perf], - perf_data.urea_rates[perf], - cq_s, - microbialConcentration, - oxygenConcentration, - ureaConcentration); + if constexpr (has_micp) { + std::variant oxygenConcentration; + std::variant ureaConcentration; + if (this->isInjector()) { + microbialConcentration = this->wmicrobes(); + oxygenConcentration = this->woxygen(); + ureaConcentration = this->wurea(); + } else { + microbialConcentration = this->extendEval(intQuants.microbialConcentration()); + oxygenConcentration = this->extendEval(intQuants.oxygenConcentration()); + ureaConcentration = this->extendEval(intQuants.ureaConcentration()); + } + std::tie(connectionRates[perf][Indices::contiMicrobialEqIdx], + connectionRates[perf][Indices::contiOxygenEqIdx], + connectionRates[perf][Indices::contiUreaEqIdx]) = + this->connections_.connectionRatesMICP(perf_data.microbial_rates[perf], + perf_data.oxygen_rates[perf], + perf_data.urea_rates[perf], + cq_s, + microbialConcentration, + oxygenConcentration, + ureaConcentration); + } + else { + if (this->isProducer()) { + microbialConcentration = this->extendEval(intQuants.microbialConcentration()); + connectionRates[perf][Indices::contiMicrobialEqIdx] = + this->connections_.connectionRateBioeffects(perf_data.microbial_rates[perf], + perf_rates.vap_wat, cq_s, + microbialConcentration); + } + } } // Store the perforation pressure for later usage. @@ -1175,7 +1186,7 @@ namespace Opm { // the following implementation assume that the polymer is always after the w-o-g phases // For the polymer, energy and foam cases, there is one more mass balance equations of reservoir than wells - assert((int(B_avg.size()) == this->num_conservation_quantities_) || has_polymer || has_energy || has_foam || has_brine || has_zFraction || has_micp); + assert((int(B_avg.size()) == this->num_conservation_quantities_) || has_polymer || has_energy || has_foam || has_brine || has_zFraction || has_bioeffects); Scalar tol_wells = this->param_.tolerance_wells_; // use stricter tolerance for stopped wells and wells under zero rate target control. diff --git a/opm/simulators/wells/WellInterface.hpp b/opm/simulators/wells/WellInterface.hpp index b60858334b2..ff2debd733d 100644 --- a/opm/simulators/wells/WellInterface.hpp +++ b/opm/simulators/wells/WellInterface.hpp @@ -120,7 +120,8 @@ class WellInterface : public WellInterfaceIndices(); static constexpr bool has_disgas_in_water = getPropValue(); static constexpr bool has_saltPrecip = getPropValue(); - static constexpr bool has_micp = getPropValue(); + static constexpr bool has_bioeffects = getPropValue(); + static constexpr bool has_micp = Indices::enableMICP; // For the conversion between the surface volume rate and reservoir voidage rate using FluidState = BlackOilFluidState(), - getPropValue(), - getPropValue(), - getPropValue(), - getPropValue(), - getPropValue(), - /*PVOffset=*/0, - /*disabledCompIdx=*/FluidSystem::oilCompIdx, - getPropValue()>; + getPropValue(), + getPropValue(), + getPropValue(), + getPropValue(), + getPropValue(), + /*PVOffset=*/0, + /*disabledCompIdx=*/FluidSystem::oilCompIdx, + getPropValue()>; }; } } diff --git a/regressionTests.cmake b/regressionTests.cmake index a814a8d5fae..19c97ca6315 100644 --- a/regressionTests.cmake +++ b/regressionTests.cmake @@ -856,6 +856,14 @@ add_test_compareECLFiles(CASENAME 3d_tran_operator DIR parallel_fieldprops TEST_ARGS --enable-tuning=true --relaxed-max-pv-fraction=0) +add_test_compareECLFiles(CASENAME h2store_biofilm + FILENAME H2STORE_BIOFILM + SIMULATOR flow + ABS_TOL ${abs_tol} + REL_TOL ${rel_tol} + DIR h2store + TEST_ARGS --enable-opm-rst-file=true --initial-time-step-in-days=0.01) + add_test_compareECLFiles(CASENAME micp FILENAME MICP SIMULATOR flow From d4e587d58fe3d31667b8bd4ddc585f78671080ac Mon Sep 17 00:00:00 2001 From: Kjetil Olsen Lye Date: Thu, 18 Sep 2025 10:53:40 +0200 Subject: [PATCH 2/2] Formatting --- cmake/test/testFloatFromChars.cpp | 5 +- examples/art2dgf.cpp | 95 +- examples/co2_ptflash_ecfv.cpp | 23 +- examples/co2injection_flash_ecfv.cpp | 54 +- examples/co2injection_flash_ni_ecfv.cpp | 61 +- examples/co2injection_flash_ni_vcfv.cpp | 54 +- examples/co2injection_flash_vcfv.cpp | 47 +- examples/co2injection_immiscible_ecfv.cpp | 25 +- examples/co2injection_immiscible_ni_ecfv.cpp | 41 +- examples/co2injection_immiscible_ni_vcfv.cpp | 34 +- examples/co2injection_immiscible_vcfv.cpp | 25 +- examples/co2injection_ncp_ecfv.cpp | 27 +- examples/co2injection_ncp_ni_ecfv.cpp | 41 +- examples/co2injection_ncp_ni_vcfv.cpp | 34 +- examples/co2injection_ncp_vcfv.cpp | 25 +- examples/co2injection_pvs_ecfv.cpp | 27 +- examples/co2injection_pvs_ni_ecfv.cpp | 41 +- examples/co2injection_pvs_ni_vcfv.cpp | 34 +- examples/co2injection_pvs_vcfv.cpp | 25 +- examples/cuvette_pvs.cpp | 16 +- examples/diffusion_flash.cpp | 17 +- examples/diffusion_ncp.cpp | 15 +- examples/diffusion_pvs.cpp | 17 +- examples/finger_immiscible_ecfv.cpp | 23 +- examples/finger_immiscible_vcfv.cpp | 23 +- examples/fracture_discretefracture.cpp | 3 +- examples/groundwater_immiscible.cpp | 18 +- examples/infiltration_pvs.cpp | 18 +- examples/lens_immiscible_ecfv_ad.cpp | 3 +- examples/lens_immiscible_ecfv_ad_23.cpp | 81 +- examples/lens_immiscible_ecfv_ad_cu1.cpp | 5 +- examples/lens_immiscible_ecfv_ad_cu2.cpp | 5 +- examples/lens_immiscible_ecfv_ad_main.cpp | 7 +- examples/lens_immiscible_ecfv_ad_trans.cpp | 29 +- examples/lens_immiscible_vcfv_ad.cpp | 27 +- examples/lens_immiscible_vcfv_fd.cpp | 27 +- examples/lens_richards_ecfv.cpp | 30 +- examples/lens_richards_vcfv.cpp | 23 +- examples/obstacle_immiscible.cpp | 18 +- examples/obstacle_ncp.cpp | 16 +- examples/obstacle_pvs.cpp | 16 +- examples/opmrst_inspect.cpp | 29 +- examples/outflow_pvs.cpp | 16 +- examples/powerinjection_darcy_ad.cpp | 30 +- examples/powerinjection_darcy_fd.cpp | 30 +- examples/powerinjection_forchheimer_ad.cpp | 30 +- examples/powerinjection_forchheimer_fd.cpp | 30 +- examples/printvfp.cpp | 43 +- examples/reservoir_blackoil_ecfv.cpp | 32 +- examples/reservoir_blackoil_vcfv.cpp | 25 +- examples/reservoir_ncp_ecfv.cpp | 32 +- examples/reservoir_ncp_vcfv.cpp | 30 +- examples/tutorial1.cpp | 5 +- examples/waterair_pvs_ni.cpp | 25 +- flow/flow.cpp | 4 +- flow/flow_biofilm.cpp | 143 +- flow/flow_biofilm.hpp | 5 +- flow/flow_biofilm_main.cpp | 3 +- flow/flow_blackoil.cpp | 50 +- flow/flow_blackoil.hpp | 8 +- flow/flow_blackoil_alugrid.cpp | 64 +- flow/flow_blackoil_float_main.cpp | 15 +- flow/flow_blackoil_legacyassembly.cpp | 16 +- flow/flow_blackoil_legacyassembly.hpp | 21 +- flow/flow_blackoil_legacyassembly_main.cpp | 3 +- flow/flow_blackoil_main.cpp | 3 +- flow/flow_blackoil_polyhedralgrid.cpp | 54 +- flow/flow_brine.cpp | 46 +- flow/flow_brine.hpp | 5 +- flow/flow_brine_energy.cpp | 40 +- flow/flow_brine_energy.hpp | 5 +- flow/flow_brine_energy_main.cpp | 3 +- flow/flow_brine_main.cpp | 3 +- flow/flow_brine_precsalt_vapwat.cpp | 62 +- flow/flow_brine_precsalt_vapwat.hpp | 5 +- flow/flow_brine_precsalt_vapwat_main.cpp | 3 +- flow/flow_brine_saltprecipitation.cpp | 54 +- flow/flow_brine_saltprecipitation.hpp | 5 +- flow/flow_brine_saltprecipitation_main.cpp | 3 +- flow/flow_distribute_z.cpp | 27 +- flow/flow_energy.cpp | 60 +- flow/flow_energy.hpp | 5 +- flow/flow_energy_main.cpp | 3 +- flow/flow_extbo.cpp | 46 +- flow/flow_extbo.hpp | 5 +- flow/flow_extbo_main.cpp | 3 +- flow/flow_foam.cpp | 46 +- flow/flow_foam.hpp | 5 +- flow/flow_foam_main.cpp | 3 +- flow/flow_gasoil.cpp | 105 +- flow/flow_gasoil.hpp | 5 +- flow/flow_gasoil_energy.cpp | 123 +- flow/flow_gasoil_energy.hpp | 5 +- flow/flow_gasoil_energy_main.cpp | 3 +- flow/flow_gasoil_main.cpp | 3 +- flow/flow_gasoildiffuse.cpp | 115 +- flow/flow_gasoildiffuse.hpp | 5 +- flow/flow_gasoildiffuse_main.cpp | 3 +- flow/flow_gaswater.cpp | 95 +- flow/flow_gaswater.hpp | 8 +- flow/flow_gaswater_brine.cpp | 99 +- flow/flow_gaswater_brine.hpp | 5 +- flow/flow_gaswater_brine_main.cpp | 3 +- flow/flow_gaswater_dissolution.cpp | 125 +- flow/flow_gaswater_dissolution.hpp | 5 +- flow/flow_gaswater_dissolution_diffuse.cpp | 133 +- flow/flow_gaswater_dissolution_diffuse.hpp | 5 +- ...flow_gaswater_dissolution_diffuse_main.cpp | 3 +- flow/flow_gaswater_dissolution_main.cpp | 3 +- flow/flow_gaswater_energy.cpp | 143 +- flow/flow_gaswater_energy.hpp | 5 +- flow/flow_gaswater_energy_main.cpp | 3 +- flow/flow_gaswater_main.cpp | 3 +- flow/flow_gaswater_saltprec_energy.cpp | 129 +- flow/flow_gaswater_saltprec_energy.hpp | 5 +- flow/flow_gaswater_saltprec_energy_main.cpp | 3 +- flow/flow_gaswater_saltprec_vapwat.cpp | 119 +- flow/flow_gaswater_saltprec_vapwat.hpp | 5 +- flow/flow_gaswater_saltprec_vapwat_main.cpp | 3 +- flow/flow_gaswater_solvent.cpp | 91 +- flow/flow_gaswater_solvent.hpp | 5 +- flow/flow_gaswater_solvent_main.cpp | 3 +- flow/flow_micp.cpp | 117 +- flow/flow_micp.hpp | 5 +- flow/flow_micp_main.cpp | 3 +- flow/flow_oilwater.cpp | 107 +- flow/flow_oilwater.hpp | 5 +- flow/flow_oilwater_brine.cpp | 83 +- flow/flow_oilwater_brine.hpp | 5 +- flow/flow_oilwater_brine_main.cpp | 3 +- flow/flow_oilwater_main.cpp | 3 +- flow/flow_oilwater_polymer.cpp | 83 +- flow/flow_oilwater_polymer.hpp | 5 +- flow/flow_oilwater_polymer_injectivity.cpp | 97 +- flow/flow_oilwater_polymer_injectivity.hpp | 5 +- ...flow_oilwater_polymer_injectivity_main.cpp | 3 +- flow/flow_oilwater_polymer_main.cpp | 3 +- flow/flow_onephase.cpp | 103 +- flow/flow_onephase.hpp | 5 +- flow/flow_onephase_energy.cpp | 83 +- flow/flow_onephase_energy.hpp | 5 +- flow/flow_onephase_energy_main.cpp | 5 +- flow/flow_onephase_main.cpp | 3 +- flow/flow_polymer.cpp | 46 +- flow/flow_polymer.hpp | 5 +- flow/flow_polymer_main.cpp | 3 +- flow/flow_solvent.cpp | 46 +- flow/flow_solvent.hpp | 5 +- flow/flow_solvent_foam.cpp | 54 +- flow/flow_solvent_foam.hpp | 5 +- flow/flow_solvent_foam_main.cpp | 3 +- flow/flow_solvent_main.cpp | 3 +- ...ilEnergyIntensiveQuantitiesGlobalIndex.hpp | 24 +- ...BlackOilIntensiveQuantitiesGlobalIndex.hpp | 173 +- flowexperimental/FIBlackOilModelNoCache.hpp | 17 +- flowexperimental/FlowExpNewtonMethod.hpp | 101 +- flowexperimental/comp/EmptyModel.hpp | 72 +- flowexperimental/comp/flowexp_comp.hpp | 85 +- flowexperimental/comp/flowexp_comp2.cpp | 10 +- flowexperimental/comp/flowexp_comp2_2p.cpp | 10 +- flowexperimental/comp/flowexp_comp3.cpp | 10 +- flowexperimental/comp/flowexp_comp3_2p.cpp | 10 +- flowexperimental/comp/flowexp_comp4.cpp | 10 +- flowexperimental/comp/flowexp_comp4_2p.cpp | 10 +- flowexperimental/comp/flowexp_comp5.cpp | 10 +- flowexperimental/comp/flowexp_comp5_2p.cpp | 10 +- flowexperimental/comp/flowexp_comp6.cpp | 10 +- flowexperimental/comp/flowexp_comp6_2p.cpp | 10 +- flowexperimental/comp/flowexp_comp7.cpp | 10 +- flowexperimental/comp/flowexp_comp7_2p.cpp | 10 +- flowexperimental/comp/wells/CompWell.hpp | 76 +- .../comp/wells/CompWellEquations.hpp | 3 +- .../comp/wells/CompWellEquations_impl.hpp | 40 +- .../comp/wells/CompWellInterface.hpp | 25 +- .../comp/wells/CompWellInterface_impl.hpp | 20 +- flowexperimental/comp/wells/CompWellModel.hpp | 126 +- .../comp/wells/CompWellModel_impl.hpp | 99 +- .../comp/wells/CompWellPrimaryVariables.hpp | 9 +- .../wells/CompWellPrimaryVariables_impl.hpp | 42 +- flowexperimental/comp/wells/CompWellState.hpp | 11 +- .../comp/wells/CompWellState_impl.hpp | 103 +- flowexperimental/comp/wells/CompWell_impl.hpp | 220 +- .../comp/wells/SingleCompWellState.hpp | 19 +- .../comp/wells/SingleCompWellState_impl.hpp | 106 +- flowexperimental/flowexp.hpp | 51 +- flowexperimental/flowexp_blackoil.cpp | 50 +- .../blackoil/blackoilbioeffectsparams.cpp | 55 +- .../blackoil/blackoilbioeffectsparams.hpp | 40 +- opm/models/blackoil/blackoilbrineparams.cpp | 40 +- opm/models/blackoil/blackoilbrineparams.hpp | 10 +- opm/models/blackoil/blackoilextboparams.cpp | 69 +- opm/models/blackoil/blackoilextboparams.hpp | 10 +- opm/models/blackoil/blackoilfoamparams.cpp | 25 +- opm/models/blackoil/blackoilfoamparams.hpp | 32 +- opm/models/blackoil/blackoilnewtonmethod.hpp | 141 +- .../blackoil/blackoilnewtonmethodparams.cpp | 51 +- .../blackoil/blackoilnewtonmethodparams.hpp | 75 +- opm/models/blackoil/blackoilpolymerparams.cpp | 127 +- opm/models/blackoil/blackoilpolymerparams.hpp | 41 +- opm/models/blackoil/blackoilsolventparams.cpp | 91 +- opm/models/blackoil/blackoilsolventparams.hpp | 58 +- opm/models/io/restart.cpp | 41 +- opm/models/io/restart.hpp | 25 +- opm/models/io/vtkblackoilbioeffectsmodule.hpp | 47 +- opm/models/io/vtkblackoilbioeffectsparams.cpp | 31 +- opm/models/io/vtkblackoilbioeffectsparams.hpp | 29 +- opm/models/io/vtkblackoilenergymodule.hpp | 41 +- opm/models/io/vtkblackoilenergyparams.cpp | 28 +- opm/models/io/vtkblackoilenergyparams.hpp | 25 +- opm/models/io/vtkblackoilmodule.hpp | 141 +- opm/models/io/vtkblackoilparams.cpp | 73 +- opm/models/io/vtkblackoilparams.hpp | 53 +- opm/models/io/vtkblackoilpolymermodule.hpp | 62 +- opm/models/io/vtkblackoilpolymerparams.cpp | 43 +- opm/models/io/vtkblackoilpolymerparams.hpp | 33 +- opm/models/io/vtkblackoilsolventmodule.hpp | 45 +- opm/models/io/vtkblackoilsolventparams.cpp | 35 +- opm/models/io/vtkblackoilsolventparams.hpp | 29 +- opm/models/io/vtkcompositionmodule.hpp | 63 +- opm/models/io/vtkcompositionparams.cpp | 33 +- opm/models/io/vtkcompositionparams.hpp | 39 +- opm/models/io/vtkdiffusionmodule.hpp | 31 +- opm/models/io/vtkdiffusionparams.cpp | 24 +- opm/models/io/vtkdiffusionparams.hpp | 21 +- opm/models/io/vtkdiscretefracturemodule.hpp | 59 +- opm/models/io/vtkdiscretefractureparams.cpp | 39 +- opm/models/io/vtkdiscretefractureparams.hpp | 37 +- opm/models/io/vtkenergymodule.hpp | 25 +- opm/models/io/vtkenergyparams.cpp | 29 +- opm/models/io/vtkenergyparams.hpp | 25 +- opm/models/io/vtkmultiphasemodule.hpp | 68 +- opm/models/io/vtkmultiphaseparams.cpp | 52 +- opm/models/io/vtkmultiphaseparams.hpp | 57 +- opm/models/io/vtkphasepresencemodule.hpp | 14 +- opm/models/io/vtkphasepresenceparams.cpp | 14 +- opm/models/io/vtkphasepresenceparams.hpp | 13 +- opm/models/io/vtkprimaryvarsmodule.hpp | 13 +- opm/models/io/vtkprimaryvarsparams.cpp | 19 +- opm/models/io/vtkprimaryvarsparams.hpp | 21 +- opm/models/io/vtkptflashmodule.hpp | 13 +- opm/models/io/vtkptflashparams.cpp | 17 +- opm/models/io/vtkptflashparams.hpp | 17 +- opm/models/io/vtktemperaturemodule.hpp | 12 +- opm/models/io/vtktemperatureparams.cpp | 12 +- opm/models/io/vtktemperatureparams.hpp | 13 +- opm/models/nonlinear/newtonmethodparams.cpp | 39 +- opm/models/nonlinear/newtonmethodparams.hpp | 39 +- opm/models/parallel/tasklets.cpp | 55 +- opm/models/parallel/tasklets.hpp | 47 +- opm/models/parallel/threadmanager.cpp | 20 +- opm/models/parallel/threadmanager.hpp | 7 +- opm/models/utils/parametersystem.cpp | 483 +- opm/models/utils/parametersystem.hpp | 132 +- opm/models/utils/simulatorutils.cpp | 79 +- opm/models/utils/simulatorutils.hpp | 15 +- opm/models/utils/terminal.cpp | 34 +- opm/models/utils/terminal.hpp | 7 +- opm/models/utils/timer.cpp | 42 +- opm/models/utils/timer.hpp | 10 +- opm/simulators/aquifers/AquiferAnalytical.hpp | 99 +- .../aquifers/AquiferCarterTracy.hpp | 126 +- .../aquifers/AquiferConstantFlux.hpp | 73 +- opm/simulators/aquifers/AquiferFetkovich.hpp | 46 +- opm/simulators/aquifers/AquiferGridUtils.hpp | 30 +- opm/simulators/aquifers/AquiferInterface.hpp | 19 +- opm/simulators/aquifers/AquiferNumerical.hpp | 66 +- .../aquifers/BlackoilAquiferModel.hpp | 13 +- .../aquifers/BlackoilAquiferModel_impl.hpp | 136 +- opm/simulators/aquifers/SupportsFaceTag.hpp | 24 +- opm/simulators/flow/ActionHandler.cpp | 245 +- opm/simulators/flow/ActionHandler.hpp | 23 +- .../flow/AluGridCartesianIndexMapper.hpp | 101 +- .../flow/AluGridLevelCartesianIndexMapper.hpp | 43 +- opm/simulators/flow/AluGridVanguard.hpp | 145 +- opm/simulators/flow/Banners.cpp | 56 +- opm/simulators/flow/Banners.hpp | 6 +- opm/simulators/flow/BaseAquiferModel.hpp | 58 +- opm/simulators/flow/BioeffectsContainer.cpp | 102 +- opm/simulators/flow/BioeffectsContainer.hpp | 36 +- opm/simulators/flow/BlackoilModel.hpp | 170 +- .../flow/BlackoilModelConvergenceMonitor.cpp | 38 +- .../flow/BlackoilModelConvergenceMonitor.hpp | 3 +- opm/simulators/flow/BlackoilModelNldd.hpp | 267 +- .../flow/BlackoilModelParameters.cpp | 335 +- .../flow/BlackoilModelParameters.hpp | 404 +- .../flow/BlackoilModelProperties.hpp | 163 +- opm/simulators/flow/BlackoilModel_impl.hpp | 493 +- opm/simulators/flow/CollectDataOnIORank.cpp | 11 +- opm/simulators/flow/CollectDataOnIORank.hpp | 102 +- .../flow/CollectDataOnIORank_impl.hpp | 448 +- .../flow/CompositionalContainer.cpp | 99 +- .../flow/CompositionalContainer.hpp | 29 +- .../flow/ConvergenceOutputConfiguration.cpp | 129 +- .../flow/ConvergenceOutputConfiguration.hpp | 10 +- opm/simulators/flow/CpGridVanguard.hpp | 98 +- opm/simulators/flow/DamarisParameters.cpp | 112 +- opm/simulators/flow/DamarisParameters.hpp | 68 +- opm/simulators/flow/DamarisWriter.cpp | 48 +- opm/simulators/flow/DamarisWriter.hpp | 441 +- .../flow/DummyGradientCalculator.hpp | 29 +- opm/simulators/flow/EclGenericWriter.cpp | 35 +- opm/simulators/flow/EclGenericWriter.hpp | 88 +- opm/simulators/flow/EclGenericWriter_impl.hpp | 408 +- opm/simulators/flow/EclWriter.hpp | 346 +- opm/simulators/flow/EquilInitializer.hpp | 17 +- opm/simulators/flow/ExtboContainer.cpp | 75 +- opm/simulators/flow/ExtboContainer.hpp | 26 +- .../flow/ExtraConvergenceOutputThread.cpp | 441 +- .../flow/ExtraConvergenceOutputThread.hpp | 30 +- opm/simulators/flow/FIBlackoilModel.hpp | 18 +- opm/simulators/flow/FIPContainer.cpp | 266 +- opm/simulators/flow/FIPContainer.hpp | 70 +- opm/simulators/flow/FemCpGridCompat.hpp | 46 +- .../flow/FlowBaseProblemProperties.hpp | 229 +- opm/simulators/flow/FlowBaseVanguard.hpp | 152 +- opm/simulators/flow/FlowGenericProblem.cpp | 21 +- opm/simulators/flow/FlowGenericProblem.hpp | 74 +- .../flow/FlowGenericProblem_impl.hpp | 455 +- opm/simulators/flow/FlowGenericVanguard.cpp | 310 +- opm/simulators/flow/FlowGenericVanguard.hpp | 242 +- opm/simulators/flow/FlowMain.hpp | 731 +-- opm/simulators/flow/FlowProblem.hpp | 450 +- opm/simulators/flow/FlowProblemBlackoil.hpp | 509 +- .../flow/FlowProblemBlackoilProperties.hpp | 61 +- opm/simulators/flow/FlowProblemComp.hpp | 92 +- .../flow/FlowProblemCompProperties.hpp | 38 +- opm/simulators/flow/FlowProblemParameters.cpp | 54 +- opm/simulators/flow/FlowProblemParameters.hpp | 37 +- opm/simulators/flow/FlowThresholdPressure.hpp | 11 +- opm/simulators/flow/FlowUtils.cpp | 182 +- opm/simulators/flow/FlowUtils.hpp | 18 +- opm/simulators/flow/FlowsContainer.cpp | 252 +- opm/simulators/flow/FlowsContainer.hpp | 71 +- opm/simulators/flow/FlowsData.hpp | 8 +- opm/simulators/flow/GenericCpGridVanguard.cpp | 524 +- opm/simulators/flow/GenericCpGridVanguard.hpp | 149 +- .../flow/GenericOutputBlackoilModule.cpp | 1138 ++--- .../flow/GenericOutputBlackoilModule.hpp | 121 +- .../flow/GenericThresholdPressure.cpp | 33 +- .../flow/GenericThresholdPressure.hpp | 28 +- .../flow/GenericThresholdPressure_impl.hpp | 117 +- opm/simulators/flow/GenericTracerModel.cpp | 29 +- opm/simulators/flow/GenericTracerModel.hpp | 58 +- .../flow/GenericTracerModel_impl.hpp | 273 +- opm/simulators/flow/InterRegFlows.cpp | 90 +- opm/simulators/flow/InterRegFlows.hpp | 659 ++- opm/simulators/flow/KeywordValidation.cpp | 308 +- opm/simulators/flow/KeywordValidation.hpp | 26 +- opm/simulators/flow/LogOutputHelper.cpp | 1200 +++-- opm/simulators/flow/LogOutputHelper.hpp | 58 +- opm/simulators/flow/Main.cpp | 122 +- opm/simulators/flow/Main.hpp | 106 +- opm/simulators/flow/MainDispatchDynamic.cpp | 121 +- opm/simulators/flow/MechContainer.cpp | 189 +- opm/simulators/flow/MechContainer.hpp | 37 +- opm/simulators/flow/MixingRateControls.cpp | 231 +- opm/simulators/flow/MixingRateControls.hpp | 62 +- opm/simulators/flow/NewTranFluxModule.hpp | 149 +- opm/simulators/flow/NlddReporting.cpp | 90 +- opm/simulators/flow/NlddReporting.hpp | 136 +- opm/simulators/flow/NonlinearSolver.cpp | 88 +- opm/simulators/flow/NonlinearSolver.hpp | 431 +- opm/simulators/flow/OutputBlackoilModule.hpp | 507 +- .../flow/OutputCompositionalModule.hpp | 203 +- opm/simulators/flow/OutputExtractor.hpp | 317 +- .../flow/PolyhedralGridVanguard.hpp | 84 +- opm/simulators/flow/RFTContainer.cpp | 92 +- opm/simulators/flow/RFTContainer.hpp | 20 +- opm/simulators/flow/RSTConv.cpp | 90 +- opm/simulators/flow/RSTConv.hpp | 39 +- opm/simulators/flow/RegionPhasePVAverage.cpp | 183 +- opm/simulators/flow/RegionPhasePVAverage.hpp | 632 ++- opm/simulators/flow/ReservoirCoupling.cpp | 212 +- opm/simulators/flow/ReservoirCoupling.hpp | 248 +- .../flow/ReservoirCouplingMaster.cpp | 233 +- .../flow/ReservoirCouplingMaster.hpp | 180 +- .../flow/ReservoirCouplingMpiTraits.hpp | 240 +- .../flow/ReservoirCouplingSlave.cpp | 260 +- .../flow/ReservoirCouplingSlave.hpp | 52 +- .../flow/ReservoirCouplingSpawnSlaves.cpp | 245 +- .../flow/ReservoirCouplingSpawnSlaves.hpp | 31 +- .../flow/SimulatorConvergenceOutput.cpp | 66 +- .../flow/SimulatorConvergenceOutput.hpp | 20 +- .../flow/SimulatorFullyImplicitBlackoil.cpp | 65 +- .../flow/SimulatorFullyImplicitBlackoil.hpp | 239 +- .../flow/SimulatorReportBanners.cpp | 17 +- .../flow/SimulatorReportBanners.hpp | 8 +- opm/simulators/flow/SimulatorSerializer.cpp | 90 +- opm/simulators/flow/SimulatorSerializer.hpp | 27 +- opm/simulators/flow/SolutionContainers.cpp | 52 +- opm/simulators/flow/SolutionContainers.hpp | 11 +- opm/simulators/flow/SubDomain.hpp | 113 +- .../flow/TTagFlowProblemGasWater.hpp | 21 +- opm/simulators/flow/TTagFlowProblemTPFA.hpp | 25 +- opm/simulators/flow/TracerContainer.cpp | 117 +- opm/simulators/flow/TracerContainer.hpp | 28 +- opm/simulators/flow/TracerModel.hpp | 326 +- opm/simulators/flow/Transmissibility.cpp | 25 +- opm/simulators/flow/Transmissibility.hpp | 85 +- opm/simulators/flow/Transmissibility_impl.hpp | 696 ++- opm/simulators/flow/ValidationFunctions.cpp | 130 +- opm/simulators/flow/ValidationFunctions.hpp | 12 +- opm/simulators/flow/VtkTracerModule.hpp | 207 +- opm/simulators/flow/countGlobalCells.hpp | 107 +- .../flow/equil/EquilibrationHelpers.cpp | 57 +- .../flow/equil/EquilibrationHelpers.hpp | 1455 +++--- .../flow/equil/EquilibrationHelpers_impl.hpp | 1154 ++--- opm/simulators/flow/equil/InitStateEquil.cpp | 107 +- opm/simulators/flow/equil/InitStateEquil.hpp | 1377 +++-- .../flow/equil/InitStateEquil_impl.hpp | 3514 ++++++------- opm/simulators/flow/partitionCells.cpp | 507 +- opm/simulators/flow/partitionCells.hpp | 23 +- opm/simulators/flow/priVarsPacking.hpp | 64 +- .../flow/python/PyBaseSimulator.hpp | 59 +- .../flow/python/PyBaseSimulator_impl.hpp | 188 +- .../flow/python/PyBlackOilSimulator.hpp | 14 +- opm/simulators/flow/python/PyFluidState.hpp | 44 +- .../flow/python/PyFluidState_impl.hpp | 174 +- .../flow/python/PyGasWaterSimulator.hpp | 16 +- opm/simulators/flow/python/PyMain.hpp | 11 +- .../flow/python/PyMaterialState.hpp | 50 +- .../flow/python/PyMaterialState_impl.hpp | 20 +- .../flow/python/Pybind11Exporter.hpp | 15 +- opm/simulators/linalg/AbstractISTLSolver.hpp | 1 - opm/simulators/linalg/AmgxPreconditioner.hpp | 50 +- opm/simulators/linalg/DILU.hpp | 5 +- opm/simulators/linalg/ExtraSmoothers.hpp | 9 +- .../ExtractParallelGridInformationToISTL.cpp | 35 +- .../ExtractParallelGridInformationToISTL.hpp | 13 +- opm/simulators/linalg/FlexibleSolver.hpp | 19 +- opm/simulators/linalg/FlexibleSolver1.cpp | 4 +- opm/simulators/linalg/FlexibleSolver2.cpp | 4 +- opm/simulators/linalg/FlexibleSolver3.cpp | 4 +- opm/simulators/linalg/FlexibleSolver4.cpp | 4 +- opm/simulators/linalg/FlexibleSolver5.cpp | 4 +- opm/simulators/linalg/FlexibleSolver6.cpp | 4 +- opm/simulators/linalg/FlexibleSolver_impl.hpp | 474 +- .../linalg/FlowLinearSolverParameters.cpp | 237 +- .../linalg/FlowLinearSolverParameters.hpp | 163 +- opm/simulators/linalg/GraphColoring.hpp | 152 +- opm/simulators/linalg/HyprePreconditioner.hpp | 44 +- opm/simulators/linalg/ISTLSolver.cpp | 247 +- opm/simulators/linalg/ISTLSolver.hpp | 973 ++-- opm/simulators/linalg/ISTLSolverGpuBridge.cpp | 251 +- opm/simulators/linalg/ISTLSolverGpuBridge.hpp | 179 +- .../linalg/ISTLSolverRuntimeOptionProxy.hpp | 15 +- .../linalg/LinearSolverAcceleratorType.hpp | 6 +- opm/simulators/linalg/MILU.cpp | 392 +- opm/simulators/linalg/MILU.hpp | 99 +- .../linalg/MatrixMarketSpecializations.hpp | 18 +- .../linalg/OwningBlockPreconditioner.hpp | 3 +- .../linalg/OwningTwoLevelPreconditioner.hpp | 67 +- .../linalg/ParallelIstlInformation.cpp | 261 +- .../linalg/ParallelIstlInformation.hpp | 183 +- .../linalg/ParallelOverlappingILU0.cpp | 41 +- .../linalg/ParallelOverlappingILU0.hpp | 261 +- .../linalg/ParallelOverlappingILU0_impl.hpp | 660 ++- .../ParallelRestrictedAdditiveSchwarz.hpp | 152 +- .../linalg/PreconditionerFactory.hpp | 43 +- .../linalg/PreconditionerFactory1.cpp | 9 +- .../linalg/PreconditionerFactory2.cpp | 9 +- .../linalg/PreconditionerFactory3.cpp | 9 +- .../linalg/PreconditionerFactory4.cpp | 9 +- .../linalg/PreconditionerFactory5.cpp | 9 +- .../linalg/PreconditionerFactory6.cpp | 9 +- ...PreconditionerFactoryGPUIncludeWrapper.hpp | 4 +- .../linalg/PreconditionerFactory_impl.hpp | 69 +- .../linalg/PreconditionerWithUpdate.hpp | 30 +- .../linalg/PressureBhpTransferPolicy.hpp | 229 +- .../linalg/PressureSolverPolicy.hpp | 18 +- .../linalg/PressureTransferPolicy.hpp | 45 +- opm/simulators/linalg/PropertyTree.cpp | 59 +- opm/simulators/linalg/PropertyTree.hpp | 23 +- .../linalg/SmallDenseMatrixUtils.hpp | 101 +- .../linalg/StandardPreconditioners.hpp | 2 +- .../StandardPreconditioners_gpu_mpi.hpp | 73 +- .../StandardPreconditioners_gpu_serial.hpp | 79 +- .../linalg/StandardPreconditioners_mpi.hpp | 134 +- .../linalg/StandardPreconditioners_serial.hpp | 169 +- opm/simulators/linalg/WellOperators.hpp | 225 +- .../linalg/WriteSystemMatrixHelper.hpp | 469 +- opm/simulators/linalg/extractMatrix.hpp | 24 +- .../linalg/findOverlapRowsAndColumns.hpp | 61 +- .../linalg/getQuasiImpesWeights.hpp | 58 +- .../linalg/gpubridge/BlockedMatrix.cpp | 24 +- .../linalg/gpubridge/BlockedMatrix.hpp | 37 +- .../linalg/gpubridge/CprCreation.cpp | 94 +- .../linalg/gpubridge/CprCreation.hpp | 46 +- opm/simulators/linalg/gpubridge/GpuBridge.cpp | 184 +- opm/simulators/linalg/gpubridge/GpuBridge.hpp | 47 +- opm/simulators/linalg/gpubridge/GpuResult.hpp | 32 +- opm/simulators/linalg/gpubridge/GpuSolver.hpp | 157 +- opm/simulators/linalg/gpubridge/Matrix.hpp | 64 +- opm/simulators/linalg/gpubridge/Misc.cpp | 69 +- opm/simulators/linalg/gpubridge/Misc.hpp | 116 +- .../MultisegmentWellContribution.cpp | 73 +- .../MultisegmentWellContribution.hpp | 38 +- .../linalg/gpubridge/Preconditioner.hpp | 42 +- opm/simulators/linalg/gpubridge/Reorder.cpp | 37 +- opm/simulators/linalg/gpubridge/Reorder.hpp | 27 +- .../linalg/gpubridge/WellContributions.cpp | 97 +- .../linalg/gpubridge/WellContributions.hpp | 69 +- .../linalg/gpubridge/amgclSolverBackend.cpp | 154 +- .../linalg/gpubridge/amgclSolverBackend.hpp | 47 +- .../gpubridge/cuda/cuWellContributions.hpp | 12 +- .../linalg/gpubridge/cuda/cuda_header.hpp | 10 +- .../gpubridge/cuda/cusparseSolverBackend.hpp | 49 +- .../linalg/gpubridge/opencl/ChowPatelIlu.cpp | 1051 ++-- .../linalg/gpubridge/opencl/ChowPatelIlu.hpp | 183 +- .../linalg/gpubridge/opencl/OpenclMatrix.cpp | 76 +- .../linalg/gpubridge/opencl/OpenclMatrix.hpp | 57 +- .../linalg/gpubridge/opencl/opencl.cpp | 196 +- .../linalg/gpubridge/opencl/opencl.hpp | 12 +- .../linalg/gpubridge/opencl/openclBILU0.cpp | 223 +- .../linalg/gpubridge/opencl/openclBILU0.hpp | 57 +- .../linalg/gpubridge/opencl/openclBISAI.cpp | 304 +- .../linalg/gpubridge/opencl/openclBISAI.hpp | 51 +- .../linalg/gpubridge/opencl/openclCPR.cpp | 149 +- .../linalg/gpubridge/opencl/openclCPR.hpp | 54 +- .../linalg/gpubridge/opencl/openclKernels.cpp | 527 +- .../linalg/gpubridge/opencl/openclKernels.hpp | 346 +- .../gpubridge/opencl/openclPreconditioner.cpp | 47 +- .../gpubridge/opencl/openclPreconditioner.hpp | 21 +- .../gpubridge/opencl/openclSolverBackend.cpp | 207 +- .../gpubridge/opencl/openclSolverBackend.hpp | 72 +- .../opencl/openclWellContributions.cpp | 129 +- .../opencl/openclWellContributions.hpp | 10 +- .../linalg/gpubridge/rocm/hipKernels.cpp | 291 +- .../linalg/gpubridge/rocm/hipKernels.hpp | 67 +- .../rocm/rocalutionSolverBackend.cpp | 93 +- .../rocm/rocalutionSolverBackend.hpp | 53 +- .../linalg/gpubridge/rocm/rocsparseBILU0.cpp | 699 ++- .../linalg/gpubridge/rocm/rocsparseBILU0.hpp | 43 +- .../linalg/gpubridge/rocm/rocsparseCPR.cpp | 644 ++- .../linalg/gpubridge/rocm/rocsparseCPR.hpp | 74 +- .../linalg/gpubridge/rocm/rocsparseMatrix.cpp | 71 +- .../linalg/gpubridge/rocm/rocsparseMatrix.hpp | 44 +- .../rocm/rocsparsePreconditioner.cpp | 57 +- .../rocm/rocsparsePreconditioner.hpp | 45 +- .../gpubridge/rocm/rocsparseSolverBackend.cpp | 598 ++- .../gpubridge/rocm/rocsparseSolverBackend.hpp | 36 +- .../rocm/rocsparseWellContributions.cpp | 160 +- .../rocm/rocsparseWellContributions.hpp | 12 +- .../linalg/gpuistl/AmgxInterface.hpp | 11 +- .../linalg/gpuistl/GpuBlockPreconditioner.hpp | 3 +- opm/simulators/linalg/gpuistl/GpuBuffer.cpp | 25 +- opm/simulators/linalg/gpuistl/GpuBuffer.hpp | 6 +- opm/simulators/linalg/gpuistl/GpuDILU.cpp | 12 +- opm/simulators/linalg/gpuistl/GpuJac.cpp | 25 +- opm/simulators/linalg/gpuistl/GpuJac.hpp | 5 +- opm/simulators/linalg/gpuistl/GpuSender.hpp | 2 +- opm/simulators/linalg/gpuistl/GpuSeqILU0.cpp | 28 +- opm/simulators/linalg/gpuistl/GpuSeqILU0.hpp | 5 +- .../linalg/gpuistl/GpuSparseMatrix.cpp | 47 +- .../linalg/gpuistl/GpuSparseMatrix.hpp | 58 +- opm/simulators/linalg/gpuistl/GpuVector.cpp | 30 +- opm/simulators/linalg/gpuistl/GpuVector.hpp | 16 +- opm/simulators/linalg/gpuistl/GpuView.cpp | 2 +- opm/simulators/linalg/gpuistl/GpuView.hpp | 92 +- .../linalg/gpuistl/ISTLSolverGPUISTL.hpp | 84 +- opm/simulators/linalg/gpuistl/OpmGpuILU0.cpp | 126 +- opm/simulators/linalg/gpuistl/OpmGpuILU0.hpp | 13 +- .../linalg/gpuistl/PreconditionerAdapter.hpp | 3 +- .../PreconditionerConvertFieldTypeAdapter.hpp | 5 +- .../linalg/gpuistl/SolverAdapter.hpp | 2 +- .../gpuistl/detail/CuMatrixDescription.hpp | 6 +- .../gpuistl/detail/CuSparseResource.hpp | 5 +- .../gpuistl/detail/FlexibleSolverWrapper.cpp | 31 +- .../gpuistl/detail/FlexibleSolverWrapper.hpp | 18 +- .../linalg/gpuistl/detail/autotuner.hpp | 8 +- .../gpuistl/detail/cuda_check_last_error.hpp | 7 +- .../gpuistl/detail/deviceBlockOperations.hpp | 9 +- .../detail/gpu_preconditioner_utils.hpp | 11 +- .../linalg/gpuistl/detail/gpu_safe_call.hpp | 4 +- .../detail/gpusparse_matrix_operations.hpp | 11 +- .../linalg/gpuistl/detail/kernel_enums.hpp | 145 +- .../preconditionerKernels/ILU0Kernels.hpp | 2 +- .../ILU_variants_helper_kernels.hpp | 14 +- .../linalg/gpuistl/detail/safe_conversion.hpp | 2 +- .../gpuistl/detail/vector_operations.hpp | 7 +- .../linalg/gpuistl/device_management.cpp | 94 +- .../linalg/gpuistl/device_management.hpp | 9 +- .../linalg/gpuistl/gpu_smart_pointer.hpp | 29 +- .../hypreinterface/HypreCpuTransfers.hpp | 52 +- .../hypreinterface/HypreDataStructures.hpp | 2 +- .../gpuistl/hypreinterface/HypreSetup.hpp | 34 +- opm/simulators/linalg/gpuistl/set_device.cpp | 8 +- opm/simulators/linalg/is_gpu_operator.hpp | 34 +- .../linalg/printlinearsolverparameter.hpp | 10 +- opm/simulators/linalg/setupPropertyTree.cpp | 25 +- opm/simulators/linalg/setupPropertyTree.hpp | 5 +- .../opm-simulators_doxygen_main.hpp | 4 +- .../timestepping/AdaptiveSimulatorTimer.cpp | 280 +- .../timestepping/AdaptiveSimulatorTimer.hpp | 172 +- .../timestepping/AdaptiveTimeStepping.cpp | 480 +- .../timestepping/AdaptiveTimeStepping.hpp | 167 +- .../AdaptiveTimeStepping_impl.hpp | 845 ++-- .../timestepping/ConvergenceReport.cpp | 132 +- .../timestepping/ConvergenceReport.hpp | 770 +-- .../timestepping/EclTimeSteppingParams.cpp | 39 +- .../timestepping/EclTimeSteppingParams.hpp | 60 +- .../timestepping/SimulatorReport.cpp | 656 ++- .../timestepping/SimulatorReport.hpp | 222 +- .../timestepping/SimulatorTimer.cpp | 287 +- .../timestepping/SimulatorTimer.hpp | 216 +- .../timestepping/SimulatorTimerInterface.cpp | 13 +- .../timestepping/SimulatorTimerInterface.hpp | 177 +- .../timestepping/TimeStepControl.cpp | 764 ++- .../timestepping/TimeStepControl.hpp | 606 +-- .../timestepping/TimeStepControlInterface.hpp | 93 +- .../timestepping/gatherConvergenceReport.cpp | 216 +- .../timestepping/gatherConvergenceReport.hpp | 8 +- opm/simulators/utils/ComponentName.cpp | 12 +- opm/simulators/utils/ComponentName.hpp | 8 +- opm/simulators/utils/DamarisKeywords.cpp | 166 +- opm/simulators/utils/DamarisKeywords.hpp | 55 +- opm/simulators/utils/DamarisOutputModule.cpp | 40 +- opm/simulators/utils/DamarisOutputModule.hpp | 20 +- opm/simulators/utils/DamarisVar.cpp | 163 +- opm/simulators/utils/DamarisVar.hpp | 9 +- opm/simulators/utils/DeferredLogger.cpp | 158 +- opm/simulators/utils/DeferredLogger.hpp | 114 +- .../utils/DeferredLoggingErrorHelpers.hpp | 141 +- .../utils/FullySupportedFlowKeywords.cpp | 71 +- opm/simulators/utils/GridDataOutput.cpp | 28 +- opm/simulators/utils/GridDataOutput.hpp | 9 +- opm/simulators/utils/GridDataOutput_impl.hpp | 107 +- opm/simulators/utils/HDF5File.cpp | 114 +- opm/simulators/utils/HDF5File.hpp | 33 +- opm/simulators/utils/HDF5Serializer.cpp | 35 +- opm/simulators/utils/HDF5Serializer.hpp | 21 +- .../utils/InstantiationIndicesMacros.hpp | 61 +- opm/simulators/utils/MPIPacker.cpp | 140 +- opm/simulators/utils/MPIPacker.hpp | 322 +- opm/simulators/utils/MPISerializer.hpp | 27 +- .../utils/ParallelCommunication.hpp | 8 +- opm/simulators/utils/ParallelEclipseState.cpp | 129 +- opm/simulators/utils/ParallelEclipseState.hpp | 33 +- opm/simulators/utils/ParallelFileMerger.cpp | 115 +- opm/simulators/utils/ParallelFileMerger.hpp | 78 +- .../utils/ParallelNLDDPartitioningZoltan.cpp | 900 ++-- .../utils/ParallelNLDDPartitioningZoltan.hpp | 163 +- opm/simulators/utils/ParallelRestart.cpp | 45 +- opm/simulators/utils/ParallelRestart.hpp | 10 +- .../utils/ParallelSerialization.cpp | 39 +- .../utils/ParallelSerialization.hpp | 17 +- .../utils/PartiallySupportedFlowKeywords.cpp | 1421 ++++-- opm/simulators/utils/PressureAverage.cpp | 87 +- opm/simulators/utils/PressureAverage.hpp | 35 +- opm/simulators/utils/PropsDataHandle.hpp | 84 +- opm/simulators/utils/SerializationPackers.cpp | 52 +- opm/simulators/utils/SerializationPackers.hpp | 26 +- .../utils/SetupPartitioningParams.cpp | 158 +- .../utils/SetupPartitioningParams.hpp | 11 +- .../utils/UnsupportedFlowKeywords.cpp | 26 +- .../utils/VectorVectorDataHandle.hpp | 93 +- opm/simulators/utils/compressPartition.cpp | 66 +- opm/simulators/utils/compressPartition.hpp | 11 +- opm/simulators/utils/gatherDeferredLogger.cpp | 261 +- opm/simulators/utils/gatherDeferredLogger.hpp | 5 +- opm/simulators/utils/initDamarisXmlFile.cpp | 7 +- opm/simulators/utils/moduleVersion.cpp | 60 +- opm/simulators/utils/moduleVersion.hpp | 34 +- opm/simulators/utils/readDeck.cpp | 839 ++-- opm/simulators/utils/readDeck.hpp | 81 +- .../satfunc/GasPhaseConsistencyChecks.cpp | 35 +- .../satfunc/GasPhaseConsistencyChecks.hpp | 334 +- .../satfunc/OilPhaseConsistencyChecks.cpp | 100 +- .../satfunc/OilPhaseConsistencyChecks.hpp | 981 ++-- .../utils/satfunc/PhaseCheckBase.cpp | 27 +- .../utils/satfunc/PhaseCheckBase.hpp | 115 +- .../utils/satfunc/RelpermDiagnostics.cpp | 1429 +++--- .../utils/satfunc/RelpermDiagnostics.hpp | 197 +- .../satfunc/SatfuncCheckPointInterface.hpp | 74 +- .../SatfuncConsistencyCheckManager.cpp | 507 +- .../SatfuncConsistencyCheckManager.hpp | 541 +- .../satfunc/SatfuncConsistencyChecks.cpp | 522 +- .../satfunc/SatfuncConsistencyChecks.hpp | 1070 ++-- .../utils/satfunc/ScaledSatfuncCheckPoint.cpp | 8 +- .../utils/satfunc/ScaledSatfuncCheckPoint.hpp | 150 +- .../ThreePointHorizontalConsistencyChecks.cpp | 48 +- .../ThreePointHorizontalConsistencyChecks.hpp | 295 +- .../satfunc/UnscaledSatfuncCheckPoint.cpp | 15 +- .../satfunc/UnscaledSatfuncCheckPoint.hpp | 166 +- .../satfunc/WaterPhaseConsistencyChecks.cpp | 35 +- .../satfunc/WaterPhaseConsistencyChecks.hpp | 334 +- opm/simulators/wells/ALQState.cpp | 65 +- opm/simulators/wells/ALQState.hpp | 22 +- opm/simulators/wells/BlackoilWellModel.hpp | 887 ++-- .../wells/BlackoilWellModelConstraints.cpp | 387 +- .../wells/BlackoilWellModelConstraints.hpp | 57 +- .../wells/BlackoilWellModelGasLift.cpp | 60 +- .../wells/BlackoilWellModelGasLift.hpp | 52 +- .../wells/BlackoilWellModelGasLift_impl.hpp | 147 +- .../wells/BlackoilWellModelGeneric.cpp | 1362 +++-- .../wells/BlackoilWellModelGeneric.hpp | 305 +- .../wells/BlackoilWellModelGuideRates.cpp | 345 +- .../wells/BlackoilWellModelGuideRates.hpp | 41 +- .../wells/BlackoilWellModelNldd.cpp | 52 +- .../wells/BlackoilWellModelNldd.hpp | 54 +- .../wells/BlackoilWellModelNldd_impl.hpp | 108 +- .../wells/BlackoilWellModelRestart.cpp | 195 +- .../wells/BlackoilWellModelRestart.hpp | 77 +- opm/simulators/wells/BlackoilWellModelWBP.cpp | 115 +- opm/simulators/wells/BlackoilWellModelWBP.hpp | 20 +- .../wells/BlackoilWellModel_impl.hpp | 3892 +++++++------- opm/simulators/wells/ConnFiltrateData.cpp | 28 +- opm/simulators/wells/ConnFiltrateData.hpp | 12 +- opm/simulators/wells/ConnFracStatistics.hpp | 30 +- opm/simulators/wells/ConnectionIndexMap.hpp | 21 +- opm/simulators/wells/FractionCalculator.cpp | 117 +- opm/simulators/wells/FractionCalculator.hpp | 36 +- opm/simulators/wells/GasLiftCommon.cpp | 50 +- opm/simulators/wells/GasLiftCommon.hpp | 15 +- opm/simulators/wells/GasLiftGroupInfo.cpp | 475 +- opm/simulators/wells/GasLiftGroupInfo.hpp | 169 +- opm/simulators/wells/GasLiftSingleWell.hpp | 32 +- .../wells/GasLiftSingleWellGeneric.cpp | 594 +-- .../wells/GasLiftSingleWellGeneric.hpp | 272 +- .../wells/GasLiftSingleWell_impl.hpp | 165 +- opm/simulators/wells/GasLiftStage2.cpp | 700 ++- opm/simulators/wells/GasLiftStage2.hpp | 119 +- opm/simulators/wells/GasLiftWellState.hpp | 81 +- opm/simulators/wells/GlobalWellInfo.cpp | 91 +- opm/simulators/wells/GlobalWellInfo.hpp | 34 +- .../wells/GroupEconomicLimitsChecker.cpp | 284 +- .../wells/GroupEconomicLimitsChecker.hpp | 30 +- opm/simulators/wells/GroupState.cpp | 391 +- opm/simulators/wells/GroupState.hpp | 63 +- opm/simulators/wells/GuideRateHandler.cpp | 382 +- opm/simulators/wells/GuideRateHandler.hpp | 165 +- opm/simulators/wells/MSWellHelpers.cpp | 259 +- opm/simulators/wells/MSWellHelpers.hpp | 51 +- opm/simulators/wells/MultisegmentWell.hpp | 570 ++- .../wells/MultisegmentWellAssemble.cpp | 242 +- .../wells/MultisegmentWellAssemble.hpp | 45 +- .../wells/MultisegmentWellEquations.cpp | 231 +- .../wells/MultisegmentWellEquations.hpp | 50 +- opm/simulators/wells/MultisegmentWellEval.cpp | 367 +- opm/simulators/wells/MultisegmentWellEval.hpp | 40 +- .../wells/MultisegmentWellGeneric.cpp | 104 +- .../wells/MultisegmentWellGeneric.hpp | 23 +- .../MultisegmentWellPrimaryVariables.cpp | 311 +- .../MultisegmentWellPrimaryVariables.hpp | 59 +- .../wells/MultisegmentWellSegments.cpp | 434 +- .../wells/MultisegmentWellSegments.hpp | 43 +- .../wells/MultisegmentWell_impl.hpp | 3747 +++++++------- .../wells/ParallelPAvgCalculator.cpp | 27 +- .../wells/ParallelPAvgCalculator.hpp | 16 +- .../wells/ParallelPAvgDynamicSourceData.cpp | 97 +- .../wells/ParallelPAvgDynamicSourceData.hpp | 38 +- .../wells/ParallelWBPCalculation.cpp | 268 +- .../wells/ParallelWBPCalculation.hpp | 62 +- opm/simulators/wells/ParallelWellInfo.cpp | 651 ++- opm/simulators/wells/ParallelWellInfo.hpp | 111 +- opm/simulators/wells/PerfData.cpp | 72 +- opm/simulators/wells/PerfData.hpp | 66 +- opm/simulators/wells/PerforationData.hpp | 23 +- opm/simulators/wells/RateConverter.cpp | 602 ++- opm/simulators/wells/RateConverter.hpp | 691 ++- opm/simulators/wells/RatioCalculator.cpp | 218 +- opm/simulators/wells/RatioCalculator.hpp | 15 +- .../wells/RegionAttributeHelpers.hpp | 458 +- .../wells/RegionAverageCalculator.hpp | 339 +- opm/simulators/wells/RunningStatistics.hpp | 57 +- opm/simulators/wells/RuntimePerforation.hpp | 12 +- opm/simulators/wells/SegmentState.cpp | 103 +- opm/simulators/wells/SegmentState.hpp | 16 +- opm/simulators/wells/SingleWellState.cpp | 216 +- opm/simulators/wells/SingleWellState.hpp | 48 +- opm/simulators/wells/StandardWell.hpp | 725 ++- opm/simulators/wells/StandardWellAssemble.cpp | 178 +- opm/simulators/wells/StandardWellAssemble.hpp | 24 +- .../wells/StandardWellConnections.cpp | 562 +-- .../wells/StandardWellConnections.hpp | 120 +- .../wells/StandardWellEquations.cpp | 226 +- .../wells/StandardWellEquations.hpp | 40 +- opm/simulators/wells/StandardWellEval.cpp | 109 +- opm/simulators/wells/StandardWellEval.hpp | 35 +- .../wells/StandardWellPrimaryVariables.cpp | 259 +- .../wells/StandardWellPrimaryVariables.hpp | 45 +- opm/simulators/wells/StandardWell_impl.hpp | 4198 ++++++++-------- opm/simulators/wells/TargetCalculator.cpp | 149 +- opm/simulators/wells/TargetCalculator.hpp | 158 +- opm/simulators/wells/VFPHelpers.cpp | 824 ++- opm/simulators/wells/VFPHelpers.hpp | 222 +- opm/simulators/wells/VFPInjProperties.cpp | 111 +- opm/simulators/wells/VFPInjProperties.hpp | 26 +- opm/simulators/wells/VFPProdProperties.cpp | 216 +- opm/simulators/wells/VFPProdProperties.hpp | 29 +- opm/simulators/wells/VFPProperties.hpp | 14 +- opm/simulators/wells/WGState.cpp | 47 +- opm/simulators/wells/WGState.hpp | 19 +- opm/simulators/wells/WellAssemble.cpp | 192 +- opm/simulators/wells/WellAssemble.hpp | 20 +- opm/simulators/wells/WellBhpThpCalculator.cpp | 647 ++- opm/simulators/wells/WellBhpThpCalculator.hpp | 157 +- .../wells/WellConnectionAuxiliaryModule.hpp | 35 +- opm/simulators/wells/WellConstraints.cpp | 113 +- opm/simulators/wells/WellConstraints.hpp | 72 +- opm/simulators/wells/WellContainer.hpp | 73 +- opm/simulators/wells/WellConvergence.cpp | 119 +- opm/simulators/wells/WellConvergence.hpp | 15 +- opm/simulators/wells/WellFilterCake.cpp | 167 +- opm/simulators/wells/WellFilterCake.hpp | 39 +- opm/simulators/wells/WellGroupConstraints.cpp | 173 +- opm/simulators/wells/WellGroupConstraints.hpp | 71 +- opm/simulators/wells/WellGroupControls.cpp | 400 +- opm/simulators/wells/WellGroupControls.hpp | 77 +- opm/simulators/wells/WellGroupHelpers.cpp | 1577 +++--- opm/simulators/wells/WellGroupHelpers.hpp | 226 +- opm/simulators/wells/WellHelpers.cpp | 328 +- opm/simulators/wells/WellHelpers.hpp | 122 +- opm/simulators/wells/WellInterface.hpp | 155 +- .../wells/WellInterfaceFluidSystem.cpp | 306 +- .../wells/WellInterfaceFluidSystem.hpp | 58 +- opm/simulators/wells/WellInterfaceGeneric.cpp | 477 +- opm/simulators/wells/WellInterfaceGeneric.hpp | 161 +- opm/simulators/wells/WellInterfaceIndices.cpp | 47 +- opm/simulators/wells/WellInterfaceIndices.hpp | 7 +- opm/simulators/wells/WellInterface_impl.hpp | 3527 +++++++------ .../wells/WellProdIndexCalculator.cpp | 101 +- .../wells/WellProdIndexCalculator.hpp | 27 +- opm/simulators/wells/WellState.cpp | 649 +-- opm/simulators/wells/WellState.hpp | 95 +- opm/simulators/wells/WellTest.cpp | 282 +- opm/simulators/wells/WellTest.hpp | 29 +- opm/simulators/wells/WellTracerRate.hpp | 42 +- python/simulators/PyBlackOilSimulator.cpp | 88 +- python/simulators/PyGasWaterSimulator.cpp | 143 +- tests/DuneIstlTestHelpers.hpp | 145 +- tests/HypreTestHelper.hpp | 139 +- tests/MpiFixture.hpp | 42 +- tests/TestTypeTag.hpp | 32 +- tests/gpuistl/test_GpuDILU.cpp | 8 +- tests/gpuistl/test_GpuJac.cpp | 4 +- tests/gpuistl/test_GpuOwnerOverlapCopy.cpp | 12 +- tests/gpuistl/test_GpuSparseMatrix.cpp | 5 +- tests/gpuistl/test_GpuVector.cpp | 3 +- tests/gpuistl/test_HypreInterfaceCPU.cpp | 2 +- tests/gpuistl/test_HypreInterfaceGPU.cpp | 2 +- tests/gpuistl/test_converttofloatadapter.cpp | 3 +- .../test_cuSparse_matrix_operations.cpp | 2 +- tests/gpuistl/test_cublas_handle.cpp | 2 +- tests/gpuistl/test_gpu_safe_call.cpp | 2 +- tests/gpuistl/test_solver_adapter.cpp | 3 +- tests/models/test_propertysystem.cpp | 190 +- tests/models/test_quadrature.cpp | 123 +- tests/models/test_tasklets.cpp | 18 +- tests/models/test_tasklets_failure.cpp | 42 +- tests/not-unit/test_ad.cpp | 7 +- tests/rescoup/test_chopstep.cpp | 150 +- tests/test_ALQState.cpp | 8 +- tests/test_GasSatfuncConsistencyChecks.cpp | 166 +- tests/test_GroupState.cpp | 21 +- tests/test_HDF5File.cpp | 43 +- tests/test_HDF5File_Parallel.cpp | 11 +- tests/test_HDF5Serializer.cpp | 20 +- tests/test_HDF5Serializer_Parallel.cpp | 19 +- tests/test_HyprePreconditionerCPU.cpp | 8 +- tests/test_HyprePreconditionerGPU.cpp | 6 +- tests/test_LogOutputHelper.cpp | 158 +- tests/test_OilSatfuncConsistencyChecks.cpp | 546 +- tests/test_ParallelSerialization.cpp | 136 +- tests/test_RestartSerialization.cpp | 290 +- tests/test_RunningStatistics.cpp | 121 +- tests/test_SatfuncCheckPoint.cpp | 579 ++- tests/test_SatfuncConsistencyCheckManager.cpp | 500 +- tests/test_SatfuncConsistencyChecks.cpp | 857 ++-- ...test_SatfuncConsistencyChecks_parallel.cpp | 1282 +++-- ...ointHorizontalSatfuncConsistencyChecks.cpp | 112 +- tests/test_WaterSatfuncConsistencyChecks.cpp | 170 +- tests/test_aquifergridutils.cpp | 20 +- tests/test_blackoil_amg.cpp | 250 +- tests/test_broadcast.cpp | 23 +- tests/test_convergenceoutputconfiguration.cpp | 57 +- tests/test_convergencereport.cpp | 1 - tests/test_csrToCscOffsetMap.cpp | 5 +- tests/test_cusparseSolver.cpp | 47 +- tests/test_deferredlogger.cpp | 37 +- tests/test_dilu.cpp | 8 +- tests/test_equil.cpp | 1007 ++-- tests/test_extractMatrix.cpp | 27 +- tests/test_flexiblesolver.cpp | 9 +- tests/test_gatherconvergencereport.cpp | 104 +- tests/test_gatherdeferredlogger.cpp | 53 +- tests/test_ghostlastmatrixadapter.cpp | 246 +- tests/test_glift1.cpp | 117 +- tests/test_graphcoloring.cpp | 115 +- tests/test_interregflows.cpp | 1135 +++-- tests/test_invert.cpp | 11 +- tests/test_keyword_validator.cpp | 4 +- tests/test_milu.cpp | 181 +- tests/test_multmatrixtransposed.cpp | 18 +- tests/test_nonnc.cpp | 86 +- tests/test_norne_pvt.cpp | 140 +- tests/test_openclSolver.cpp | 51 +- tests/test_outputdir.cpp | 41 +- tests/test_parallel_wbp_calculation.cpp | 1123 +++-- tests/test_parallel_wbp_sourcevalues.cpp | 96 +- tests/test_parallelistlinformation.cpp | 69 +- tests/test_parallelwellinfo.cpp | 347 +- tests/test_parametersystem.cpp | 150 +- tests/test_partitionCells.cpp | 337 +- tests/test_preconditionerfactory.cpp | 79 +- tests/test_privarspacking.cpp | 44 +- tests/test_propertytree.cpp | 100 +- tests/test_region_phase_pvaverage.cpp | 1601 +++--- tests/test_relpermdiagnostics.cpp | 20 +- tests/test_rftcontainer.cpp | 1808 ++++--- tests/test_rocalutionSolver.cpp | 37 +- tests/test_rocsparseSolver.cpp | 57 +- tests/test_rstconv.cpp | 164 +- tests/test_solvetransposed3x3.cpp | 27 +- tests/test_stoppedwells.cpp | 6 +- tests/test_thresholdpressure.cpp | 21 +- tests/test_timer.cpp | 92 +- tests/test_tuning_TRGMBE.cpp | 74 +- tests/test_tuning_TSINIT_NEXTSTEP.cpp | 43 +- tests/test_vfpproperties.cpp | 4460 ++++++++++++++++- tests/test_wellmodel.cpp | 65 +- tests/test_wellprodindexcalculator.cpp | 495 +- tests/test_wellstate.cpp | 389 +- 923 files changed, 74364 insertions(+), 68281 deletions(-) diff --git a/cmake/test/testFloatFromChars.cpp b/cmake/test/testFloatFromChars.cpp index 859ef3f1192..89ef9d6256e 100644 --- a/cmake/test/testFloatFromChars.cpp +++ b/cmake/test/testFloatFromChars.cpp @@ -3,9 +3,10 @@ #include #include -int main() +int +main() { - const auto s = std::string_view { "2.71828" }; + const auto s = std::string_view {"2.71828"}; auto e = 0.0; std::from_chars(s.data(), s.data() + s.size(), e); } diff --git a/examples/art2dgf.cpp b/examples/art2dgf.cpp index 28b112a730b..9b3d0a10c9e 100644 --- a/examples/art2dgf.cpp +++ b/examples/art2dgf.cpp @@ -21,44 +21,41 @@ copyright holders. */ -#include -#include #include +#include +#include #include #include -#include #include +#include #include #include -namespace Ewoms { +namespace Ewoms +{ /*! * \brief Reads in mesh files in the ART format. * * This file format is used to specify grids with fractures. */ - struct Art2DGF - { +struct Art2DGF { /*! * \brief Create the Grid */ - static void convert( const std::string& artFileName, - std::ostream& dgfFile, - const unsigned precision = 16 ) + static void convert(const std::string& artFileName, std::ostream& dgfFile, const unsigned precision = 16) { using Scalar = double; - using GlobalPosition = Dune::FieldVector< Scalar, 2 >; + using GlobalPosition = Dune::FieldVector; enum ParseMode { Vertex, Edge, Element, Finished }; - std::vector< std::pair > vertexPos; - std::vector > edges; - std::vector > fractureEdges; - std::vector > elements; + std::vector> vertexPos; + std::vector> edges; + std::vector> fractureEdges; + std::vector> elements; std::ifstream inStream(artFileName); if (!inStream.is_open()) { - throw std::runtime_error("File '"+artFileName - +"' does not exist or is not readable"); + throw std::runtime_error("File '" + artFileName + "' does not exist or is not readable"); } std::string curLine; ParseMode curParseMode = Vertex; @@ -73,16 +70,13 @@ namespace Ewoms { // remove leading whitespace unsigned numLeadingSpaces = 0; - while (curLine.size() > numLeadingSpaces - && std::isspace(curLine[numLeadingSpaces])) + while (curLine.size() > numLeadingSpaces && std::isspace(curLine[numLeadingSpaces])) ++numLeadingSpaces; - curLine = curLine.substr(numLeadingSpaces, - curLine.size() - numLeadingSpaces); + curLine = curLine.substr(numLeadingSpaces, curLine.size() - numLeadingSpaces); // remove trailing whitespace unsigned numTrailingSpaces = 0; - while (curLine.size() > numTrailingSpaces - && std::isspace(curLine[curLine.size() - numTrailingSpaces])) + while (curLine.size() > numTrailingSpaces && std::isspace(curLine[curLine.size() - numTrailingSpaces])) ++numTrailingSpaces; curLine.erase(numTrailingSpaces); @@ -108,9 +102,8 @@ namespace Ewoms { // coordinate. the last number is the Z coordinate // which we ignore (so far) iss >> coord[0] >> coord[1]; - vertexPos.push_back( std::make_pair( coord, 0 ) ); - } - else if (curParseMode == Edge) { + vertexPos.push_back(std::make_pair(coord, 0)); + } else if (curParseMode == Edge) { // read an edge and update the fracture mapper // read the data attached to the edge @@ -141,11 +134,10 @@ namespace Ewoms { // add the edge to the fracture mapper if it is a fracture if (dataVal < 0) { fractureEdges.push_back(edge); - vertexPos[ edge.first ].second = 1; - vertexPos[ edge.second ].second = 1; + vertexPos[edge.first].second = 1; + vertexPos[edge.second].second = 1; } - } - else if (curParseMode == Element) { + } else if (curParseMode == Element) { // skip the data attached to an element std::istringstream iss(curLine); int dataVal; @@ -206,9 +198,8 @@ namespace Ewoms { if (mat.determinant() < 0) std::swap(vertIndices[2], vertIndices[1]); - elements.push_back( vertIndices ); - } - else if (curParseMode == Finished) { + elements.push_back(vertIndices); + } else if (curParseMode == Finished) { assert(curLine.size() == 0); } } @@ -218,23 +209,21 @@ namespace Ewoms { dgfFile << "GridParameter" << std::endl << "overlap 1" << std::endl << "closure green" << std::endl - << "#" << std::endl << std::endl; + << "#" << std::endl + << std::endl; dgfFile << "Vertex" << std::endl; const bool hasFractures = fractureEdges.size() > 0; - if( hasFractures ) - { + if (hasFractures) { dgfFile << "parameters 1" << std::endl; } dgfFile << std::scientific; - dgfFile.precision( precision ); + dgfFile.precision(precision); const size_t vxSize = vertexPos.size(); - for( size_t i=0; i #include "problems/co2ptflashproblem.hh" +#include -namespace Opm::Properties { +namespace Opm::Properties +{ -namespace TTag { +namespace TTag +{ struct CO2PTEcfvProblem { - using InheritsFrom = std::tuple; -}; -} + using InheritsFrom = std::tuple; + }; +} // namespace TTag template -struct SpatialDiscretizationSplice -{ +struct SpatialDiscretizationSplice { using type = TTag::EcfvDiscretization; }; template -struct LocalLinearizerSplice -{ +struct LocalLinearizerSplice { using type = TTag::AutoDiffLocalLinearizer; }; } // namespace Opm::Properties -int main(int argc, char **argv) +int +main(int argc, char** argv) { using EcfvProblemTypeTag = Opm::Properties::TTag::CO2PTEcfvProblem; return Opm::start(argc, argv, true); diff --git a/examples/co2injection_flash_ecfv.cpp b/examples/co2injection_flash_ecfv.cpp index 25e90a2928b..32ccaeb5f51 100644 --- a/examples/co2injection_flash_ecfv.cpp +++ b/examples/co2injection_flash_ecfv.cpp @@ -32,53 +32,61 @@ #include #endif -#include -#include -#include -#include #include "problems/co2injectionflash.hh" #include "problems/co2injectionproblem.hh" +#include +#include +#include +#include -namespace Opm::Properties { +namespace Opm::Properties +{ // Create new type tags -namespace TTag { +namespace TTag +{ -struct Co2InjectionFlashEcfvProblem -{ using InheritsFrom = std::tuple; }; + struct Co2InjectionFlashEcfvProblem { + using InheritsFrom = std::tuple; + }; } // end namespace TTag -template -struct SpatialDiscretizationSplice -{ using type = TTag::EcfvDiscretization; }; +template +struct SpatialDiscretizationSplice { + using type = TTag::EcfvDiscretization; +}; // use automatic differentiation for this simulator -template -struct LocalLinearizerSplice -{ using type = TTag::AutoDiffLocalLinearizer; }; +template +struct LocalLinearizerSplice { + using type = TTag::AutoDiffLocalLinearizer; +}; // use the flash solver adapted to the CO2 injection problem -template -struct FlashSolver -{ using type = Opm::Co2InjectionFlash, - GetPropType>; }; +template +struct FlashSolver { + using type = Opm::Co2InjectionFlash, + GetPropType>; +}; // the flash model has serious problems with the numerical // precision. if quadruple precision math is available, we use it, // else we increase the tolerance of the Newton solver #if HAVE_QUAD -template -struct Scalar -{ using type = quad; }; +template +struct Scalar { + using type = quad; +}; #endif } // namespace Opm::Properties -int main(int argc, char **argv) +int +main(int argc, char** argv) { using EcfvProblemTypeTag = Opm::Properties::TTag::Co2InjectionFlashEcfvProblem; -#if ! HAVE_QUAD +#if !HAVE_QUAD Opm::Co2InjectionTolerance = 1e-5; #endif return Opm::start(argc, argv, true); diff --git a/examples/co2injection_flash_ni_ecfv.cpp b/examples/co2injection_flash_ni_ecfv.cpp index 5e6f809f83d..6db1d4ac62f 100644 --- a/examples/co2injection_flash_ni_ecfv.cpp +++ b/examples/co2injection_flash_ni_ecfv.cpp @@ -31,56 +31,65 @@ // this must be included before the vanguard #include -#include -#include -#include -#include #include "problems/co2injectionflash.hh" #include "problems/co2injectionproblem.hh" +#include +#include +#include +#include -namespace Opm::Properties { +namespace Opm::Properties +{ // Create new type tags -namespace TTag { +namespace TTag +{ -struct Co2InjectionFlashNiEcfvProblem -{ using InheritsFrom = std::tuple; }; + struct Co2InjectionFlashNiEcfvProblem { + using InheritsFrom = std::tuple; + }; } // end namespace TTag -template -struct SpatialDiscretizationSplice -{ using type = TTag::EcfvDiscretization; }; +template +struct SpatialDiscretizationSplice { + using type = TTag::EcfvDiscretization; +}; -template -struct EnableEnergy -{ static constexpr bool value = true; }; +template +struct EnableEnergy { + static constexpr bool value = true; +}; //! Use automatic differentiation to linearize the system of PDEs -template -struct LocalLinearizerSplice -{ using type = TTag::AutoDiffLocalLinearizer; }; +template +struct LocalLinearizerSplice { + using type = TTag::AutoDiffLocalLinearizer; +}; // use the CO2 injection problem adapted flash solver -template -struct FlashSolver -{ using type = Opm::Co2InjectionFlash, - GetPropType>; }; +template +struct FlashSolver { + using type = Opm::Co2InjectionFlash, + GetPropType>; +}; // the flash model has serious problems with the numerical // precision. if quadruple precision math is available, we use it, // else we increase the tolerance of the Newton solver #if HAVE_QUAD -template -struct Scalar -{ using type = quad; }; +template +struct Scalar { + using type = quad; +}; #endif } // namespace Opm::Properties -int main(int argc, char **argv) +int +main(int argc, char** argv) { using EcfvProblemTypeTag = Opm::Properties::TTag::Co2InjectionFlashNiEcfvProblem; -#if ! HAVE_QUAD +#if !HAVE_QUAD Opm::Co2InjectionTolerance = 1e-5; #endif return Opm::start(argc, argv, true); diff --git a/examples/co2injection_flash_ni_vcfv.cpp b/examples/co2injection_flash_ni_vcfv.cpp index a8a8b83e37d..a3e29dceaf4 100644 --- a/examples/co2injection_flash_ni_vcfv.cpp +++ b/examples/co2injection_flash_ni_vcfv.cpp @@ -31,52 +31,60 @@ // this must be included before the vanguard #include -#include -#include -#include -#include #include "problems/co2injectionflash.hh" #include "problems/co2injectionproblem.hh" +#include +#include +#include +#include -namespace Opm::Properties { +namespace Opm::Properties +{ // Create new type tags -namespace TTag { +namespace TTag +{ -struct Co2InjectionFlashNiVcfvProblem -{ using InheritsFrom = std::tuple; }; + struct Co2InjectionFlashNiVcfvProblem { + using InheritsFrom = std::tuple; + }; } // end namespace TTag -template -struct SpatialDiscretizationSplice -{ using type = TTag::VcfvDiscretization; }; +template +struct SpatialDiscretizationSplice { + using type = TTag::VcfvDiscretization; +}; -template -struct EnableEnergy -{ static constexpr bool value = true; }; +template +struct EnableEnergy { + static constexpr bool value = true; +}; // use the CO2 injection problem adapted flash solver -template -struct FlashSolver -{ using type = Opm::Co2InjectionFlash, - GetPropType>; }; +template +struct FlashSolver { + using type = Opm::Co2InjectionFlash, + GetPropType>; +}; // the flash model has serious problems with the numerical // precision. if quadruple precision math is available, we use it, // else we increase the tolerance of the Newton solver #if HAVE_QUAD -template -struct Scalar -{ using type = quad; }; +template +struct Scalar { + using type = quad; +}; #endif } // namespace Opm::Properties -int main(int argc, char **argv) +int +main(int argc, char** argv) { using VcfvProblemTypeTag = Opm::Properties::TTag::Co2InjectionFlashNiVcfvProblem; -#if ! HAVE_QUAD +#if !HAVE_QUAD Opm::Co2InjectionTolerance = 1e-5; #endif return Opm::start(argc, argv, true); diff --git a/examples/co2injection_flash_vcfv.cpp b/examples/co2injection_flash_vcfv.cpp index 117c21b8925..931b47f740b 100644 --- a/examples/co2injection_flash_vcfv.cpp +++ b/examples/co2injection_flash_vcfv.cpp @@ -32,47 +32,54 @@ #include #endif -#include -#include -#include -#include #include "problems/co2injectionflash.hh" #include "problems/co2injectionproblem.hh" +#include +#include +#include +#include -namespace Opm::Properties { +namespace Opm::Properties +{ // Create new type tags -namespace TTag { +namespace TTag +{ -struct Co2InjectionFlashVcfvProblem -{ using InheritsFrom = std::tuple; }; + struct Co2InjectionFlashVcfvProblem { + using InheritsFrom = std::tuple; + }; } // end namespace TTag -template -struct SpatialDiscretizationSplice -{ using type = TTag::VcfvDiscretization; }; +template +struct SpatialDiscretizationSplice { + using type = TTag::VcfvDiscretization; +}; // use the flash solver adapted to the CO2 injection problem -template -struct FlashSolver -{ using type = Opm::Co2InjectionFlash, - GetPropType>; }; +template +struct FlashSolver { + using type = Opm::Co2InjectionFlash, + GetPropType>; +}; // the flash model has serious problems with the numerical // precision. if quadruple precision math is available, we use it, // else we increase the tolerance of the Newton solver #if HAVE_QUAD -template -struct Scalar -{ using type = quad; }; +template +struct Scalar { + using type = quad; +}; #endif } // namespace Opm::Properties -int main(int argc, char **argv) +int +main(int argc, char** argv) { using VcfvProblemTypeTag = Opm::Properties::TTag::Co2InjectionFlashVcfvProblem; -#if ! HAVE_QUAD +#if !HAVE_QUAD Opm::Co2InjectionTolerance = 1e-5; #endif return Opm::start(argc, argv, true); diff --git a/examples/co2injection_immiscible_ecfv.cpp b/examples/co2injection_immiscible_ecfv.cpp index ae6fdbb64a1..92110213e81 100644 --- a/examples/co2injection_immiscible_ecfv.cpp +++ b/examples/co2injection_immiscible_ecfv.cpp @@ -28,32 +28,37 @@ */ #include "config.h" +#include +#include #include #include -#include -#include #include "problems/co2injectionproblem.hh" -namespace Opm::Properties { +namespace Opm::Properties +{ -namespace TTag { +namespace TTag +{ -struct Co2InjectionImmiscibleEcfvProblem -{ using InheritsFrom = std::tuple; }; + struct Co2InjectionImmiscibleEcfvProblem { + using InheritsFrom = std::tuple; + }; } // end namespace TTag -template -struct SpatialDiscretizationSplice -{ using type = TTag::EcfvDiscretization; }; +template +struct SpatialDiscretizationSplice { + using type = TTag::EcfvDiscretization; +}; } // namespace Opm::Properties //////////////////////// // the main function //////////////////////// -int main(int argc, char **argv) +int +main(int argc, char** argv) { using EcfvProblemTypeTag = Opm::Properties::TTag::Co2InjectionImmiscibleEcfvProblem; return Opm::start(argc, argv, true); diff --git a/examples/co2injection_immiscible_ni_ecfv.cpp b/examples/co2injection_immiscible_ni_ecfv.cpp index 21469c1f367..c80c1f2284a 100644 --- a/examples/co2injection_immiscible_ni_ecfv.cpp +++ b/examples/co2injection_immiscible_ni_ecfv.cpp @@ -28,40 +28,47 @@ */ #include "config.h" +#include "problems/co2injectionproblem.hh" +#include +#include #include #include -#include -#include -#include "problems/co2injectionproblem.hh" -namespace Opm::Properties { +namespace Opm::Properties +{ // Create new type tags -namespace TTag { -struct Co2InjectionImmiscibleNiEcfvProblem -{ using InheritsFrom = std::tuple; }; +namespace TTag +{ + struct Co2InjectionImmiscibleNiEcfvProblem { + using InheritsFrom = std::tuple; + }; } // end namespace TTag -template -struct SpatialDiscretizationSplice -{ using type = TTag::EcfvDiscretization; }; +template +struct SpatialDiscretizationSplice { + using type = TTag::EcfvDiscretization; +}; -template -struct EnableEnergy -{ static constexpr bool value = true; }; +template +struct EnableEnergy { + static constexpr bool value = true; +}; //! Use automatic differentiation to linearize the system of PDEs -template -struct LocalLinearizerSplice -{ using type = TTag::AutoDiffLocalLinearizer; }; +template +struct LocalLinearizerSplice { + using type = TTag::AutoDiffLocalLinearizer; +}; } // namespace Opm::Properties //////////////////////// // the main function //////////////////////// -int main(int argc, char **argv) +int +main(int argc, char** argv) { using EcfvProblemTypeTag = Opm::Properties::TTag::Co2InjectionImmiscibleNiEcfvProblem; return Opm::start(argc, argv, true); diff --git a/examples/co2injection_immiscible_ni_vcfv.cpp b/examples/co2injection_immiscible_ni_vcfv.cpp index 8ffe8ee2c61..dc0392fcaa6 100644 --- a/examples/co2injection_immiscible_ni_vcfv.cpp +++ b/examples/co2injection_immiscible_ni_vcfv.cpp @@ -28,35 +28,41 @@ */ #include "config.h" +#include "problems/co2injectionproblem.hh" +#include +#include #include #include -#include -#include -#include "problems/co2injectionproblem.hh" -namespace Opm::Properties { +namespace Opm::Properties +{ -namespace TTag { +namespace TTag +{ -struct Co2InjectionImmiscibleNiVcfvProblem -{ using InheritsFrom = std::tuple; }; + struct Co2InjectionImmiscibleNiVcfvProblem { + using InheritsFrom = std::tuple; + }; } // namespace TTag -template -struct SpatialDiscretizationSplice -{ using type = TTag::VcfvDiscretization; }; +template +struct SpatialDiscretizationSplice { + using type = TTag::VcfvDiscretization; +}; -template -struct EnableEnergy -{ static constexpr bool value = true; }; +template +struct EnableEnergy { + static constexpr bool value = true; +}; } // namespace Opm::Properties //////////////////////// // the main function //////////////////////// -int main(int argc, char **argv) +int +main(int argc, char** argv) { using VcfvProblemTypeTag = Opm::Properties::TTag::Co2InjectionImmiscibleNiVcfvProblem; return Opm::start(argc, argv, true); diff --git a/examples/co2injection_immiscible_vcfv.cpp b/examples/co2injection_immiscible_vcfv.cpp index 26d929f66d2..81487afe0bf 100644 --- a/examples/co2injection_immiscible_vcfv.cpp +++ b/examples/co2injection_immiscible_vcfv.cpp @@ -28,32 +28,37 @@ */ #include "config.h" +#include +#include #include #include -#include -#include #include "problems/co2injectionproblem.hh" -namespace Opm::Properties { +namespace Opm::Properties +{ -namespace TTag { +namespace TTag +{ -struct Co2InjectionImmiscibleVcfvProblem -{ using InheritsFrom = std::tuple; }; + struct Co2InjectionImmiscibleVcfvProblem { + using InheritsFrom = std::tuple; + }; } // namespace TTag -template -struct SpatialDiscretizationSplice -{ using type = TTag::VcfvDiscretization; }; +template +struct SpatialDiscretizationSplice { + using type = TTag::VcfvDiscretization; +}; } // namespace Opm::Properties //////////////////////// // the main function //////////////////////// -int main(int argc, char **argv) +int +main(int argc, char** argv) { using VcfvProblemTypeTag = Opm::Properties::TTag::Co2InjectionImmiscibleVcfvProblem; return Opm::start(argc, argv, true); diff --git a/examples/co2injection_ncp_ecfv.cpp b/examples/co2injection_ncp_ecfv.cpp index 400fe73156b..d8dde461ba8 100644 --- a/examples/co2injection_ncp_ecfv.cpp +++ b/examples/co2injection_ncp_ecfv.cpp @@ -28,29 +28,34 @@ */ #include "config.h" +#include "problems/co2injectionproblem.hh" +#include #include -#include #include -#include -#include "problems/co2injectionproblem.hh" +#include -namespace Opm::Properties { +namespace Opm::Properties +{ // Create new type tags -namespace TTag { +namespace TTag +{ -struct Co2InjectionNcpEcfvProblem -{ using InheritsFrom = std::tuple; }; + struct Co2InjectionNcpEcfvProblem { + using InheritsFrom = std::tuple; + }; } // end namespace TTag -template -struct SpatialDiscretizationSplice -{ using type = TTag::EcfvDiscretization; }; +template +struct SpatialDiscretizationSplice { + using type = TTag::EcfvDiscretization; +}; } // namespace Opm::Properties -int main(int argc, char **argv) +int +main(int argc, char** argv) { using EcfvProblemTypeTag = Opm::Properties::TTag::Co2InjectionNcpEcfvProblem; return Opm::start(argc, argv, true); diff --git a/examples/co2injection_ncp_ni_ecfv.cpp b/examples/co2injection_ncp_ni_ecfv.cpp index d4e89fed612..5e87813a614 100644 --- a/examples/co2injection_ncp_ni_ecfv.cpp +++ b/examples/co2injection_ncp_ni_ecfv.cpp @@ -28,38 +28,45 @@ */ #include "config.h" +#include "problems/co2injectionproblem.hh" +#include #include -#include #include -#include -#include "problems/co2injectionproblem.hh" +#include -namespace Opm::Properties { +namespace Opm::Properties +{ // Create new type tags -namespace TTag { +namespace TTag +{ -struct Co2InjectionNcpNiEcfvProblem -{ using InheritsFrom = std::tuple; }; + struct Co2InjectionNcpNiEcfvProblem { + using InheritsFrom = std::tuple; + }; } // end namespace TTag -template -struct SpatialDiscretizationSplice -{ using type = TTag::EcfvDiscretization; }; +template +struct SpatialDiscretizationSplice { + using type = TTag::EcfvDiscretization; +}; -template -struct EnableEnergy -{ static constexpr bool value = true; }; +template +struct EnableEnergy { + static constexpr bool value = true; +}; //! Use automatic differentiation to linearize the system of PDEs -template -struct LocalLinearizerSplice -{ using type = TTag::AutoDiffLocalLinearizer; }; +template +struct LocalLinearizerSplice { + using type = TTag::AutoDiffLocalLinearizer; +}; } // namespace Opm::Properties -int main(int argc, char **argv) +int +main(int argc, char** argv) { using EcfvProblemTypeTag = Opm::Properties::TTag::Co2InjectionNcpNiEcfvProblem; return Opm::start(argc, argv, true); diff --git a/examples/co2injection_ncp_ni_vcfv.cpp b/examples/co2injection_ncp_ni_vcfv.cpp index cc4a20929f4..284029c96a2 100644 --- a/examples/co2injection_ncp_ni_vcfv.cpp +++ b/examples/co2injection_ncp_ni_vcfv.cpp @@ -28,32 +28,38 @@ */ #include "config.h" +#include "problems/co2injectionproblem.hh" +#include #include -#include #include -#include -#include "problems/co2injectionproblem.hh" +#include -namespace Opm::Properties { +namespace Opm::Properties +{ // Create new type tags -namespace TTag { +namespace TTag +{ -struct Co2InjectionNcpNiVcfvProblem -{ using InheritsFrom = std::tuple; }; + struct Co2InjectionNcpNiVcfvProblem { + using InheritsFrom = std::tuple; + }; } // end namespace TTag -template -struct SpatialDiscretizationSplice -{ using type = TTag::VcfvDiscretization; }; +template +struct SpatialDiscretizationSplice { + using type = TTag::VcfvDiscretization; +}; -template -struct EnableEnergy -{ static constexpr bool value = true; }; +template +struct EnableEnergy { + static constexpr bool value = true; +}; } // namespace Opm::Properties -int main(int argc, char **argv) +int +main(int argc, char** argv) { using VcfvProblemTypeTag = Opm::Properties::TTag::Co2InjectionNcpNiVcfvProblem; return Opm::start(argc, argv, true); diff --git a/examples/co2injection_ncp_vcfv.cpp b/examples/co2injection_ncp_vcfv.cpp index 11a4efc2d37..2aefd08adfe 100644 --- a/examples/co2injection_ncp_vcfv.cpp +++ b/examples/co2injection_ncp_vcfv.cpp @@ -28,30 +28,35 @@ */ #include "config.h" +#include #include -#include #include -#include +#include #include "problems/co2injectionproblem.hh" -namespace Opm::Properties { +namespace Opm::Properties +{ // Create new type tags -namespace TTag { +namespace TTag +{ -struct Co2InjectionNcpVcfvProblem -{ using InheritsFrom = std::tuple; }; + struct Co2InjectionNcpVcfvProblem { + using InheritsFrom = std::tuple; + }; } // end namespace TTag -template -struct SpatialDiscretizationSplice -{ using type = TTag::VcfvDiscretization; }; +template +struct SpatialDiscretizationSplice { + using type = TTag::VcfvDiscretization; +}; } // namespace Opm::Properties -int main(int argc, char **argv) +int +main(int argc, char** argv) { using VcfvProblemTypeTag = Opm::Properties::TTag::Co2InjectionNcpVcfvProblem; return Opm::start(argc, argv, true); diff --git a/examples/co2injection_pvs_ecfv.cpp b/examples/co2injection_pvs_ecfv.cpp index 7efef6559e1..892ccbc3f98 100644 --- a/examples/co2injection_pvs_ecfv.cpp +++ b/examples/co2injection_pvs_ecfv.cpp @@ -28,29 +28,34 @@ */ #include "config.h" +#include "problems/co2injectionproblem.hh" +#include #include -#include #include -#include -#include "problems/co2injectionproblem.hh" +#include -namespace Opm::Properties { +namespace Opm::Properties +{ // Create new type tags -namespace TTag { +namespace TTag +{ -struct Co2InjectionPvsEcfvProblem -{ using InheritsFrom = std::tuple; }; + struct Co2InjectionPvsEcfvProblem { + using InheritsFrom = std::tuple; + }; } // end namespace TTag -template -struct SpatialDiscretizationSplice -{ using type = TTag::EcfvDiscretization; }; +template +struct SpatialDiscretizationSplice { + using type = TTag::EcfvDiscretization; +}; } // namespace Opm::Properties -int main(int argc, char **argv) +int +main(int argc, char** argv) { using EcfvProblemTypeTag = Opm::Properties::TTag::Co2InjectionPvsEcfvProblem; return Opm::start(argc, argv, true); diff --git a/examples/co2injection_pvs_ni_ecfv.cpp b/examples/co2injection_pvs_ni_ecfv.cpp index 4015dd56fba..12879c9337e 100644 --- a/examples/co2injection_pvs_ni_ecfv.cpp +++ b/examples/co2injection_pvs_ni_ecfv.cpp @@ -28,37 +28,44 @@ */ #include "config.h" +#include "problems/co2injectionproblem.hh" +#include #include -#include #include -#include -#include "problems/co2injectionproblem.hh" +#include -namespace Opm::Properties { +namespace Opm::Properties +{ // Create new type tags -namespace TTag { +namespace TTag +{ -struct Co2InjectionPvsNiEcfvProblem -{ using InheritsFrom = std::tuple; }; + struct Co2InjectionPvsNiEcfvProblem { + using InheritsFrom = std::tuple; + }; } // end namespace TTag -template -struct SpatialDiscretizationSplice -{ using type = TTag::EcfvDiscretization; }; +template +struct SpatialDiscretizationSplice { + using type = TTag::EcfvDiscretization; +}; -template -struct EnableEnergy -{ static constexpr bool value = true; }; +template +struct EnableEnergy { + static constexpr bool value = true; +}; //! Use automatic differentiation to linearize the system of PDEs -template -struct LocalLinearizerSplice -{ using type = TTag::AutoDiffLocalLinearizer; }; +template +struct LocalLinearizerSplice { + using type = TTag::AutoDiffLocalLinearizer; +}; } // namespace Opm::Properties -int main(int argc, char **argv) +int +main(int argc, char** argv) { using EcfvProblemTypeTag = Opm::Properties::TTag::Co2InjectionPvsNiEcfvProblem; return Opm::start(argc, argv, true); diff --git a/examples/co2injection_pvs_ni_vcfv.cpp b/examples/co2injection_pvs_ni_vcfv.cpp index a42ff62a037..27b7bbe4b51 100644 --- a/examples/co2injection_pvs_ni_vcfv.cpp +++ b/examples/co2injection_pvs_ni_vcfv.cpp @@ -28,33 +28,39 @@ */ #include "config.h" +#include "problems/co2injectionproblem.hh" +#include #include -#include #include -#include -#include "problems/co2injectionproblem.hh" +#include -namespace Opm::Properties { +namespace Opm::Properties +{ // Create new type tags -namespace TTag { +namespace TTag +{ -struct Co2InjectionPvsNiVcfvProblem -{ using InheritsFrom = std::tuple; }; + struct Co2InjectionPvsNiVcfvProblem { + using InheritsFrom = std::tuple; + }; } // end namespace TTag -template -struct SpatialDiscretizationSplice -{ using type = TTag::VcfvDiscretization; }; +template +struct SpatialDiscretizationSplice { + using type = TTag::VcfvDiscretization; +}; -template -struct EnableEnergy -{ static constexpr bool value = true; }; +template +struct EnableEnergy { + static constexpr bool value = true; +}; } // namespace Opm::Properties -int main(int argc, char **argv) +int +main(int argc, char** argv) { using VcfvProblemTypeTag = Opm::Properties::TTag::Co2InjectionPvsNiVcfvProblem; return Opm::start(argc, argv, true); diff --git a/examples/co2injection_pvs_vcfv.cpp b/examples/co2injection_pvs_vcfv.cpp index fd830ead5b0..b180a6068ef 100644 --- a/examples/co2injection_pvs_vcfv.cpp +++ b/examples/co2injection_pvs_vcfv.cpp @@ -28,30 +28,35 @@ */ #include "config.h" +#include #include -#include #include -#include +#include #include "problems/co2injectionproblem.hh" -namespace Opm::Properties { +namespace Opm::Properties +{ // Create new type tags -namespace TTag { +namespace TTag +{ -struct Co2InjectionPvsVcfvProblem -{ using InheritsFrom = std::tuple; }; + struct Co2InjectionPvsVcfvProblem { + using InheritsFrom = std::tuple; + }; } // end namespace TTag -template -struct SpatialDiscretizationSplice -{ using type = TTag::VcfvDiscretization; }; +template +struct SpatialDiscretizationSplice { + using type = TTag::VcfvDiscretization; +}; } // namespace Opm::Properties -int main(int argc, char **argv) +int +main(int argc, char** argv) { using VcfvProblemTypeTag = Opm::Properties::TTag::Co2InjectionPvsVcfvProblem; return Opm::start(argc, argv, true); diff --git a/examples/cuvette_pvs.cpp b/examples/cuvette_pvs.cpp index 9a2578ff04d..3e10e24afae 100644 --- a/examples/cuvette_pvs.cpp +++ b/examples/cuvette_pvs.cpp @@ -28,24 +28,28 @@ #include "config.h" #include -#include #include +#include #include #include "problems/cuvetteproblem.hh" -namespace Opm::Properties { +namespace Opm::Properties +{ // Create new type tags -namespace TTag { -struct CuvetteProblem -{ using InheritsFrom = std::tuple; }; +namespace TTag +{ + struct CuvetteProblem { + using InheritsFrom = std::tuple; + }; } // end namespace TTag } // namespace Opm::Properties -int main(int argc, char **argv) +int +main(int argc, char** argv) { using ProblemTypeTag = Opm::Properties::TTag::CuvetteProblem; return Opm::start(argc, argv, true); diff --git a/examples/diffusion_flash.cpp b/examples/diffusion_flash.cpp index d47b6e6ceb6..3f3ffc8e39a 100644 --- a/examples/diffusion_flash.cpp +++ b/examples/diffusion_flash.cpp @@ -27,21 +27,26 @@ */ #include "config.h" -#include +#include "problems/diffusionproblem.hh" #include +#include #include -#include "problems/diffusionproblem.hh" -namespace Opm::Properties { +namespace Opm::Properties +{ // Create new type tags -namespace TTag { -struct DiffusionProblem { using InheritsFrom = std::tuple; }; +namespace TTag +{ + struct DiffusionProblem { + using InheritsFrom = std::tuple; + }; } // end namespace TTag } // namespace Opm::Properties -int main(int argc, char **argv) +int +main(int argc, char** argv) { using ProblemTypeTag = Opm::Properties::TTag::DiffusionProblem; return Opm::start(argc, argv, true); diff --git a/examples/diffusion_ncp.cpp b/examples/diffusion_ncp.cpp index 992a6ef4e62..31940bd200e 100644 --- a/examples/diffusion_ncp.cpp +++ b/examples/diffusion_ncp.cpp @@ -27,22 +27,27 @@ */ #include "config.h" -#include #include +#include #include #include "problems/diffusionproblem.hh" -namespace Opm::Properties { +namespace Opm::Properties +{ // Create new type tags -namespace TTag { -struct DiffusionProblem { using InheritsFrom = std::tuple; }; +namespace TTag +{ + struct DiffusionProblem { + using InheritsFrom = std::tuple; + }; } // end namespace TTag } // namespace Opm::Properties -int main(int argc, char **argv) +int +main(int argc, char** argv) { using ProblemTypeTag = Opm::Properties::TTag::DiffusionProblem; return Opm::start(argc, argv, true); diff --git a/examples/diffusion_pvs.cpp b/examples/diffusion_pvs.cpp index f6428dde4a4..dfc0a48451b 100644 --- a/examples/diffusion_pvs.cpp +++ b/examples/diffusion_pvs.cpp @@ -27,21 +27,26 @@ */ #include "config.h" -#include +#include "problems/diffusionproblem.hh" #include +#include #include -#include "problems/diffusionproblem.hh" -namespace Opm::Properties { +namespace Opm::Properties +{ // Create new type tags -namespace TTag { -struct DiffusionProblem { using InheritsFrom = std::tuple; }; +namespace TTag +{ + struct DiffusionProblem { + using InheritsFrom = std::tuple; + }; } // end namespace TTag } // namespace Opm::Properties -int main(int argc, char **argv) +int +main(int argc, char** argv) { using ProblemTypeTag = Opm::Properties::TTag::DiffusionProblem; return Opm::start(argc, argv, true); diff --git a/examples/finger_immiscible_ecfv.cpp b/examples/finger_immiscible_ecfv.cpp index a3858033253..f0cc18d300c 100644 --- a/examples/finger_immiscible_ecfv.cpp +++ b/examples/finger_immiscible_ecfv.cpp @@ -27,25 +27,32 @@ */ #include "config.h" -#include -#include #include +#include +#include #include #include "problems/fingerproblem.hh" -namespace Opm::Properties { +namespace Opm::Properties +{ // Create new type tags -namespace TTag { -struct FingerProblemEcfv { using InheritsFrom = std::tuple; }; +namespace TTag +{ + struct FingerProblemEcfv { + using InheritsFrom = std::tuple; + }; } // end namespace TTag -template -struct SpatialDiscretizationSplice { using type = TTag::EcfvDiscretization; }; +template +struct SpatialDiscretizationSplice { + using type = TTag::EcfvDiscretization; +}; } // namespace Opm::Properties -int main(int argc, char **argv) +int +main(int argc, char** argv) { using ProblemTypeTag = Opm::Properties::TTag::FingerProblemEcfv; return Opm::start(argc, argv, true); diff --git a/examples/finger_immiscible_vcfv.cpp b/examples/finger_immiscible_vcfv.cpp index d5e4b4c591a..bd4a174cdfb 100644 --- a/examples/finger_immiscible_vcfv.cpp +++ b/examples/finger_immiscible_vcfv.cpp @@ -27,25 +27,32 @@ */ #include "config.h" -#include -#include #include +#include +#include #include #include "problems/fingerproblem.hh" -namespace Opm::Properties { +namespace Opm::Properties +{ // Create new type tags -namespace TTag { -struct FingerProblemVcfv { using InheritsFrom = std::tuple; }; +namespace TTag +{ + struct FingerProblemVcfv { + using InheritsFrom = std::tuple; + }; } // end namespace TTag -template -struct SpatialDiscretizationSplice { using type = TTag::VcfvDiscretization; }; +template +struct SpatialDiscretizationSplice { + using type = TTag::VcfvDiscretization; +}; } // namespace Opm::Properties -int main(int argc, char **argv) +int +main(int argc, char** argv) { using ProblemTypeTag = Opm::Properties::TTag::FingerProblemVcfv; return Opm::start(argc, argv, true); diff --git a/examples/fracture_discretefracture.cpp b/examples/fracture_discretefracture.cpp index ba71aba77e7..32cb226ed9b 100644 --- a/examples/fracture_discretefracture.cpp +++ b/examples/fracture_discretefracture.cpp @@ -32,7 +32,8 @@ #include "problems/fractureproblem.hh" -int main(int argc, char **argv) +int +main(int argc, char** argv) { using ProblemTypeTag = Opm::Properties::TTag::FractureProblem; return Opm::start(argc, argv, true); diff --git a/examples/groundwater_immiscible.cpp b/examples/groundwater_immiscible.cpp index a6dc2e8ab5e..1fad2fb6853 100644 --- a/examples/groundwater_immiscible.cpp +++ b/examples/groundwater_immiscible.cpp @@ -27,24 +27,28 @@ */ #include "config.h" +#include "problems/groundwaterproblem.hh" +#include #include #include -#include -#include "problems/groundwaterproblem.hh" -namespace Opm::Properties { +namespace Opm::Properties +{ // Create new type tags -namespace TTag { +namespace TTag +{ -struct GroundWaterProblem -{ using InheritsFrom = std::tuple; }; + struct GroundWaterProblem { + using InheritsFrom = std::tuple; + }; } // end namespace TTag } // namespace Opm::Properties -int main(int argc, char **argv) +int +main(int argc, char** argv) { using ProblemTypeTag = Opm::Properties::TTag::GroundWaterProblem; return Opm::start(argc, argv, true); diff --git a/examples/infiltration_pvs.cpp b/examples/infiltration_pvs.cpp index 4429ac832e6..4ce107a0883 100644 --- a/examples/infiltration_pvs.cpp +++ b/examples/infiltration_pvs.cpp @@ -27,23 +27,27 @@ */ #include "config.h" +#include "problems/infiltrationproblem.hh" #include -#include #include +#include #include -#include "problems/infiltrationproblem.hh" -namespace Opm::Properties { +namespace Opm::Properties +{ // Create new type tags -namespace TTag { -struct InfiltrationProblem -{ using InheritsFrom = std::tuple; }; +namespace TTag +{ + struct InfiltrationProblem { + using InheritsFrom = std::tuple; + }; } // end namespace TTag } // namespace Opm::Properties -int main(int argc, char **argv) +int +main(int argc, char** argv) { using ProblemTypeTag = Opm::Properties::TTag::InfiltrationProblem; return Opm::start(argc, argv, true); diff --git a/examples/lens_immiscible_ecfv_ad.cpp b/examples/lens_immiscible_ecfv_ad.cpp index 9fd53e98417..c0c9394a196 100644 --- a/examples/lens_immiscible_ecfv_ad.cpp +++ b/examples/lens_immiscible_ecfv_ad.cpp @@ -33,7 +33,8 @@ #include #include -int main(int argc, char **argv) +int +main(int argc, char** argv) { using ProblemTypeTag = Opm::Properties::TTag::LensProblemEcfvAd; return Opm::start(argc, argv, true); diff --git a/examples/lens_immiscible_ecfv_ad_23.cpp b/examples/lens_immiscible_ecfv_ad_23.cpp index 544e2c770b4..5cb7003914f 100644 --- a/examples/lens_immiscible_ecfv_ad_23.cpp +++ b/examples/lens_immiscible_ecfv_ad_23.cpp @@ -35,58 +35,57 @@ #include -namespace Opm::Properties { - -// Use Dune-grid's GeometryGrid< YaspGrid > -template -struct Grid +namespace Opm::Properties { - template< class ctype, unsigned int dim, unsigned int dimworld > - class IdentityCoordFct - : public Dune::AnalyticalCoordFunction - < ctype, dim, dimworld, IdentityCoordFct< ctype, dim, dimworld > > - { - using This = IdentityCoordFct< ctype, dim, dimworld >; - using Base = Dune::AnalyticalCoordFunction< ctype, dim, dimworld, This >; - - public: - using DomainVector = typename Base :: DomainVector; - using RangeVector = typename Base :: RangeVector ; - - template< typename... Args > - IdentityCoordFct( Args&... ) - {} - - RangeVector operator()(const DomainVector& x) const - { - RangeVector y; - evaluate( x, y ); - return y; - } - void evaluate( const DomainVector &x, RangeVector &y ) const +// Use Dune-grid's GeometryGrid< YaspGrid > +template +struct Grid { + template + class IdentityCoordFct + : public Dune::AnalyticalCoordFunction> { - y = 0; - for( unsigned int i = 0; i; + using This = IdentityCoordFct; + using Base = Dune::AnalyticalCoordFunction; + + public: + using DomainVector = typename Base ::DomainVector; + using RangeVector = typename Base ::RangeVector; + + template + IdentityCoordFct(Args&...) + { + } + + RangeVector operator()(const DomainVector& x) const + { + RangeVector y; + evaluate(x, y); + return y; + } + + void evaluate(const DomainVector& x, RangeVector& y) const + { + y = 0; + for (unsigned int i = 0; i < dim; ++i) + y[i] = x[i]; + } + }; + + using MyYaspGrid = Dune::YaspGrid<2>; public: - using type = Dune::GeometryGrid< MyYaspGrid, - IdentityCoordFct< typename MyYaspGrid::ctype, - MyYaspGrid::dimension, - MyYaspGrid::dimensionworld+1> >; + using type = Dune::GeometryGrid< + MyYaspGrid, + IdentityCoordFct>; }; } // namespace Opm::Properties #include -int main(int argc, char **argv) +int +main(int argc, char** argv) { using ProblemTypeTag = Opm::Properties::TTag::LensProblemEcfvAd; return Opm::start(argc, argv, true); diff --git a/examples/lens_immiscible_ecfv_ad_cu1.cpp b/examples/lens_immiscible_ecfv_ad_cu1.cpp index 8b0fa784f6c..abf9e7fa6e7 100644 --- a/examples/lens_immiscible_ecfv_ad_cu1.cpp +++ b/examples/lens_immiscible_ecfv_ad_cu1.cpp @@ -40,9 +40,10 @@ #include // fake forward declaration to prevent esoteric compiler warning -int mainCU1(int argc, char **argv); +int mainCU1(int argc, char** argv); -int mainCU1(int argc, char **argv) +int +mainCU1(int argc, char** argv) { using ProblemTypeTag = Opm::Properties::TTag::LensProblemEcfvAd; return Opm::start(argc, argv, true); diff --git a/examples/lens_immiscible_ecfv_ad_cu2.cpp b/examples/lens_immiscible_ecfv_ad_cu2.cpp index fcb7a9cd8f7..8a460070f7b 100644 --- a/examples/lens_immiscible_ecfv_ad_cu2.cpp +++ b/examples/lens_immiscible_ecfv_ad_cu2.cpp @@ -40,9 +40,10 @@ #include // fake forward declaration to prevent esoteric compiler warning -int mainCU2(int argc, char **argv); +int mainCU2(int argc, char** argv); -int mainCU2(int argc, char **argv) +int +mainCU2(int argc, char** argv) { using ProblemTypeTag = Opm::Properties::TTag::LensProblemEcfvAd; return Opm::start(argc, argv, true); diff --git a/examples/lens_immiscible_ecfv_ad_main.cpp b/examples/lens_immiscible_ecfv_ad_main.cpp index 8e40ee737d4..0ed341faed4 100644 --- a/examples/lens_immiscible_ecfv_ad_main.cpp +++ b/examples/lens_immiscible_ecfv_ad_main.cpp @@ -32,10 +32,11 @@ * compile units. This file calls contains main() and just calls the main entry point * defined by the first compile unit. */ -int mainCU1(int argc, char **argv); -int mainCU2(int argc, char **argv); +int mainCU1(int argc, char** argv); +int mainCU2(int argc, char** argv); -int main(int argc, char **argv) +int +main(int argc, char** argv) { return mainCU1(argc, argv); } diff --git a/examples/lens_immiscible_ecfv_ad_trans.cpp b/examples/lens_immiscible_ecfv_ad_trans.cpp index d185d7b0d4a..f154c45068f 100644 --- a/examples/lens_immiscible_ecfv_ad_trans.cpp +++ b/examples/lens_immiscible_ecfv_ad_trans.cpp @@ -29,27 +29,35 @@ */ #include "config.h" +#include #include #include -#include #include #include "problems/lensproblem.hh" -namespace Opm::Properties { +namespace Opm::Properties +{ // Create new type tags -namespace TTag { -struct LensProblemEcfvAdTrans { using InheritsFrom = std::tuple; }; +namespace TTag +{ + struct LensProblemEcfvAdTrans { + using InheritsFrom = std::tuple; + }; } // end namespace TTag // use automatic differentiation for this simulator -template -struct LocalLinearizerSplice { using type = TTag::AutoDiffLocalLinearizer; }; +template +struct LocalLinearizerSplice { + using type = TTag::AutoDiffLocalLinearizer; +}; // use the element centered finite volume spatial discretization -template -struct SpatialDiscretizationSplice { using type = TTag::EcfvDiscretization; }; +template +struct SpatialDiscretizationSplice { + using type = TTag::EcfvDiscretization; +}; // Set the problem property template @@ -57,9 +65,10 @@ struct FluxModule { using type = TransFluxModule; }; -} +} // namespace Opm::Properties -int main(int argc, char **argv) +int +main(int argc, char** argv) { using ProblemTypeTag = Opm::Properties::TTag::LensProblemEcfvAdTrans; return Opm::start(argc, argv, true); diff --git a/examples/lens_immiscible_vcfv_ad.cpp b/examples/lens_immiscible_vcfv_ad.cpp index a216d264027..12a6b7d2062 100644 --- a/examples/lens_immiscible_vcfv_ad.cpp +++ b/examples/lens_immiscible_vcfv_ad.cpp @@ -28,32 +28,41 @@ */ #include "config.h" -#include #include +#include #include #include "problems/lensproblem.hh" -namespace Opm::Properties { +namespace Opm::Properties +{ // Create new type tags -namespace TTag { -struct LensProblemVcfvAd { using InheritsFrom = std::tuple; }; +namespace TTag +{ + struct LensProblemVcfvAd { + using InheritsFrom = std::tuple; + }; } // end namespace TTag // use automatic differentiation for this simulator -template -struct LocalLinearizerSplice { using type = TTag::AutoDiffLocalLinearizer; }; +template +struct LocalLinearizerSplice { + using type = TTag::AutoDiffLocalLinearizer; +}; // use linear finite element gradients if dune-localfunctions is available #if HAVE_DUNE_LOCALFUNCTIONS -template -struct UseP1FiniteElementGradients { static constexpr bool value = true; }; +template +struct UseP1FiniteElementGradients { + static constexpr bool value = true; +}; #endif } // namespace Opm::Properties -int main(int argc, char **argv) +int +main(int argc, char** argv) { using ProblemTypeTag = Opm::Properties::TTag::LensProblemVcfvAd; return Opm::start(argc, argv, true); diff --git a/examples/lens_immiscible_vcfv_fd.cpp b/examples/lens_immiscible_vcfv_fd.cpp index 61fa1334675..aecd0fc92c5 100644 --- a/examples/lens_immiscible_vcfv_fd.cpp +++ b/examples/lens_immiscible_vcfv_fd.cpp @@ -28,32 +28,41 @@ */ #include "config.h" -#include #include +#include #include #include "problems/lensproblem.hh" -namespace Opm::Properties { +namespace Opm::Properties +{ // Create new type tags -namespace TTag { -struct LensProblemVcfvFd { using InheritsFrom = std::tuple; }; +namespace TTag +{ + struct LensProblemVcfvFd { + using InheritsFrom = std::tuple; + }; } // end namespace TTag // use the finite difference methodfor this simulator -template -struct LocalLinearizerSplice { using type = TTag::FiniteDifferenceLocalLinearizer; }; +template +struct LocalLinearizerSplice { + using type = TTag::FiniteDifferenceLocalLinearizer; +}; // use linear finite element gradients if dune-localfunctions is available #if HAVE_DUNE_LOCALFUNCTIONS -template -struct UseP1FiniteElementGradients { static constexpr bool value = true; }; +template +struct UseP1FiniteElementGradients { + static constexpr bool value = true; +}; #endif } // namespace Opm::Properties -int main(int argc, char **argv) +int +main(int argc, char** argv) { using ProblemTypeTag = Opm::Properties::TTag::LensProblemVcfvFd; return Opm::start(argc, argv, true); diff --git a/examples/lens_richards_ecfv.cpp b/examples/lens_richards_ecfv.cpp index fa12ada84d9..9d170531385 100644 --- a/examples/lens_richards_ecfv.cpp +++ b/examples/lens_richards_ecfv.cpp @@ -27,34 +27,40 @@ */ #include "config.h" +#include #include #include -#include #include #include "problems/richardslensproblem.hh" -namespace Opm::Properties { +namespace Opm::Properties +{ // Create new type tags -namespace TTag { -struct RichardsLensEcfvProblem -{ using InheritsFrom = std::tuple; }; +namespace TTag +{ + struct RichardsLensEcfvProblem { + using InheritsFrom = std::tuple; + }; } // end namespace TTag -template -struct SpatialDiscretizationSplice -{ using type = TTag::EcfvDiscretization; }; +template +struct SpatialDiscretizationSplice { + using type = TTag::EcfvDiscretization; +}; //! Use automatic differentiation to linearize the system of PDEs -template -struct LocalLinearizerSplice -{ using type = TTag::AutoDiffLocalLinearizer; }; +template +struct LocalLinearizerSplice { + using type = TTag::AutoDiffLocalLinearizer; +}; } // namespace Opm::Properties -int main(int argc, char **argv) +int +main(int argc, char** argv) { using ProblemTypeTag = Opm::Properties::TTag::RichardsLensEcfvProblem; return Opm::start(argc, argv, true); diff --git a/examples/lens_richards_vcfv.cpp b/examples/lens_richards_vcfv.cpp index 40acde088d2..cb1e47bcb62 100644 --- a/examples/lens_richards_vcfv.cpp +++ b/examples/lens_richards_vcfv.cpp @@ -27,30 +27,35 @@ */ #include "config.h" +#include #include #include -#include #include #include "problems/richardslensproblem.hh" -namespace Opm::Properties { +namespace Opm::Properties +{ // Create new type tags -namespace TTag { +namespace TTag +{ -struct RichardsLensVcfvProblem -{ using InheritsFrom = std::tuple; }; + struct RichardsLensVcfvProblem { + using InheritsFrom = std::tuple; + }; } // end namespace TTag -template -struct SpatialDiscretizationSplice -{ using type = TTag::VcfvDiscretization; }; +template +struct SpatialDiscretizationSplice { + using type = TTag::VcfvDiscretization; +}; } // namespace Opm::Properties -int main(int argc, char **argv) +int +main(int argc, char** argv) { using ProblemTypeTag = Opm::Properties::TTag::RichardsLensVcfvProblem; return Opm::start(argc, argv, true); diff --git a/examples/obstacle_immiscible.cpp b/examples/obstacle_immiscible.cpp index 9ca86ba8af0..e26926bc7fa 100644 --- a/examples/obstacle_immiscible.cpp +++ b/examples/obstacle_immiscible.cpp @@ -28,24 +28,28 @@ */ #include "config.h" +#include "problems/obstacleproblem.hh" +#include #include #include #include -#include -#include "problems/obstacleproblem.hh" -namespace Opm::Properties { +namespace Opm::Properties +{ // Create new type tags -namespace TTag { -struct ObstacleProblem -{ using InheritsFrom = std::tuple; }; +namespace TTag +{ + struct ObstacleProblem { + using InheritsFrom = std::tuple; + }; } // end namespace TTag } // namespace Opm::Properties -int main(int argc, char **argv) +int +main(int argc, char** argv) { using ProblemTypeTag = Opm::Properties::TTag::ObstacleProblem; return Opm::start(argc, argv, true); diff --git a/examples/obstacle_ncp.cpp b/examples/obstacle_ncp.cpp index aed07cf5e9e..50a67c3dfcb 100644 --- a/examples/obstacle_ncp.cpp +++ b/examples/obstacle_ncp.cpp @@ -28,25 +28,29 @@ #include "config.h" #include -#include #include +#include #include #include "problems/obstacleproblem.hh" -namespace Opm::Properties { +namespace Opm::Properties +{ // Create new type tags -namespace TTag { +namespace TTag +{ -struct ObstacleProblem -{ using InheritsFrom = std::tuple; }; + struct ObstacleProblem { + using InheritsFrom = std::tuple; + }; } // end namespace TTag } // namespace Opm::Properties -int main(int argc, char **argv) +int +main(int argc, char** argv) { using ProblemTypeTag = Opm::Properties::TTag::ObstacleProblem; return Opm::start(argc, argv, true); diff --git a/examples/obstacle_pvs.cpp b/examples/obstacle_pvs.cpp index e33343efa4f..62d279a5c21 100644 --- a/examples/obstacle_pvs.cpp +++ b/examples/obstacle_pvs.cpp @@ -30,25 +30,29 @@ #include "config.h" #include -#include #include +#include #include #include "problems/obstacleproblem.hh" -namespace Opm::Properties { +namespace Opm::Properties +{ // Create new type tags -namespace TTag { +namespace TTag +{ -struct ObstacleProblem -{ using InheritsFrom = std::tuple; }; + struct ObstacleProblem { + using InheritsFrom = std::tuple; + }; } // end namespace TTag } // namespace Opm::Properties -int main(int argc, char **argv) +int +main(int argc, char** argv) { using ProblemTypeTag = Opm::Properties::TTag::ObstacleProblem; return Opm::start(argc, argv, true); diff --git a/examples/opmrst_inspect.cpp b/examples/opmrst_inspect.cpp index 133d9761a3c..61d96404217 100644 --- a/examples/opmrst_inspect.cpp +++ b/examples/opmrst_inspect.cpp @@ -32,7 +32,8 @@ #include #include -int main(int argc, char** argv) +int +main(int argc, char** argv) { if (argc < 2) { std::cerr << "Need one parameter, the .OPMRST file to inspect\n"; @@ -41,46 +42,48 @@ int main(int argc, char** argv) Dune::MPIHelper::instance(argc, argv); #if HAVE_MPI - Opm::Parallel::Communication comm{MPI_COMM_SELF}; + Opm::Parallel::Communication comm {MPI_COMM_SELF}; #else - Opm::Parallel::Communication comm{}; + Opm::Parallel::Communication comm {}; #endif Opm::HDF5Serializer ser(argv[1], Opm::HDF5File::OpenMode::READ, comm); - std::tuple,int> header; + std::tuple, int> header; try { ser.read(header, "/", "simulator_info", Opm::HDF5File::DataSetMode::ROOT_ONLY); - } catch(...) { + } catch (...) { std::cerr << "Error reading data from file, is it really a .OPMRST file?\n"; return 2; } const auto& [strings, procs] = header; - std::cout << "Info for " << argv[1] <<":\n"; + std::cout << "Info for " << argv[1] << ":\n"; std::cout << fmt::format("\tSimulator name: {}\n" "\tSimulator version: {}\n" "\tCompile time stamp: {}\n" "\tCase name: {}\n" "\tNumber of processes: {}\n", - strings[0], strings[1], strings[2], strings[3], procs); + strings[0], + strings[1], + strings[2], + strings[3], + procs); std::cout << fmt::format("\tLast report step: {}\n", ser.lastReportStep()); const std::vector reportSteps = ser.reportSteps(); for (int step : reportSteps) { Opm::SimulatorTimer timer; try { - ser.read(timer, fmt::format("/report_step/{}", step), - "simulator_timer", Opm::HDF5File::DataSetMode::ROOT_ONLY); + ser.read( + timer, fmt::format("/report_step/{}", step), "simulator_timer", Opm::HDF5File::DataSetMode::ROOT_ONLY); } catch (...) { std::cerr << "*** Failed to read timer info for level " << step << std::endl; } - std::cout << "\t\tReport step id " << step << ": Time " - << timer.currentDateTime() << std::endl; + std::cout << "\t\tReport step id " << step << ": Time " << timer.currentDateTime() << std::endl; } - std::cout << "====== Parameter values ====\n" - << strings[4]; + std::cout << "====== Parameter values ====\n" << strings[4]; return 0; } diff --git a/examples/outflow_pvs.cpp b/examples/outflow_pvs.cpp index 0a312a572f2..51df2f74564 100644 --- a/examples/outflow_pvs.cpp +++ b/examples/outflow_pvs.cpp @@ -28,25 +28,29 @@ #include "config.h" #include -#include #include +#include #include #include "problems/outflowproblem.hh" -namespace Opm::Properties { +namespace Opm::Properties +{ // Create new type tags -namespace TTag { +namespace TTag +{ -struct OutflowProblem -{ using InheritsFrom = std::tuple; }; + struct OutflowProblem { + using InheritsFrom = std::tuple; + }; } // end namespace TTag } // namespace Opm::Properties -int main(int argc, char **argv) +int +main(int argc, char** argv) { using ProblemTypeTag = Opm::Properties::TTag::OutflowProblem; return Opm::start(argc, argv, true); diff --git a/examples/powerinjection_darcy_ad.cpp b/examples/powerinjection_darcy_ad.cpp index f8505fd0b3c..d624dd1a518 100644 --- a/examples/powerinjection_darcy_ad.cpp +++ b/examples/powerinjection_darcy_ad.cpp @@ -27,28 +27,36 @@ */ #include "config.h" +#include "problems/powerinjectionproblem.hh" +#include #include #include -#include -#include "problems/powerinjectionproblem.hh" -namespace Opm::Properties { +namespace Opm::Properties +{ -namespace TTag { +namespace TTag +{ -struct PowerInjectionDarcyAdProblem -{ using InheritsFrom = std::tuple; }; + struct PowerInjectionDarcyAdProblem { + using InheritsFrom = std::tuple; + }; } // namespace TTag -template -struct FluxModule { using type = Opm::DarcyFluxModule; }; -template -struct LocalLinearizerSplice { using type = TTag::AutoDiffLocalLinearizer; }; +template +struct FluxModule { + using type = Opm::DarcyFluxModule; +}; +template +struct LocalLinearizerSplice { + using type = TTag::AutoDiffLocalLinearizer; +}; } // namespace Opm::Properties -int main(int argc, char **argv) +int +main(int argc, char** argv) { using ProblemTypeTag = Opm::Properties::TTag::PowerInjectionDarcyAdProblem; return Opm::start(argc, argv, true); diff --git a/examples/powerinjection_darcy_fd.cpp b/examples/powerinjection_darcy_fd.cpp index 6dd5a5dfb03..43778a5d7e7 100644 --- a/examples/powerinjection_darcy_fd.cpp +++ b/examples/powerinjection_darcy_fd.cpp @@ -27,28 +27,36 @@ */ #include "config.h" -#include +#include "problems/powerinjectionproblem.hh" #include +#include #include -#include "problems/powerinjectionproblem.hh" -namespace Opm::Properties { +namespace Opm::Properties +{ -namespace TTag { +namespace TTag +{ -struct PowerInjectionDarcyFdProblem -{ using InheritsFrom = std::tuple; }; + struct PowerInjectionDarcyFdProblem { + using InheritsFrom = std::tuple; + }; } // namespace TTag -template -struct FluxModule { using type = Opm::DarcyFluxModule; }; -template -struct LocalLinearizerSplice { using type = TTag::FiniteDifferenceLocalLinearizer; }; +template +struct FluxModule { + using type = Opm::DarcyFluxModule; +}; +template +struct LocalLinearizerSplice { + using type = TTag::FiniteDifferenceLocalLinearizer; +}; } // namespace Opm::Properties -int main(int argc, char **argv) +int +main(int argc, char** argv) { using ProblemTypeTag = Opm::Properties::TTag::PowerInjectionDarcyFdProblem; return Opm::start(argc, argv, true); diff --git a/examples/powerinjection_forchheimer_ad.cpp b/examples/powerinjection_forchheimer_ad.cpp index 9c61f4bbd4d..e689b6f0b6f 100644 --- a/examples/powerinjection_forchheimer_ad.cpp +++ b/examples/powerinjection_forchheimer_ad.cpp @@ -27,28 +27,36 @@ */ #include "config.h" +#include "problems/powerinjectionproblem.hh" +#include #include #include -#include -#include "problems/powerinjectionproblem.hh" -namespace Opm::Properties { +namespace Opm::Properties +{ -namespace TTag { +namespace TTag +{ -struct PowerInjectionForchheimerAdProblem -{ using InheritsFrom = std::tuple; }; + struct PowerInjectionForchheimerAdProblem { + using InheritsFrom = std::tuple; + }; } // namespace TTag -template -struct FluxModule { using type = Opm::ForchheimerFluxModule; }; -template -struct LocalLinearizerSplice { using type = TTag::AutoDiffLocalLinearizer; }; +template +struct FluxModule { + using type = Opm::ForchheimerFluxModule; +}; +template +struct LocalLinearizerSplice { + using type = TTag::AutoDiffLocalLinearizer; +}; } // namespace Opm::Properties -int main(int argc, char **argv) +int +main(int argc, char** argv) { using ProblemTypeTag = Opm::Properties::TTag::PowerInjectionForchheimerAdProblem; return Opm::start(argc, argv, true); diff --git a/examples/powerinjection_forchheimer_fd.cpp b/examples/powerinjection_forchheimer_fd.cpp index 09855c9bee1..a352b106edf 100644 --- a/examples/powerinjection_forchheimer_fd.cpp +++ b/examples/powerinjection_forchheimer_fd.cpp @@ -27,28 +27,36 @@ */ #include "config.h" -#include +#include "problems/powerinjectionproblem.hh" #include +#include #include -#include "problems/powerinjectionproblem.hh" -namespace Opm::Properties { +namespace Opm::Properties +{ -namespace TTag { +namespace TTag +{ -struct PowerInjectionForchheimerFdProblem -{ using InheritsFrom = std::tuple; }; + struct PowerInjectionForchheimerFdProblem { + using InheritsFrom = std::tuple; + }; } // namespace TTag -template -struct FluxModule { using type = Opm::ForchheimerFluxModule; }; -template -struct LocalLinearizerSplice { using type = TTag::FiniteDifferenceLocalLinearizer; }; +template +struct FluxModule { + using type = Opm::ForchheimerFluxModule; +}; +template +struct LocalLinearizerSplice { + using type = TTag::FiniteDifferenceLocalLinearizer; +}; } // namespace Opm::Properties -int main(int argc, char **argv) +int +main(int argc, char** argv) { using ProblemTypeTag = Opm::Properties::TTag::PowerInjectionForchheimerFdProblem; return Opm::start(argc, argv, true); diff --git a/examples/printvfp.cpp b/examples/printvfp.cpp index 7c7114e44c2..b5400c22b52 100644 --- a/examples/printvfp.cpp +++ b/examples/printvfp.cpp @@ -33,8 +33,8 @@ #include #include -#include #include +#include #include @@ -52,19 +52,20 @@ using namespace Opm; -namespace { - -struct Setup +namespace { + +struct Setup { using IndexTraits = BlackOilDefaultFluidSystemIndices; using PhaseUsage = PhaseUsageInfo; explicit Setup(const std::string& file) - : Setup { Parser{}.parseFile(file) } - {} + : Setup {Parser {}.parseFile(file)} + { + } explicit Setup(const Deck& deck) - : ecl_state { std::make_unique(deck) } - , schedule { std::make_unique(deck, *ecl_state, std::make_shared()) } + : ecl_state {std::make_unique(deck)} + , schedule {std::make_unique(deck, *ecl_state, std::make_shared())} { const int step = 0; const auto& sched_state = (*this->schedule)[step]; @@ -74,8 +75,8 @@ struct Setup this->well_state = std::make_unique>(pu); - this->vfp_properties = std::make_unique> - (sched_state.vfpinj(), sched_state.vfpprod(), *well_state); + this->vfp_properties = std::make_unique>( + sched_state.vfpinj(), sched_state.vfpprod(), *well_state); } std::unique_ptr ecl_state; @@ -85,12 +86,9 @@ struct Setup }; -double computeBhp(const VFPProdTable& table, - const double flo, - const double thp, - const double wfr, - const double gfr, - const double alq) +double +computeBhp( + const VFPProdTable& table, const double flo, const double thp, const double wfr, const double gfr, const double alq) { // First, find the values to interpolate between. @@ -108,7 +106,8 @@ double computeBhp(const VFPProdTable& table, } // Anonymous namespace -int main(int argc, char** argv) +int +main(int argc, char** argv) { if (argc < 2) { return EXIT_FAILURE; @@ -116,14 +115,14 @@ int main(int argc, char** argv) const Setup setup(argv[1]); -// const int table_id = 1; + // const int table_id = 1; const int table_id = 4; const double wct = 0.0; -// const double gor = 35.2743; + // const double gor = 35.2743; const double gor = 0.0; const double alq = 0.0; const int n = 51; - const double m3pd = unit::cubic(unit::meter)/unit::day; + const double m3pd = unit::cubic(unit::meter) / unit::day; const double rate_min = 20.0 * m3pd; const double rate_max = 2000.0 * m3pd; // const double thp = 32.1744 * unit::barsa; @@ -133,7 +132,7 @@ int main(int argc, char** argv) std::vector rates(n); std::vector thps(n); for (int ii = 0; ii < n; ++ii) { - const double q = double(ii) / double(n-1); + const double q = double(ii) / double(n - 1); rates[ii] = (1.0 - q) * rate_min + q * rate_max; thps[ii] = (1.0 - q) * thp_min + q * thp_max; } @@ -145,7 +144,7 @@ int main(int argc, char** argv) const double bhp = computeBhp(table, rate, thp, wct, gor, alq); std::cout //<< std::setw(18) << unit::convert::to(rate, m3pd) //<< std::setw(18) << unit::convert::to(thp, unit::barsa) - << std::setw(18) << unit::convert::to(bhp, unit::barsa) << '\n'; + << std::setw(18) << unit::convert::to(bhp, unit::barsa) << '\n'; } } diff --git a/examples/reservoir_blackoil_ecfv.cpp b/examples/reservoir_blackoil_ecfv.cpp index 394f1f14005..ceb27dac57c 100644 --- a/examples/reservoir_blackoil_ecfv.cpp +++ b/examples/reservoir_blackoil_ecfv.cpp @@ -28,37 +28,43 @@ */ #include "config.h" -#include -#include #include #include +#include +#include #include #include "problems/reservoirproblem.hh" -namespace Opm::Properties { +namespace Opm::Properties +{ // Create new type tags -namespace TTag { +namespace TTag +{ -struct ReservoirBlackOilEcfvProblem -{ using InheritsFrom = std::tuple; }; + struct ReservoirBlackOilEcfvProblem { + using InheritsFrom = std::tuple; + }; } // end namespace TTag // Select the element centered finite volume method as spatial discretization -template -struct SpatialDiscretizationSplice -{ using type = TTag::EcfvDiscretization; }; +template +struct SpatialDiscretizationSplice { + using type = TTag::EcfvDiscretization; +}; // Use automatic differentiation to linearize the system of PDEs -template -struct LocalLinearizerSplice -{ using type = TTag::AutoDiffLocalLinearizer; }; +template +struct LocalLinearizerSplice { + using type = TTag::AutoDiffLocalLinearizer; +}; } // namespace Opm::Properties -int main(int argc, char **argv) +int +main(int argc, char** argv) { using ProblemTypeTag = Opm::Properties::TTag::ReservoirBlackOilEcfvProblem; return Opm::start(argc, argv, true); diff --git a/examples/reservoir_blackoil_vcfv.cpp b/examples/reservoir_blackoil_vcfv.cpp index 0c119e03edf..b7f2d255051 100644 --- a/examples/reservoir_blackoil_vcfv.cpp +++ b/examples/reservoir_blackoil_vcfv.cpp @@ -27,32 +27,37 @@ */ #include "config.h" -#include -#include #include #include +#include +#include #include #include "problems/reservoirproblem.hh" -namespace Opm::Properties { +namespace Opm::Properties +{ // Create new type tags -namespace TTag { +namespace TTag +{ -struct ReservoirBlackOilVcfvProblem -{ using InheritsFrom = std::tuple; }; + struct ReservoirBlackOilVcfvProblem { + using InheritsFrom = std::tuple; + }; } // end namespace TTag // Select the vertex centered finite volume method as spatial discretization -template -struct SpatialDiscretizationSplice -{ using type = TTag::VcfvDiscretization; }; +template +struct SpatialDiscretizationSplice { + using type = TTag::VcfvDiscretization; +}; } // namespace Opm::Properties -int main(int argc, char **argv) +int +main(int argc, char** argv) { using ProblemTypeTag = Opm::Properties::TTag::ReservoirBlackOilVcfvProblem; return Opm::start(argc, argv, true); diff --git a/examples/reservoir_ncp_ecfv.cpp b/examples/reservoir_ncp_ecfv.cpp index 1feec1c2dc8..ebf8b61f75a 100644 --- a/examples/reservoir_ncp_ecfv.cpp +++ b/examples/reservoir_ncp_ecfv.cpp @@ -27,37 +27,43 @@ */ #include "config.h" +#include #include -#include #include -#include +#include #include #include "problems/reservoirproblem.hh" -namespace Opm::Properties { +namespace Opm::Properties +{ // Create new type tags -namespace TTag { +namespace TTag +{ -struct ReservoirNcpEcfvProblem -{ using InheritsFrom = std::tuple; }; + struct ReservoirNcpEcfvProblem { + using InheritsFrom = std::tuple; + }; } // end namespace TTag // Select the element centered finite volume method as spatial discretization -template -struct SpatialDiscretizationSplice -{ using type = TTag::EcfvDiscretization; }; +template +struct SpatialDiscretizationSplice { + using type = TTag::EcfvDiscretization; +}; //! use automatic differentiation to linearize the system of PDEs -template -struct LocalLinearizerSplice -{ using type = TTag::AutoDiffLocalLinearizer; }; +template +struct LocalLinearizerSplice { + using type = TTag::AutoDiffLocalLinearizer; +}; } // namespace Opm::Properties -int main(int argc, char **argv) +int +main(int argc, char** argv) { using ProblemTypeTag = Opm::Properties::TTag::ReservoirNcpEcfvProblem; return Opm::start(argc, argv, true); diff --git a/examples/reservoir_ncp_vcfv.cpp b/examples/reservoir_ncp_vcfv.cpp index 95515a983ca..c9733831e6f 100644 --- a/examples/reservoir_ncp_vcfv.cpp +++ b/examples/reservoir_ncp_vcfv.cpp @@ -28,41 +28,45 @@ */ #include "config.h" +#include #include -#include #include -#include +#include #include #include "problems/reservoirproblem.hh" -namespace Opm::Properties { +namespace Opm::Properties +{ // Create new type tags -namespace TTag { +namespace TTag +{ -struct ReservoirNcpVcfvProblem -{ using InheritsFrom = std::tuple; }; + struct ReservoirNcpVcfvProblem { + using InheritsFrom = std::tuple; + }; } // end namespace TTag // Select the vertex centered finite volume method as spatial discretization -template -struct SpatialDiscretizationSplice -{ using type = TTag::VcfvDiscretization; }; +template +struct SpatialDiscretizationSplice { + using type = TTag::VcfvDiscretization; +}; // reduce the base epsilon for the finite difference method to 10^-11. for some reason // the simulator converges better with this. (TODO: use automatic differentiation?) -template -struct BaseEpsilon -{ +template +struct BaseEpsilon { using type = GetPropType; static constexpr type value = 1e-11; }; } // namespace Opm::Properties -int main(int argc, char **argv) +int +main(int argc, char** argv) { using ProblemTypeTag = Opm::Properties::TTag::ReservoirNcpVcfvProblem; return Opm::start(argc, argv, true); diff --git a/examples/tutorial1.cpp b/examples/tutorial1.cpp index 7fb8efa1e8b..5f76d28e632 100644 --- a/examples/tutorial1.cpp +++ b/examples/tutorial1.cpp @@ -26,13 +26,14 @@ * \brief Main file of the tutorial problem using the model which assumes * immisciblility. */ -#include "config.h" /*@\label{tutorial1:include-begin}@*/ +#include "config.h" /*@\label{tutorial1:include-begin}@*/ #include /*@\label{tutorial1:include-end}@*/ #include #include "tutorial1problem.hh" /*@\label{tutorial1:include-problem-header}@*/ -int main(int argc, char **argv) +int +main(int argc, char** argv) { using TypeTag = Opm::Properties::TTag::Tutorial1Problem; /*@\label{tutorial1:set-type-tag}@*/ return Opm::start(argc, argv, true); /*@\label{tutorial1:call-start}@*/ diff --git a/examples/waterair_pvs_ni.cpp b/examples/waterair_pvs_ni.cpp index f6445f24903..f3c3e1644ea 100644 --- a/examples/waterair_pvs_ni.cpp +++ b/examples/waterair_pvs_ni.cpp @@ -27,26 +27,31 @@ */ #include "config.h" +#include "problems/waterairproblem.hh" #include -#include #include -#include "problems/waterairproblem.hh" +#include -namespace Opm::Properties { +namespace Opm::Properties +{ // Create new type tags -namespace TTag { -struct WaterAirProblem -{ using InheritsFrom = std::tuple; }; +namespace TTag +{ + struct WaterAirProblem { + using InheritsFrom = std::tuple; + }; } // end namespace TTag -template -struct EnableEnergy -{ static constexpr bool value = true; }; +template +struct EnableEnergy { + static constexpr bool value = true; +}; } // namespace Opm::Properties -int main(int argc, char **argv) +int +main(int argc, char** argv) { using ProblemTypeTag = Opm::Properties::TTag::WaterAirProblem; return Opm::start(argc, argv, true); diff --git a/flow/flow.cpp b/flow/flow.cpp index 4d0d4d3fed6..f62b7776001 100644 --- a/flow/flow.cpp +++ b/flow/flow.cpp @@ -23,7 +23,8 @@ #include -int main(int argc, char** argv) +int +main(int argc, char** argv) { auto mainObject = std::make_unique(argc, argv); auto ret = mainObject->runDynamic(); @@ -31,4 +32,3 @@ int main(int argc, char** argv) mainObject.reset(); return ret; } - diff --git a/flow/flow_biofilm.cpp b/flow/flow_biofilm.cpp index 08fb20df17c..4d3426fe58f 100644 --- a/flow/flow_biofilm.cpp +++ b/flow/flow_biofilm.cpp @@ -22,96 +22,105 @@ #include #include -#include #include +#include #include #include #include #include -namespace Opm { +namespace Opm +{ /*! * \brief Two-phase (gas+water) flow problem including biofilm effects (one transported - * quantity: suspended microbes and one solid phase: biofilm). + * quantity: suspended microbes and one solid phase: biofilm). */ -namespace Properties { -namespace TTag { -struct FlowBiofilmProblem { - using InheritsFrom = std::tuple; -}; -} +namespace Properties +{ + namespace TTag + { + struct FlowBiofilmProblem { + using InheritsFrom = std::tuple; + }; + } // namespace TTag + + template + struct EnableBioeffects { + static constexpr bool value = true; + }; + + template + struct EnableDiffusion { + static constexpr bool value = true; + }; + + template + struct EnableDispersion { + static constexpr bool value = true; + }; + + template + struct EnableDisgasInWater { + static constexpr bool value = true; + }; + + template + struct EnableVapwat { + static constexpr bool value = true; + }; + + template + struct Linearizer { + using type = TpfaLinearizer; + }; + template + struct LocalResidual { + using type = BlackOilLocalResidualTPFA; + }; + + //! The indices required by the model + template + struct Indices { + private: + // it is unfortunately not possible to simply use 'TypeTag' here because this leads + // to cyclic definitions of some properties. if this happens the compiler error + // messages unfortunately are *really* confusing and not really helpful. + using BaseTypeTag = TTag::FlowProblem; + using FluidSystem = GetPropType; + + public: + using type = BlackOilTwoPhaseIndices(), + getPropValue(), + getPropValue(), + getPropValue(), + getPropValue(), + getPropValue(), + /*PVOffset=*/0, + /*disabledCompIdx=*/FluidSystem::oilCompIdx, + 2>; // Two biocomponents (suspended microbes and biofilm) + }; +} // namespace Properties +} // namespace Opm -template -struct EnableBioeffects { - static constexpr bool value = true; -}; - -template -struct EnableDiffusion { - static constexpr bool value = true; -}; - -template -struct EnableDispersion { - static constexpr bool value = true; -}; - -template -struct EnableDisgasInWater { - static constexpr bool value = true; -}; - -template -struct EnableVapwat { - static constexpr bool value = true; -}; - -template -struct Linearizer { using type = TpfaLinearizer; }; -template -struct LocalResidual { using type = BlackOilLocalResidualTPFA; }; - -//! The indices required by the model -template -struct Indices +namespace Opm { -private: - // it is unfortunately not possible to simply use 'TypeTag' here because this leads - // to cyclic definitions of some properties. if this happens the compiler error - // messages unfortunately are *really* confusing and not really helpful. - using BaseTypeTag = TTag::FlowProblem; - using FluidSystem = GetPropType; - -public: - using type = BlackOilTwoPhaseIndices(), - getPropValue(), - getPropValue(), - getPropValue(), - getPropValue(), - getPropValue(), - /*PVOffset=*/0, - /*disabledCompIdx=*/FluidSystem::oilCompIdx, - 2>; //Two biocomponents (suspended microbes and biofilm) -}; -}} - -namespace Opm { // ----------------- Main program ----------------- -int flowBiofilmMain(int argc, char** argv, bool outputCout, bool outputFiles) +int +flowBiofilmMain(int argc, char** argv, bool outputCout, bool outputFiles) { // we always want to use the default locale, and thus spare us the trouble // with incorrect locale settings. resetLocale(); - FlowMain - mainfunc {argc, argv, outputCout, outputFiles} ; + FlowMain mainfunc {argc, argv, outputCout, outputFiles}; return mainfunc.execute(); } -int flowBiofilmMainStandalone(int argc, char** argv) +int +flowBiofilmMainStandalone(int argc, char** argv) { using TypeTag = Properties::TTag::FlowBiofilmProblem; auto mainObject = std::make_unique(argc, argv); diff --git a/flow/flow_biofilm.hpp b/flow/flow_biofilm.hpp index 71b7727784c..0b230f747dd 100644 --- a/flow/flow_biofilm.hpp +++ b/flow/flow_biofilm.hpp @@ -14,7 +14,8 @@ #ifndef FLOW_BIOFILM_HPP #define FLOW_BIOFILM_HPP -namespace Opm { +namespace Opm +{ //! \brief Main function used in flow binary. int flowBiofilmMain(int argc, char** argv, bool outputCout, bool outputFiles); @@ -22,6 +23,6 @@ int flowBiofilmMain(int argc, char** argv, bool outputCout, bool outputFiles); //! \brief Main function used in flow_biofilm binary. int flowBiofilmMainStandalone(int argc, char** argv); -} +} // namespace Opm #endif // FLOW_BIOFILM_HPP diff --git a/flow/flow_biofilm_main.cpp b/flow/flow_biofilm_main.cpp index 9faf25d76f5..22b5204bc42 100644 --- a/flow/flow_biofilm_main.cpp +++ b/flow/flow_biofilm_main.cpp @@ -15,7 +15,8 @@ #include -int main(int argc, char** argv) +int +main(int argc, char** argv) { return Opm::flowBiofilmMainStandalone(argc, argv); } diff --git a/flow/flow_blackoil.cpp b/flow/flow_blackoil.cpp index ce284beb32b..f8bac05bae8 100644 --- a/flow/flow_blackoil.cpp +++ b/flow/flow_blackoil.cpp @@ -18,31 +18,41 @@ #include -#include #include -#include +#include #include +#include #include #include -namespace Opm { - namespace Properties { +namespace Opm +{ +namespace Properties +{ - template - struct Linearizer { using type = TpfaLinearizer; }; + template + struct Linearizer { + using type = TpfaLinearizer; + }; - template - struct LocalResidual { using type = BlackOilLocalResidualTPFA; }; + template + struct LocalResidual { + using type = BlackOilLocalResidualTPFA; + }; - template - struct EnableDiffusion { static constexpr bool value = false; }; + template + struct EnableDiffusion { + static constexpr bool value = false; + }; - template - struct AvoidElementContext { static constexpr bool value = true; }; + template + struct AvoidElementContext { + static constexpr bool value = true; + }; - } -} +} // namespace Properties +} // namespace Opm namespace Opm @@ -54,23 +64,23 @@ flowBlackoilTpfaMainInit(int argc, char** argv, bool outputCout, bool outputFile // with incorrect locale settings. resetLocale(); - return std::make_unique>( - argc, argv, outputCout, outputFiles); + return std::make_unique>(argc, argv, outputCout, outputFiles); } // ----------------- Main program ----------------- -int flowBlackoilTpfaMain(int argc, char** argv, bool outputCout, bool outputFiles) +int +flowBlackoilTpfaMain(int argc, char** argv, bool outputCout, bool outputFiles) { // we always want to use the default locale, and thus spare us the trouble // with incorrect locale settings. resetLocale(); - FlowMain - mainfunc {argc, argv, outputCout, outputFiles}; + FlowMain mainfunc {argc, argv, outputCout, outputFiles}; return mainfunc.execute(); } -int flowBlackoilTpfaMainStandalone(int argc, char** argv) +int +flowBlackoilTpfaMainStandalone(int argc, char** argv) { using TypeTag = Properties::TTag::FlowProblemTPFA; auto mainObject = std::make_unique(argc, argv); diff --git a/flow/flow_blackoil.hpp b/flow/flow_blackoil.hpp index d15790685c5..116322be4e0 100644 --- a/flow/flow_blackoil.hpp +++ b/flow/flow_blackoil.hpp @@ -21,12 +21,14 @@ #include -namespace Opm { +namespace Opm +{ //! \brief Main function used in flow binary. int flowBlackoilTpfaMain(int argc, char** argv, bool outputCout, bool outputFiles); -template class FlowMain; +template +class FlowMain; //! \brief Initialization function used in flow binary and python simulator. std::unique_ptr> @@ -35,6 +37,6 @@ flowBlackoilTpfaMainInit(int argc, char** argv, bool outputCout, bool outputFile //! \brief Main function used in flow_brine binary. int flowBlackoilTpfaMainStandalone(int argc, char** argv); -} +} // namespace Opm #endif // FLOW_BLACKOIL_TPFA_HPP diff --git a/flow/flow_blackoil_alugrid.cpp b/flow/flow_blackoil_alugrid.cpp index f18f1586521..02c401e5a6d 100644 --- a/flow/flow_blackoil_alugrid.cpp +++ b/flow/flow_blackoil_alugrid.cpp @@ -23,7 +23,7 @@ // can switch to it by defining the macro #define DISABLE_SFC_ORDERING 1. // This will change the default cell order to Cartesian. // Note that this option is not available for pre-built or installed versions of dune-ALUGrid. -// To enable changig to Cartesian ordering, you will need to rebuild dune-ALUGrid from source, ensuring +// To enable changig to Cartesian ordering, you will need to rebuild dune-ALUGrid from source, ensuring // the build configuration allows disabling SFC ordering from OPM. // For more details, refer to the files gridfactory.hh and aluinline.hh located in the dune-alugrid/3d/ @@ -46,43 +46,47 @@ #include #include -namespace Opm { -namespace Properties { -namespace TTag { -struct FlowProblemAlugrid { - using InheritsFrom = std::tuple; -}; -} +namespace Opm +{ +namespace Properties +{ + namespace TTag + { + struct FlowProblemAlugrid { + using InheritsFrom = std::tuple; + }; + } // namespace TTag -template -struct Grid { - static const int dim = 3; + template + struct Grid { + static const int dim = 3; #if HAVE_MPI - using type = Dune::ALUGrid; + using type = Dune::ALUGrid; #else - using type = Dune::ALUGrid; + using type = Dune::ALUGrid; #endif -}; + }; -// alugrid need cp grid as equilgrid -template -struct EquilGrid { - using type = Dune::CpGrid; -}; -template -struct Vanguard { - using type = Opm::AluGridVanguard; -}; -} + // alugrid need cp grid as equilgrid + template + struct EquilGrid { + using type = Dune::CpGrid; + }; + template + struct Vanguard { + using type = Opm::AluGridVanguard; + }; +} // namespace Properties -template<> -class SupportsFaceTag> - : public std::bool_constant -{}; +template <> +class SupportsFaceTag> : public std::bool_constant +{ +}; -} +} // namespace Opm -int main(int argc, char** argv) +int +main(int argc, char** argv) { using TypeTag = Opm::Properties::TTag::FlowProblemAlugrid; auto mainObject = std::make_unique(argc, argv); diff --git a/flow/flow_blackoil_float_main.cpp b/flow/flow_blackoil_float_main.cpp index 7855fb8bb1c..e2e89ed32a7 100644 --- a/flow/flow_blackoil_float_main.cpp +++ b/flow/flow_blackoil_float_main.cpp @@ -18,20 +18,21 @@ */ #include -#include #include +#include -namespace Opm::Properties { - -template -struct Scalar +namespace Opm::Properties { + +template +struct Scalar { using type = float; }; -} +} // namespace Opm::Properties -int main(int argc, char** argv) +int +main(int argc, char** argv) { using TypeTag = Opm::Properties::TTag::FlowProblemTPFA; auto mainObject = Opm::Main(argc, argv); diff --git a/flow/flow_blackoil_legacyassembly.cpp b/flow/flow_blackoil_legacyassembly.cpp index 00ddd9e912b..0498c7abc54 100644 --- a/flow/flow_blackoil_legacyassembly.cpp +++ b/flow/flow_blackoil_legacyassembly.cpp @@ -19,10 +19,11 @@ #include #include -#include #include +#include -namespace Opm { +namespace Opm +{ std::unique_ptr> flowBlackoilMainInit(int argc, char** argv, bool outputCout, bool outputFiles) @@ -31,18 +32,19 @@ flowBlackoilMainInit(int argc, char** argv, bool outputCout, bool outputFiles) // with incorrect locale settings. resetLocale(); - return std::make_unique>( - argc, argv, outputCout, outputFiles); + return std::make_unique>(argc, argv, outputCout, outputFiles); } // ----------------- Main program ----------------- -int flowBlackoilMain(int argc, char** argv, bool outputCout, bool outputFiles) +int +flowBlackoilMain(int argc, char** argv, bool outputCout, bool outputFiles) { auto mainfunc = flowBlackoilMainInit(argc, argv, outputCout, outputFiles); return mainfunc->execute(); } -int flowBlackoilMainStandalone(int argc, char** argv) +int +flowBlackoilMainStandalone(int argc, char** argv) { using TypeTag = Properties::TTag::FlowProblem; auto mainObject = std::make_unique(argc, argv); @@ -52,4 +54,4 @@ int flowBlackoilMainStandalone(int argc, char** argv) return ret; } -} +} // namespace Opm diff --git a/flow/flow_blackoil_legacyassembly.hpp b/flow/flow_blackoil_legacyassembly.hpp index b94a9515f4b..0f6321fe48c 100644 --- a/flow/flow_blackoil_legacyassembly.hpp +++ b/flow/flow_blackoil_legacyassembly.hpp @@ -19,14 +19,23 @@ #include -namespace Opm { +namespace Opm +{ -template class FlowMain; +template +class FlowMain; -namespace Action { -class State; +namespace Action +{ + class State; } -namespace Properties { namespace TTag { struct FlowProblem; } } +namespace Properties +{ + namespace TTag + { + struct FlowProblem; + } +} // namespace Properties //! \brief Main function used in flow binary. int flowBlackoilMain(int argc, char** argv, bool outputCout, bool outputFiles); @@ -38,6 +47,6 @@ flowBlackoilMainInit(int argc, char** argv, bool outputCout, bool outputFiles); //! \brief Main function used in flow_blackoil binary. int flowBlackoilMainStandalone(int argc, char** argv); -} +} // namespace Opm #endif // FLOW_EBOS_BLACKOIL_HPP diff --git a/flow/flow_blackoil_legacyassembly_main.cpp b/flow/flow_blackoil_legacyassembly_main.cpp index 4c7b97f4c6e..1165af308d7 100644 --- a/flow/flow_blackoil_legacyassembly_main.cpp +++ b/flow/flow_blackoil_legacyassembly_main.cpp @@ -18,7 +18,8 @@ #include -int main(int argc, char** argv) +int +main(int argc, char** argv) { return Opm::flowBlackoilMainStandalone(argc, argv); } diff --git a/flow/flow_blackoil_main.cpp b/flow/flow_blackoil_main.cpp index f0b0cb37043..fef5cec5ece 100644 --- a/flow/flow_blackoil_main.cpp +++ b/flow/flow_blackoil_main.cpp @@ -19,7 +19,8 @@ #include -int main(int argc, char** argv) +int +main(int argc, char** argv) { return Opm::flowBlackoilTpfaMainStandalone(argc, argv); } diff --git a/flow/flow_blackoil_polyhedralgrid.cpp b/flow/flow_blackoil_polyhedralgrid.cpp index 70e3637bbc0..9d92a88145e 100644 --- a/flow/flow_blackoil_polyhedralgrid.cpp +++ b/flow/flow_blackoil_polyhedralgrid.cpp @@ -23,8 +23,8 @@ #include #include -#include #include +#include // these are not explicitly instanced in library #include @@ -36,47 +36,57 @@ #include #include -namespace Opm { -namespace Properties { - namespace TTag { +namespace Opm +{ +namespace Properties +{ + namespace TTag + { struct FlowProblemPoly { using InheritsFrom = std::tuple; }; - } + } // namespace TTag - template - struct Linearizer { using type = TpfaLinearizer; }; + template + struct Linearizer { + using type = TpfaLinearizer; + }; - template - struct LocalResidual { using type = BlackOilLocalResidualTPFA; }; + template + struct LocalResidual { + using type = BlackOilLocalResidualTPFA; + }; - template - struct EnableDiffusion { static constexpr bool value = false; }; + template + struct EnableDiffusion { + static constexpr bool value = false; + }; - template + template struct Grid { using type = Dune::PolyhedralGrid<3, 3>; }; - template + template struct EquilGrid { - //using type = Dune::CpGrid; + // using type = Dune::CpGrid; using type = GetPropType; }; - template + template struct Vanguard { using type = Opm::PolyhedralGridVanguard; }; -} +} // namespace Properties -template<> -class SupportsFaceTag> - : public std::bool_constant -{}; +template <> +class SupportsFaceTag> : public std::bool_constant +{ +}; -} +} // namespace Opm -int main(int argc, char** argv) +int +main(int argc, char** argv) { using TypeTag = Opm::Properties::TTag::FlowProblemPoly; auto mainObject = std::make_unique(argc, argv); diff --git a/flow/flow_brine.cpp b/flow/flow_brine.cpp index 0436d0d752f..90bf4498f64 100644 --- a/flow/flow_brine.cpp +++ b/flow/flow_brine.cpp @@ -18,39 +18,45 @@ #include -#include #include -#include +#include #include +#include -namespace Opm { -namespace Properties { -namespace TTag { -struct FlowBrineProblem { - using InheritsFrom = std::tuple; -}; -} -template -struct EnableBrine { - static constexpr bool value = true; -}; -}} +namespace Opm +{ +namespace Properties +{ + namespace TTag + { + struct FlowBrineProblem { + using InheritsFrom = std::tuple; + }; + } // namespace TTag + template + struct EnableBrine { + static constexpr bool value = true; + }; +} // namespace Properties +} // namespace Opm -namespace Opm { +namespace Opm +{ // ----------------- Main program ----------------- -int flowBrineMain(int argc, char** argv, bool outputCout, bool outputFiles) +int +flowBrineMain(int argc, char** argv, bool outputCout, bool outputFiles) { // we always want to use the default locale, and thus spare us the trouble // with incorrect locale settings. resetLocale(); - FlowMain - mainfunc {argc, argv, outputCout, outputFiles}; + FlowMain mainfunc {argc, argv, outputCout, outputFiles}; return mainfunc.execute(); } -int flowBrineMainStandalone(int argc, char** argv) +int +flowBrineMainStandalone(int argc, char** argv) { using TypeTag = Properties::TTag::FlowBrineProblem; auto mainObject = std::make_unique(argc, argv); @@ -60,4 +66,4 @@ int flowBrineMainStandalone(int argc, char** argv) return ret; } -} +} // namespace Opm diff --git a/flow/flow_brine.hpp b/flow/flow_brine.hpp index 7fff49a3d3f..6b54b5ede74 100644 --- a/flow/flow_brine.hpp +++ b/flow/flow_brine.hpp @@ -17,7 +17,8 @@ #ifndef FLOW_BRINE_HPP #define FLOW_BRINE_HPP -namespace Opm { +namespace Opm +{ //! \brief Main function used in flow binary. int flowBrineMain(int argc, char** argv, bool outputCout, bool outputFiles); @@ -25,6 +26,6 @@ int flowBrineMain(int argc, char** argv, bool outputCout, bool outputFiles); //! \brief Main function used in flow_brine binary. int flowBrineMainStandalone(int argc, char** argv); -} +} // namespace Opm #endif // FLOW_EBOS_HPP diff --git a/flow/flow_brine_energy.cpp b/flow/flow_brine_energy.cpp index ef42910e3c7..94cf8c394ea 100644 --- a/flow/flow_brine_energy.cpp +++ b/flow/flow_brine_energy.cpp @@ -17,24 +17,28 @@ #include "config.h" #include -namespace Opm { -namespace Properties { -namespace TTag { -struct FlowBrineEnergyProblem { - using InheritsFrom = std::tuple; -}; -} -template -struct EnableBrine { - static constexpr bool value = true; -}; -template -struct EnableEnergy { - static constexpr bool value = true; -}; -} +namespace Opm +{ +namespace Properties +{ + namespace TTag + { + struct FlowBrineEnergyProblem { + using InheritsFrom = std::tuple; + }; + } // namespace TTag + template + struct EnableBrine { + static constexpr bool value = true; + }; + template + struct EnableEnergy { + static constexpr bool value = true; + }; +} // namespace Properties -int flowBrineEnergyMain(int argc, char** argv) +int +flowBrineEnergyMain(int argc, char** argv) { using TypeTag = Opm::Properties::TTag::FlowBrineEnergyProblem; auto mainObject = std::make_unique(argc, argv); @@ -44,4 +48,4 @@ int flowBrineEnergyMain(int argc, char** argv) return ret; } -} +} // namespace Opm diff --git a/flow/flow_brine_energy.hpp b/flow/flow_brine_energy.hpp index 2c2f0d64bd3..480619d3c2b 100644 --- a/flow/flow_brine_energy.hpp +++ b/flow/flow_brine_energy.hpp @@ -18,8 +18,9 @@ #ifndef FLOW_BRINE_ENERGY_HPP #define FLOW_BRINE_ENERGY_HPP -namespace Opm { - int flowBrineEnergyMain(int argc, char** argv); +namespace Opm +{ +int flowBrineEnergyMain(int argc, char** argv); } #endif diff --git a/flow/flow_brine_energy_main.cpp b/flow/flow_brine_energy_main.cpp index 6dc288f4dd1..3aad3533838 100644 --- a/flow/flow_brine_energy_main.cpp +++ b/flow/flow_brine_energy_main.cpp @@ -17,7 +17,8 @@ #include "config.h" #include -int main(int argc, char** argv) +int +main(int argc, char** argv) { return Opm::flowBrineEnergyMain(argc, argv); } diff --git a/flow/flow_brine_main.cpp b/flow/flow_brine_main.cpp index baa927d31a8..5a992355112 100644 --- a/flow/flow_brine_main.cpp +++ b/flow/flow_brine_main.cpp @@ -18,7 +18,8 @@ #include -int main(int argc, char** argv) +int +main(int argc, char** argv) { return Opm::flowBrineMainStandalone(argc, argv); } diff --git a/flow/flow_brine_precsalt_vapwat.cpp b/flow/flow_brine_precsalt_vapwat.cpp index 5305500c2f5..5f072854a28 100644 --- a/flow/flow_brine_precsalt_vapwat.cpp +++ b/flow/flow_brine_precsalt_vapwat.cpp @@ -18,49 +18,55 @@ #include -#include #include -#include +#include #include +#include -namespace Opm { -namespace Properties { -namespace TTag { -struct FlowBrinePrecsaltVapwatProblem { - using InheritsFrom = std::tuple; -}; -} -template -struct EnableBrine { - static constexpr bool value = true; -}; +namespace Opm +{ +namespace Properties +{ + namespace TTag + { + struct FlowBrinePrecsaltVapwatProblem { + using InheritsFrom = std::tuple; + }; + } // namespace TTag + template + struct EnableBrine { + static constexpr bool value = true; + }; -template -struct EnableSaltPrecipitation { - static constexpr bool value = true; -}; + template + struct EnableSaltPrecipitation { + static constexpr bool value = true; + }; -template -struct EnableVapwat { - static constexpr bool value = true; -}; -}} + template + struct EnableVapwat { + static constexpr bool value = true; + }; +} // namespace Properties +} // namespace Opm -namespace Opm { +namespace Opm +{ // ----------------- Main program ----------------- -int flowBrinePrecsaltVapwatMain(int argc, char** argv, bool outputCout, bool outputFiles) +int +flowBrinePrecsaltVapwatMain(int argc, char** argv, bool outputCout, bool outputFiles) { // we always want to use the default locale, and thus spare us the trouble // with incorrect locale settings. resetLocale(); - FlowMain - mainfunc {argc, argv, outputCout, outputFiles}; + FlowMain mainfunc {argc, argv, outputCout, outputFiles}; return mainfunc.execute(); } -int flowBrinePrecsaltVapwatMainStandalone(int argc, char** argv) +int +flowBrinePrecsaltVapwatMainStandalone(int argc, char** argv) { using TypeTag = Properties::TTag::FlowBrinePrecsaltVapwatProblem; auto mainObject = std::make_unique(argc, argv); @@ -70,4 +76,4 @@ int flowBrinePrecsaltVapwatMainStandalone(int argc, char** argv) return ret; } -} +} // namespace Opm diff --git a/flow/flow_brine_precsalt_vapwat.hpp b/flow/flow_brine_precsalt_vapwat.hpp index 073d0c55747..0054058f9b3 100644 --- a/flow/flow_brine_precsalt_vapwat.hpp +++ b/flow/flow_brine_precsalt_vapwat.hpp @@ -17,7 +17,8 @@ #ifndef FLOW_BRINE_PRECSALT_VAPWAT_HPP #define FLOW_BRINE_PRECSALT_VAPWAT_HPP -namespace Opm { +namespace Opm +{ //! \brief Main function used in flow binary. int flowBrinePrecsaltVapwatMain(int argc, char** argv, bool outputCout, bool outputFiles); @@ -25,6 +26,6 @@ int flowBrinePrecsaltVapwatMain(int argc, char** argv, bool outputCout, bool out //! \brief Main function used in flow_brine binary. int flowBrinePrecsaltVapwatMainStandalone(int argc, char** argv); -} +} // namespace Opm #endif // FLOW_BRINE_PRECSALT_VAPWAT_HPP diff --git a/flow/flow_brine_precsalt_vapwat_main.cpp b/flow/flow_brine_precsalt_vapwat_main.cpp index 2fbb481230d..af5f9383613 100644 --- a/flow/flow_brine_precsalt_vapwat_main.cpp +++ b/flow/flow_brine_precsalt_vapwat_main.cpp @@ -18,7 +18,8 @@ #include -int main(int argc, char** argv) +int +main(int argc, char** argv) { return Opm::flowBrinePrecsaltVapwatMainStandalone(argc, argv); } diff --git a/flow/flow_brine_saltprecipitation.cpp b/flow/flow_brine_saltprecipitation.cpp index 9016fc52c08..2f984f59dc3 100644 --- a/flow/flow_brine_saltprecipitation.cpp +++ b/flow/flow_brine_saltprecipitation.cpp @@ -18,44 +18,50 @@ #include -#include #include -#include +#include #include +#include -namespace Opm { -namespace Properties { -namespace TTag { -struct FlowBrineSaltPrecipitationProblem { - using InheritsFrom = std::tuple; -}; -} -template -struct EnableBrine { - static constexpr bool value = true; -}; +namespace Opm +{ +namespace Properties +{ + namespace TTag + { + struct FlowBrineSaltPrecipitationProblem { + using InheritsFrom = std::tuple; + }; + } // namespace TTag + template + struct EnableBrine { + static constexpr bool value = true; + }; -template -struct EnableSaltPrecipitation { - static constexpr bool value = true; -}; -}} + template + struct EnableSaltPrecipitation { + static constexpr bool value = true; + }; +} // namespace Properties +} // namespace Opm -namespace Opm { +namespace Opm +{ // ----------------- Main program ----------------- -int flowBrineSaltPrecipitationMain(int argc, char** argv, bool outputCout, bool outputFiles) +int +flowBrineSaltPrecipitationMain(int argc, char** argv, bool outputCout, bool outputFiles) { // we always want to use the default locale, and thus spare us the trouble // with incorrect locale settings. resetLocale(); - FlowMain - mainfunc {argc, argv, outputCout, outputFiles}; + FlowMain mainfunc {argc, argv, outputCout, outputFiles}; return mainfunc.execute(); } -int flowBrineSaltPrecipitationMainStandalone(int argc, char** argv) +int +flowBrineSaltPrecipitationMainStandalone(int argc, char** argv) { using TypeTag = Properties::TTag::FlowBrineSaltPrecipitationProblem; auto mainObject = std::make_unique(argc, argv); @@ -65,4 +71,4 @@ int flowBrineSaltPrecipitationMainStandalone(int argc, char** argv) return ret; } -} +} // namespace Opm diff --git a/flow/flow_brine_saltprecipitation.hpp b/flow/flow_brine_saltprecipitation.hpp index 60fb736e971..1f2c6783984 100644 --- a/flow/flow_brine_saltprecipitation.hpp +++ b/flow/flow_brine_saltprecipitation.hpp @@ -17,7 +17,8 @@ #ifndef FLOW_BRINE_SALTPRECIPITATION_HPP #define FLOW_BRINE_SALTPRECIPITATION_HPP -namespace Opm { +namespace Opm +{ //! \brief Main function used in flow binary. int flowBrineSaltPrecipitationMain(int argc, char** argv, bool outputCout, bool outputFiles); @@ -25,6 +26,6 @@ int flowBrineSaltPrecipitationMain(int argc, char** argv, bool outputCout, bool //! \brief Main function used in flow_brine binary. int flowBrineSaltPrecipitationMainStandalone(int argc, char** argv); -} +} // namespace Opm #endif // FLOW_BRINE_HPP diff --git a/flow/flow_brine_saltprecipitation_main.cpp b/flow/flow_brine_saltprecipitation_main.cpp index 50175578ee3..81620b68219 100644 --- a/flow/flow_brine_saltprecipitation_main.cpp +++ b/flow/flow_brine_saltprecipitation_main.cpp @@ -18,7 +18,8 @@ #include -int main(int argc, char** argv) +int +main(int argc, char** argv) { return Opm::flowBrineSaltPrecipitationMainStandalone(argc, argv); } diff --git a/flow/flow_distribute_z.cpp b/flow/flow_distribute_z.cpp index 353ab833580..6c5df19c245 100644 --- a/flow/flow_distribute_z.cpp +++ b/flow/flow_distribute_z.cpp @@ -22,43 +22,41 @@ #include "config.h" -#include #include +#include -std::vector loadBalanceInZOnly(const Dune::CpGrid& grid) +std::vector +loadBalanceInZOnly(const Dune::CpGrid& grid) { auto cartMapper = Dune::CartesianIndexMapper(grid); auto dims = cartMapper.cartesianDimensions(); std::vector parts(grid.leafGridView().size(0)); - auto numCellsPerProc = dims[2]/grid.comm().size(); + auto numCellsPerProc = dims[2] / grid.comm().size(); - if (grid.size(0)>0 && numCellsPerProc == 0) - { - OPM_THROW(std::logic_error, - "cartesian grid must have more cells in z direction than number of processes."); + if (grid.size(0) > 0 && numCellsPerProc == 0) { + OPM_THROW(std::logic_error, "cartesian grid must have more cells in z direction than number of processes."); } - using ElementMapper = - Dune::MultipleCodimMultipleGeomTypeMapper; + using ElementMapper = Dune::MultipleCodimMultipleGeomTypeMapper; const auto& gridView = grid.leafGridView(); const auto& idSet = grid.localIdSet(); ElementMapper elemMapper(gridView, Dune::mcmgElementLayout()); - for( const auto &element : elements(gridView) ) - { + for (const auto& element : elements(gridView)) { const auto& id = idSet.id(element); unsigned elemIdx = elemMapper.index(element); const auto& cartIndex = cartMapper.cartesianIndex(elemIdx); - std::array cartCoord; + std::array cartCoord; cartMapper.cartesianCoordinate(cartIndex, cartCoord); using std::min; - auto rank = min(grid.comm().size() -1, cartCoord[2] / numCellsPerProc); + auto rank = min(grid.comm().size() - 1, cartCoord[2] / numCellsPerProc); parts[id] = rank; } return parts; } -int main(int argc, char** argv) +int +main(int argc, char** argv) { auto mainObject = std::make_unique(argc, argv); Opm::CpGridVanguard::setExternalLoadBalancer(loadBalanceInZOnly); @@ -67,4 +65,3 @@ int main(int argc, char** argv) mainObject.reset(); return ret; } - diff --git a/flow/flow_energy.cpp b/flow/flow_energy.cpp index 7ff67a65af7..09d21213a89 100644 --- a/flow/flow_energy.cpp +++ b/flow/flow_energy.cpp @@ -18,48 +18,58 @@ #include -#include #include -#include -#include +#include #include #include +#include +#include -namespace Opm { -namespace Properties { -namespace TTag { -struct FlowEnergyProblem { - using InheritsFrom = std::tuple; -}; -} +namespace Opm +{ +namespace Properties +{ + namespace TTag + { + struct FlowEnergyProblem { + using InheritsFrom = std::tuple; + }; + } // namespace TTag -template -struct EnableEnergy { - static constexpr bool value = true; -}; -template -struct Linearizer { using type = TpfaLinearizer; }; -template -struct LocalResidual { using type = BlackOilLocalResidualTPFA; }; + template + struct EnableEnergy { + static constexpr bool value = true; + }; + template + struct Linearizer { + using type = TpfaLinearizer; + }; + template + struct LocalResidual { + using type = BlackOilLocalResidualTPFA; + }; -}} +} // namespace Properties +} // namespace Opm -namespace Opm { +namespace Opm +{ // ----------------- Main program ----------------- -int flowEnergyMain(int argc, char** argv, bool outputCout, bool outputFiles) +int +flowEnergyMain(int argc, char** argv, bool outputCout, bool outputFiles) { // we always want to use the default locale, and thus spare us the trouble // with incorrect locale settings. resetLocale(); - FlowMain - mainfunc {argc, argv, outputCout, outputFiles}; + FlowMain mainfunc {argc, argv, outputCout, outputFiles}; return mainfunc.execute(); } -int flowEnergyMainStandalone(int argc, char** argv) +int +flowEnergyMainStandalone(int argc, char** argv) { using TypeTag = Properties::TTag::FlowEnergyProblem; auto mainObject = std::make_unique(argc, argv); @@ -69,4 +79,4 @@ int flowEnergyMainStandalone(int argc, char** argv) return ret; } -} +} // namespace Opm diff --git a/flow/flow_energy.hpp b/flow/flow_energy.hpp index 0af2be7451f..91c2506d3cf 100644 --- a/flow/flow_energy.hpp +++ b/flow/flow_energy.hpp @@ -17,7 +17,8 @@ #ifndef FLOW_ENERGY_HPP #define FLOW_ENERGY_HPP -namespace Opm { +namespace Opm +{ //! \brief Main function used in flow binary. int flowEnergyMain(int argc, char** argv, bool outputCout, bool outputFiles); @@ -25,6 +26,6 @@ int flowEnergyMain(int argc, char** argv, bool outputCout, bool outputFiles); //! \brief Main function used in flow_energy binary. int flowEnergyMainStandalone(int argc, char** argv); -} +} // namespace Opm #endif // FLOW_ENERGY_HPP diff --git a/flow/flow_energy_main.cpp b/flow/flow_energy_main.cpp index 3f9ee661efe..657adc2ecd1 100644 --- a/flow/flow_energy_main.cpp +++ b/flow/flow_energy_main.cpp @@ -18,7 +18,8 @@ #include -int main(int argc, char** argv) +int +main(int argc, char** argv) { return Opm::flowEnergyMainStandalone(argc, argv); } diff --git a/flow/flow_extbo.cpp b/flow/flow_extbo.cpp index 7c9340240ce..5e534fcb7c0 100644 --- a/flow/flow_extbo.cpp +++ b/flow/flow_extbo.cpp @@ -18,39 +18,45 @@ #include -#include #include -#include +#include #include +#include -namespace Opm { -namespace Properties { -namespace TTag { -struct FlowExtboProblem { - using InheritsFrom = std::tuple; -}; -} -template -struct EnableExtbo { - static constexpr bool value = true; -}; -}} +namespace Opm +{ +namespace Properties +{ + namespace TTag + { + struct FlowExtboProblem { + using InheritsFrom = std::tuple; + }; + } // namespace TTag + template + struct EnableExtbo { + static constexpr bool value = true; + }; +} // namespace Properties +} // namespace Opm -namespace Opm { +namespace Opm +{ // ----------------- Main program ----------------- -int flowExtboMain(int argc, char** argv, bool outputCout, bool outputFiles) +int +flowExtboMain(int argc, char** argv, bool outputCout, bool outputFiles) { // we always want to use the default locale, and thus spare us the trouble // with incorrect locale settings. resetLocale(); - FlowMain - mainfunc {argc, argv, outputCout, outputFiles}; + FlowMain mainfunc {argc, argv, outputCout, outputFiles}; return mainfunc.execute(); } -int flowExtboMainStandalone(int argc, char** argv) +int +flowExtboMainStandalone(int argc, char** argv) { using TypeTag = Properties::TTag::FlowExtboProblem; auto mainObject = std::make_unique(argc, argv); @@ -60,4 +66,4 @@ int flowExtboMainStandalone(int argc, char** argv) return ret; } -} +} // namespace Opm diff --git a/flow/flow_extbo.hpp b/flow/flow_extbo.hpp index 8f030f7dcf4..26ed08d3419 100644 --- a/flow/flow_extbo.hpp +++ b/flow/flow_extbo.hpp @@ -17,7 +17,8 @@ #ifndef FLOW_EXTBO_HPP #define FLOW_EXTBO_HPP -namespace Opm { +namespace Opm +{ //! \brief Main function used in flow binary. int flowExtboMain(int argc, char** argv, bool outputCout, bool outputFiles); @@ -25,6 +26,6 @@ int flowExtboMain(int argc, char** argv, bool outputCout, bool outputFiles); //! \brief Main function used in flow_extbo binary. int flowExtboMainStandalone(int argc, char** argv); -} +} // namespace Opm #endif // FLOW_EXTBO_HPP diff --git a/flow/flow_extbo_main.cpp b/flow/flow_extbo_main.cpp index 2e2b0950af8..38622cccacd 100644 --- a/flow/flow_extbo_main.cpp +++ b/flow/flow_extbo_main.cpp @@ -18,7 +18,8 @@ #include -int main(int argc, char** argv) +int +main(int argc, char** argv) { return Opm::flowExtboMainStandalone(argc, argv); } diff --git a/flow/flow_foam.cpp b/flow/flow_foam.cpp index 8e1109a165b..877109cc041 100644 --- a/flow/flow_foam.cpp +++ b/flow/flow_foam.cpp @@ -18,39 +18,45 @@ #include -#include #include -#include +#include #include +#include -namespace Opm { -namespace Properties { -namespace TTag { -struct FlowFoamProblem { - using InheritsFrom = std::tuple; -}; -} -template -struct EnableFoam { - static constexpr bool value = true; -}; -}} +namespace Opm +{ +namespace Properties +{ + namespace TTag + { + struct FlowFoamProblem { + using InheritsFrom = std::tuple; + }; + } // namespace TTag + template + struct EnableFoam { + static constexpr bool value = true; + }; +} // namespace Properties +} // namespace Opm -namespace Opm { +namespace Opm +{ // ----------------- Main program ----------------- -int flowFoamMain(int argc, char** argv, bool outputCout, bool outputFiles) +int +flowFoamMain(int argc, char** argv, bool outputCout, bool outputFiles) { // we always want to use the default locale, and thus spare us the trouble // with incorrect locale settings. resetLocale(); - FlowMain - mainfunc {argc, argv, outputCout, outputFiles}; + FlowMain mainfunc {argc, argv, outputCout, outputFiles}; return mainfunc.execute(); } -int flowFoamMainStandalone(int argc, char** argv) +int +flowFoamMainStandalone(int argc, char** argv) { using TypeTag = Properties::TTag::FlowFoamProblem; auto mainObject = std::make_unique(argc, argv); @@ -60,4 +66,4 @@ int flowFoamMainStandalone(int argc, char** argv) return ret; } -} +} // namespace Opm diff --git a/flow/flow_foam.hpp b/flow/flow_foam.hpp index d8db1c4c554..861ce7d0bd1 100644 --- a/flow/flow_foam.hpp +++ b/flow/flow_foam.hpp @@ -17,7 +17,8 @@ #ifndef FLOW_FOAM_HPP #define FLOW_FOAM_HPP -namespace Opm { +namespace Opm +{ //! \brief Main function used in flow binary. int flowFoamMain(int argc, char** argv, bool outputCout, bool outputFiles); @@ -25,6 +26,6 @@ int flowFoamMain(int argc, char** argv, bool outputCout, bool outputFiles); //! \brief Main function used in flow_foam binary. int flowFoamMainStandalone(int argc, char** argv); -} +} // namespace Opm #endif // FLOW_FOAM_HPP diff --git a/flow/flow_foam_main.cpp b/flow/flow_foam_main.cpp index 37e2cd9fec4..7d18c14f84d 100644 --- a/flow/flow_foam_main.cpp +++ b/flow/flow_foam_main.cpp @@ -18,7 +18,8 @@ #include -int main(int argc, char** argv) +int +main(int argc, char** argv) { return Opm::flowFoamMainStandalone(argc, argv); } diff --git a/flow/flow_gasoil.cpp b/flow/flow_gasoil.cpp index 252957a7e87..38f7b14e47b 100644 --- a/flow/flow_gasoil.cpp +++ b/flow/flow_gasoil.cpp @@ -22,68 +22,79 @@ #include #include -#include #include +#include #include #include -namespace Opm { -namespace Properties { -namespace TTag { -struct FlowGasOilProblem { - using InheritsFrom = std::tuple; -}; -} - -template -struct Linearizer { using type = TpfaLinearizer; }; - -template -struct LocalResidual { using type = BlackOilLocalResidualTPFA; }; - -template -struct EnableDiffusion { static constexpr bool value = false; }; - -//! The indices required by the model -template -struct Indices +namespace Opm +{ +namespace Properties +{ + namespace TTag + { + struct FlowGasOilProblem { + using InheritsFrom = std::tuple; + }; + } // namespace TTag + + template + struct Linearizer { + using type = TpfaLinearizer; + }; + + template + struct LocalResidual { + using type = BlackOilLocalResidualTPFA; + }; + + template + struct EnableDiffusion { + static constexpr bool value = false; + }; + + //! The indices required by the model + template + struct Indices { + private: + // it is unfortunately not possible to simply use 'TypeTag' here because this leads + // to cyclic definitions of some properties. if this happens the compiler error + // messages unfortunately are *really* confusing and not really helpful. + using BaseTypeTag = TTag::FlowProblem; + using FluidSystem = GetPropType; + + public: + using type = BlackOilTwoPhaseIndices(), + getPropValue(), + getPropValue(), + getPropValue(), + getPropValue(), + getPropValue(), + /*PVOffset=*/0, + /*disabledCompIdx=*/FluidSystem::waterCompIdx, + getPropValue()>; + }; +} // namespace Properties +} // namespace Opm + +namespace Opm { -private: - // it is unfortunately not possible to simply use 'TypeTag' here because this leads - // to cyclic definitions of some properties. if this happens the compiler error - // messages unfortunately are *really* confusing and not really helpful. - using BaseTypeTag = TTag::FlowProblem; - using FluidSystem = GetPropType; - -public: - using type = BlackOilTwoPhaseIndices(), - getPropValue(), - getPropValue(), - getPropValue(), - getPropValue(), - getPropValue(), - /*PVOffset=*/0, - /*disabledCompIdx=*/FluidSystem::waterCompIdx, - getPropValue()>; -}; -}} - -namespace Opm { // ----------------- Main program ----------------- -int flowGasOilMain(int argc, char** argv, bool outputCout, bool outputFiles) +int +flowGasOilMain(int argc, char** argv, bool outputCout, bool outputFiles) { // we always want to use the default locale, and thus spare us the trouble // with incorrect locale settings. resetLocale(); - FlowMain - mainfunc {argc, argv, outputCout, outputFiles} ; + FlowMain mainfunc {argc, argv, outputCout, outputFiles}; return mainfunc.execute(); } -int flowGasOilMainStandalone(int argc, char** argv) +int +flowGasOilMainStandalone(int argc, char** argv) { using TypeTag = Properties::TTag::FlowGasOilProblem; auto mainObject = std::make_unique(argc, argv); @@ -93,4 +104,4 @@ int flowGasOilMainStandalone(int argc, char** argv) return ret; } -} +} // namespace Opm diff --git a/flow/flow_gasoil.hpp b/flow/flow_gasoil.hpp index 331a5e8ae23..dc66a05e429 100644 --- a/flow/flow_gasoil.hpp +++ b/flow/flow_gasoil.hpp @@ -17,7 +17,8 @@ #ifndef FLOW_GASOIL_HPP #define FLOW_GASOIL_HPP -namespace Opm { +namespace Opm +{ //! \brief Main function used in flow binary. int flowGasOilMain(int argc, char** argv, bool outputCout, bool outputFiles); @@ -25,6 +26,6 @@ int flowGasOilMain(int argc, char** argv, bool outputCout, bool outputFiles); //! \brief Main function used in flow_gasoil binary. int flowGasOilMainStandalone(int argc, char** argv); -} +} // namespace Opm #endif // FLOW_GASOIL_HPP diff --git a/flow/flow_gasoil_energy.cpp b/flow/flow_gasoil_energy.cpp index 88c773dbca1..fcbc7e4f8d5 100644 --- a/flow/flow_gasoil_energy.cpp +++ b/flow/flow_gasoil_energy.cpp @@ -22,74 +22,87 @@ #include #include -#include -#include #include #include +#include +#include -namespace Opm { -namespace Properties { -namespace TTag { -struct FlowGasOilEnergyProblem { - using InheritsFrom = std::tuple; -}; -} - -//! The indices required by the model -template -struct Indices +namespace Opm +{ +namespace Properties +{ + namespace TTag + { + struct FlowGasOilEnergyProblem { + using InheritsFrom = std::tuple; + }; + } // namespace TTag + + //! The indices required by the model + template + struct Indices { + private: + // it is unfortunately not possible to simply use 'TypeTag' here because this leads + // to cyclic definitions of some properties. if this happens the compiler error + // messages unfortunately are *really* confusing and not really helpful. + using BaseTypeTag = TTag::FlowProblem; + using FluidSystem = GetPropType; + + public: + using type = BlackOilTwoPhaseIndices(), + getPropValue(), + getPropValue(), + getPropValue(), + getPropValue(), + getPropValue(), + /*PVOffset=*/0, + /*disabledCompIdx=*/FluidSystem::waterCompIdx, + getPropValue()>; + }; + template + struct EnableEnergy { + static constexpr bool value = true; + }; + template + struct Linearizer { + using type = TpfaLinearizer; + }; + + template + struct LocalResidual { + using type = BlackOilLocalResidualTPFA; + }; + + template + struct EnableDiffusion { + static constexpr bool value = true; + }; + + template + struct EnableDispersion { + static constexpr bool value = true; + }; + +} // namespace Properties +} // namespace Opm + +namespace Opm { -private: - // it is unfortunately not possible to simply use 'TypeTag' here because this leads - // to cyclic definitions of some properties. if this happens the compiler error - // messages unfortunately are *really* confusing and not really helpful. - using BaseTypeTag = TTag::FlowProblem; - using FluidSystem = GetPropType; - -public: - using type = BlackOilTwoPhaseIndices(), - getPropValue(), - getPropValue(), - getPropValue(), - getPropValue(), - getPropValue(), - /*PVOffset=*/0, - /*disabledCompIdx=*/FluidSystem::waterCompIdx, - getPropValue()>; -}; -template -struct EnableEnergy { - static constexpr bool value = true; -}; -template -struct Linearizer { using type = TpfaLinearizer; }; - -template -struct LocalResidual { using type = BlackOilLocalResidualTPFA; }; - -template -struct EnableDiffusion { static constexpr bool value = true; }; - -template -struct EnableDispersion { static constexpr bool value = true; }; - -}} - -namespace Opm { // ----------------- Main program ----------------- -int flowGasOilEnergyMain(int argc, char** argv, bool outputCout, bool outputFiles) +int +flowGasOilEnergyMain(int argc, char** argv, bool outputCout, bool outputFiles) { // we always want to use the default locale, and thus spare us the trouble // with incorrect locale settings. resetLocale(); - FlowMain - mainfunc {argc, argv, outputCout, outputFiles} ; + FlowMain mainfunc {argc, argv, outputCout, outputFiles}; return mainfunc.execute(); } -int flowGasOilEnergyMainStandalone(int argc, char** argv) +int +flowGasOilEnergyMainStandalone(int argc, char** argv) { using TypeTag = Properties::TTag::FlowGasOilEnergyProblem; auto mainObject = std::make_unique(argc, argv); @@ -99,4 +112,4 @@ int flowGasOilEnergyMainStandalone(int argc, char** argv) return ret; } -} +} // namespace Opm diff --git a/flow/flow_gasoil_energy.hpp b/flow/flow_gasoil_energy.hpp index 8be6061ac04..4c49685f836 100644 --- a/flow/flow_gasoil_energy.hpp +++ b/flow/flow_gasoil_energy.hpp @@ -17,7 +17,8 @@ #ifndef FLOW_GASOIL_ENERGY_HPP #define FLOW_GASOIL_ENERGY_HPP -namespace Opm { +namespace Opm +{ //! \brief Main function used in flow binary. int flowGasOilEnergyMain(int argc, char** argv, bool outputCout, bool outputFiles); @@ -25,6 +26,6 @@ int flowGasOilEnergyMain(int argc, char** argv, bool outputCout, bool outputFile //! \brief Main function used in flow_gasoil_energy binary. int flowGasOilEnergyMainStandalone(int argc, char** argv); -} +} // namespace Opm #endif // FLOW_GASOIL_ENERGY_HPP diff --git a/flow/flow_gasoil_energy_main.cpp b/flow/flow_gasoil_energy_main.cpp index 18050d2047c..9e824a7fcd6 100644 --- a/flow/flow_gasoil_energy_main.cpp +++ b/flow/flow_gasoil_energy_main.cpp @@ -18,7 +18,8 @@ #include -int main(int argc, char** argv) +int +main(int argc, char** argv) { return Opm::flowGasOilEnergyMainStandalone(argc, argv); } diff --git a/flow/flow_gasoil_main.cpp b/flow/flow_gasoil_main.cpp index a89a1237176..deb42846526 100644 --- a/flow/flow_gasoil_main.cpp +++ b/flow/flow_gasoil_main.cpp @@ -18,7 +18,8 @@ #include -int main(int argc, char** argv) +int +main(int argc, char** argv) { return Opm::flowGasOilMainStandalone(argc, argv); } diff --git a/flow/flow_gasoildiffuse.cpp b/flow/flow_gasoildiffuse.cpp index 99429e09194..bb9c1e2eb56 100644 --- a/flow/flow_gasoildiffuse.cpp +++ b/flow/flow_gasoildiffuse.cpp @@ -22,70 +22,83 @@ #include #include -#include -#include #include #include +#include +#include -namespace Opm { -namespace Properties { -namespace TTag { -struct FlowGasOilDiffuseProblem { - using InheritsFrom = std::tuple; -}; -} - -template -struct Linearizer { using type = TpfaLinearizer; }; - -template -struct LocalResidual { using type = BlackOilLocalResidualTPFA; }; - -template -struct EnableDiffusion { static constexpr bool value = true; }; - -template -struct EnableDispersion { static constexpr bool value = true; }; - -//! The indices required by the model -template -struct Indices +namespace Opm +{ +namespace Properties +{ + namespace TTag + { + struct FlowGasOilDiffuseProblem { + using InheritsFrom = std::tuple; + }; + } // namespace TTag + + template + struct Linearizer { + using type = TpfaLinearizer; + }; + + template + struct LocalResidual { + using type = BlackOilLocalResidualTPFA; + }; + + template + struct EnableDiffusion { + static constexpr bool value = true; + }; + + template + struct EnableDispersion { + static constexpr bool value = true; + }; + + //! The indices required by the model + template + struct Indices { + private: + // it is unfortunately not possible to simply use 'TypeTag' here because this leads + // to cyclic definitions of some properties. if this happens the compiler error + // messages unfortunately are *really* confusing and not really helpful. + using BaseTypeTag = TTag::FlowProblem; + using FluidSystem = GetPropType; + + public: + using type = BlackOilTwoPhaseIndices(), + getPropValue(), + getPropValue(), + getPropValue(), + getPropValue(), + getPropValue(), + /*PVOffset=*/0, + /*disabledCompIdx=*/FluidSystem::waterCompIdx, + getPropValue()>; + }; +} // namespace Properties +} // namespace Opm + +namespace Opm { -private: - // it is unfortunately not possible to simply use 'TypeTag' here because this leads - // to cyclic definitions of some properties. if this happens the compiler error - // messages unfortunately are *really* confusing and not really helpful. - using BaseTypeTag = TTag::FlowProblem; - using FluidSystem = GetPropType; - -public: - using type = BlackOilTwoPhaseIndices(), - getPropValue(), - getPropValue(), - getPropValue(), - getPropValue(), - getPropValue(), - /*PVOffset=*/0, - /*disabledCompIdx=*/FluidSystem::waterCompIdx, - getPropValue()>; -}; -}} - -namespace Opm { // ----------------- Main program ----------------- -int flowGasOilDiffuseMain(int argc, char** argv, bool outputCout, bool outputFiles) +int +flowGasOilDiffuseMain(int argc, char** argv, bool outputCout, bool outputFiles) { // we always want to use the default locale, and thus spare us the trouble // with incorrect locale settings. resetLocale(); - FlowMain - mainfunc {argc, argv, outputCout, outputFiles} ; + FlowMain mainfunc {argc, argv, outputCout, outputFiles}; return mainfunc.execute(); } -int flowGasOilDiffuseMainStandalone(int argc, char** argv) +int +flowGasOilDiffuseMainStandalone(int argc, char** argv) { using TypeTag = Properties::TTag::FlowGasOilDiffuseProblem; auto mainObject = std::make_unique(argc, argv); @@ -95,4 +108,4 @@ int flowGasOilDiffuseMainStandalone(int argc, char** argv) return ret; } -} +} // namespace Opm diff --git a/flow/flow_gasoildiffuse.hpp b/flow/flow_gasoildiffuse.hpp index 679a78b80fc..292cf1b2cc0 100644 --- a/flow/flow_gasoildiffuse.hpp +++ b/flow/flow_gasoildiffuse.hpp @@ -17,7 +17,8 @@ #ifndef FLOW_GASOILDIFFUSE_HPP #define FLOW_GASOILDIFFUSE_HPP -namespace Opm { +namespace Opm +{ //! \brief Main function used in flow binary. int flowGasOilDiffuseMain(int argc, char** argv, bool outputCout, bool outputFiles); @@ -25,6 +26,6 @@ int flowGasOilDiffuseMain(int argc, char** argv, bool outputCout, bool outputFil //! \brief Main function used in flow_gasoil binary. int flowGasOilDiffuseMainStandalone(int argc, char** argv); -} +} // namespace Opm #endif // FLOW_GASOILDIFFUSE_HPP diff --git a/flow/flow_gasoildiffuse_main.cpp b/flow/flow_gasoildiffuse_main.cpp index de057257ebe..dd443805f48 100644 --- a/flow/flow_gasoildiffuse_main.cpp +++ b/flow/flow_gasoildiffuse_main.cpp @@ -18,7 +18,8 @@ #include -int main(int argc, char** argv) +int +main(int argc, char** argv) { return Opm::flowGasOilDiffuseMainStandalone(argc, argv); } diff --git a/flow/flow_gaswater.cpp b/flow/flow_gaswater.cpp index eb98ba7d958..e67b6de7113 100644 --- a/flow/flow_gaswater.cpp +++ b/flow/flow_gaswater.cpp @@ -25,64 +25,74 @@ #include #include -#include #include +#include #include #include -namespace Opm { -namespace Properties { - -template -struct Linearizer { using type = TpfaLinearizer; }; - -template -struct LocalResidual { using type = BlackOilLocalResidualTPFA; }; - -template -struct EnableDiffusion { static constexpr bool value = false; }; +namespace Opm +{ +namespace Properties +{ -//! The indices required by the model -template -struct Indices + template + struct Linearizer { + using type = TpfaLinearizer; + }; + + template + struct LocalResidual { + using type = BlackOilLocalResidualTPFA; + }; + + template + struct EnableDiffusion { + static constexpr bool value = false; + }; + + //! The indices required by the model + template + struct Indices { + private: + // it is unfortunately not possible to simply use 'TypeTag' here because this leads + // to cyclic definitions of some properties. if this happens the compiler error + // messages unfortunately are *really* confusing and not really helpful. + using BaseTypeTag = TTag::FlowProblem; + using FluidSystem = GetPropType; + + public: + using type = BlackOilTwoPhaseIndices(), + getPropValue(), + getPropValue(), + getPropValue(), + getPropValue(), + getPropValue(), + /*PVOffset=*/0, + /*disabledCompIdx=*/FluidSystem::oilCompIdx, + getPropValue()>; + }; +} // namespace Properties +} // namespace Opm + +namespace Opm { -private: - // it is unfortunately not possible to simply use 'TypeTag' here because this leads - // to cyclic definitions of some properties. if this happens the compiler error - // messages unfortunately are *really* confusing and not really helpful. - using BaseTypeTag = TTag::FlowProblem; - using FluidSystem = GetPropType; - -public: - using type = BlackOilTwoPhaseIndices(), - getPropValue(), - getPropValue(), - getPropValue(), - getPropValue(), - getPropValue(), - /*PVOffset=*/0, - /*disabledCompIdx=*/FluidSystem::oilCompIdx, - getPropValue()>; -}; -}} - -namespace Opm { // ----------------- Main program ----------------- -int flowGasWaterMain(int argc, char** argv, bool outputCout, bool outputFiles) +int +flowGasWaterMain(int argc, char** argv, bool outputCout, bool outputFiles) { // we always want to use the default locale, and thus spare us the trouble // with incorrect locale settings. resetLocale(); - FlowMain - mainfunc {argc, argv, outputCout, outputFiles} ; + FlowMain mainfunc {argc, argv, outputCout, outputFiles}; return mainfunc.execute(); } -int flowGasWaterMainStandalone(int argc, char** argv) +int +flowGasWaterMainStandalone(int argc, char** argv) { using TypeTag = Properties::TTag::FlowGasWaterProblem; auto mainObject = std::make_unique(argc, argv); @@ -99,8 +109,7 @@ flowGasWaterMainInit(int argc, char** argv, bool outputCout, bool outputFiles) // with incorrect locale settings. resetLocale(); - return std::make_unique>( - argc, argv, outputCout, outputFiles); + return std::make_unique>(argc, argv, outputCout, outputFiles); } -} +} // namespace Opm diff --git a/flow/flow_gaswater.hpp b/flow/flow_gaswater.hpp index 15c9a1f6141..da6efb4e755 100644 --- a/flow/flow_gaswater.hpp +++ b/flow/flow_gaswater.hpp @@ -21,7 +21,8 @@ #include -namespace Opm { +namespace Opm +{ //! \brief Main function used in flow binary. int flowGasWaterMain(int argc, char** argv, bool outputCout, bool outputFiles); @@ -29,10 +30,11 @@ int flowGasWaterMain(int argc, char** argv, bool outputCout, bool outputFiles); //! \brief Main function used in flow_gaswater binary. int flowGasWaterMainStandalone(int argc, char** argv); -template class FlowMain; +template +class FlowMain; std::unique_ptr> flowGasWaterMainInit(int argc, char** argv, bool outputCout, bool outputFiles); -} +} // namespace Opm #endif // FLOW_GASWATER_HPP diff --git a/flow/flow_gaswater_brine.cpp b/flow/flow_gaswater_brine.cpp index bdd12e7b0b7..bc531da834a 100644 --- a/flow/flow_gaswater_brine.cpp +++ b/flow/flow_gaswater_brine.cpp @@ -22,67 +22,72 @@ #include #include -#include #include +#include -namespace Opm { -namespace Properties { -namespace TTag { -struct FlowGasWaterBrineProblem { - using InheritsFrom = std::tuple; -}; -} -template -struct EnableBrine { - static constexpr bool value = true; -}; -template -struct EnableDisgasInWater { - static constexpr bool value = true; -}; -template -struct EnableVapwat { - static constexpr bool value = true; -}; -//! The indices required by the model -template -struct Indices +namespace Opm { -private: - // it is unfortunately not possible to simply use 'TypeTag' here because this leads - // to cyclic definitions of some properties. if this happens the compiler error - // messages unfortunately are *really* confusing and not really helpful. - using BaseTypeTag = TTag::FlowProblem; - using FluidSystem = GetPropType; +namespace Properties +{ + namespace TTag + { + struct FlowGasWaterBrineProblem { + using InheritsFrom = std::tuple; + }; + } // namespace TTag + template + struct EnableBrine { + static constexpr bool value = true; + }; + template + struct EnableDisgasInWater { + static constexpr bool value = true; + }; + template + struct EnableVapwat { + static constexpr bool value = true; + }; + //! The indices required by the model + template + struct Indices { + private: + // it is unfortunately not possible to simply use 'TypeTag' here because this leads + // to cyclic definitions of some properties. if this happens the compiler error + // messages unfortunately are *really* confusing and not really helpful. + using BaseTypeTag = TTag::FlowProblem; + using FluidSystem = GetPropType; -public: - using type = BlackOilTwoPhaseIndices(), - getPropValue(), - getPropValue(), - getPropValue(), - getPropValue(), - getPropValue(), - /*PVOffset=*/0, - /*disabledCompIdx=*/FluidSystem::oilCompIdx, - getPropValue()>; -}; -}} + public: + using type = BlackOilTwoPhaseIndices(), + getPropValue(), + getPropValue(), + getPropValue(), + getPropValue(), + getPropValue(), + /*PVOffset=*/0, + /*disabledCompIdx=*/FluidSystem::oilCompIdx, + getPropValue()>; + }; +} // namespace Properties +} // namespace Opm -namespace Opm { +namespace Opm +{ // ----------------- Main program ----------------- -int flowGasWaterBrineMain(int argc, char** argv, bool outputCout, bool outputFiles) +int +flowGasWaterBrineMain(int argc, char** argv, bool outputCout, bool outputFiles) { // we always want to use the default locale, and thus spare us the trouble // with incorrect locale settings. resetLocale(); - FlowMain - mainfunc {argc, argv, outputCout, outputFiles}; + FlowMain mainfunc {argc, argv, outputCout, outputFiles}; return mainfunc.execute(); } -int flowGasWaterBrineMainStandalone(int argc, char** argv) +int +flowGasWaterBrineMainStandalone(int argc, char** argv) { using TypeTag = Properties::TTag::FlowGasWaterBrineProblem; auto mainObject = std::make_unique(argc, argv); @@ -92,4 +97,4 @@ int flowGasWaterBrineMainStandalone(int argc, char** argv) return ret; } -} +} // namespace Opm diff --git a/flow/flow_gaswater_brine.hpp b/flow/flow_gaswater_brine.hpp index 385cfb7b56d..573552f2c32 100644 --- a/flow/flow_gaswater_brine.hpp +++ b/flow/flow_gaswater_brine.hpp @@ -17,7 +17,8 @@ #ifndef FLOW_GASWATER_BRINE_HPP #define FLOW_GASWATER_BRINE_HPP -namespace Opm { +namespace Opm +{ //! \brief Main function used in flow binary. int flowGasWaterBrineMain(int argc, char** argv, bool outputCout, bool outputFiles); @@ -25,6 +26,6 @@ int flowGasWaterBrineMain(int argc, char** argv, bool outputCout, bool outputFil //! \brief Main function used in flow_gaswater_brine binary. int flowGasWaterBrineMainStandalone(int argc, char** argv); -} +} // namespace Opm #endif // FLOW_GASWATER_BRINE_HPP diff --git a/flow/flow_gaswater_brine_main.cpp b/flow/flow_gaswater_brine_main.cpp index 3b902f3f961..c37a087310b 100644 --- a/flow/flow_gaswater_brine_main.cpp +++ b/flow/flow_gaswater_brine_main.cpp @@ -18,7 +18,8 @@ #include -int main(int argc, char** argv) +int +main(int argc, char** argv) { return Opm::flowGasWaterBrineMainStandalone(argc, argv); } diff --git a/flow/flow_gaswater_dissolution.cpp b/flow/flow_gaswater_dissolution.cpp index 954a75dbac3..28f4567fd8e 100644 --- a/flow/flow_gaswater_dissolution.cpp +++ b/flow/flow_gaswater_dissolution.cpp @@ -25,79 +25,90 @@ #include #include -#include #include +#include #include #include -namespace Opm { -namespace Properties { -namespace TTag { -struct FlowGasWaterDissolutionProblem { - using InheritsFrom = std::tuple; -}; -} - -template -struct Linearizer { using type = TpfaLinearizer; }; - -template -struct LocalResidual { using type = BlackOilLocalResidualTPFA; }; - -template -struct EnableDiffusion { static constexpr bool value = false; }; - -template -struct EnableDisgasInWater { - static constexpr bool value = true; -}; - -template -struct EnableVapwat { - static constexpr bool value = true; -}; - -//! The indices required by the model -template -struct Indices +namespace Opm +{ +namespace Properties +{ + namespace TTag + { + struct FlowGasWaterDissolutionProblem { + using InheritsFrom = std::tuple; + }; + } // namespace TTag + + template + struct Linearizer { + using type = TpfaLinearizer; + }; + + template + struct LocalResidual { + using type = BlackOilLocalResidualTPFA; + }; + + template + struct EnableDiffusion { + static constexpr bool value = false; + }; + + template + struct EnableDisgasInWater { + static constexpr bool value = true; + }; + + template + struct EnableVapwat { + static constexpr bool value = true; + }; + + //! The indices required by the model + template + struct Indices { + private: + // it is unfortunately not possible to simply use 'TypeTag' here because this leads + // to cyclic definitions of some properties. if this happens the compiler error + // messages unfortunately are *really* confusing and not really helpful. + using BaseTypeTag = TTag::FlowProblem; + using FluidSystem = GetPropType; + + public: + using type = BlackOilTwoPhaseIndices(), + getPropValue(), + getPropValue(), + getPropValue(), + getPropValue(), + getPropValue(), + /*PVOffset=*/0, + /*disabledCompIdx=*/FluidSystem::oilCompIdx, + getPropValue()>; + }; +} // namespace Properties +} // namespace Opm + +namespace Opm { -private: - // it is unfortunately not possible to simply use 'TypeTag' here because this leads - // to cyclic definitions of some properties. if this happens the compiler error - // messages unfortunately are *really* confusing and not really helpful. - using BaseTypeTag = TTag::FlowProblem; - using FluidSystem = GetPropType; - -public: - using type = BlackOilTwoPhaseIndices(), - getPropValue(), - getPropValue(), - getPropValue(), - getPropValue(), - getPropValue(), - /*PVOffset=*/0, - /*disabledCompIdx=*/FluidSystem::oilCompIdx, - getPropValue()>; -}; -}} - -namespace Opm { // ----------------- Main program ----------------- -int flowGasWaterDissolutionMain(int argc, char** argv, bool outputCout, bool outputFiles) +int +flowGasWaterDissolutionMain(int argc, char** argv, bool outputCout, bool outputFiles) { // we always want to use the default locale, and thus spare us the trouble // with incorrect locale settings. resetLocale(); - FlowMain - mainfunc {argc, argv, outputCout, outputFiles} ; + FlowMain mainfunc {argc, argv, outputCout, outputFiles}; return mainfunc.execute(); } -int flowGasWaterDissolutionMainStandalone(int argc, char** argv) +int +flowGasWaterDissolutionMainStandalone(int argc, char** argv) { using TypeTag = Properties::TTag::FlowGasWaterDissolutionProblem; auto mainObject = std::make_unique(argc, argv); @@ -107,4 +118,4 @@ int flowGasWaterDissolutionMainStandalone(int argc, char** argv) return ret; } -} +} // namespace Opm diff --git a/flow/flow_gaswater_dissolution.hpp b/flow/flow_gaswater_dissolution.hpp index a86393b7769..d21cc3938a9 100644 --- a/flow/flow_gaswater_dissolution.hpp +++ b/flow/flow_gaswater_dissolution.hpp @@ -17,7 +17,8 @@ #ifndef FLOW_GASWATER_DISSOLUTION_HPP #define FLOW_GASWATER_DISSOLUTION_HPP -namespace Opm { +namespace Opm +{ //! \brief Main function used in flow binary. int flowGasWaterDissolutionMain(int argc, char** argv, bool outputCout, bool outputFiles); @@ -25,6 +26,6 @@ int flowGasWaterDissolutionMain(int argc, char** argv, bool outputCout, bool out //! \brief Main function used in flow_gaswater_dissolution binary. int flowGasWaterDissolutionMainStandalone(int argc, char** argv); -} +} // namespace Opm #endif // FLOW_GASWATER_DISSOLUTION_HPP diff --git a/flow/flow_gaswater_dissolution_diffuse.cpp b/flow/flow_gaswater_dissolution_diffuse.cpp index 19e7fcd46ba..cb2346d0d2e 100644 --- a/flow/flow_gaswater_dissolution_diffuse.cpp +++ b/flow/flow_gaswater_dissolution_diffuse.cpp @@ -25,82 +25,95 @@ #include #include -#include #include +#include #include #include -namespace Opm { -namespace Properties { -namespace TTag { -struct FlowGasWaterDissolutionDiffuseProblem { - using InheritsFrom = std::tuple; -}; -} - -template -struct Linearizer { using type = TpfaLinearizer; }; - -template -struct LocalResidual { using type = BlackOilLocalResidualTPFA; }; - -template -struct EnableDiffusion { static constexpr bool value = true; }; - -template -struct EnableDispersion { static constexpr bool value = true; }; - -template -struct EnableDisgasInWater { - static constexpr bool value = true; -}; - -template -struct EnableVapwat { - static constexpr bool value = true; -}; - -//! The indices required by the model -template -struct Indices +namespace Opm +{ +namespace Properties +{ + namespace TTag + { + struct FlowGasWaterDissolutionDiffuseProblem { + using InheritsFrom = std::tuple; + }; + } // namespace TTag + + template + struct Linearizer { + using type = TpfaLinearizer; + }; + + template + struct LocalResidual { + using type = BlackOilLocalResidualTPFA; + }; + + template + struct EnableDiffusion { + static constexpr bool value = true; + }; + + template + struct EnableDispersion { + static constexpr bool value = true; + }; + + template + struct EnableDisgasInWater { + static constexpr bool value = true; + }; + + template + struct EnableVapwat { + static constexpr bool value = true; + }; + + //! The indices required by the model + template + struct Indices { + private: + // it is unfortunately not possible to simply use 'TypeTag' here because this leads + // to cyclic definitions of some properties. if this happens the compiler error + // messages unfortunately are *really* confusing and not really helpful. + using BaseTypeTag = TTag::FlowProblem; + using FluidSystem = GetPropType; + + public: + using type = BlackOilTwoPhaseIndices(), + getPropValue(), + getPropValue(), + getPropValue(), + getPropValue(), + getPropValue(), + /*PVOffset=*/0, + /*disabledCompIdx=*/FluidSystem::oilCompIdx, + getPropValue()>; + }; +} // namespace Properties +} // namespace Opm + +namespace Opm { -private: - // it is unfortunately not possible to simply use 'TypeTag' here because this leads - // to cyclic definitions of some properties. if this happens the compiler error - // messages unfortunately are *really* confusing and not really helpful. - using BaseTypeTag = TTag::FlowProblem; - using FluidSystem = GetPropType; - -public: - using type = BlackOilTwoPhaseIndices(), - getPropValue(), - getPropValue(), - getPropValue(), - getPropValue(), - getPropValue(), - /*PVOffset=*/0, - /*disabledCompIdx=*/FluidSystem::oilCompIdx, - getPropValue()>; -}; -}} - -namespace Opm { // ----------------- Main program ----------------- -int flowGasWaterDissolutionDiffuseMain(int argc, char** argv, bool outputCout, bool outputFiles) +int +flowGasWaterDissolutionDiffuseMain(int argc, char** argv, bool outputCout, bool outputFiles) { // we always want to use the default locale, and thus spare us the trouble // with incorrect locale settings. resetLocale(); - FlowMain - mainfunc {argc, argv, outputCout, outputFiles} ; + FlowMain mainfunc {argc, argv, outputCout, outputFiles}; return mainfunc.execute(); } -int flowGasWaterDissolutionDiffuseMainStandalone(int argc, char** argv) +int +flowGasWaterDissolutionDiffuseMainStandalone(int argc, char** argv) { using TypeTag = Properties::TTag::FlowGasWaterDissolutionDiffuseProblem; auto mainObject = std::make_unique(argc, argv); @@ -110,4 +123,4 @@ int flowGasWaterDissolutionDiffuseMainStandalone(int argc, char** argv) return ret; } -} +} // namespace Opm diff --git a/flow/flow_gaswater_dissolution_diffuse.hpp b/flow/flow_gaswater_dissolution_diffuse.hpp index fabf1b9b11f..6c0f98c62ec 100644 --- a/flow/flow_gaswater_dissolution_diffuse.hpp +++ b/flow/flow_gaswater_dissolution_diffuse.hpp @@ -17,7 +17,8 @@ #ifndef FLOW_GASWATER_DISSOLUTION_DIFFUSE_HPP #define FLOW_GASWATER_DISSOLUTION_DIFFUSE_HPP -namespace Opm { +namespace Opm +{ //! \brief Main function used in flow binary. int flowGasWaterDissolutionDiffuseMain(int argc, char** argv, bool outputCout, bool outputFiles); @@ -25,6 +26,6 @@ int flowGasWaterDissolutionDiffuseMain(int argc, char** argv, bool outputCout, b //! \brief Main function used in flow_gaswater_dissolution binary. int flowGasWaterDissolutionDiffuseMainStandalone(int argc, char** argv); -} +} // namespace Opm #endif // FLOW_GASWATER_DISSOLUTION_DIFFUSE_HPP diff --git a/flow/flow_gaswater_dissolution_diffuse_main.cpp b/flow/flow_gaswater_dissolution_diffuse_main.cpp index c73b69ae168..ca340f9b59f 100644 --- a/flow/flow_gaswater_dissolution_diffuse_main.cpp +++ b/flow/flow_gaswater_dissolution_diffuse_main.cpp @@ -18,7 +18,8 @@ #include -int main(int argc, char** argv) +int +main(int argc, char** argv) { return Opm::flowGasWaterDissolutionDiffuseMainStandalone(argc, argv); } diff --git a/flow/flow_gaswater_dissolution_main.cpp b/flow/flow_gaswater_dissolution_main.cpp index b8ee199ca27..5c237b6984e 100644 --- a/flow/flow_gaswater_dissolution_main.cpp +++ b/flow/flow_gaswater_dissolution_main.cpp @@ -18,7 +18,8 @@ #include -int main(int argc, char** argv) +int +main(int argc, char** argv) { return Opm::flowGasWaterDissolutionMainStandalone(argc, argv); } diff --git a/flow/flow_gaswater_energy.cpp b/flow/flow_gaswater_energy.cpp index 8cdbd85d898..e4698245d9c 100644 --- a/flow/flow_gaswater_energy.cpp +++ b/flow/flow_gaswater_energy.cpp @@ -25,87 +25,100 @@ #include #include -#include #include +#include #include #include -namespace Opm { -namespace Properties { -namespace TTag { -struct FlowGasWaterEnergyProblem { - using InheritsFrom = std::tuple; -}; -} - -template -struct Linearizer { using type = TpfaLinearizer; }; - -template -struct LocalResidual { using type = BlackOilLocalResidualTPFA; }; - -template -struct EnableDiffusion { static constexpr bool value = true; }; - -template -struct EnableDispersion { static constexpr bool value = true; }; - -template -struct EnableEnergy { - static constexpr bool value = true; -}; - -template -struct EnableDisgasInWater { - static constexpr bool value = true; -}; - -template -struct EnableVapwat { - static constexpr bool value = true; -}; - -//! The indices required by the model -template -struct Indices +namespace Opm +{ +namespace Properties +{ + namespace TTag + { + struct FlowGasWaterEnergyProblem { + using InheritsFrom = std::tuple; + }; + } // namespace TTag + + template + struct Linearizer { + using type = TpfaLinearizer; + }; + + template + struct LocalResidual { + using type = BlackOilLocalResidualTPFA; + }; + + template + struct EnableDiffusion { + static constexpr bool value = true; + }; + + template + struct EnableDispersion { + static constexpr bool value = true; + }; + + template + struct EnableEnergy { + static constexpr bool value = true; + }; + + template + struct EnableDisgasInWater { + static constexpr bool value = true; + }; + + template + struct EnableVapwat { + static constexpr bool value = true; + }; + + //! The indices required by the model + template + struct Indices { + private: + // it is unfortunately not possible to simply use 'TypeTag' here because this leads + // to cyclic definitions of some properties. if this happens the compiler error + // messages unfortunately are *really* confusing and not really helpful. + using BaseTypeTag = TTag::FlowProblem; + using FluidSystem = GetPropType; + + public: + using type = BlackOilTwoPhaseIndices(), + getPropValue(), + getPropValue(), + getPropValue(), + getPropValue(), + getPropValue(), + /*PVOffset=*/0, + /*disabledCompIdx=*/FluidSystem::oilCompIdx, + getPropValue()>; + }; +} // namespace Properties +} // namespace Opm + +namespace Opm { -private: - // it is unfortunately not possible to simply use 'TypeTag' here because this leads - // to cyclic definitions of some properties. if this happens the compiler error - // messages unfortunately are *really* confusing and not really helpful. - using BaseTypeTag = TTag::FlowProblem; - using FluidSystem = GetPropType; - -public: - using type = BlackOilTwoPhaseIndices(), - getPropValue(), - getPropValue(), - getPropValue(), - getPropValue(), - getPropValue(), - /*PVOffset=*/0, - /*disabledCompIdx=*/FluidSystem::oilCompIdx, - getPropValue()>; -}; -}} - -namespace Opm { // ----------------- Main program ----------------- -int flowGasWaterEnergyMain(int argc, char** argv, bool outputCout, bool outputFiles) +int +flowGasWaterEnergyMain(int argc, char** argv, bool outputCout, bool outputFiles) { // we always want to use the default locale, and thus spare us the trouble // with incorrect locale settings. resetLocale(); - FlowMain - mainfunc {argc, argv, outputCout, outputFiles} ; + FlowMain mainfunc {argc, argv, outputCout, outputFiles}; return mainfunc.execute(); } -int flowGasWaterEnergyMainStandalone(int argc, char** argv) +int +flowGasWaterEnergyMainStandalone(int argc, char** argv) { using TypeTag = Properties::TTag::FlowGasWaterEnergyProblem; auto mainObject = std::make_unique(argc, argv); @@ -115,4 +128,4 @@ int flowGasWaterEnergyMainStandalone(int argc, char** argv) return ret; } -} +} // namespace Opm diff --git a/flow/flow_gaswater_energy.hpp b/flow/flow_gaswater_energy.hpp index 1c8b6827f73..decd5c24cc3 100644 --- a/flow/flow_gaswater_energy.hpp +++ b/flow/flow_gaswater_energy.hpp @@ -17,7 +17,8 @@ #ifndef FLOW_GASWATER_ENERGY_HPP #define FLOW_GASWATER_ENERGY_HPP -namespace Opm { +namespace Opm +{ //! \brief Main function used in flow binary. int flowGasWaterEnergyMain(int argc, char** argv, bool outputCout, bool outputFiles); @@ -25,6 +26,6 @@ int flowGasWaterEnergyMain(int argc, char** argv, bool outputCout, bool outputFi //! \brief Main function used in flow_gaswater binary. int flowGasWaterEnergyMainStandalone(int argc, char** argv); -} +} // namespace Opm #endif // FLOW_GASWATER_ENERGY_HPP diff --git a/flow/flow_gaswater_energy_main.cpp b/flow/flow_gaswater_energy_main.cpp index 68632bb329c..9ffea52a89d 100644 --- a/flow/flow_gaswater_energy_main.cpp +++ b/flow/flow_gaswater_energy_main.cpp @@ -18,7 +18,8 @@ #include -int main(int argc, char** argv) +int +main(int argc, char** argv) { return Opm::flowGasWaterEnergyMainStandalone(argc, argv); } diff --git a/flow/flow_gaswater_main.cpp b/flow/flow_gaswater_main.cpp index 0c8301e94ad..af17fc99683 100644 --- a/flow/flow_gaswater_main.cpp +++ b/flow/flow_gaswater_main.cpp @@ -18,7 +18,8 @@ #include -int main(int argc, char** argv) +int +main(int argc, char** argv) { return Opm::flowGasWaterMainStandalone(argc, argv); } diff --git a/flow/flow_gaswater_saltprec_energy.cpp b/flow/flow_gaswater_saltprec_energy.cpp index c9f58c23d64..acec1a5c26d 100644 --- a/flow/flow_gaswater_saltprec_energy.cpp +++ b/flow/flow_gaswater_saltprec_energy.cpp @@ -22,80 +22,85 @@ #include #include -#include #include +#include -namespace Opm { -namespace Properties { -namespace TTag { -struct FlowGasWaterSaltprecEnergyProblem { - using InheritsFrom = std::tuple; -}; -} -template -struct EnableBrine { - static constexpr bool value = true; -}; - -template -struct EnableSaltPrecipitation { - static constexpr bool value = true; -}; - -template -struct EnableVapwat { - static constexpr bool value = true; -}; - -template -struct EnableDisgasInWater { - static constexpr bool value = true; -}; - -template -struct EnableEnergy { - static constexpr bool value = true; -}; - -//! The indices required by the model -template -struct Indices +namespace Opm +{ +namespace Properties +{ + namespace TTag + { + struct FlowGasWaterSaltprecEnergyProblem { + using InheritsFrom = std::tuple; + }; + } // namespace TTag + template + struct EnableBrine { + static constexpr bool value = true; + }; + + template + struct EnableSaltPrecipitation { + static constexpr bool value = true; + }; + + template + struct EnableVapwat { + static constexpr bool value = true; + }; + + template + struct EnableDisgasInWater { + static constexpr bool value = true; + }; + + template + struct EnableEnergy { + static constexpr bool value = true; + }; + + //! The indices required by the model + template + struct Indices { + private: + // it is unfortunately not possible to simply use 'TypeTag' here because this leads + // to cyclic definitions of some properties. if this happens the compiler error + // messages unfortunately are *really* confusing and not really helpful. + using BaseTypeTag = TTag::FlowProblem; + using FluidSystem = GetPropType; + + public: + using type = BlackOilTwoPhaseIndices(), + getPropValue(), + getPropValue(), + getPropValue(), + getPropValue(), + getPropValue(), + /*PVOffset=*/0, + /*disabledCompIdx=*/FluidSystem::oilCompIdx, + getPropValue()>; + }; +} // namespace Properties +} // namespace Opm + +namespace Opm { -private: - // it is unfortunately not possible to simply use 'TypeTag' here because this leads - // to cyclic definitions of some properties. if this happens the compiler error - // messages unfortunately are *really* confusing and not really helpful. - using BaseTypeTag = TTag::FlowProblem; - using FluidSystem = GetPropType; - -public: - using type = BlackOilTwoPhaseIndices(), - getPropValue(), - getPropValue(), - getPropValue(), - getPropValue(), - getPropValue(), - /*PVOffset=*/0, - /*disabledCompIdx=*/FluidSystem::oilCompIdx, - getPropValue()>; -}; -}} - -namespace Opm { // ----------------- Main program ----------------- -int flowGasWaterSaltprecEnergyMain(int argc, char** argv, bool outputCout, bool outputFiles) +int +flowGasWaterSaltprecEnergyMain(int argc, char** argv, bool outputCout, bool outputFiles) { // we always want to use the default locale, and thus spare us the trouble // with incorrect locale settings. resetLocale(); - FlowMain - mainfunc {argc, argv, outputCout, outputFiles}; + FlowMain mainfunc {argc, argv, outputCout, outputFiles}; return mainfunc.execute(); } -int flowGasWaterSaltprecEnergyMainStandalone(int argc, char** argv) +int +flowGasWaterSaltprecEnergyMainStandalone(int argc, char** argv) { using TypeTag = Properties::TTag::FlowGasWaterSaltprecEnergyProblem; auto mainObject = std::make_unique(argc, argv); @@ -105,4 +110,4 @@ int flowGasWaterSaltprecEnergyMainStandalone(int argc, char** argv) return ret; } -} +} // namespace Opm diff --git a/flow/flow_gaswater_saltprec_energy.hpp b/flow/flow_gaswater_saltprec_energy.hpp index 50c5ccb3415..9d9fe65d0e6 100644 --- a/flow/flow_gaswater_saltprec_energy.hpp +++ b/flow/flow_gaswater_saltprec_energy.hpp @@ -17,7 +17,8 @@ #ifndef FLOW_GASWATER_SALTPREC_ENERGY_HPP #define FLOW_GASWATER_SALTPREC_ENERGY_HPP -namespace Opm { +namespace Opm +{ //! \brief Main function used in flow binary. int flowGasWaterSaltprecEnergyMain(int argc, char** argv, bool outputCout, bool outputFiles); @@ -25,6 +26,6 @@ int flowGasWaterSaltprecEnergyMain(int argc, char** argv, bool outputCout, bool //! \brief Main function used in flow_gaswater_saltprec_energy binary. int flowGasWaterSaltprecEnergyMainStandalone(int argc, char** argv); -} +} // namespace Opm #endif // FLOW_GASWATER_SALTPREC_ENERGY_HPP diff --git a/flow/flow_gaswater_saltprec_energy_main.cpp b/flow/flow_gaswater_saltprec_energy_main.cpp index 3db8516b00d..74a650d307b 100644 --- a/flow/flow_gaswater_saltprec_energy_main.cpp +++ b/flow/flow_gaswater_saltprec_energy_main.cpp @@ -18,7 +18,8 @@ #include -int main(int argc, char** argv) +int +main(int argc, char** argv) { return Opm::flowGasWaterSaltprecEnergyMainStandalone(argc, argv); } diff --git a/flow/flow_gaswater_saltprec_vapwat.cpp b/flow/flow_gaswater_saltprec_vapwat.cpp index 2fd1c1244e9..31b13c566af 100644 --- a/flow/flow_gaswater_saltprec_vapwat.cpp +++ b/flow/flow_gaswater_saltprec_vapwat.cpp @@ -22,75 +22,80 @@ #include #include -#include #include +#include -namespace Opm { -namespace Properties { -namespace TTag { -struct FlowGasWaterSaltprecVapwatProblem { - using InheritsFrom = std::tuple; -}; -} -template -struct EnableBrine { - static constexpr bool value = true; -}; - -template -struct EnableSaltPrecipitation { - static constexpr bool value = true; -}; - -template -struct EnableVapwat { - static constexpr bool value = true; -}; - -template -struct EnableDisgasInWater { - static constexpr bool value = true; -}; - -//! The indices required by the model -template -struct Indices +namespace Opm +{ +namespace Properties +{ + namespace TTag + { + struct FlowGasWaterSaltprecVapwatProblem { + using InheritsFrom = std::tuple; + }; + } // namespace TTag + template + struct EnableBrine { + static constexpr bool value = true; + }; + + template + struct EnableSaltPrecipitation { + static constexpr bool value = true; + }; + + template + struct EnableVapwat { + static constexpr bool value = true; + }; + + template + struct EnableDisgasInWater { + static constexpr bool value = true; + }; + + //! The indices required by the model + template + struct Indices { + private: + // it is unfortunately not possible to simply use 'TypeTag' here because this leads + // to cyclic definitions of some properties. if this happens the compiler error + // messages unfortunately are *really* confusing and not really helpful. + using BaseTypeTag = TTag::FlowProblem; + using FluidSystem = GetPropType; + + public: + using type = BlackOilTwoPhaseIndices(), + getPropValue(), + getPropValue(), + getPropValue(), + getPropValue(), + getPropValue(), + /*PVOffset=*/0, + /*disabledCompIdx=*/FluidSystem::oilCompIdx, + getPropValue()>; + }; +} // namespace Properties +} // namespace Opm + +namespace Opm { -private: - // it is unfortunately not possible to simply use 'TypeTag' here because this leads - // to cyclic definitions of some properties. if this happens the compiler error - // messages unfortunately are *really* confusing and not really helpful. - using BaseTypeTag = TTag::FlowProblem; - using FluidSystem = GetPropType; - -public: - using type = BlackOilTwoPhaseIndices(), - getPropValue(), - getPropValue(), - getPropValue(), - getPropValue(), - getPropValue(), - /*PVOffset=*/0, - /*disabledCompIdx=*/FluidSystem::oilCompIdx, - getPropValue()>; -}; -}} - -namespace Opm { // ----------------- Main program ----------------- -int flowGasWaterSaltprecVapwatMain(int argc, char** argv, bool outputCout, bool outputFiles) +int +flowGasWaterSaltprecVapwatMain(int argc, char** argv, bool outputCout, bool outputFiles) { // we always want to use the default locale, and thus spare us the trouble // with incorrect locale settings. resetLocale(); - FlowMain - mainfunc {argc, argv, outputCout, outputFiles}; + FlowMain mainfunc {argc, argv, outputCout, outputFiles}; return mainfunc.execute(); } -int flowGasWaterSaltprecVapwatMainStandalone(int argc, char** argv) +int +flowGasWaterSaltprecVapwatMainStandalone(int argc, char** argv) { using TypeTag = Properties::TTag::FlowGasWaterSaltprecVapwatProblem; auto mainObject = std::make_unique(argc, argv); @@ -100,4 +105,4 @@ int flowGasWaterSaltprecVapwatMainStandalone(int argc, char** argv) return ret; } -} +} // namespace Opm diff --git a/flow/flow_gaswater_saltprec_vapwat.hpp b/flow/flow_gaswater_saltprec_vapwat.hpp index b50d516cf6c..9077b6413f8 100644 --- a/flow/flow_gaswater_saltprec_vapwat.hpp +++ b/flow/flow_gaswater_saltprec_vapwat.hpp @@ -17,7 +17,8 @@ #ifndef FLOW_GASWATERSALTPRECVAPWAT_BRINE_HPP #define FLOW_GASWATERSALTPRECVAPWAT_BRINE_HPP -namespace Opm { +namespace Opm +{ //! \brief Main function used in flow binary. int flowGasWaterSaltprecVapwatMain(int argc, char** argv, bool outputCout, bool outputFiles); @@ -25,6 +26,6 @@ int flowGasWaterSaltprecVapwatMain(int argc, char** argv, bool outputCout, bool //! \brief Main function used in flow_gaswater_brine binary. int flowGasWaterSaltprecVapwatMainStandalone(int argc, char** argv); -} +} // namespace Opm #endif // FLOW_GASWATERSALTPRECVAPWAT_HPP diff --git a/flow/flow_gaswater_saltprec_vapwat_main.cpp b/flow/flow_gaswater_saltprec_vapwat_main.cpp index a9db14b4f42..502cd751acd 100644 --- a/flow/flow_gaswater_saltprec_vapwat_main.cpp +++ b/flow/flow_gaswater_saltprec_vapwat_main.cpp @@ -18,7 +18,8 @@ #include -int main(int argc, char** argv) +int +main(int argc, char** argv) { return Opm::flowGasWaterSaltprecVapwatMainStandalone(argc, argv); } diff --git a/flow/flow_gaswater_solvent.cpp b/flow/flow_gaswater_solvent.cpp index 31eafe750d5..0d3ff7d50ce 100644 --- a/flow/flow_gaswater_solvent.cpp +++ b/flow/flow_gaswater_solvent.cpp @@ -25,62 +25,67 @@ #include #include -#include #include +#include -namespace Opm { -namespace Properties { -namespace TTag { -struct FlowGasWaterSolventProblem { - using InheritsFrom = std::tuple; -}; -} - -template -struct EnableSolvent { - static constexpr bool value = true; -}; - -//! The indices required by the model -template -struct Indices +namespace Opm +{ +namespace Properties +{ + namespace TTag + { + struct FlowGasWaterSolventProblem { + using InheritsFrom = std::tuple; + }; + } // namespace TTag + + template + struct EnableSolvent { + static constexpr bool value = true; + }; + + //! The indices required by the model + template + struct Indices { + private: + // it is unfortunately not possible to simply use 'TypeTag' here because this leads + // to cyclic definitions of some properties. if this happens the compiler error + // messages unfortunately are *really* confusing and not really helpful. + using BaseTypeTag = TTag::FlowProblem; + using FluidSystem = GetPropType; + + public: + using type = BlackOilTwoPhaseIndices(), + getPropValue(), + getPropValue(), + getPropValue(), + getPropValue(), + getPropValue(), + /*PVOffset=*/0, + /*disabledCompIdx=*/FluidSystem::oilCompIdx, + getPropValue()>; + }; +} // namespace Properties +} // namespace Opm + +namespace Opm { -private: - // it is unfortunately not possible to simply use 'TypeTag' here because this leads - // to cyclic definitions of some properties. if this happens the compiler error - // messages unfortunately are *really* confusing and not really helpful. - using BaseTypeTag = TTag::FlowProblem; - using FluidSystem = GetPropType; - -public: - using type = BlackOilTwoPhaseIndices(), - getPropValue(), - getPropValue(), - getPropValue(), - getPropValue(), - getPropValue(), - /*PVOffset=*/0, - /*disabledCompIdx=*/FluidSystem::oilCompIdx, - getPropValue()>; -}; -}} - -namespace Opm { // ----------------- Main program ----------------- -int flowGasWaterSolventMain(int argc, char** argv, bool outputCout, bool outputFiles) +int +flowGasWaterSolventMain(int argc, char** argv, bool outputCout, bool outputFiles) { // we always want to use the default locale, and thus spare us the trouble // with incorrect locale settings. resetLocale(); - FlowMain - mainfunc {argc, argv, outputCout, outputFiles} ; + FlowMain mainfunc {argc, argv, outputCout, outputFiles}; return mainfunc.execute(); } -int flowGasWaterSolventMainStandalone(int argc, char** argv) +int +flowGasWaterSolventMainStandalone(int argc, char** argv) { using TypeTag = Properties::TTag::FlowGasWaterSolventProblem; auto mainObject = std::make_unique(argc, argv); @@ -90,4 +95,4 @@ int flowGasWaterSolventMainStandalone(int argc, char** argv) return ret; } -} +} // namespace Opm diff --git a/flow/flow_gaswater_solvent.hpp b/flow/flow_gaswater_solvent.hpp index 53f3a075e94..ed5fdbf85d9 100644 --- a/flow/flow_gaswater_solvent.hpp +++ b/flow/flow_gaswater_solvent.hpp @@ -17,7 +17,8 @@ #ifndef FLOW_GASWATER_SOLVENT_HPP #define FLOW_GASWATER_SOLVENT_HPP -namespace Opm { +namespace Opm +{ //! \brief Main function used in flow binary. int flowGasWaterSolventMain(int argc, char** argv, bool outputCout, bool outputFiles); @@ -25,6 +26,6 @@ int flowGasWaterSolventMain(int argc, char** argv, bool outputCout, bool outputF //! \brief Main function used in flow_gaswater_solvent binary. int flowGasWaterSolventMainStandalone(int argc, char** argv); -} +} // namespace Opm #endif // FLOW_GASWATER_SOLVENT_HPP diff --git a/flow/flow_gaswater_solvent_main.cpp b/flow/flow_gaswater_solvent_main.cpp index 19262d10196..05a5fa737e2 100644 --- a/flow/flow_gaswater_solvent_main.cpp +++ b/flow/flow_gaswater_solvent_main.cpp @@ -18,7 +18,8 @@ #include -int main(int argc, char** argv) +int +main(int argc, char** argv) { return Opm::flowGasWaterSolventMainStandalone(argc, argv); } diff --git a/flow/flow_micp.cpp b/flow/flow_micp.cpp index f746da2c4df..fd072cc1702 100644 --- a/flow/flow_micp.cpp +++ b/flow/flow_micp.cpp @@ -21,79 +21,92 @@ #include #include -#include #include +#include #include #include #include -namespace Opm { +namespace Opm +{ /*! * \brief Single-phase (water) flow problem including microbially induced calcite precipitation (MICP) * effects (three transported quantities: suspended microbes, oxygen, and urea, and two solid phases: * biofilm and calcite). */ -namespace Properties { -namespace TTag { -struct FlowMICPProblem { - using InheritsFrom = std::tuple; -}; -} -template -struct EnableBioeffects { - static constexpr bool value = true; -}; -template -struct Linearizer { using type = TpfaLinearizer; }; -template -struct LocalResidual { using type = BlackOilLocalResidualTPFA; }; -//! The indices required by the model -template -struct Indices +namespace Properties +{ + namespace TTag + { + struct FlowMICPProblem { + using InheritsFrom = std::tuple; + }; + } // namespace TTag + template + struct EnableBioeffects { + static constexpr bool value = true; + }; + template + struct Linearizer { + using type = TpfaLinearizer; + }; + template + struct LocalResidual { + using type = BlackOilLocalResidualTPFA; + }; + //! The indices required by the model + template + struct Indices { + private: + // it is unfortunately not possible to simply use 'TypeTag' here because this leads + // to cyclic definitions of some properties. if this happens the compiler error + // messages unfortunately are *really* confusing and not really helpful. + using BaseTypeTag = TTag::FlowProblem; + using FluidSystem = GetPropType; + + public: + using type = BlackOilOnePhaseIndices(), + getPropValue(), + getPropValue(), + getPropValue(), + getPropValue(), + getPropValue(), + /*PVOffset=*/0, + /*enabledCompIdx=*/FluidSystem::waterCompIdx, + 5>; // Five MICP components + }; + + template + struct EnableDiffusion { + static constexpr bool value = true; + }; + + template + struct EnableDispersion { + static constexpr bool value = true; + }; + +} // namespace Properties +} // namespace Opm + +namespace Opm { -private: - // it is unfortunately not possible to simply use 'TypeTag' here because this leads - // to cyclic definitions of some properties. if this happens the compiler error - // messages unfortunately are *really* confusing and not really helpful. - using BaseTypeTag = TTag::FlowProblem; - using FluidSystem = GetPropType; - -public: - using type = BlackOilOnePhaseIndices(), - getPropValue(), - getPropValue(), - getPropValue(), - getPropValue(), - getPropValue(), - /*PVOffset=*/0, - /*enabledCompIdx=*/FluidSystem::waterCompIdx, - 5>; //Five MICP components -}; - -template -struct EnableDiffusion { static constexpr bool value = true; }; - -template -struct EnableDispersion { static constexpr bool value = true; }; - -}} - -namespace Opm { // ----------------- Main program ----------------- -int flowMICPMain(int argc, char** argv, bool outputCout, bool outputFiles) +int +flowMICPMain(int argc, char** argv, bool outputCout, bool outputFiles) { // we always want to use the default locale, and thus spare us the trouble // with incorrect locale settings. resetLocale(); - FlowMain - mainfunc {argc, argv, outputCout, outputFiles}; + FlowMain mainfunc {argc, argv, outputCout, outputFiles}; return mainfunc.execute(); } -int flowMICPMainStandalone(int argc, char** argv) +int +flowMICPMainStandalone(int argc, char** argv) { using TypeTag = Properties::TTag::FlowMICPProblem; auto mainObject = std::make_unique(argc, argv); @@ -103,4 +116,4 @@ int flowMICPMainStandalone(int argc, char** argv) return ret; } -} +} // namespace Opm diff --git a/flow/flow_micp.hpp b/flow/flow_micp.hpp index 12c27f500d8..04f2cba4446 100644 --- a/flow/flow_micp.hpp +++ b/flow/flow_micp.hpp @@ -17,7 +17,8 @@ #ifndef FLOW_MICP_HPP #define FLOW_MICP_HPP -namespace Opm { +namespace Opm +{ //! \brief Main function used in flow binary. int flowMICPMain(int argc, char** argv, bool outputCout, bool outputFiles); @@ -25,6 +26,6 @@ int flowMICPMain(int argc, char** argv, bool outputCout, bool outputFiles); //! \brief Main function used in flow_micp binary. int flowMICPMainStandalone(int argc, char** argv); -} +} // namespace Opm #endif // FLOW_MICP_HPP diff --git a/flow/flow_micp_main.cpp b/flow/flow_micp_main.cpp index 2e2d6c65382..cb661029e1d 100644 --- a/flow/flow_micp_main.cpp +++ b/flow/flow_micp_main.cpp @@ -18,7 +18,8 @@ #include -int main(int argc, char** argv) +int +main(int argc, char** argv) { return Opm::flowMICPMainStandalone(argc, argv); } diff --git a/flow/flow_oilwater.cpp b/flow/flow_oilwater.cpp index 84283b30dfb..8447e894c2b 100644 --- a/flow/flow_oilwater.cpp +++ b/flow/flow_oilwater.cpp @@ -22,69 +22,80 @@ #include #include -#include #include +#include #include #include -namespace Opm { -namespace Properties { -namespace TTag { -struct FlowOilWaterProblem { - using InheritsFrom = std::tuple; -}; -} - -template -struct Linearizer { using type = TpfaLinearizer; }; - -template -struct LocalResidual { using type = BlackOilLocalResidualTPFA; }; - -template -struct EnableDiffusion { static constexpr bool value = false; }; - - -//! The indices required by the model -template -struct Indices +namespace Opm +{ +namespace Properties +{ + namespace TTag + { + struct FlowOilWaterProblem { + using InheritsFrom = std::tuple; + }; + } // namespace TTag + + template + struct Linearizer { + using type = TpfaLinearizer; + }; + + template + struct LocalResidual { + using type = BlackOilLocalResidualTPFA; + }; + + template + struct EnableDiffusion { + static constexpr bool value = false; + }; + + + //! The indices required by the model + template + struct Indices { + private: + // it is unfortunately not possible to simply use 'TypeTag' here because this leads + // to cyclic definitions of some properties. if this happens the compiler error + // messages unfortunately are *really* confusing and not really helpful. + using BaseTypeTag = TTag::FlowProblem; + using FluidSystem = GetPropType; + + public: + using type = BlackOilTwoPhaseIndices(), + getPropValue(), + getPropValue(), + getPropValue(), + getPropValue(), + getPropValue(), + /*PVOffset=*/0, + /*disabledCompIdx=*/FluidSystem::gasCompIdx, + getPropValue()>; + }; +} // namespace Properties +} // namespace Opm + +namespace Opm { -private: - // it is unfortunately not possible to simply use 'TypeTag' here because this leads - // to cyclic definitions of some properties. if this happens the compiler error - // messages unfortunately are *really* confusing and not really helpful. - using BaseTypeTag = TTag::FlowProblem; - using FluidSystem = GetPropType; - -public: - using type = BlackOilTwoPhaseIndices(), - getPropValue(), - getPropValue(), - getPropValue(), - getPropValue(), - getPropValue(), - /*PVOffset=*/0, - /*disabledCompIdx=*/FluidSystem::gasCompIdx, - getPropValue()>; -}; -}} - -namespace Opm { // ----------------- Main program ----------------- -int flowOilWaterMain(int argc, char** argv, bool outputCout, bool outputFiles) +int +flowOilWaterMain(int argc, char** argv, bool outputCout, bool outputFiles) { // we always want to use the default locale, and thus spare us the trouble // with incorrect locale settings. resetLocale(); - FlowMain - mainfunc {argc, argv, outputCout, outputFiles}; + FlowMain mainfunc {argc, argv, outputCout, outputFiles}; return mainfunc.execute(); } -int flowOilWaterMainStandalone(int argc, char** argv) +int +flowOilWaterMainStandalone(int argc, char** argv) { using TypeTag = Properties::TTag::FlowOilWaterProblem; auto mainObject = std::make_unique(argc, argv); @@ -94,4 +105,4 @@ int flowOilWaterMainStandalone(int argc, char** argv) return ret; } -} +} // namespace Opm diff --git a/flow/flow_oilwater.hpp b/flow/flow_oilwater.hpp index 93e616a1e7f..4f57020ffdf 100644 --- a/flow/flow_oilwater.hpp +++ b/flow/flow_oilwater.hpp @@ -17,7 +17,8 @@ #ifndef FLOW_OILWATER_HPP #define FLOW_OILWATER_HPP -namespace Opm { +namespace Opm +{ //! \brief Main functon used in main flow binary. int flowOilWaterMain(int argc, char** argv, bool outputCout, bool outputFiles); @@ -25,6 +26,6 @@ int flowOilWaterMain(int argc, char** argv, bool outputCout, bool outputFiles); //! \brief Main function used in flow_oilwater binary. int flowOilWaterMainStandalone(int argc, char** argv); -} +} // namespace Opm #endif // FLOW_OILWATER_HPP diff --git a/flow/flow_oilwater_brine.cpp b/flow/flow_oilwater_brine.cpp index e794bafca6c..8bf04aece60 100644 --- a/flow/flow_oilwater_brine.cpp +++ b/flow/flow_oilwater_brine.cpp @@ -22,59 +22,64 @@ #include #include -#include #include +#include -namespace Opm { -namespace Properties { -namespace TTag { -struct FlowOilWaterBrineProblem { - using InheritsFrom = std::tuple; -}; -} -template -struct EnableBrine { - static constexpr bool value = true; -}; -//! The indices required by the model -template -struct Indices +namespace Opm { -private: - // it is unfortunately not possible to simply use 'TypeTag' here because this leads - // to cyclic definitions of some properties. if this happens the compiler error - // messages unfortunately are *really* confusing and not really helpful. - using BaseTypeTag = TTag::FlowProblem; - using FluidSystem = GetPropType; +namespace Properties +{ + namespace TTag + { + struct FlowOilWaterBrineProblem { + using InheritsFrom = std::tuple; + }; + } // namespace TTag + template + struct EnableBrine { + static constexpr bool value = true; + }; + //! The indices required by the model + template + struct Indices { + private: + // it is unfortunately not possible to simply use 'TypeTag' here because this leads + // to cyclic definitions of some properties. if this happens the compiler error + // messages unfortunately are *really* confusing and not really helpful. + using BaseTypeTag = TTag::FlowProblem; + using FluidSystem = GetPropType; -public: - using type = BlackOilTwoPhaseIndices(), - getPropValue(), - getPropValue(), - getPropValue(), - getPropValue(), - getPropValue(), - /*PVOffset=*/0, - /*disabledCompIdx=*/FluidSystem::gasCompIdx, - getPropValue()>; -}; -}} + public: + using type = BlackOilTwoPhaseIndices(), + getPropValue(), + getPropValue(), + getPropValue(), + getPropValue(), + getPropValue(), + /*PVOffset=*/0, + /*disabledCompIdx=*/FluidSystem::gasCompIdx, + getPropValue()>; + }; +} // namespace Properties +} // namespace Opm -namespace Opm { +namespace Opm +{ // ----------------- Main program ----------------- -int flowOilWaterBrineMain(int argc, char** argv, bool outputCout, bool outputFiles) +int +flowOilWaterBrineMain(int argc, char** argv, bool outputCout, bool outputFiles) { // we always want to use the default locale, and thus spare us the trouble // with incorrect locale settings. resetLocale(); - FlowMain - mainfunc {argc, argv, outputCout, outputFiles}; + FlowMain mainfunc {argc, argv, outputCout, outputFiles}; return mainfunc.execute(); } -int flowOilWaterBrineMainStandalone(int argc, char** argv) +int +flowOilWaterBrineMainStandalone(int argc, char** argv) { using TypeTag = Properties::TTag::FlowOilWaterBrineProblem; auto mainObject = std::make_unique(argc, argv); @@ -84,4 +89,4 @@ int flowOilWaterBrineMainStandalone(int argc, char** argv) return ret; } -} +} // namespace Opm diff --git a/flow/flow_oilwater_brine.hpp b/flow/flow_oilwater_brine.hpp index d8c8f2b0641..02874d0e1b5 100644 --- a/flow/flow_oilwater_brine.hpp +++ b/flow/flow_oilwater_brine.hpp @@ -17,7 +17,8 @@ #ifndef FLOW_OILWATER_BRINE_HPP #define FLOW_OILWATER_BRINE_HPP -namespace Opm { +namespace Opm +{ //! \brief Main function used in flow binary. int flowOilWaterBrineMain(int argc, char** argv, bool outputCout, bool outputFiles); @@ -25,6 +26,6 @@ int flowOilWaterBrineMain(int argc, char** argv, bool outputCout, bool outputFil //! \brief Main function used in flow_oilwater_brine binary. int flowOilWaterBrineMainStandalone(int argc, char** argv); -} +} // namespace Opm #endif // FLOW_OILWATER_BRINE_HPP diff --git a/flow/flow_oilwater_brine_main.cpp b/flow/flow_oilwater_brine_main.cpp index 2881e0f3467..b6765603877 100644 --- a/flow/flow_oilwater_brine_main.cpp +++ b/flow/flow_oilwater_brine_main.cpp @@ -18,7 +18,8 @@ #include -int main(int argc, char** argv) +int +main(int argc, char** argv) { return Opm::flowOilWaterBrineMainStandalone(argc, argv); } diff --git a/flow/flow_oilwater_main.cpp b/flow/flow_oilwater_main.cpp index 5aa0e5c1f89..1390e961a6f 100644 --- a/flow/flow_oilwater_main.cpp +++ b/flow/flow_oilwater_main.cpp @@ -18,7 +18,8 @@ #include -int main(int argc, char** argv) +int +main(int argc, char** argv) { return Opm::flowOilWaterMainStandalone(argc, argv); } diff --git a/flow/flow_oilwater_polymer.cpp b/flow/flow_oilwater_polymer.cpp index 36266375138..006fe745a68 100644 --- a/flow/flow_oilwater_polymer.cpp +++ b/flow/flow_oilwater_polymer.cpp @@ -22,59 +22,64 @@ #include #include -#include #include +#include -namespace Opm { -namespace Properties { -namespace TTag { -struct FlowOilWaterPolymerProblem { - using InheritsFrom = std::tuple; -}; -} -template -struct EnablePolymer { - static constexpr bool value = true; -}; -//! The indices required by the model -template -struct Indices +namespace Opm { -private: - // it is unfortunately not possible to simply use 'TypeTag' here because this leads - // to cyclic definitions of some properties. if this happens the compiler error - // messages unfortunately are *really* confusing and not really helpful. - using BaseTypeTag = TTag::FlowProblem; - using FluidSystem = GetPropType; +namespace Properties +{ + namespace TTag + { + struct FlowOilWaterPolymerProblem { + using InheritsFrom = std::tuple; + }; + } // namespace TTag + template + struct EnablePolymer { + static constexpr bool value = true; + }; + //! The indices required by the model + template + struct Indices { + private: + // it is unfortunately not possible to simply use 'TypeTag' here because this leads + // to cyclic definitions of some properties. if this happens the compiler error + // messages unfortunately are *really* confusing and not really helpful. + using BaseTypeTag = TTag::FlowProblem; + using FluidSystem = GetPropType; -public: - using type = BlackOilTwoPhaseIndices(), - getPropValue(), - getPropValue(), - getPropValue(), - getPropValue(), - getPropValue(), - /*PVOffset=*/0, - /*disabledCompIdx=*/FluidSystem::gasCompIdx, - getPropValue()>; -}; -}} + public: + using type = BlackOilTwoPhaseIndices(), + getPropValue(), + getPropValue(), + getPropValue(), + getPropValue(), + getPropValue(), + /*PVOffset=*/0, + /*disabledCompIdx=*/FluidSystem::gasCompIdx, + getPropValue()>; + }; +} // namespace Properties +} // namespace Opm -namespace Opm { +namespace Opm +{ // ----------------- Main program ----------------- -int flowOilWaterPolymerMain(int argc, char** argv, bool outputCout, bool outputFiles) +int +flowOilWaterPolymerMain(int argc, char** argv, bool outputCout, bool outputFiles) { // we always want to use the default locale, and thus spare us the trouble // with incorrect locale settings. resetLocale(); - FlowMain - mainfunc {argc, argv, outputCout, outputFiles}; + FlowMain mainfunc {argc, argv, outputCout, outputFiles}; return mainfunc.execute(); } -int flowOilWaterPolymerMainStandalone(int argc, char** argv) +int +flowOilWaterPolymerMainStandalone(int argc, char** argv) { using TypeTag = Properties::TTag::FlowOilWaterPolymerProblem; auto mainObject = std::make_unique(argc, argv); @@ -84,4 +89,4 @@ int flowOilWaterPolymerMainStandalone(int argc, char** argv) return ret; } -} +} // namespace Opm diff --git a/flow/flow_oilwater_polymer.hpp b/flow/flow_oilwater_polymer.hpp index 2ce65a6015f..750358d7778 100644 --- a/flow/flow_oilwater_polymer.hpp +++ b/flow/flow_oilwater_polymer.hpp @@ -17,7 +17,8 @@ #ifndef FLOW_OILWATER_POLYMER_HPP #define FLOW_OILWATER_POLYMER_HPP -namespace Opm { +namespace Opm +{ //! \brief Main functon used in main flow binary. int flowOilWaterPolymerMain(int argc, char** argv, bool outputCout, bool outputFiles); @@ -25,6 +26,6 @@ int flowOilWaterPolymerMain(int argc, char** argv, bool outputCout, bool outputF //! \brief Main function used in flow_oilwater_polymer binary. int flowOilWaterPolymerMainStandalone(int argc, char** argv); -} +} // namespace Opm #endif // FLOW_OILWATER_POLYMER_HPP diff --git a/flow/flow_oilwater_polymer_injectivity.cpp b/flow/flow_oilwater_polymer_injectivity.cpp index ca716397d72..b866f08a879 100644 --- a/flow/flow_oilwater_polymer_injectivity.cpp +++ b/flow/flow_oilwater_polymer_injectivity.cpp @@ -22,66 +22,71 @@ #include #include -#include #include +#include -namespace Opm { -namespace Properties { -namespace TTag { -struct FlowOilWaterPolymerInjectivityProblem { - using InheritsFrom = std::tuple; -}; -} -template -struct EnablePolymer { - static constexpr bool value = true; -}; -template -struct EnablePolymerMW { - static constexpr bool value = true; -}; - -//! The indices required by the model -// For this case, there will be two primary variables introduced for the polymer -// polymer concentration and polymer molecular weight -template -struct Indices +namespace Opm { -private: - // it is unfortunately not possible to simply use 'TypeTag' here because this leads - // to cyclic definitions of some properties. if this happens the compiler error - // messages unfortunately are *really* confusing and not really helpful. - using BaseTypeTag = TTag::FlowProblem; - using FluidSystem = GetPropType; +namespace Properties +{ + namespace TTag + { + struct FlowOilWaterPolymerInjectivityProblem { + using InheritsFrom = std::tuple; + }; + } // namespace TTag + template + struct EnablePolymer { + static constexpr bool value = true; + }; + template + struct EnablePolymerMW { + static constexpr bool value = true; + }; + + //! The indices required by the model + // For this case, there will be two primary variables introduced for the polymer + // polymer concentration and polymer molecular weight + template + struct Indices { + private: + // it is unfortunately not possible to simply use 'TypeTag' here because this leads + // to cyclic definitions of some properties. if this happens the compiler error + // messages unfortunately are *really* confusing and not really helpful. + using BaseTypeTag = TTag::FlowProblem; + using FluidSystem = GetPropType; -public: - using type = BlackOilTwoPhaseIndices<0, - 0, - 2, - 0, - getPropValue(), - getPropValue(), - /*PVOffset=*/0, - /*disabledCompIdx=*/FluidSystem::gasCompIdx, - getPropValue()>; -}; -}} + public: + using type = BlackOilTwoPhaseIndices<0, + 0, + 2, + 0, + getPropValue(), + getPropValue(), + /*PVOffset=*/0, + /*disabledCompIdx=*/FluidSystem::gasCompIdx, + getPropValue()>; + }; +} // namespace Properties +} // namespace Opm -namespace Opm { +namespace Opm +{ // ----------------- Main program ----------------- -int flowOilWaterPolymerInjectivityMain(int argc, char** argv, bool outputCout, bool outputFiles) +int +flowOilWaterPolymerInjectivityMain(int argc, char** argv, bool outputCout, bool outputFiles) { // we always want to use the default locale, and thus spare us the trouble // with incorrect locale settings. resetLocale(); - FlowMain - mainfunc {argc, argv, outputCout, outputFiles}; + FlowMain mainfunc {argc, argv, outputCout, outputFiles}; return mainfunc.execute(); } -int flowOilWaterPolymerInjectivityMainStandalone(int argc, char** argv) +int +flowOilWaterPolymerInjectivityMainStandalone(int argc, char** argv) { using TypeTag = Properties::TTag::FlowOilWaterPolymerInjectivityProblem; auto mainObject = std::make_unique(argc, argv); @@ -91,4 +96,4 @@ int flowOilWaterPolymerInjectivityMainStandalone(int argc, char** argv) return ret; } -} +} // namespace Opm diff --git a/flow/flow_oilwater_polymer_injectivity.hpp b/flow/flow_oilwater_polymer_injectivity.hpp index f8701e251ed..498bca35889 100644 --- a/flow/flow_oilwater_polymer_injectivity.hpp +++ b/flow/flow_oilwater_polymer_injectivity.hpp @@ -17,7 +17,8 @@ #ifndef FLOW_OILWATER_POLYMER_INJECTIVITY_HPP #define FLOW_OILWATER_POLYMER_INJECTIVITY_HPP -namespace Opm { +namespace Opm +{ //! \brief Main function used in flow binary. int flowOilWaterPolymerInjectivityMain(int argc, char** argv, bool outputCout, bool outputFiles); @@ -25,6 +26,6 @@ int flowOilWaterPolymerInjectivityMain(int argc, char** argv, bool outputCout, b //! \brief Main function used in flow_oilwater_polymer_injectivity binary. int flowOilWaterPolymerInjectivityMainStandalone(int argc, char** argv); -} +} // namespace Opm #endif // FLOW_OILWATER_POLYMER_INJECTIVITY_HPP diff --git a/flow/flow_oilwater_polymer_injectivity_main.cpp b/flow/flow_oilwater_polymer_injectivity_main.cpp index d71426a0877..066b4b1735c 100644 --- a/flow/flow_oilwater_polymer_injectivity_main.cpp +++ b/flow/flow_oilwater_polymer_injectivity_main.cpp @@ -18,7 +18,8 @@ #include -int main(int argc, char** argv) +int +main(int argc, char** argv) { return Opm::flowOilWaterPolymerInjectivityMainStandalone(argc, argv); } diff --git a/flow/flow_oilwater_polymer_main.cpp b/flow/flow_oilwater_polymer_main.cpp index 3e7d9a4d51e..093c3aa3fc5 100644 --- a/flow/flow_oilwater_polymer_main.cpp +++ b/flow/flow_oilwater_polymer_main.cpp @@ -18,7 +18,8 @@ #include -int main(int argc, char** argv) +int +main(int argc, char** argv) { return Opm::flowOilWaterPolymerMainStandalone(argc, argv); } diff --git a/flow/flow_onephase.cpp b/flow/flow_onephase.cpp index c418bf6bb63..8d3dea5e485 100644 --- a/flow/flow_onephase.cpp +++ b/flow/flow_onephase.cpp @@ -19,68 +19,77 @@ along with OPM. If not, see . */ #include "config.h" -#include #include +#include #include #include -namespace Opm { -namespace Properties { - -namespace TTag { -struct FlowWaterOnlyProblem { - using InheritsFrom = std::tuple; -}; -} - -template -struct Linearizer { using type = TpfaLinearizer; }; - -template -struct LocalResidual { using type = BlackOilLocalResidualTPFA; }; - -template -struct EnableDiffusion { static constexpr bool value = false; }; - -//! The indices required by the model -template -struct Indices +namespace Opm +{ +namespace Properties { -private: - // it is unfortunately not possible to simply use 'TypeTag' here because this leads - // to cyclic definitions of some properties. if this happens the compiler error - // messages unfortunately are *really* confusing and not really helpful. - using BaseTypeTag = TTag::FlowProblem; - using FluidSystem = GetPropType; - -public: - using type = BlackOilOnePhaseIndices(), - getPropValue(), - getPropValue(), - getPropValue(), - getPropValue(), - getPropValue(), - /*PVOffset=*/0, - /*enabledCompIdx=*/FluidSystem::waterCompIdx, - getPropValue()>; -}; - -} // namespace Opm::Properties + + namespace TTag + { + struct FlowWaterOnlyProblem { + using InheritsFrom = std::tuple; + }; + } // namespace TTag + + template + struct Linearizer { + using type = TpfaLinearizer; + }; + + template + struct LocalResidual { + using type = BlackOilLocalResidualTPFA; + }; + + template + struct EnableDiffusion { + static constexpr bool value = false; + }; + + //! The indices required by the model + template + struct Indices { + private: + // it is unfortunately not possible to simply use 'TypeTag' here because this leads + // to cyclic definitions of some properties. if this happens the compiler error + // messages unfortunately are *really* confusing and not really helpful. + using BaseTypeTag = TTag::FlowProblem; + using FluidSystem = GetPropType; + + public: + using type = BlackOilOnePhaseIndices(), + getPropValue(), + getPropValue(), + getPropValue(), + getPropValue(), + getPropValue(), + /*PVOffset=*/0, + /*enabledCompIdx=*/FluidSystem::waterCompIdx, + getPropValue()>; + }; + +} // namespace Properties // ----------------- Main program ----------------- -int flowWaterOnlyMain(int argc, char** argv, bool outputCout, bool outputFiles) +int +flowWaterOnlyMain(int argc, char** argv, bool outputCout, bool outputFiles) { // we always want to use the default locale, and thus spare us the trouble // with incorrect locale settings. resetLocale(); - FlowMain - mainfunc {argc, argv, outputCout, outputFiles}; + FlowMain mainfunc {argc, argv, outputCout, outputFiles}; return mainfunc.execute(); } -int flowWaterOnlyMainStandalone(int argc, char** argv) +int +flowWaterOnlyMainStandalone(int argc, char** argv) { using TypeTag = Opm::Properties::TTag::FlowWaterOnlyProblem; auto mainObject = std::make_unique(argc, argv); @@ -90,4 +99,4 @@ int flowWaterOnlyMainStandalone(int argc, char** argv) return ret; } -} +} // namespace Opm diff --git a/flow/flow_onephase.hpp b/flow/flow_onephase.hpp index fced20a6719..6c2a96bc001 100644 --- a/flow/flow_onephase.hpp +++ b/flow/flow_onephase.hpp @@ -22,13 +22,14 @@ #ifndef FLOW_ONEPHASE_HPP #define FLOW_ONEPHASE_HPP -namespace Opm { +namespace Opm +{ //! \brief Main functon used in main flow binary. int flowWaterOnlyMain(int argc, char** argv, bool outputCout, bool outputFiles); //! \brief Main function used in flow_onephase binary. int flowWaterOnlyMainStandalone(int argc, char** argv); -} +} // namespace Opm #endif diff --git a/flow/flow_onephase_energy.cpp b/flow/flow_onephase_energy.cpp index f0205fcec2b..d1a1009de89 100644 --- a/flow/flow_onephase_energy.cpp +++ b/flow/flow_onephase_energy.cpp @@ -22,60 +22,63 @@ #include -#include -#include #include +#include +#include -namespace Opm { -namespace Properties { - -namespace TTag { -struct FlowWaterOnlyEnergyProblem { - using InheritsFrom = std::tuple; -}; -} -template -struct EnableEnergy { - static constexpr bool value = true; -}; -//! The indices required by the model -template -struct Indices +namespace Opm +{ +namespace Properties { -private: - // it is unfortunately not possible to simply use 'TypeTag' here because this leads - // to cyclic definitions of some properties. if this happens the compiler error - // messages unfortunately are *really* confusing and not really helpful. - using BaseTypeTag = TTag::FlowProblem; - using FluidSystem = GetPropType; -public: - using type = Opm::BlackOilOnePhaseIndices(), - getPropValue(), - getPropValue(), - getPropValue(), - getPropValue(), - getPropValue(), - /*PVOffset=*/0, - /*enebledCompIdx=*/FluidSystem::waterCompIdx, - getPropValue()>; -}; + namespace TTag + { + struct FlowWaterOnlyEnergyProblem { + using InheritsFrom = std::tuple; + }; + } // namespace TTag + template + struct EnableEnergy { + static constexpr bool value = true; + }; + //! The indices required by the model + template + struct Indices { + private: + // it is unfortunately not possible to simply use 'TypeTag' here because this leads + // to cyclic definitions of some properties. if this happens the compiler error + // messages unfortunately are *really* confusing and not really helpful. + using BaseTypeTag = TTag::FlowProblem; + using FluidSystem = GetPropType; -} // namespace Opm::Properties + public: + using type = Opm::BlackOilOnePhaseIndices(), + getPropValue(), + getPropValue(), + getPropValue(), + getPropValue(), + getPropValue(), + /*PVOffset=*/0, + /*enebledCompIdx=*/FluidSystem::waterCompIdx, + getPropValue()>; + }; + +} // namespace Properties // ----------------- Main program ----------------- -int flowWaterOnlyEnergyMain(int argc, char** argv, bool outputCout, bool outputFiles) +int +flowWaterOnlyEnergyMain(int argc, char** argv, bool outputCout, bool outputFiles) { // we always want to use the default locale, and thus spare us the trouble // with incorrect locale settings. resetLocale(); - FlowMain - mainfunc {argc, argv, outputCout, outputFiles}; + FlowMain mainfunc {argc, argv, outputCout, outputFiles}; return mainfunc.execute(); } -int flowWaterOnlyEnergyMainStandalone(int argc, char** argv) +int +flowWaterOnlyEnergyMainStandalone(int argc, char** argv) { using TypeTag = Opm::Properties::TTag::FlowWaterOnlyEnergyProblem; auto mainObject = std::make_unique(argc, argv); @@ -85,4 +88,4 @@ int flowWaterOnlyEnergyMainStandalone(int argc, char** argv) return ret; } -} +} // namespace Opm diff --git a/flow/flow_onephase_energy.hpp b/flow/flow_onephase_energy.hpp index 6669969c375..8fd0c721f0e 100644 --- a/flow/flow_onephase_energy.hpp +++ b/flow/flow_onephase_energy.hpp @@ -22,7 +22,8 @@ #ifndef FLOW_ONEPHASE_ENERGY_HPP #define FLOW_ONEPHASE_ENERGY_HPP -namespace Opm { +namespace Opm +{ //! \brief Main functon used in main flow binary. int flowWaterOnlyEnergyMain(int argc, char** argv, bool outputCout, bool outputFiles); @@ -30,6 +31,6 @@ int flowWaterOnlyEnergyMain(int argc, char** argv, bool outputCout, bool outputF //! \brief Main function used in flow_onephase_energy binary. int flowWaterOnlyEnergyMainStandalone(int argc, char** argv); -} +} // namespace Opm #endif diff --git a/flow/flow_onephase_energy_main.cpp b/flow/flow_onephase_energy_main.cpp index c32da2bd1b1..3118139906d 100644 --- a/flow/flow_onephase_energy_main.cpp +++ b/flow/flow_onephase_energy_main.cpp @@ -21,7 +21,8 @@ #include "config.h" #include -int main(int argc, char** argv) +int +main(int argc, char** argv) { - return Opm::flowWaterOnlyEnergyMainStandalone(argc,argv); + return Opm::flowWaterOnlyEnergyMainStandalone(argc, argv); } diff --git a/flow/flow_onephase_main.cpp b/flow/flow_onephase_main.cpp index eb972e7d4d1..324432cf27d 100644 --- a/flow/flow_onephase_main.cpp +++ b/flow/flow_onephase_main.cpp @@ -22,7 +22,8 @@ #include -int main(int argc, char** argv) +int +main(int argc, char** argv) { return Opm::flowWaterOnlyMainStandalone(argc, argv); } diff --git a/flow/flow_polymer.cpp b/flow/flow_polymer.cpp index 3456b41321c..a9504b9c6bc 100644 --- a/flow/flow_polymer.cpp +++ b/flow/flow_polymer.cpp @@ -18,39 +18,45 @@ #include -#include #include -#include +#include #include +#include -namespace Opm { -namespace Properties { -namespace TTag { -struct FlowPolymerProblem { - using InheritsFrom = std::tuple; -}; -} -template -struct EnablePolymer { - static constexpr bool value = true; -}; -}} +namespace Opm +{ +namespace Properties +{ + namespace TTag + { + struct FlowPolymerProblem { + using InheritsFrom = std::tuple; + }; + } // namespace TTag + template + struct EnablePolymer { + static constexpr bool value = true; + }; +} // namespace Properties +} // namespace Opm -namespace Opm { +namespace Opm +{ // ----------------- Main program ----------------- -int flowPolymerMain(int argc, char** argv, bool outputCout, bool outputFiles) +int +flowPolymerMain(int argc, char** argv, bool outputCout, bool outputFiles) { // we always want to use the default locale, and thus spare us the trouble // with incorrect locale settings. resetLocale(); - FlowMain - mainfunc {argc, argv, outputCout, outputFiles}; + FlowMain mainfunc {argc, argv, outputCout, outputFiles}; return mainfunc.execute(); } -int flowPolymerMainStandalone(int argc, char** argv) +int +flowPolymerMainStandalone(int argc, char** argv) { using TypeTag = Properties::TTag::FlowPolymerProblem; auto mainObject = std::make_unique(argc, argv); @@ -60,4 +66,4 @@ int flowPolymerMainStandalone(int argc, char** argv) return ret; } -} +} // namespace Opm diff --git a/flow/flow_polymer.hpp b/flow/flow_polymer.hpp index 6b9cb3a4f8d..64fc02662af 100644 --- a/flow/flow_polymer.hpp +++ b/flow/flow_polymer.hpp @@ -17,7 +17,8 @@ #ifndef FLOW_POLYMER_HPP #define FLOW_POLYMER_HPP -namespace Opm { +namespace Opm +{ //! \brief Main function used in flow binary. int flowPolymerMain(int argc, char** argv, bool outputCout, bool outputFiles); @@ -25,6 +26,6 @@ int flowPolymerMain(int argc, char** argv, bool outputCout, bool outputFiles); //! \brief Main function used in flow_polymer binary. int flowPolymerMainStandalone(int argc, char** argv); -} +} // namespace Opm #endif // FLOW_POLYMER_HPP diff --git a/flow/flow_polymer_main.cpp b/flow/flow_polymer_main.cpp index 6e1297e5563..1c5ff61c028 100644 --- a/flow/flow_polymer_main.cpp +++ b/flow/flow_polymer_main.cpp @@ -18,7 +18,8 @@ #include -int main(int argc, char** argv) +int +main(int argc, char** argv) { return Opm::flowPolymerMainStandalone(argc, argv); } diff --git a/flow/flow_solvent.cpp b/flow/flow_solvent.cpp index f331c854469..9af4826c786 100644 --- a/flow/flow_solvent.cpp +++ b/flow/flow_solvent.cpp @@ -18,39 +18,45 @@ #include -#include #include -#include +#include #include +#include -namespace Opm { -namespace Properties { -namespace TTag { -struct FlowSolventProblem { - using InheritsFrom = std::tuple; -}; -} -template -struct EnableSolvent { - static constexpr bool value = true; -}; -}} +namespace Opm +{ +namespace Properties +{ + namespace TTag + { + struct FlowSolventProblem { + using InheritsFrom = std::tuple; + }; + } // namespace TTag + template + struct EnableSolvent { + static constexpr bool value = true; + }; +} // namespace Properties +} // namespace Opm -namespace Opm { +namespace Opm +{ // ----------------- Main program ----------------- -int flowSolventMain(int argc, char** argv, bool outputCout, bool outputFiles) +int +flowSolventMain(int argc, char** argv, bool outputCout, bool outputFiles) { // we always want to use the default locale, and thus spare us the trouble // with incorrect locale settings. resetLocale(); - FlowMain - mainfunc {argc, argv, outputCout, outputFiles}; + FlowMain mainfunc {argc, argv, outputCout, outputFiles}; return mainfunc.execute(); } -int flowSolventMainStandalone(int argc, char** argv) +int +flowSolventMainStandalone(int argc, char** argv) { using TypeTag = Properties::TTag::FlowSolventProblem; auto mainObject = std::make_unique(argc, argv); @@ -60,4 +66,4 @@ int flowSolventMainStandalone(int argc, char** argv) return ret; } -} +} // namespace Opm diff --git a/flow/flow_solvent.hpp b/flow/flow_solvent.hpp index 7fda54c97ec..af4c560f7a8 100644 --- a/flow/flow_solvent.hpp +++ b/flow/flow_solvent.hpp @@ -17,7 +17,8 @@ #ifndef FLOW_SOLVENT_HPP #define FLOW_SOLVENT_HPP -namespace Opm { +namespace Opm +{ //! \brief Main function used in flow binary. int flowSolventMain(int argc, char** argv, bool outoutCout, bool outputFiles); @@ -25,6 +26,6 @@ int flowSolventMain(int argc, char** argv, bool outoutCout, bool outputFiles); //! \brief Main function used in flow_solvent binary. int flowSolventMainStandalone(int argc, char** argv); -} +} // namespace Opm #endif // FLOW_SOLVENT_HPP diff --git a/flow/flow_solvent_foam.cpp b/flow/flow_solvent_foam.cpp index eadd1b740ec..dfe336e9528 100644 --- a/flow/flow_solvent_foam.cpp +++ b/flow/flow_solvent_foam.cpp @@ -18,44 +18,50 @@ #include -#include #include -#include +#include #include +#include -namespace Opm { -namespace Properties { -namespace TTag { -struct FlowSolventFoamProblem { - using InheritsFrom = std::tuple; -}; -} -template -struct EnableSolvent { - static constexpr bool value = true; -}; +namespace Opm +{ +namespace Properties +{ + namespace TTag + { + struct FlowSolventFoamProblem { + using InheritsFrom = std::tuple; + }; + } // namespace TTag + template + struct EnableSolvent { + static constexpr bool value = true; + }; -template -struct EnableFoam { - static constexpr bool value = true; -}; -}} + template + struct EnableFoam { + static constexpr bool value = true; + }; +} // namespace Properties +} // namespace Opm -namespace Opm { +namespace Opm +{ // ----------------- Main program ----------------- -int flowSolventFoamMain(int argc, char** argv, bool outputCout, bool outputFiles) +int +flowSolventFoamMain(int argc, char** argv, bool outputCout, bool outputFiles) { // we always want to use the default locale, and thus spare us the trouble // with incorrect locale settings. resetLocale(); - FlowMain - mainfunc {argc, argv, outputCout, outputFiles}; + FlowMain mainfunc {argc, argv, outputCout, outputFiles}; return mainfunc.execute(); } -int flowSolventFoamMainStandalone(int argc, char** argv) +int +flowSolventFoamMainStandalone(int argc, char** argv) { using TypeTag = Properties::TTag::FlowSolventFoamProblem; auto mainObject = std::make_unique(argc, argv); @@ -65,4 +71,4 @@ int flowSolventFoamMainStandalone(int argc, char** argv) return ret; } -} +} // namespace Opm diff --git a/flow/flow_solvent_foam.hpp b/flow/flow_solvent_foam.hpp index 438dd9a9e0e..253d02ba158 100644 --- a/flow/flow_solvent_foam.hpp +++ b/flow/flow_solvent_foam.hpp @@ -17,7 +17,8 @@ #ifndef FLOW_SOLVENT_FOAM_HPP #define FLOW_SOLVENT_FOAM_HPP -namespace Opm { +namespace Opm +{ //! \brief Main function used in flow binary. int flowSolventFoamMain(int argc, char** argv, bool outoutCout, bool outputFiles); @@ -25,6 +26,6 @@ int flowSolventFoamMain(int argc, char** argv, bool outoutCout, bool outputFiles //! \brief Main function used in flow_solvent_foam binary. int flowSolventFoamMainStandalone(int argc, char** argv); -} +} // namespace Opm #endif // FLOW_SOLVENT_FOAM_HPP diff --git a/flow/flow_solvent_foam_main.cpp b/flow/flow_solvent_foam_main.cpp index e1f2fcb43a3..e009a1c54bc 100644 --- a/flow/flow_solvent_foam_main.cpp +++ b/flow/flow_solvent_foam_main.cpp @@ -18,7 +18,8 @@ #include -int main(int argc, char** argv) +int +main(int argc, char** argv) { return Opm::flowSolventFoamMainStandalone(argc, argv); } diff --git a/flow/flow_solvent_main.cpp b/flow/flow_solvent_main.cpp index 68f013b55ca..50ef5eb6046 100644 --- a/flow/flow_solvent_main.cpp +++ b/flow/flow_solvent_main.cpp @@ -18,7 +18,8 @@ #include -int main(int argc, char** argv) +int +main(int argc, char** argv) { return Opm::flowSolventMainStandalone(argc, argv); } diff --git a/flowexperimental/BlackOilEnergyIntensiveQuantitiesGlobalIndex.hpp b/flowexperimental/BlackOilEnergyIntensiveQuantitiesGlobalIndex.hpp index 94f9b5aa31f..992731091d8 100644 --- a/flowexperimental/BlackOilEnergyIntensiveQuantitiesGlobalIndex.hpp +++ b/flowexperimental/BlackOilEnergyIntensiveQuantitiesGlobalIndex.hpp @@ -30,7 +30,8 @@ #include -namespace Opm { +namespace Opm +{ template class BlackOilEnergyIntensiveQuantitiesGlobalIndex; @@ -42,19 +43,19 @@ class BlackOilEnergyIntensiveQuantitiesGlobalIndex; */ template class BlackOilEnergyIntensiveQuantitiesGlobalIndex - : public BlackOilEnergyIntensiveQuantities + : public BlackOilEnergyIntensiveQuantities { - using Parent = BlackOilEnergyIntensiveQuantities; + using Parent = BlackOilEnergyIntensiveQuantities; using FluidSystem = GetPropType; using Problem = GetPropType; using PrimaryVariables = GetPropType; using Evaluation = GetPropType; using Scalar = GetPropType; using SolidEnergyLaw = GetPropType; - using ThermalConductionLaw = GetPropType; + using ThermalConductionLaw = GetPropType; using ParamCache = typename FluidSystem::template ParameterCache; static constexpr bool enableTemperature = getPropValue(); - + using Indices = GetPropType; static constexpr unsigned temperatureIdx = Indices::temperatureIdx; static constexpr unsigned numPhases = FluidSystem::numPhases; @@ -76,10 +77,10 @@ class BlackOilEnergyIntensiveQuantitiesGlobalIndex const ParamCache& paramCache) { auto& fs = Parent::asImp_().fluidState_; - + // compute the specific enthalpy of the fluids, the specific enthalpy of the rock // and the thermal conductivity coefficients - for (int phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) { + for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { if (!FluidSystem::phaseIsActive(phaseIdx)) { continue; } @@ -107,7 +108,7 @@ template class BlackOilEnergyIntensiveQuantitiesGlobalIndex : public BlackOilEnergyIntensiveQuantities { - using Parent = BlackOilEnergyIntensiveQuantities; + using Parent = BlackOilEnergyIntensiveQuantities; using Problem = GetPropType; using PrimaryVariables = GetPropType; using FluidSystem = GetPropType; @@ -135,9 +136,10 @@ class BlackOilEnergyIntensiveQuantitiesGlobalIndex [[maybe_unused]] unsigned globalSpaceIdx, [[maybe_unused]] unsigned timeIdx, const typename FluidSystem::template ParameterCache&) - { } + { + } }; - + } // namespace Opm -#endif +#endif diff --git a/flowexperimental/BlackOilIntensiveQuantitiesGlobalIndex.hpp b/flowexperimental/BlackOilIntensiveQuantitiesGlobalIndex.hpp index ca12bef7f9d..233ac7e781f 100644 --- a/flowexperimental/BlackOilIntensiveQuantitiesGlobalIndex.hpp +++ b/flowexperimental/BlackOilIntensiveQuantitiesGlobalIndex.hpp @@ -37,19 +37,19 @@ #include -#include #include +#include -#include -#include -#include -#include -#include -#include -#include -#include #include +#include #include +#include +#include +#include +#include +#include +#include +#include #include #include @@ -59,7 +59,8 @@ #include -namespace Opm { +namespace Opm +{ /*! * \ingroup BlackOilModel @@ -70,17 +71,18 @@ namespace Opm { */ template class BlackOilIntensiveQuantitiesGlobalIndex - : public GetPropType - , public GetPropType::FluxIntensiveQuantities - , public BlackOilDiffusionIntensiveQuantities()> - , public BlackOilSolventIntensiveQuantities()> - , public BlackOilExtboIntensiveQuantities()> - , public BlackOilPolymerIntensiveQuantities()> - , public BlackOilFoamIntensiveQuantities()> - , public BlackOilBrineIntensiveQuantities()> - , public BlackOilEnergyIntensiveQuantitiesGlobalIndex()> - , public BlackOilBioeffectsIntensiveQuantities()> - , public BlackOilConvectiveMixingIntensiveQuantities()> + : public GetPropType, + public GetPropType::FluxIntensiveQuantities, + public BlackOilDiffusionIntensiveQuantities()>, + public BlackOilSolventIntensiveQuantities()>, + public BlackOilExtboIntensiveQuantities()>, + public BlackOilPolymerIntensiveQuantities()>, + public BlackOilFoamIntensiveQuantities()>, + public BlackOilBrineIntensiveQuantities()>, + public BlackOilEnergyIntensiveQuantitiesGlobalIndex()>, + public BlackOilBioeffectsIntensiveQuantities()>, + public BlackOilConvectiveMixingIntensiveQuantities()> { using ParentType = GetPropType; using Implementation = GetPropType; @@ -165,30 +167,25 @@ class BlackOilIntensiveQuantitiesGlobalIndex const auto& problem = elemCtx.problem(); const auto& priVars = elemCtx.primaryVars(dofIdx, timeIdx); unsigned globalSpaceIdx = elemCtx.globalSpaceIndex(dofIdx, timeIdx); - this->update(problem,priVars,globalSpaceIdx,timeIdx); + this->update(problem, priVars, globalSpaceIdx, timeIdx); } - void update(const Problem& problem, - const PrimaryVariables& priVars, - unsigned globalSpaceIdx, - unsigned timeIdx) + void update(const Problem& problem, const PrimaryVariables& priVars, unsigned globalSpaceIdx, unsigned timeIdx) { - this->extrusionFactor_ = 1.0;// to avoid fixing parent update + this->extrusionFactor_ = 1.0; // to avoid fixing parent update OPM_TIMEBLOCK_LOCAL(UpdateIntensiveQuantities); - Scalar RvMax = FluidSystem::enableVaporizedOil() - ? problem.maxOilVaporizationFactor(timeIdx, globalSpaceIdx) - : 0.0; - Scalar RsMax = FluidSystem::enableDissolvedGas() - ? problem.maxGasDissolutionFactor(timeIdx, globalSpaceIdx) - : 0.0; + Scalar RvMax + = FluidSystem::enableVaporizedOil() ? problem.maxOilVaporizationFactor(timeIdx, globalSpaceIdx) : 0.0; + Scalar RsMax + = FluidSystem::enableDissolvedGas() ? problem.maxGasDissolutionFactor(timeIdx, globalSpaceIdx) : 0.0; asImp_().updateTemperature_(problem, priVars, globalSpaceIdx, timeIdx); unsigned pvtRegionIdx = priVars.pvtRegionIndex(); fluidState_.setPvtRegionIndex(pvtRegionIdx); - //asImp_().updateSaltConcentration_(elemCtx, dofIdx, timeIdx); + // asImp_().updateSaltConcentration_(elemCtx, dofIdx, timeIdx); // extract the water and the gas saturations for convenience Evaluation Sw = 0.0; @@ -237,7 +234,7 @@ class BlackOilIntensiveQuantitiesGlobalIndex fluidState_.setSaturation(oilPhaseIdx, So); } - std::array pC{}; + std::array pC {}; computeRelpermAndPC(mobility_, pC, problem, fluidState_, globalSpaceIdx); // oil is the reference phase for pressure if (priVars.primaryVarsMeaningPressure() == PrimaryVariables::PressureMeaning::Pg) { @@ -258,8 +255,7 @@ class BlackOilIntensiveQuantitiesGlobalIndex Evaluation SoMax = 0.0; if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)) { - SoMax = max(fluidState_.saturation(oilPhaseIdx), - problem.maxOilSaturation(globalSpaceIdx)); + SoMax = max(fluidState_.saturation(oilPhaseIdx), problem.maxOilSaturation(globalSpaceIdx)); } // take the meaning of the switching primary variable into account for the gas @@ -270,14 +266,11 @@ class BlackOilIntensiveQuantitiesGlobalIndex } else { if (FluidSystem::enableDissolvedGas()) { // Add So > 0? i.e. if only water set rs = 0) OPM_TIMEBLOCK_LOCAL(UpdateSaturatedRs); - const Evaluation& RsSat = enableExtbo ? asImp_().rs() : - FluidSystem::saturatedDissolutionFactor(fluidState_, - oilPhaseIdx, - pvtRegionIdx, - SoMax); + const Evaluation& RsSat = enableExtbo + ? asImp_().rs() + : FluidSystem::saturatedDissolutionFactor(fluidState_, oilPhaseIdx, pvtRegionIdx, SoMax); fluidState_.setRs(min(RsMax, RsSat)); - } - else if constexpr (compositionSwitchEnabled) { + } else if constexpr (compositionSwitchEnabled) { fluidState_.setRs(0.0); } } @@ -286,17 +279,14 @@ class BlackOilIntensiveQuantitiesGlobalIndex const auto& Rv = priVars.makeEvaluation(Indices::compositionSwitchIdx, timeIdx); fluidState_.setRv(Rv); } else { - if (FluidSystem::enableVaporizedOil() ) { // Add Sg > 0? i.e. if only water set rv = 0) + if (FluidSystem::enableVaporizedOil()) { // Add Sg > 0? i.e. if only water set rv = 0) OPM_TIMEBLOCK_LOCAL(UpdateSaturatedRv); - //NB! should save the indexing for later evalustion - const Evaluation& RvSat = enableExtbo ? asImp_().rv() : - FluidSystem::saturatedDissolutionFactor(fluidState_, - gasPhaseIdx, - pvtRegionIdx, - SoMax); + // NB! should save the indexing for later evalustion + const Evaluation& RvSat = enableExtbo + ? asImp_().rv() + : FluidSystem::saturatedDissolutionFactor(fluidState_, gasPhaseIdx, pvtRegionIdx, SoMax); fluidState_.setRv(min(RvMax, RvSat)); - } - else if constexpr (compositionSwitchEnabled) { + } else if constexpr (compositionSwitchEnabled) { fluidState_.setRv(0.0); } } @@ -306,12 +296,11 @@ class BlackOilIntensiveQuantitiesGlobalIndex const auto& Rvw = priVars.makeEvaluation(Indices::waterSwitchIdx, timeIdx); fluidState_.setRvw(Rvw); } else { - //NB! should save the indexing for later evaluation + // NB! should save the indexing for later evaluation if (FluidSystem::enableVaporizedWater()) { // Add Sg > 0? i.e. if only water set rv = 0) OPM_TIMEBLOCK_LOCAL(UpdateSaturatedRv); - const Evaluation& RvwSat = FluidSystem::saturatedVaporizationFactor(fluidState_, - gasPhaseIdx, - pvtRegionIdx); + const Evaluation& RvwSat + = FluidSystem::saturatedVaporizationFactor(fluidState_, gasPhaseIdx, pvtRegionIdx); fluidState_.setRvw(RvwSat); } } @@ -339,14 +328,12 @@ class BlackOilIntensiveQuantitiesGlobalIndex rho = fluidState_.invB(gasPhaseIdx); rho *= FluidSystem::referenceDensity(gasPhaseIdx, pvtRegionIdx); if (FluidSystem::enableVaporizedOil()) { - rho += fluidState_.invB(gasPhaseIdx) * - fluidState_.Rv() * - FluidSystem::referenceDensity(oilPhaseIdx, pvtRegionIdx); + rho += fluidState_.invB(gasPhaseIdx) * fluidState_.Rv() + * FluidSystem::referenceDensity(oilPhaseIdx, pvtRegionIdx); } if (FluidSystem::enableVaporizedWater()) { - rho += fluidState_.invB(gasPhaseIdx) * - fluidState_.Rvw() * - FluidSystem::referenceDensity(waterPhaseIdx, pvtRegionIdx); + rho += fluidState_.invB(gasPhaseIdx) * fluidState_.Rvw() + * FluidSystem::referenceDensity(waterPhaseIdx, pvtRegionIdx); } fluidState_.setDensity(gasPhaseIdx, rho); } @@ -356,15 +343,14 @@ class BlackOilIntensiveQuantitiesGlobalIndex rho = fluidState_.invB(oilPhaseIdx); rho *= FluidSystem::referenceDensity(oilPhaseIdx, pvtRegionIdx); if (FluidSystem::enableDissolvedGas()) { - rho += fluidState_.invB(oilPhaseIdx) * - fluidState_.Rs() * - FluidSystem::referenceDensity(gasPhaseIdx, pvtRegionIdx); + rho += fluidState_.invB(oilPhaseIdx) * fluidState_.Rs() + * FluidSystem::referenceDensity(gasPhaseIdx, pvtRegionIdx); } fluidState_.setDensity(oilPhaseIdx, rho); } // retrieve the porosity from the problem - referencePorosity_ = problem.porosity(globalSpaceIdx,timeIdx); + referencePorosity_ = problem.porosity(globalSpaceIdx, timeIdx); porosity_ = referencePorosity_; // the porosity must be modified by the compressibility of the // rock... @@ -374,11 +360,11 @@ class BlackOilIntensiveQuantitiesGlobalIndex Scalar rockRefPressure = problem.rockReferencePressure(globalSpaceIdx); Evaluation x; if (FluidSystem::phaseIsActive(oilPhaseIdx)) { - x = rockCompressibility*(fluidState_.pressure(oilPhaseIdx) - rockRefPressure); + x = rockCompressibility * (fluidState_.pressure(oilPhaseIdx) - rockRefPressure); } else if (FluidSystem::phaseIsActive(waterPhaseIdx)) { - x = rockCompressibility*(fluidState_.pressure(waterPhaseIdx) - rockRefPressure); + x = rockCompressibility * (fluidState_.pressure(waterPhaseIdx) - rockRefPressure); } else { - x = rockCompressibility*(fluidState_.pressure(gasPhaseIdx) - rockRefPressure); + x = rockCompressibility * (fluidState_.pressure(gasPhaseIdx) - rockRefPressure); } porosity_ *= 1.0 + x + 0.5 * x * x; } @@ -394,7 +380,7 @@ class BlackOilIntensiveQuantitiesGlobalIndex #ifndef NDEBUG // some safety checks in debug mode - for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) { + for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { if (!FluidSystem::phaseIsActive(phaseIdx)) { continue; } @@ -414,13 +400,17 @@ class BlackOilIntensiveQuantitiesGlobalIndex * \copydoc ImmiscibleIntensiveQuantities::fluidState */ const FluidState& fluidState() const - { return fluidState_; } + { + return fluidState_; + } /*! * \copydoc ImmiscibleIntensiveQuantities::mobility */ const Evaluation& mobility(unsigned phaseIdx) const - { return mobility_[phaseIdx]; } + { + return mobility_[phaseIdx]; + } const Evaluation& mobility(unsigned phaseIdx, FaceDir::DirEnum facedir) const { @@ -441,9 +431,9 @@ class BlackOilIntensiveQuantitiesGlobalIndex } } - void computeInverseFormationVolumeFactorAndViscosity(FluidState& fluidState, - unsigned phaseIdx, - unsigned pvtRegionIdx) { + void + computeInverseFormationVolumeFactorAndViscosity(FluidState& fluidState, unsigned phaseIdx, unsigned pvtRegionIdx) + { OPM_TIMEBLOCK_LOCAL(UpdateInverseFormationFactorAndViscosity); { OPM_TIMEBLOCK_LOCAL(UpdateFormationFactor); @@ -461,11 +451,12 @@ class BlackOilIntensiveQuantitiesGlobalIndex } } - void computeRelpermAndPC(std::array& mobility, + void computeRelpermAndPC(std::array& mobility, std::array& pC, const Problem& problem, const FluidState& fluidState, - unsigned globalSpaceIdx){ + unsigned globalSpaceIdx) + { OPM_TIMEBLOCK_LOCAL(UpdateRelperm); const auto& materialParams = problem.materialLawParams(globalSpaceIdx); MaterialLaw::capillaryPressures(pC, materialParams, fluidState_); @@ -476,13 +467,17 @@ class BlackOilIntensiveQuantitiesGlobalIndex * \copydoc ImmiscibleIntensiveQuantities::porosity */ const Evaluation& porosity() const - { return porosity_; } + { + return porosity_; + } /*! * The pressure-dependent transmissibility multiplier due to rock compressibility. */ const Evaluation& rockCompTransMultiplier() const - { return rockCompTransMultiplier_; } + { + return rockCompTransMultiplier_; + } /*! * \brief Returns the index of the PVT region used to calculate the thermodynamic @@ -498,7 +493,9 @@ class BlackOilIntensiveQuantitiesGlobalIndex * specified, the PVT region index is 0.) */ auto pvtRegionIndex() const -> decltype(std::declval().pvtRegionIndex()) - { return fluidState_.pvtRegionIndex(); } + { + return fluidState_.pvtRegionIndex(); + } /*! * \copydoc ImmiscibleIntensiveQuantities::relativePermeability @@ -506,7 +503,7 @@ class BlackOilIntensiveQuantitiesGlobalIndex Evaluation relativePermeability(unsigned phaseIdx) const { // warning: slow - return fluidState_.viscosity(phaseIdx)*mobility(phaseIdx); + return fluidState_.viscosity(phaseIdx) * mobility(phaseIdx); } /*! @@ -516,11 +513,13 @@ class BlackOilIntensiveQuantitiesGlobalIndex * changes. */ Scalar referencePorosity() const - { return referencePorosity_; } + { + return referencePorosity_; + } const Evaluation& permFactor() const { - throw std::logic_error("permFactor() is not yet implemented for compositional modeling"); + throw std::logic_error("permFactor() is not yet implemented for compositional modeling"); } private: @@ -533,13 +532,15 @@ class BlackOilIntensiveQuantitiesGlobalIndex friend BlackOilBioeffectsIntensiveQuantities; Implementation& asImp_() - { return *static_cast(this); } + { + return *static_cast(this); + } FluidState fluidState_; Scalar referencePorosity_; Evaluation porosity_; Evaluation rockCompTransMultiplier_; - std::array mobility_; + std::array mobility_; // Instead of writing a custom copy constructor and a custom assignment operator just to handle // the dirMob_ unique ptr member variable when copying BlackOilIntensiveQuantites (see for example diff --git a/flowexperimental/FIBlackOilModelNoCache.hpp b/flowexperimental/FIBlackOilModelNoCache.hpp index 8ffbe0efd2a..9c4084c588c 100644 --- a/flowexperimental/FIBlackOilModelNoCache.hpp +++ b/flowexperimental/FIBlackOilModelNoCache.hpp @@ -3,10 +3,11 @@ #include -namespace Opm { +namespace Opm +{ -template -class FIBlackOilModelNoCache: public FIBlackOilModel +template +class FIBlackOilModelNoCache : public FIBlackOilModel { using Simulator = GetPropType; using IntensiveQuantities = GetPropType; @@ -14,18 +15,18 @@ class FIBlackOilModelNoCache: public FIBlackOilModel public: explicit FIBlackOilModelNoCache(Simulator& simulator) : FIBlackOilModel(simulator) - {} + { + } IntensiveQuantities intensiveQuantities(unsigned globalIdx, unsigned timeIdx) const { OPM_TIMEBLOCK_LOCAL(intensiveQuantitiesNoCache); const auto& primaryVar = this->solution(timeIdx)[globalIdx]; const auto& problem = this->simulator_.problem(); - if (!(this->enableIntensiveQuantityCache_) || - !(this->intensiveQuantityCacheUpToDate_[timeIdx][globalIdx])) { + if (!(this->enableIntensiveQuantityCache_) || !(this->intensiveQuantityCacheUpToDate_[timeIdx][globalIdx])) { IntensiveQuantities intQuants; - intQuants.update(problem,primaryVar, globalIdx, timeIdx); - return intQuants;// reqiored for updating extrution factor + intQuants.update(problem, primaryVar, globalIdx, timeIdx); + return intQuants; // reqiored for updating extrution factor } else { IntensiveQuantities intQuants = (this->intensiveQuantityCache_[timeIdx][globalIdx]); return intQuants; diff --git a/flowexperimental/FlowExpNewtonMethod.hpp b/flowexperimental/FlowExpNewtonMethod.hpp index 831b340b59f..02260767e46 100644 --- a/flowexperimental/FlowExpNewtonMethod.hpp +++ b/flowexperimental/FlowExpNewtonMethod.hpp @@ -34,34 +34,46 @@ #include #include -namespace Opm::Parameters { +namespace Opm::Parameters +{ // the tolerated amount of "incorrect" amount of oil per time step for the complete // reservoir. this is scaled by the pore volume of the reservoir, i.e., larger reservoirs // will tolerate larger residuals. -template -struct EclNewtonSumTolerance { static constexpr Scalar value = 1e-5; }; +template +struct EclNewtonSumTolerance { + static constexpr Scalar value = 1e-5; +}; // make all Newton iterations strict, i.e., the volumetric Newton tolerance must be // always be upheld in the majority of the spatial domain. In this context, "majority" // means 1 - EclNewtonRelaxedVolumeFraction. -struct EclNewtonStrictIterations { static constexpr int value = 100; }; +struct EclNewtonStrictIterations { + static constexpr int value = 100; +}; // set fraction of the pore volume where the volumetric residual may be violated during // strict Newton iterations -template -struct EclNewtonRelaxedVolumeFraction { static constexpr Scalar value = 0.05; }; +template +struct EclNewtonRelaxedVolumeFraction { + static constexpr Scalar value = 0.05; +}; -template -struct EclNewtonSumToleranceExponent { static constexpr Scalar value = 1.0 / 3.0; }; +template +struct EclNewtonSumToleranceExponent { + static constexpr Scalar value = 1.0 / 3.0; +}; // the maximum volumetric error of a cell in the relaxed region -template -struct EclNewtonRelaxedTolerance { static constexpr Scalar value = NewtonTolerance::value * 1e6; }; +template +struct EclNewtonRelaxedTolerance { + static constexpr Scalar value = NewtonTolerance::value * 1e6; +}; } // namespace Opm::Parameters -namespace Opm { +namespace Opm +{ /*! * \brief A newton solver. @@ -94,7 +106,8 @@ class FlowExpNewtonMethod : public BlackOilNewtonMethod friend ParentType; public: - explicit FlowExpNewtonMethod(Simulator& simulator) : ParentType(simulator) + explicit FlowExpNewtonMethod(Simulator& simulator) + : ParentType(simulator) { errorPvFraction_ = 1.0; relaxedMaxPvFraction_ = Parameters::Get>(); @@ -112,21 +125,20 @@ class FlowExpNewtonMethod : public BlackOilNewtonMethod { ParentType::registerParameters(); - Parameters::Register> - ("The maximum error tolerated by the Newton " - "method for considering a solution to be converged"); - Parameters::Register - ("The number of Newton iterations where the " - "volumetric error is considered."); - Parameters::Register> - ("The fraction of the pore volume of the reservoir " - "where the volumetric error may be violated during strict Newton iterations."); - Parameters::Register> - ("The the exponent used to scale the sum tolerance by " - "the total pore volume of the reservoir."); - Parameters::Register> - ("The maximum error which the volumetric residual " - "may exhibit if it is in a 'relaxed' region during a strict iteration."); + Parameters::Register>( + "The maximum error tolerated by the Newton " + "method for considering a solution to be converged"); + Parameters::Register("The number of Newton iterations where the " + "volumetric error is considered."); + Parameters::Register>( + "The fraction of the pore volume of the reservoir " + "where the volumetric error may be violated during strict Newton iterations."); + Parameters::Register>( + "The the exponent used to scale the sum tolerance by " + "the total pore volume of the reservoir."); + Parameters::Register>( + "The maximum error which the volumetric residual " + "may exhibit if it is in a 'relaxed' region during a strict iteration."); } /*! @@ -136,16 +148,15 @@ class FlowExpNewtonMethod : public BlackOilNewtonMethod bool converged() const { if (errorPvFraction_ < relaxedMaxPvFraction_) { - return (this->error_ < relaxedTolerance_ && errorSum_ < sumTolerance_) ; + return (this->error_ < relaxedTolerance_ && errorSum_ < sumTolerance_); } else if (this->numIterations() > numStrictIterations_) { - return (this->error_ < relaxedTolerance_ && errorSum_ < sumTolerance_) ; + return (this->error_ < relaxedTolerance_ && errorSum_ < sumTolerance_); } return this->error_ <= this->tolerance() && errorSum_ <= sumTolerance_; } - void preSolve_(const SolutionVector&, - const GlobalEqVector& currentResidual) + void preSolve_(const SolutionVector&, const GlobalEqVector& currentResidual) { const auto& constraintsMap = this->model().linearizer().constraintsMap(); this->lastError_ = this->error_; @@ -161,8 +172,7 @@ class FlowExpNewtonMethod : public BlackOilNewtonMethod const Scalar dt = this->simulator_.timeStepSize(); for (unsigned dofIdx = 0; dofIdx < currentResidual.size(); ++dofIdx) { // do not consider auxiliary DOFs for the error - if (dofIdx >= this->model().numGridDof() - || this->model().dofTotalVolume(dofIdx) <= 0.0) { + if (dofIdx >= this->model().numGridDof() || this->model().dofTotalVolume(dofIdx) <= 0.0) { continue; } @@ -178,8 +188,8 @@ class FlowExpNewtonMethod : public BlackOilNewtonMethod } const auto& r = currentResidual[dofIdx]; - Scalar pvValue = this->simulator_.problem().referencePorosity(dofIdx, /*timeIdx=*/0) * - this->model().dofTotalVolume(dofIdx); + Scalar pvValue = this->simulator_.problem().referencePorosity(dofIdx, /*timeIdx=*/0) + * this->model().dofTotalVolume(dofIdx); sumPv += pvValue; bool cnvViolated = false; @@ -229,17 +239,16 @@ class FlowExpNewtonMethod : public BlackOilNewtonMethod // exponent is 1/3, i.e., cubic root. Scalar x = Parameters::Get>(); Scalar y = Parameters::Get>(); - sumTolerance_ = x*std::pow(sumPv, y); + sumTolerance_ = x * std::pow(sumPv, y); - this->endIterMsg() << " (max: " << this->params_.tolerance_ - << ", violated for " << errorPvFraction_ * 100 - << "% of the pore volume), aggegate error: " - << errorSum_ << " (max: " << sumTolerance_ << ")"; + this->endIterMsg() << " (max: " << this->params_.tolerance_ << ", violated for " << errorPvFraction_ * 100 + << "% of the pore volume), aggegate error: " << errorSum_ << " (max: " << sumTolerance_ + << ")"; // make sure that the error never grows beyond the maximum // allowed one if (this->error_ > newtonMaxError) { - throw NumericalProblem("Newton: Error "+std::to_string(double(this->error_)) + throw NumericalProblem("Newton: Error " + std::to_string(double(this->error_)) + " is larger than maximum allowed error of " + std::to_string(double(newtonMaxError))); } @@ -247,19 +256,17 @@ class FlowExpNewtonMethod : public BlackOilNewtonMethod // make sure that the error never grows beyond the maximum // allowed one if (errorSum_ > newtonMaxError) { - throw NumericalProblem("Newton: Sum of the error "+std::to_string(double(errorSum_)) + throw NumericalProblem("Newton: Sum of the error " + std::to_string(double(errorSum_)) + " is larger than maximum allowed error of " + std::to_string(double(newtonMaxError))); } } - void endIteration_(SolutionVector& nextSolution, - const SolutionVector& currentSolution) + void endIteration_(SolutionVector& nextSolution, const SolutionVector& currentSolution) { ParentType::endIteration_(nextSolution, currentSolution); - OpmLog::debug( "Newton iteration " + std::to_string(this->numIterations_) + "" - + " error: " + std::to_string(double(this->error_)) - + this->endIterMsg().str()); + OpmLog::debug("Newton iteration " + std::to_string(this->numIterations_) + "" + + " error: " + std::to_string(double(this->error_)) + this->endIterMsg().str()); this->endIterMsg().str(""); } diff --git a/flowexperimental/comp/EmptyModel.hpp b/flowexperimental/comp/EmptyModel.hpp index 9f0c75efcc2..43049a7d5d1 100644 --- a/flowexperimental/comp/EmptyModel.hpp +++ b/flowexperimental/comp/EmptyModel.hpp @@ -27,9 +27,10 @@ #include -namespace Opm { +namespace Opm +{ -template +template class EmptyModel : public BaseAuxiliaryModule { using Scalar = GetPropType; @@ -43,37 +44,54 @@ class EmptyModel : public BaseAuxiliaryModule { } - void init(){} - template - void init(Something /*A*/){} - void prepareTracerBatches(){}; + void init() + { + } + template + void init(Something /*A*/) + { + } + void prepareTracerBatches() { }; using NeighborSet = std::set; - void linearize(SparseMatrixAdapter& /*matrix*/, GlobalEqVector& /*residual*/) override {} - unsigned numDofs() const override { return 0; } - void addNeighbors(std::vector& /*neighbors*/) const override {} - void initialSolutionApplied(){}; + void linearize(SparseMatrixAdapter& /*matrix*/, GlobalEqVector& /*residual*/) override + { + } + unsigned numDofs() const override + { + return 0; + } + void addNeighbors(std::vector& /*neighbors*/) const override + { + } + void initialSolutionApplied() { }; template - void serialize(Restarter& /*res*/){}; + void serialize(Restarter& /*res*/) { }; template - void deserialize(Restarter& /*res*/){}; + void deserialize(Restarter& /*res*/) { }; - void beginEpisode(){}; - void beginTimeStep(){}; - void beginIteration(){}; + 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() override {} - auto aquiferData() const { - return data::Aquifers{}; + 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() override + { + } + auto aquiferData() const + { + return data::Aquifers {}; } }; diff --git a/flowexperimental/comp/flowexp_comp.hpp b/flowexperimental/comp/flowexp_comp.hpp index ab3fe327ffb..cd946958550 100644 --- a/flowexperimental/comp/flowexp_comp.hpp +++ b/flowexperimental/comp/flowexp_comp.hpp @@ -38,26 +38,28 @@ // 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 { +namespace Opm +{ -template +template int dispatchFlowExpComp(int argc, char** argv); } -namespace Opm::Properties { -namespace TTag { +namespace Opm::Properties +{ +namespace TTag +{ -template -struct FlowExpCompProblem { - using InheritsFrom = std::tuple; -}; + template + struct FlowExpCompProblem { + using InheritsFrom = std::tuple; + }; -} +} // namespace TTag -template -struct SparseMatrixAdapter> -{ +template +struct SparseMatrixAdapter> { private: using Scalar = GetPropType; enum { numEq = getPropValue() }; @@ -111,22 +113,21 @@ struct LocalLinearizerSplice // Set the problem property template -struct Problem> -{ +struct Problem> { using type = FlowProblemComp; }; -template +template struct AquiferModel> { using type = EmptyModel; }; -template +template struct WellModel> { using type = CompWellModel; }; -template +template struct TracerModel> { using type = EmptyModel; }; @@ -145,7 +146,9 @@ struct FlashSolver> { template -struct NumComp { using type = UndefinedProperty; }; +struct NumComp { + using type = UndefinedProperty; +}; // TODO: this is unfortunate, have to check why we need to hard-code it template @@ -154,7 +157,9 @@ struct NumComp> { }; template -struct EnableDummyWater { using type = UndefinedProperty; }; +struct EnableDummyWater { + using type = UndefinedProperty; +}; template struct EnableDummyWater> { @@ -171,8 +176,7 @@ struct Temperature { using type = UndefinedProperty; }; #endif template -struct FluidSystem> -{ +struct FluidSystem> { private: using Scalar = GetPropType; static constexpr int num_comp = getPropValue(); @@ -181,19 +185,18 @@ struct FluidSystem> public: using type = Opm::GenericOilGasWaterFluidSystem; }; -template +template struct EnableMech> { static constexpr bool value = false; }; -template -struct EnableDisgasInWater> { - static constexpr bool value = false; +template +struct EnableDisgasInWater> { + static constexpr bool value = false; }; -template -struct Stencil> -{ +template +struct Stencil> { private: using Scalar = GetPropType; using GridView = GetPropType; @@ -202,61 +205,61 @@ struct Stencil> using type = EcfvStencil; }; -template +template struct EnableApiTracking> { static constexpr bool value = false; }; -template +template struct EnableTemperature> { static constexpr bool value = false; }; -template +template struct EnableSaltPrecipitation> { static constexpr bool value = false; }; -template +template struct EnablePolymerMW> { static constexpr bool value = false; }; -template +template struct EnablePolymer> { static constexpr bool value = false; }; -template +template struct EnableDispersion> { static constexpr bool value = false; }; -template +template struct EnableBrine> { static constexpr bool value = false; }; -template +template struct EnableVapwat> { static constexpr bool value = false; }; -template +template struct EnableSolvent> { static constexpr bool value = false; }; -template +template struct EnableEnergy> { static constexpr bool value = false; }; -template +template struct EnableFoam> { static constexpr bool value = false; }; -template +template struct EnableExtbo> { static constexpr bool value = false; }; -template +template struct EnableBioeffects> { static constexpr bool value = false; }; diff --git a/flowexperimental/comp/flowexp_comp2.cpp b/flowexperimental/comp/flowexp_comp2.cpp index 1da968da6e7..43344ba7443 100644 --- a/flowexperimental/comp/flowexp_comp2.cpp +++ b/flowexperimental/comp/flowexp_comp2.cpp @@ -25,12 +25,14 @@ #include "flowexp_comp.hpp" -namespace Opm { +namespace Opm +{ -template<> -int dispatchFlowExpComp<2, true>(int argc, char** argv) +template <> +int +dispatchFlowExpComp<2, true>(int argc, char** argv) { return start>(argc, argv, false); } -} +} // namespace Opm diff --git a/flowexperimental/comp/flowexp_comp2_2p.cpp b/flowexperimental/comp/flowexp_comp2_2p.cpp index 984bdb1a748..fbb06be752f 100644 --- a/flowexperimental/comp/flowexp_comp2_2p.cpp +++ b/flowexperimental/comp/flowexp_comp2_2p.cpp @@ -25,12 +25,14 @@ #include "flowexp_comp.hpp" -namespace Opm { +namespace Opm +{ -template<> -int dispatchFlowExpComp<2, false>(int argc, char** argv) +template <> +int +dispatchFlowExpComp<2, false>(int argc, char** argv) { return start>(argc, argv, false); } -} +} // namespace Opm diff --git a/flowexperimental/comp/flowexp_comp3.cpp b/flowexperimental/comp/flowexp_comp3.cpp index 0afadad149c..2655fece15c 100644 --- a/flowexperimental/comp/flowexp_comp3.cpp +++ b/flowexperimental/comp/flowexp_comp3.cpp @@ -25,12 +25,14 @@ #include "flowexp_comp.hpp" -namespace Opm { +namespace Opm +{ -template<> -int dispatchFlowExpComp<3, true>(int argc, char** argv) +template <> +int +dispatchFlowExpComp<3, true>(int argc, char** argv) { return start>(argc, argv, false); } -} +} // namespace Opm diff --git a/flowexperimental/comp/flowexp_comp3_2p.cpp b/flowexperimental/comp/flowexp_comp3_2p.cpp index d89d5153367..717f3b9a8c7 100644 --- a/flowexperimental/comp/flowexp_comp3_2p.cpp +++ b/flowexperimental/comp/flowexp_comp3_2p.cpp @@ -25,12 +25,14 @@ #include "flowexp_comp.hpp" -namespace Opm { +namespace Opm +{ -template<> -int dispatchFlowExpComp<3, false>(int argc, char** argv) +template <> +int +dispatchFlowExpComp<3, false>(int argc, char** argv) { return start>(argc, argv, false); } -} +} // namespace Opm diff --git a/flowexperimental/comp/flowexp_comp4.cpp b/flowexperimental/comp/flowexp_comp4.cpp index 7c018af27c4..5e94fcc06d4 100644 --- a/flowexperimental/comp/flowexp_comp4.cpp +++ b/flowexperimental/comp/flowexp_comp4.cpp @@ -25,12 +25,14 @@ #include "flowexp_comp.hpp" -namespace Opm { +namespace Opm +{ -template<> -int dispatchFlowExpComp<4, true>(int argc, char** argv) +template <> +int +dispatchFlowExpComp<4, true>(int argc, char** argv) { return start>(argc, argv, false); } -} +} // namespace Opm diff --git a/flowexperimental/comp/flowexp_comp4_2p.cpp b/flowexperimental/comp/flowexp_comp4_2p.cpp index 68446bc240b..16bdd0d36e9 100644 --- a/flowexperimental/comp/flowexp_comp4_2p.cpp +++ b/flowexperimental/comp/flowexp_comp4_2p.cpp @@ -25,12 +25,14 @@ #include "flowexp_comp.hpp" -namespace Opm { +namespace Opm +{ -template<> -int dispatchFlowExpComp<4, false>(int argc, char** argv) +template <> +int +dispatchFlowExpComp<4, false>(int argc, char** argv) { return start>(argc, argv, false); } -} +} // namespace Opm diff --git a/flowexperimental/comp/flowexp_comp5.cpp b/flowexperimental/comp/flowexp_comp5.cpp index d7b9cf5b752..711bcfbce3b 100644 --- a/flowexperimental/comp/flowexp_comp5.cpp +++ b/flowexperimental/comp/flowexp_comp5.cpp @@ -25,12 +25,14 @@ #include "flowexp_comp.hpp" -namespace Opm { +namespace Opm +{ -template<> -int dispatchFlowExpComp<5, true>(int argc, char** argv) +template <> +int +dispatchFlowExpComp<5, true>(int argc, char** argv) { return start>(argc, argv, false); } -} +} // namespace Opm diff --git a/flowexperimental/comp/flowexp_comp5_2p.cpp b/flowexperimental/comp/flowexp_comp5_2p.cpp index c2c034d8af8..b19de3c2a34 100644 --- a/flowexperimental/comp/flowexp_comp5_2p.cpp +++ b/flowexperimental/comp/flowexp_comp5_2p.cpp @@ -25,12 +25,14 @@ #include "flowexp_comp.hpp" -namespace Opm { +namespace Opm +{ -template<> -int dispatchFlowExpComp<5, false>(int argc, char** argv) +template <> +int +dispatchFlowExpComp<5, false>(int argc, char** argv) { return start>(argc, argv, false); } -} +} // namespace Opm diff --git a/flowexperimental/comp/flowexp_comp6.cpp b/flowexperimental/comp/flowexp_comp6.cpp index 95ee1306620..22a5a2c590e 100644 --- a/flowexperimental/comp/flowexp_comp6.cpp +++ b/flowexperimental/comp/flowexp_comp6.cpp @@ -25,12 +25,14 @@ #include "flowexp_comp.hpp" -namespace Opm { +namespace Opm +{ -template<> -int dispatchFlowExpComp<6, true>(int argc, char** argv) +template <> +int +dispatchFlowExpComp<6, true>(int argc, char** argv) { return start>(argc, argv, false); } -} +} // namespace Opm diff --git a/flowexperimental/comp/flowexp_comp6_2p.cpp b/flowexperimental/comp/flowexp_comp6_2p.cpp index 3d6b88210db..c468f08c2b1 100644 --- a/flowexperimental/comp/flowexp_comp6_2p.cpp +++ b/flowexperimental/comp/flowexp_comp6_2p.cpp @@ -25,12 +25,14 @@ #include "flowexp_comp.hpp" -namespace Opm { +namespace Opm +{ -template<> -int dispatchFlowExpComp<6, false>(int argc, char** argv) +template <> +int +dispatchFlowExpComp<6, false>(int argc, char** argv) { return start>(argc, argv, false); } -} +} // namespace Opm diff --git a/flowexperimental/comp/flowexp_comp7.cpp b/flowexperimental/comp/flowexp_comp7.cpp index 0c5fcc7f2fe..3104e27deba 100644 --- a/flowexperimental/comp/flowexp_comp7.cpp +++ b/flowexperimental/comp/flowexp_comp7.cpp @@ -25,12 +25,14 @@ #include "flowexp_comp.hpp" -namespace Opm { +namespace Opm +{ -template<> -int dispatchFlowExpComp<7, true>(int argc, char** argv) +template <> +int +dispatchFlowExpComp<7, true>(int argc, char** argv) { return start>(argc, argv, false); } -} +} // namespace Opm diff --git a/flowexperimental/comp/flowexp_comp7_2p.cpp b/flowexperimental/comp/flowexp_comp7_2p.cpp index 0dba55e3bb0..e4eb2f5a35f 100644 --- a/flowexperimental/comp/flowexp_comp7_2p.cpp +++ b/flowexperimental/comp/flowexp_comp7_2p.cpp @@ -25,12 +25,14 @@ #include "flowexp_comp.hpp" -namespace Opm { +namespace Opm +{ -template<> -int dispatchFlowExpComp<7, false>(int argc, char** argv) +template <> +int +dispatchFlowExpComp<7, false>(int argc, char** argv) { return start>(argc, argv, false); } -} +} // namespace Opm diff --git a/flowexperimental/comp/wells/CompWell.hpp b/flowexperimental/comp/wells/CompWell.hpp index 72fe5706ed9..8f47c67c400 100644 --- a/flowexperimental/comp/wells/CompWell.hpp +++ b/flowexperimental/comp/wells/CompWell.hpp @@ -28,10 +28,11 @@ #include -namespace Opm { +namespace Opm +{ template -class CompWell : public CompWellInterface +class CompWell : public CompWellInterface { public: using Base = CompWellInterface; @@ -61,14 +62,14 @@ class CompWell : public CompWellInterface // TODO: this can be a rate converter role later // currently, it has the surface densities for each phase and volume fractions for each phase // it is part of the secondary variables used in the assembling of the well equations - struct SurfaceConditons - { + struct SurfaceConditons { static constexpr int num_phases = 2; - std::array surface_densities_{}; - std::array volume_fractions_{}; - std::array, num_phases> mass_fractions_{}; + std::array surface_densities_ {}; + std::array volume_fractions_ {}; + std::array, num_phases> mass_fractions_ {}; - EvalWell density() const { + EvalWell density() const + { EvalWell density = 0.; for (int i = 0; i < num_phases; ++i) { density += surface_densities_[i] * volume_fractions_[i]; @@ -77,51 +78,42 @@ class CompWell : public CompWellInterface } // TODO: it looks like that we can have a concept of component mass density? - EvalWell massFraction(int comp_idx) const { + EvalWell massFraction(int comp_idx) const + { EvalWell mass = 0.; - for (unsigned p = 0; p < num_phases; ++p) { + for (unsigned p = 0; p < num_phases; ++p) { mass += surface_densities_[p] * volume_fractions_[p] * mass_fractions_[p][comp_idx]; } return mass / density(); } }; - CompWell(const Well& well, - int index_of_well, - const std::vector& well_connection_data); + CompWell(const Well& well, int index_of_well, const std::vector& well_connection_data); void init() override; - void calculateExplicitQuantities(const Simulator& simulator, - const SingleWellState& well_state) override; + void calculateExplicitQuantities(const Simulator& simulator, const SingleWellState& well_state) override; - void updatePrimaryVariables(const Simulator& simulator, - const SingleWellState& well_state) override; + void updatePrimaryVariables(const Simulator& simulator, const SingleWellState& well_state) override; void updateSecondaryQuantities(const Simulator& simulator); // TODO: control should be passed in later - void assembleWellEq(const Simulator& simulator, - const SingleWellState& well_state, - const double dt); + void assembleWellEq(const Simulator& simulator, const SingleWellState& well_state, const double dt); - bool iterateWellEq(const Simulator& simulator, - const Scalar dt, - SingleWellState& well_state) override; + bool iterateWellEq(const Simulator& simulator, const Scalar dt, SingleWellState& well_state) override; void solveEqAndUpdateWellState(SingleWellState& well_state); void apply(BVector& r) const override; - void recoverWellSolutionAndUpdateWellState(const BVector& x, - SingleWellState& well_state) override; + void recoverWellSolutionAndUpdateWellState(const BVector& x, SingleWellState& well_state) override; bool getConvergence() const override; void addWellContributions(SparseMatrixAdapter&) const override; private: - // primary variables PrimaryVariables primary_variables_; WellEquations well_equations_; @@ -129,36 +121,32 @@ class CompWell : public CompWellInterface // the following varialbes are temporary and remain to be cleaned up and re-organized // some are testing variables, and some are secondary variables might be kept // anyway, they are very rough prototype code for testing and will be changed - const Scalar wellbore_volume_ {21.6*0.001}; + const Scalar wellbore_volume_ {21.6 * 0.001}; - std::array mass_fractions_{0.}; - EvalWell fluid_density_{0.}; + std::array mass_fractions_ {0.}; + EvalWell fluid_density_ {0.}; // the original mass for each component in wellbore - std::array component_masses_{0.}; + std::array component_masses_ {0.}; // the new mass for each component in wellbore, derived from the primary variables - std::array new_component_masses_{0.}; + std::array new_component_masses_ {0.}; // quantities used to calculate the quantities under the surface conditions SurfaceConditons surface_conditions_; // following are some secondary property or variables to be used for later - void calculateSingleConnectionRate(const Simulator& simulator, - std::vector& con_rates) const; + void calculateSingleConnectionRate(const Simulator& simulator, std::vector& con_rates) const; void updateTotalMass(); // TODO: a better name void updateSurfaceQuantities(const Simulator& simulator); - void getMobility(const Simulator& simulator, - const int connection_idx, - std::vector& mob) const; + void getMobility(const Simulator& simulator, const int connection_idx, std::vector& mob) const; // TODO: the following assembling functions will be moved to a separate assmeble class void assembleSourceTerm(const Scalar dt); - void assembleControlEq(const SingleWellState& well_state, - const SummaryState& summary_state); + void assembleControlEq(const SingleWellState& well_state, const SummaryState& summary_state); void assembleControlEqProd(const SingleWellState& well_state, const Well::ProductionControls& prod_controls, @@ -173,19 +161,15 @@ class CompWell : public CompWellInterface // with passing in the SurfaceCondition, we should be able to do this in the primary variable class void updateWellStateFromPrimaryVariables(SingleWellState& well_state) const; - void updateWellState(const BVectorWell& dwells, - SingleWellState& well_state); + void updateWellState(const BVectorWell& dwells, SingleWellState& well_state); - void updateWellControl(const SummaryState& summary_state, - SingleWellState& well_state) const; + void updateWellControl(const SummaryState& summary_state, SingleWellState& well_state) const; template - void - updateSurfanceCondition_(const StandardCond& surface_cond, FluidState& fluid_state); + void updateSurfanceCondition_(const StandardCond& surface_cond, FluidState& fluid_state); template - void - flashFluidState_(FluidState& fluid_state); + void flashFluidState_(FluidState& fluid_state); }; } // end of namespace Opm diff --git a/flowexperimental/comp/wells/CompWellEquations.hpp b/flowexperimental/comp/wells/CompWellEquations.hpp index 2bb847e5717..02d56a9322a 100644 --- a/flowexperimental/comp/wells/CompWellEquations.hpp +++ b/flowexperimental/comp/wells/CompWellEquations.hpp @@ -25,7 +25,8 @@ #include #include -namespace Opm { +namespace Opm +{ // we should look into whether to use dynamic matrix and vector here template diff --git a/flowexperimental/comp/wells/CompWellEquations_impl.hpp b/flowexperimental/comp/wells/CompWellEquations_impl.hpp index fe1190867f9..71b29cb8ac3 100644 --- a/flowexperimental/comp/wells/CompWellEquations_impl.hpp +++ b/flowexperimental/comp/wells/CompWellEquations_impl.hpp @@ -19,45 +19,40 @@ #include -namespace Opm { +namespace Opm +{ template -CompWellEquations:: -CompWellEquations() +CompWellEquations::CompWellEquations() { duneB_.setBuildMode(OffDiagMatWell::row_wise); - duneC_.setBuildMode(OffDiagMatWell::row_wise), - duneD_.setBuildMode(DiagMatWell::row_wise); + duneC_.setBuildMode(OffDiagMatWell::row_wise), duneD_.setBuildMode(DiagMatWell::row_wise); invDuneD_.setBuildMode(DiagMatWell::row_wise); } template void -CompWellEquations:: -init(const int num_conn, const std::vector& cells) +CompWellEquations::init(const int num_conn, const std::vector& cells) { duneD_.setSize(1, 1, 1); duneB_.setSize(1, num_conn, num_conn); duneC_.setSize(1, num_conn, num_conn); - for (auto row = duneD_.createbegin(), - end = duneD_.createend(); row != end; ++row) { + for (auto row = duneD_.createbegin(), end = duneD_.createend(); row != end; ++row) { // Add nonzeros for diagonal row.insert(row.index()); } - for (auto row = duneB_.createbegin(), - end = duneB_.createend(); row != end; ++row) { - for (int con = 0 ; con < num_conn; ++con) { + for (auto row = duneB_.createbegin(), end = duneB_.createend(); row != end; ++row) { + for (int con = 0; con < num_conn; ++con) { row.insert(con); } } // make the C^T matrix // TODO: let us see whether we should change the naming of DuneC_ - for (auto row = duneC_.createbegin(), - end = duneC_.createend(); row != end; ++row) { + for (auto row = duneC_.createbegin(), end = duneC_.createend(); row != end; ++row) { for (int con = 0; con < num_conn; ++con) { row.insert(con); } @@ -75,8 +70,7 @@ init(const int num_conn, const std::vector& cells) template void -CompWellEquations:: -clear() +CompWellEquations::clear() { duneB_ = 0.0; duneC_ = 0.0; @@ -86,16 +80,14 @@ clear() template void -CompWellEquations:: -solve(BVectorWell& dx_well) const +CompWellEquations::solve(BVectorWell& dx_well) const { invDuneD_.mv(resWell_, dx_well); } template void -CompWellEquations:: -invert() +CompWellEquations::invert() { try { invDuneD_ = duneD_; // Not strictly need if not cpr with well contributions is used @@ -104,7 +96,7 @@ invert() // for singular matrices, use identity as the inverse invDuneD_[0][0] = 0.0; for (std::size_t i = 0; i < invDuneD_[0][0].rows; ++i) { - invDuneD_[0][0][i][i] = 1.0; + invDuneD_[0][0][i][i] = 1.0; } } } @@ -112,8 +104,7 @@ invert() template void -CompWellEquations:: -apply(BVector& r) const +CompWellEquations::apply(BVector& r) const { assert(invDrw_.size() == invDuneD_.N()); @@ -125,8 +116,7 @@ apply(BVector& r) const template void -CompWellEquations:: -recoverSolutionWell(const BVector& x, BVectorWell& xw) const +CompWellEquations::recoverSolutionWell(const BVector& x, BVectorWell& xw) const { BVectorWell resWell = resWell_; // resWell = resWell - B * x diff --git a/flowexperimental/comp/wells/CompWellInterface.hpp b/flowexperimental/comp/wells/CompWellInterface.hpp index 9efb70b0b60..9c040106b0c 100644 --- a/flowexperimental/comp/wells/CompWellInterface.hpp +++ b/flowexperimental/comp/wells/CompWellInterface.hpp @@ -27,7 +27,8 @@ #include -namespace Opm { +namespace Opm +{ template // TODO: do we need to use TypeTag here? class CompWellInterface @@ -55,34 +56,31 @@ class CompWellInterface const std::string& name() const; - virtual void calculateExplicitQuantities(const Simulator& simulator, - const SingleWellState& well_state) = 0; + virtual void calculateExplicitQuantities(const Simulator& simulator, const SingleWellState& well_state) = 0; - virtual void updatePrimaryVariables(const Simulator& simulator, - const SingleWellState& well_state) = 0; + virtual void updatePrimaryVariables(const Simulator& simulator, const SingleWellState& well_state) = 0; - virtual bool iterateWellEq(const Simulator& simulator, - const Scalar dt, - SingleWellState& well_state) = 0; + virtual bool iterateWellEq(const Simulator& simulator, const Scalar dt, SingleWellState& well_state) = 0; void addCellRates(RateVector& rates, unsigned cellIdx) const; - const std::vector& cells() const { return well_cells_; } + const std::vector& cells() const + { + return well_cells_; + } virtual void apply(BVector& r) const = 0; /// using the solution x to recover the solution xw for wells and applying /// xw to update Well State - virtual void recoverWellSolutionAndUpdateWellState(const BVector& x, - SingleWellState& well_state) = 0; + virtual void recoverWellSolutionAndUpdateWellState(const BVector& x, SingleWellState& well_state) = 0; virtual bool getConvergence() const = 0; virtual void addWellContributions(SparseMatrixAdapter&) const = 0; protected: - const Well& well_ecl_; - int index_of_well_{-1}; + int index_of_well_ {-1}; int number_of_connection_ {}; Scalar reference_depth_ {}; // TODO: we might not need it since it in well_ecl_. @@ -98,7 +96,6 @@ class CompWellInterface std::vector saturation_table_number_; // std::string name_; - }; diff --git a/flowexperimental/comp/wells/CompWellInterface_impl.hpp b/flowexperimental/comp/wells/CompWellInterface_impl.hpp index 968b382bdbd..3a45cb9e73e 100644 --- a/flowexperimental/comp/wells/CompWellInterface_impl.hpp +++ b/flowexperimental/comp/wells/CompWellInterface_impl.hpp @@ -19,12 +19,12 @@ #include -namespace Opm { +namespace Opm +{ template -CompWellInterface:: -CompWellInterface(const Well& well, - const int index_of_well, - const std::vector& well_connection_data) +CompWellInterface::CompWellInterface(const Well& well, + const int index_of_well, + const std::vector& well_connection_data) : well_ecl_(well) , index_of_well_(index_of_well) , number_of_connection_(well_connection_data.size()) @@ -48,29 +48,25 @@ CompWellInterface(const Well& well, } // TODO: saturation_table_number } - } template void -CompWellInterface:: -init() +CompWellInterface::init() { // more things to add here } template const std::string& -CompWellInterface:: -name() const +CompWellInterface::name() const { return this->well_ecl_.name(); } template void -CompWellInterface:: -addCellRates(RateVector& rates, unsigned cellIdx) const +CompWellInterface::addCellRates(RateVector& rates, unsigned cellIdx) const { for (int con = 0; con < this->number_of_connection_; ++con) { if (this->well_cells_[con] == cellIdx) { diff --git a/flowexperimental/comp/wells/CompWellModel.hpp b/flowexperimental/comp/wells/CompWellModel.hpp index d8348ae69f0..b20e970e7af 100644 --- a/flowexperimental/comp/wells/CompWellModel.hpp +++ b/flowexperimental/comp/wells/CompWellModel.hpp @@ -22,9 +22,9 @@ #include -#include -#include #include +#include +#include #include #include @@ -38,11 +38,12 @@ #include -namespace Opm { +namespace Opm +{ class Schedule; -template +template class CompWellModel : WellConnectionAuxiliaryModule> { using ElementContext = GetPropType; @@ -68,51 +69,69 @@ class CompWellModel : WellConnectionAuxiliaryModule >; + using CompWellPtr = std::shared_ptr>; explicit CompWellModel(Simulator& /*simulator*/); // No extra dofs are inserted for wells. (we use a Schur complement.) [[nodiscard]] unsigned numDofs() const override - { return 0; } + { + return 0; + } -// void addNeighbors(std::vector& /* neighbors */) const override -// {} + // void addNeighbors(std::vector& /* neighbors */) const override + // {} - void applyInitial() override {} + void applyInitial() override + { + } // void linearize(SparseMatrixAdapter& /*matrix*/, GlobalEqVector& /*residual*/) override; template void serialize(Restarter& /*res*/) - {} + { + } template void deserialize(Restarter& /*res*/) - {} + { + } - void beginEpisode() { beginReportStep(simulator_.episodeIndex()); } + void beginEpisode() + { + beginReportStep(simulator_.episodeIndex()); + } void beginReportStep(unsigned report_step); void beginTimeStep(); void beginIteration(); void init(); - void endIteration() const {} - void endTimeStep() {} - void endEpisode() {} + void endIteration() const + { + } + void endTimeStep() + { + } + void endEpisode() + { + } void computeTotalRatesForDof(RateVector& /*rate*/, unsigned /*globalIdx*/) const; // [[nodiscard]] data::Wells wellData() const; - [[nodiscard]] data::WellBlockAveragePressures wellBlockAveragePressures() const { - return data::WellBlockAveragePressures{}; + [[nodiscard]] data::WellBlockAveragePressures wellBlockAveragePressures() const + { + return data::WellBlockAveragePressures {}; } - [[nodiscard]] data::GroupAndNetworkValues groupAndNetworkData(const int&) const { - return data::GroupAndNetworkValues{}; + [[nodiscard]] data::GroupAndNetworkValues groupAndNetworkData(const int&) const + { + return data::GroupAndNetworkValues {}; } - [[nodiscard]] WellTestState wellTestState() const { - return WellTestState{}; + [[nodiscard]] WellTestState wellTestState() const + { + return WellTestState {}; } // using the solution x to recover the solution xw for wells and applying @@ -120,10 +139,22 @@ class CompWellModel : WellConnectionAuxiliaryModule getCellsForConnections(const Well& well) const; private: - Simulator& simulator_; - const Schedule& schedule_; - const SummaryState& summary_state_; - const EclipseState& ecl_state_; - const Parallel::Communication& comm_; + Simulator& simulator_; + const Schedule& schedule_; + const SummaryState& summary_state_; + const EclipseState& ecl_state_; + const Parallel::Communication& comm_; - // we might need something lighter - const CompositionalConfig& comp_config_; + // we might need something lighter + const CompositionalConfig& comp_config_; - // we will need two to handle the changes between time stepping - CompWellState comp_well_states_; + // we will need two to handle the changes between time stepping + CompWellState comp_well_states_; - // this is needed for parallel running, not all the wells will be in the same process - std::vector wells_ecl_; - std::vector > well_connection_data_; - // const Schedule& schedule_; - std::vector well_container_; + // this is needed for parallel running, not all the wells will be in the same process + std::vector wells_ecl_; + std::vector> well_connection_data_; + // const Schedule& schedule_; + std::vector well_container_; - mutable BVector x_local_; + mutable BVector x_local_; - std::size_t local_num_cells_{0}; + std::size_t local_num_cells_ {0}; - void createWellContainer(); - void initWellContainer(); + void createWellContainer(); + void initWellContainer(); - void initWellConnectionData(); - void initWellState(); + void initWellConnectionData(); + void initWellState(); - void assemble(const int iterationIdx, - const double dt); + void assemble(const int iterationIdx, const double dt); - void calculateExplicitQuantities(); + void calculateExplicitQuantities(); }; } // end of namespace Opm diff --git a/flowexperimental/comp/wells/CompWellModel_impl.hpp b/flowexperimental/comp/wells/CompWellModel_impl.hpp index e0821c3c0c1..29889cc6134 100644 --- a/flowexperimental/comp/wells/CompWellModel_impl.hpp +++ b/flowexperimental/comp/wells/CompWellModel_impl.hpp @@ -30,7 +30,8 @@ #include #include -namespace Opm { +namespace Opm +{ template CompWellModel::CompWellModel(Simulator& simulator) @@ -48,8 +49,7 @@ CompWellModel::CompWellModel(Simulator& simulator) template void -CompWellModel:: -beginReportStep(unsigned report_step) +CompWellModel::beginReportStep(unsigned report_step) { // TODO: not considering the parallel running yet wells_ecl_ = schedule_.getWells(report_step); @@ -59,8 +59,7 @@ beginReportStep(unsigned report_step) template void -CompWellModel:: -beginTimeStep() +CompWellModel::beginTimeStep() { createWellContainer(); initWellContainer(); @@ -68,16 +67,14 @@ beginTimeStep() template void -CompWellModel:: -init() +CompWellModel::init() { simulator_.model().addAuxiliaryModule(this); } template void -CompWellModel:: -createWellContainer() +CompWellModel::createWellContainer() { // const auto& schedule = simulator_.vanguard().schedule(); const auto nw = wells_ecl_.size(); // not considering the parallel running yet @@ -89,8 +86,7 @@ createWellContainer() template void -CompWellModel:: -initWellContainer() +CompWellModel::initWellContainer() { for (auto& well : well_container_) { well->init(); @@ -99,8 +95,7 @@ initWellContainer() template void -CompWellModel:: -initWellConnectionData() +CompWellModel::initWellConnectionData() { // TODO: we need to consider the parallel running // we can refer to the BlackoilWellModelGeneric::initializeWellPerfData() @@ -114,11 +109,9 @@ initWellConnectionData() well_connection_data.reserve(well_connections.size()); for (const auto& connection : well_connections) { - const auto active_index = - this->compressedIndexForInterior(connection.global_index()); + const auto active_index = this->compressedIndexForInterior(connection.global_index()); - const auto connIsOpen = - connection.state() == Connection::State::OPEN; + const auto connIsOpen = connection.state() == Connection::State::OPEN; if (connIsOpen && (active_index >= 0)) { auto& pd = well_connection_data_[well_index].emplace_back(); @@ -132,34 +125,31 @@ initWellConnectionData() } ++well_index; } - } template void -CompWellModel:: -initWellState() +CompWellModel::initWellState() { // TODO: the following might need to be adjusted based on understanding - const auto pressIx = []() - { - if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx) ) { + const auto pressIx = []() { + if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)) { return FluidSystem::oilPhaseIdx; } - if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx) ) { + if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) { return FluidSystem::gasPhaseIdx; } assert(false && "the usage of oil and gas phase is not correct"); return FluidSystem::gasPhaseIdx; }(); - auto cell_pressure = std::vector(this->local_num_cells_, Scalar{0.}); - auto cell_mole_fractions = std::vector>(this->local_num_cells_, - std::vector(FluidSystem::numComponents, Scalar{0.})); + auto cell_pressure = std::vector(this->local_num_cells_, Scalar {0.}); + auto cell_mole_fractions = std::vector>( + this->local_num_cells_, std::vector(FluidSystem::numComponents, Scalar {0.})); - auto cell_temperature = std::vector(this->local_num_cells_, Scalar{0.}); + auto cell_temperature = std::vector(this->local_num_cells_, Scalar {0.}); - auto elemCtx = ElementContext { this->simulator_ }; + auto elemCtx = ElementContext {this->simulator_}; const auto& gridView = this->simulator_.vanguard().gridView(); OPM_BEGIN_PARALLEL_TRY_CATCH(); @@ -171,43 +161,45 @@ initWellState() const auto& fs = elemCtx.intensiveQuantities(/*spaceIdx=*/0, /*timeIdx=*/0).fluidState(); cell_pressure[ix] = fs.pressure(pressIx).value(); - // TODO: we are not simulating dynamic temperature, so all the phases and cells have the same temperature for now + // TODO: we are not simulating dynamic temperature, so all the phases and cells have the same temperature for + // now cell_temperature[ix] = fs.temperature(0).value(); for (unsigned compIdx = 0; compIdx < FluidSystem::numComponents; ++compIdx) { cell_mole_fractions[ix][compIdx] = fs.moleFraction(compIdx).value(); } } OPM_END_PARALLEL_TRY_CATCH("ComposotionalWellModel::initializeWellState() failed: ", - this->simulator_.vanguard().grid().comm()); + this->simulator_.vanguard().grid().comm()); /* TODO: no prev well state for now */ - // \Note:: we are not supporting dynamic temperature, so the temperature is constant, so we just pass in a single value + // \Note:: we are not supporting dynamic temperature, so the temperature is constant, so we just pass in a single + // value this->comp_well_states_.init(this->wells_ecl_, - cell_pressure, cell_temperature[0], cell_mole_fractions, this->well_connection_data_, + cell_pressure, + cell_temperature[0], + cell_mole_fractions, + this->well_connection_data_, this->summary_state_); } template std::size_t -CompWellModel:: -compressedIndexForInterior(std::size_t cartesian_cell_idx) const +CompWellModel::compressedIndexForInterior(std::size_t cartesian_cell_idx) const { return simulator_.vanguard().compressedIndexForInterior(cartesian_cell_idx); } template std::vector -CompWellModel:: -getCellsForConnections(const Well& well) const +CompWellModel::getCellsForConnections(const Well& well) const { std::vector wellCells; // All possible connections of the well const auto& connectionSet = well.getConnections(); wellCells.reserve(connectionSet.size()); - for (const auto& connection : connectionSet) - { + for (const auto& connection : connectionSet) { int compressed_idx = compressedIndexForInterior(connection.global_index()); if (compressed_idx >= 0) { // Ignore connections in inactive/remote cells. wellCells.push_back(compressed_idx); @@ -215,13 +207,11 @@ getCellsForConnections(const Well& well) const } return wellCells; - } template void -CompWellModel:: -beginIteration() +CompWellModel::beginIteration() { // do we need to do every iteration here? const auto& grid = simulator_.vanguard().grid(); @@ -237,9 +227,7 @@ beginIteration() template void -CompWellModel:: -assemble(const int iterationIdx, - const double dt) +CompWellModel::assemble(const int iterationIdx, const double dt) { if (iterationIdx == 0) { @@ -255,8 +243,7 @@ assemble(const int iterationIdx, template void -CompWellModel:: -calculateExplicitQuantities() +CompWellModel::calculateExplicitQuantities() { for (auto& well : well_container_) { const auto& well_state = comp_well_states_[well->name()]; @@ -266,18 +253,16 @@ calculateExplicitQuantities() template void -CompWellModel:: -computeTotalRatesForDof(RateVector& rate, - unsigned globalIdx) const { - for (const auto& well: well_container_) { +CompWellModel::computeTotalRatesForDof(RateVector& rate, unsigned globalIdx) const +{ + for (const auto& well : well_container_) { well->addCellRates(rate, globalIdx); } } -template +template void -CompWellModel:: -recoverWellSolutionAndUpdateWellState(const BVector& x) +CompWellModel::recoverWellSolutionAndUpdateWellState(const BVector& x) { { for (const auto& well : well_container_) { @@ -295,8 +280,7 @@ recoverWellSolutionAndUpdateWellState(const BVector& x) template bool -CompWellModel:: -getWellConvergence() const +CompWellModel::getWellConvergence() const { bool converged = true; for (const auto& well : this->well_container_) { @@ -307,8 +291,7 @@ getWellConvergence() const template data::Wells -CompWellModel:: -wellData() const +CompWellModel::wellData() const { return this->comp_well_states_.report(); } diff --git a/flowexperimental/comp/wells/CompWellPrimaryVariables.hpp b/flowexperimental/comp/wells/CompWellPrimaryVariables.hpp index 0598d692200..6c0286a1b7d 100644 --- a/flowexperimental/comp/wells/CompWellPrimaryVariables.hpp +++ b/flowexperimental/comp/wells/CompWellPrimaryVariables.hpp @@ -26,7 +26,8 @@ #include -namespace Opm { +namespace Opm +{ template class SingleCompWellState; @@ -43,7 +44,8 @@ class CompWellPrimaryVariables // the last primary variable will be the BHP // the one in the middle with will the mole fractions for the numWellEq - 1 components // this can be changed based on the implementation itself - static constexpr int QTotal = 0; // TODO: for now, it is the total surface rate, but later, we might make it total mass rate + static constexpr int QTotal + = 0; // TODO: for now, it is the total surface rate, but later, we might make it total mass rate static constexpr int Bhp = numWellEq - numWellControlEq; using Scalar = typename FluidSystem::Scalar; @@ -83,11 +85,10 @@ class CompWellPrimaryVariables std::array evaluation_; // temperature for now is constant, so it is not part of the primary variables // we need it for the flash calculation - Scalar temperature_{0.}; + Scalar temperature_ {0.}; template T getValue_(int index) const; - }; } // end of namespace Opm diff --git a/flowexperimental/comp/wells/CompWellPrimaryVariables_impl.hpp b/flowexperimental/comp/wells/CompWellPrimaryVariables_impl.hpp index f1891e01a95..271ae6adcc8 100644 --- a/flowexperimental/comp/wells/CompWellPrimaryVariables_impl.hpp +++ b/flowexperimental/comp/wells/CompWellPrimaryVariables_impl.hpp @@ -22,12 +22,12 @@ #include -namespace Opm { +namespace Opm +{ template void -CompWellPrimaryVariables:: -update(const SingleWellState& well_state) +CompWellPrimaryVariables::update(const SingleWellState& well_state) { value_[QTotal] = well_state.get_total_surface_rate(); // the mole fractions of the first n-1 component @@ -50,8 +50,7 @@ update(const SingleWellState& well_state) template void -CompWellPrimaryVariables:: -updateEvaluation() +CompWellPrimaryVariables::updateEvaluation() { for (std::size_t idx = 0; idx < numWellEq; ++idx) { evaluation_[idx] = 0.; @@ -62,28 +61,25 @@ updateEvaluation() template typename CompWellPrimaryVariables::EvalWell -CompWellPrimaryVariables:: -getBhp() const +CompWellPrimaryVariables::getBhp() const { return evaluation_[Bhp]; } template typename CompWellPrimaryVariables::EvalWell -CompWellPrimaryVariables:: -getTotalRate() const +CompWellPrimaryVariables::getTotalRate() const { return evaluation_[QTotal]; } template typename CompWellPrimaryVariables::EvalWell -CompWellPrimaryVariables:: -extendEval(const Eval& in) +CompWellPrimaryVariables::extendEval(const Eval& in) { EvalWell out = 0.0; out.setValue(in.value()); - for(int eq_idx = 0; eq_idx < Indices::numEq;++eq_idx) { + for (int eq_idx = 0; eq_idx < Indices::numEq; ++eq_idx) { out.setDerivative(eq_idx, in.derivative(eq_idx)); } return out; @@ -91,12 +87,11 @@ extendEval(const Eval& in) template typename CompWellPrimaryVariables::Eval -CompWellPrimaryVariables:: -restrictEval(const EvalWell& in) +CompWellPrimaryVariables::restrictEval(const EvalWell& in) { Eval out = 0.0; out.setValue(in.value()); - for(int eq_idx = 0; eq_idx < Indices::numEq;++eq_idx) { + for (int eq_idx = 0; eq_idx < Indices::numEq; ++eq_idx) { out.setDerivative(eq_idx, in.derivative(eq_idx)); } return out; @@ -104,8 +99,7 @@ restrictEval(const EvalWell& in) template void -CompWellPrimaryVariables:: -updateNewton(const BVectorWell& dwells) +CompWellPrimaryVariables::updateNewton(const BVectorWell& dwells) { constexpr Scalar damping = 1.0; @@ -117,7 +111,7 @@ updateNewton(const BVectorWell& dwells) value_[2] = std::clamp(value_[2], 1.e-10, 1.); std::vector mole_fractions(FluidSystem::numComponents, 0.); Scalar sum_mole_fraction = 0.; - for (int i = 0; i < FluidSystem::numComponents-1; ++i) { + for (int i = 0; i < FluidSystem::numComponents - 1; ++i) { mole_fractions[i] = std::max(value_[i + 1], 1.e-10); sum_mole_fraction += mole_fractions[i]; } @@ -133,10 +127,10 @@ updateNewton(const BVectorWell& dwells) template template T -CompWellPrimaryVariables:: -getValue_(int index) const +CompWellPrimaryVariables::getValue_(int index) const { - static_assert(std::is_same_v || std::is_same_v, "Unsupported type in CompWellPrimaryVariables::getValue_"); + static_assert(std::is_same_v || std::is_same_v, + "Unsupported type in CompWellPrimaryVariables::getValue_"); if constexpr (std::is_same_v) { return value_[index]; @@ -148,10 +142,10 @@ getValue_(int index) const template template typename CompWellPrimaryVariables::template FluidState -CompWellPrimaryVariables:: -toFluidState() const +CompWellPrimaryVariables::toFluidState() const { - static_assert(std::is_same_v || std::is_same_v, "Unsupported type in CompWellPrimaryVariables::toFluidState"); + static_assert(std::is_same_v || std::is_same_v, + "Unsupported type in CompWellPrimaryVariables::toFluidState"); CompositionalFluidState fluid_state; const auto& pressure = getValue_(Bhp); diff --git a/flowexperimental/comp/wells/CompWellState.hpp b/flowexperimental/comp/wells/CompWellState.hpp index bcd705ef8a6..2b9a0e42430 100644 --- a/flowexperimental/comp/wells/CompWellState.hpp +++ b/flowexperimental/comp/wells/CompWellState.hpp @@ -24,8 +24,8 @@ // if yes, we might want to rename it // TODO: we also the informaton regarding the components // #include -#include #include +#include #include @@ -33,7 +33,8 @@ #include -namespace Opm { +namespace Opm +{ template class CompWellState @@ -49,7 +50,7 @@ class CompWellState const std::vector& cell_pressures, const Scalar cell_temperature, const std::vector>& cell_mole_fractions, - const std::vector >& well_connection_data, + const std::vector>& well_connection_data, const SummaryState& sumary_state, const CompWellState* prev_well_state = nullptr); @@ -68,14 +69,14 @@ class CompWellState const std::vector& cell_pressures, const Scalar temperature, const std::vector>& cell_mole_fractions, - const std::vector >& well_connection_data, + const std::vector>& well_connection_data, const SummaryState& summary_state); void initSingleWell(const Well& well, const std::vector& cell_pressures, const Scalar tempearture, const std::vector>& cell_mole_fractions, - const std::vector& conn_data, + const std::vector& conn_data, const SummaryState& summary_state); void initSingleInjector(const Well& well, diff --git a/flowexperimental/comp/wells/CompWellState_impl.hpp b/flowexperimental/comp/wells/CompWellState_impl.hpp index c2231c108e8..da0f9fa00c6 100644 --- a/flowexperimental/comp/wells/CompWellState_impl.hpp +++ b/flowexperimental/comp/wells/CompWellState_impl.hpp @@ -17,25 +17,25 @@ along with OPM. If not, see . */ -namespace Opm { +namespace Opm +{ template -CompWellState:: -CompWellState(const CompositionalConfig& comp_config) +CompWellState::CompWellState(const CompositionalConfig& comp_config) : comp_config_(comp_config) { } template -void CompWellState:: -init(const std::vector& wells_ecl, - const std::vector& cell_pressures, - const Scalar temperature, - const std::vector>& cell_mole_fractions, - const std::vector >& well_connection_data, - const SummaryState& summary_state, - const CompWellState* /*prev_well_state*/) +void +CompWellState::init(const std::vector& wells_ecl, + const std::vector& cell_pressures, + const Scalar temperature, + const std::vector>& cell_mole_fractions, + const std::vector>& well_connection_data, + const SummaryState& summary_state, + const CompWellState* /*prev_well_state*/) { this->base_init(wells_ecl, cell_pressures, temperature, cell_mole_fractions, well_connection_data, summary_state); @@ -44,98 +44,85 @@ init(const std::vector& wells_ecl, } template -void CompWellState:: -base_init(const std::vector& wells_ecl, - const std::vector& cell_pressures, - const Scalar temperature, - const std::vector>& cell_mole_fractions, - const std::vector>& well_connection_data, - const SummaryState& summary_state) +void +CompWellState::base_init(const std::vector& wells_ecl, + const std::vector& cell_pressures, + const Scalar temperature, + const std::vector>& cell_mole_fractions, + const std::vector>& well_connection_data, + const SummaryState& summary_state) { this->wells_.clear(); const auto num_wells = wells_ecl.size(); - for (auto w = 0*num_wells; w < num_wells; ++w) { + for (auto w = 0 * num_wells; w < num_wells; ++w) { const Well& well = wells_ecl[w]; const auto& conn_data = well_connection_data[w]; initSingleWell(well, cell_pressures, temperature, cell_mole_fractions, conn_data, summary_state); } - } template -void CompWellState:: -initSingleWell(const Well& well, - const std::vector& cell_pressures, - const Scalar tempearture, - const std::vector>& cell_mole_fractions, - const std::vector& conn_data, - const SummaryState& summary_state) +void +CompWellState::initSingleWell(const Well& well, + const std::vector& cell_pressures, + const Scalar tempearture, + const std::vector>& cell_mole_fractions, + const std::vector& conn_data, + const SummaryState& summary_state) { if (well.isInjector()) { initSingleInjector(well, cell_pressures, tempearture, conn_data, summary_state); } else { initSingleProducer(well, cell_pressures, tempearture, cell_mole_fractions, conn_data, summary_state); } - } template -void CompWellState:: -initSingleInjector(const Well& well, - const std::vector& /* cell_pressures */, - const Scalar temperature, - const std::vector& conn_data, - const SummaryState& summary_state) +void +CompWellState::initSingleInjector(const Well& well, + const std::vector& /* cell_pressures */, + const Scalar temperature, + const std::vector& conn_data, + const SummaryState& summary_state) { auto& ws = this->wells_.add(well.name(), - SingleWellState(well.name(), - this->comp_config_, - temperature, - conn_data, - false) ); + SingleWellState(well.name(), this->comp_config_, temperature, conn_data, false)); ws.update_injector_targets(well, summary_state); } template -void CompWellState:: -initSingleProducer(const Well& well, - const std::vector& /* cell_pressures */, - const Scalar temperature, - const std::vector>& cell_mole_fractions, - const std::vector& conn_data, - const SummaryState& summary_state) +void +CompWellState::initSingleProducer(const Well& well, + const std::vector& /* cell_pressures */, + const Scalar temperature, + const std::vector>& cell_mole_fractions, + const std::vector& conn_data, + const SummaryState& summary_state) { - auto& ws = this->wells_.add(well.name(), - SingleWellState(well.name(), - this->comp_config_, - temperature, - conn_data, - true) ); + auto& ws + = this->wells_.add(well.name(), SingleWellState(well.name(), this->comp_config_, temperature, conn_data, true)); ws.update_producer_targets(well, cell_mole_fractions, summary_state); } template const typename CompWellState::SingleWellState& -CompWellState:: -operator[](const std::string& well_name) const +CompWellState::operator[](const std::string& well_name) const { return this->wells_[well_name]; } template typename CompWellState::SingleWellState& -CompWellState:: -operator[](const std::string& well_name) +CompWellState::operator[](const std::string& well_name) { return this->wells_[well_name]; } template data::Wells -CompWellState:: -report() const +CompWellState::report() const { if (this->wells_.empty()) { return {}; diff --git a/flowexperimental/comp/wells/CompWell_impl.hpp b/flowexperimental/comp/wells/CompWell_impl.hpp index bd7c348b79e..6e492c571cd 100644 --- a/flowexperimental/comp/wells/CompWell_impl.hpp +++ b/flowexperimental/comp/wells/CompWell_impl.hpp @@ -25,21 +25,20 @@ #include #include -namespace Opm { +namespace Opm +{ template -CompWell:: -CompWell(const Well& well, - int index_of_well, - const std::vector& well_connection_data) - : CompWellInterface(well, index_of_well, well_connection_data) +CompWell::CompWell(const Well& well, + int index_of_well, + const std::vector& well_connection_data) + : CompWellInterface(well, index_of_well, well_connection_data) { } template void -CompWell:: -init() +CompWell::init() { Base::init(); well_equations_.init(this->number_of_connection_, this->well_cells_); @@ -47,9 +46,7 @@ init() template void -CompWell:: -calculateExplicitQuantities(const Simulator& simulator, - const SingleWellState& well_state) +CompWell::calculateExplicitQuantities(const Simulator& simulator, const SingleWellState& well_state) { updatePrimaryVariables(simulator, well_state); { @@ -72,25 +69,23 @@ calculateExplicitQuantities(const Simulator& simulator, const auto& density_gas = fluid_state_scalar.density(FluidSystem::gasPhaseIdx); for (unsigned compidx = 0; compidx < FluidSystem::numComponents; ++compidx) { - this->component_masses_[compidx] = (oil_mass_fractions[compidx] * density_oil * so + - gas_mass_fractions[compidx] * density_gas * sg) * wellbore_volume; + this->component_masses_[compidx] + = (oil_mass_fractions[compidx] * density_oil * so + gas_mass_fractions[compidx] * density_gas * sg) + * wellbore_volume; } } } template void -CompWell:: -updatePrimaryVariables(const Simulator& /* simulator */, - const SingleWellState& well_state) +CompWell::updatePrimaryVariables(const Simulator& /* simulator */, const SingleWellState& well_state) { this->primary_variables_.update(well_state); } template void -CompWell:: -updateSecondaryQuantities(const Simulator& simulator) +CompWell::updateSecondaryQuantities(const Simulator& simulator) { updateTotalMass(); updateSurfaceQuantities(simulator); @@ -99,8 +94,7 @@ updateSecondaryQuantities(const Simulator& simulator) template void -CompWell:: -updateTotalMass() +CompWell::updateTotalMass() { // flash calculation in the wellbore auto fluid_state = this->primary_variables_.template toFluidState(); @@ -121,8 +115,9 @@ updateTotalMass() const auto& density_gas = fluid_state.density(FluidSystem::gasPhaseIdx); const Scalar wellbore_volume = this->wellbore_volume_; for (unsigned compidx = 0; compidx < FluidSystem::numComponents; ++compidx) { - this->new_component_masses_[compidx] = (oil_mass_fractions[compidx] * density_oil * so + - gas_mass_fractions[compidx] * density_gas * sg) * wellbore_volume; + this->new_component_masses_[compidx] + = (oil_mass_fractions[compidx] * density_oil * so + gas_mass_fractions[compidx] * density_gas * sg) + * wellbore_volume; total_mass += this->new_component_masses_[compidx]; } @@ -137,8 +132,7 @@ updateTotalMass() template void -CompWell:: -updateSurfaceQuantities(const Simulator& simulator) +CompWell::updateSurfaceQuantities(const Simulator& simulator) { const auto& surface_cond = simulator.vanguard().eclState().getTableManager().stCond(); if (this->well_ecl_.isInjector()) { // we look for well stream for injection composition @@ -149,17 +143,16 @@ updateSurfaceQuantities(const Simulator& simulator) } updateSurfanceCondition_(surface_cond, fluid_state); } else { // the composition will be from the wellbore - // here, it will use the composition from the wellbore and the pressure and temperature from the surface condition + // here, it will use the composition from the wellbore and the pressure and temperature from the surface + // condition auto fluid_state = this->primary_variables_.template toFluidState(); updateSurfanceCondition_(surface_cond, fluid_state); - } + } } template void -CompWell:: -calculateSingleConnectionRate(const Simulator& simulator, - std::vector& con_rates) const +CompWell::calculateSingleConnectionRate(const Simulator& simulator, std::vector& con_rates) const { constexpr int con_idx = 0; // TODO: to be a function argument for multiple connection wells constexpr int np = 2; // TODO: this will be the number of phases @@ -180,10 +173,11 @@ calculateSingleConnectionRate(const Simulator& simulator, if (drawdown > 0.) { // producing connection std::vector cq_v(np); for (unsigned phase_idx = 0; phase_idx < np; ++phase_idx) { - cq_v[phase_idx] = - mob[phase_idx] * tw * drawdown; + cq_v[phase_idx] = -mob[phase_idx] * tw * drawdown; for (unsigned comp_idx = 0; comp_idx < FluidSystem::numComponents; comp_idx++) { const EvalWell density = PrimaryVariables::extendEval(fluid_state.density(phase_idx)); - const EvalWell mass_fraction = PrimaryVariables::extendEval(fluid_state.massFraction(phase_idx, comp_idx)); + const EvalWell mass_fraction + = PrimaryVariables::extendEval(fluid_state.massFraction(phase_idx, comp_idx)); con_rates[comp_idx] += cq_v[phase_idx] * density * mass_fraction; } } @@ -192,7 +186,7 @@ calculateSingleConnectionRate(const Simulator& simulator, for (unsigned phase_idx = 0; phase_idx < np; ++phase_idx) { total_mobility += mob[phase_idx]; } - EvalWell cq_v = - total_mobility * tw * drawdown; + EvalWell cq_v = -total_mobility * tw * drawdown; for (unsigned comp_idx = 0; comp_idx < FluidSystem::numComponents; comp_idx++) { con_rates[comp_idx] = cq_v * fluid_density_ * mass_fractions_[comp_idx]; } @@ -200,10 +194,8 @@ calculateSingleConnectionRate(const Simulator& simulator, } template -void CompWell:: -getMobility(const Simulator& simulator, - const int connectin_idx, - std::vector& mob) const +void +CompWell::getMobility(const Simulator& simulator, const int connectin_idx, std::vector& mob) const { const unsigned cell_idx = this->well_cells_[connectin_idx]; const auto& int_quants = simulator.problem().model().cachedIntensiveQuantities(cell_idx, 0); @@ -220,15 +212,11 @@ getMobility(const Simulator& simulator, mob[phase_idx] = PrimaryVariables::extendEval(int_quants->mobility(phase_idx)); } } - } template void -CompWell:: -assembleWellEq(const Simulator& simulator, - const SingleWellState& well_state, - const double dt) +CompWell::assembleWellEq(const Simulator& simulator, const SingleWellState& well_state, const double dt) { this->well_equations_.clear(); @@ -251,8 +239,10 @@ assembleWellEq(const Simulator& simulator, this->well_equations_.residual()[0][comp_idx] += connection_rates[comp_idx].value(); for (unsigned pvIdx = 0; pvIdx < PrimaryVariables::numWellEq; ++pvIdx) { // C, needs the cell_idx - this->well_equations_.C()[0][0][pvIdx][comp_idx] -= connection_rates[comp_idx].derivative(pvIdx + PrimaryVariables::numResEq); - this->well_equations_.D()[0][0][comp_idx][pvIdx] += connection_rates[comp_idx].derivative(pvIdx + PrimaryVariables::numResEq); + this->well_equations_.C()[0][0][pvIdx][comp_idx] + -= connection_rates[comp_idx].derivative(pvIdx + PrimaryVariables::numResEq); + this->well_equations_.D()[0][0][comp_idx][pvIdx] + += connection_rates[comp_idx].derivative(pvIdx + PrimaryVariables::numResEq); } for (unsigned pvIdx = 0; pvIdx < PrimaryVariables::numResEq; ++pvIdx) { @@ -267,14 +257,11 @@ assembleWellEq(const Simulator& simulator, // there will be num_comp mass balance equations for each component and one for the well control equations // for the mass balance equations, it will be the sum of the connection rates for each component, // add minus the production rate for each component, will equal to the mass change for each component - } template void -CompWell:: -assembleControlEq(const SingleWellState& well_state, - const SummaryState& summary_state) +CompWell::assembleControlEq(const SingleWellState& well_state, const SummaryState& summary_state) { EvalWell control_eq; if (this->well_ecl_.isProducer()) { @@ -287,16 +274,16 @@ assembleControlEq(const SingleWellState& well_state, this->well_equations_.residual()[0][PrimaryVariables::Bhp] = control_eq.value(); for (unsigned pvIdx = 0; pvIdx < PrimaryVariables::numWellEq; ++pvIdx) { - this->well_equations_.D()[0][0][PrimaryVariables::Bhp][pvIdx] = control_eq.derivative(pvIdx + PrimaryVariables::numResEq); + this->well_equations_.D()[0][0][PrimaryVariables::Bhp][pvIdx] + = control_eq.derivative(pvIdx + PrimaryVariables::numResEq); } } template void -CompWell:: -assembleControlEqProd(const SingleWellState& well_state, - const Well::ProductionControls& prod_controls, - EvalWell& control_eq) const +CompWell::assembleControlEqProd(const SingleWellState& well_state, + const Well::ProductionControls& prod_controls, + EvalWell& control_eq) const { // TODO: we only need to pass in the current control? const auto current = well_state.production_cmode; @@ -304,19 +291,19 @@ assembleControlEqProd(const SingleWellState& well_state, const auto& surface_cond = this->surface_conditions_; switch (current) { - case WellProducerCMode::BHP : { + case WellProducerCMode::BHP: { const Scalar bhp_limit = prod_controls.bhp_limit; control_eq = this->primary_variables_.getBhp() - bhp_limit; break; } - case WellProducerCMode::ORAT : { + case WellProducerCMode::ORAT: { const Scalar rate_target = prod_controls.oil_rate; const EvalWell& total_rate = this->primary_variables_.getTotalRate(); const EvalWell oil_rate = total_rate * surface_cond.volume_fractions_[FluidSystem::oilPhaseIdx]; control_eq = oil_rate + rate_target; break; } - case WellProducerCMode::GRAT : { + case WellProducerCMode::GRAT: { const Scalar rate_target = prod_controls.gas_rate; const EvalWell& total_rate = this->primary_variables_.getTotalRate(); const EvalWell gas_rate = total_rate * surface_cond.volume_fractions_[FluidSystem::gasPhaseIdx]; @@ -330,21 +317,20 @@ assembleControlEqProd(const SingleWellState& well_state, template void -CompWell:: -assembleControlEqInj(const SingleWellState& well_state, - const Well::InjectionControls& inj_controls, - EvalWell& control_eq) const +CompWell::assembleControlEqInj(const SingleWellState& well_state, + const Well::InjectionControls& inj_controls, + EvalWell& control_eq) const { // TODO: we only need to pass in the current control? const auto current = well_state.injection_cmode; switch (current) { - case WellInjectorCMode::BHP : { + case WellInjectorCMode::BHP: { const Scalar bhp_limit = inj_controls.bhp_limit; control_eq = this->primary_variables_.getBhp() - bhp_limit; break; } - case WellInjectorCMode::RATE : { + case WellInjectorCMode::RATE: { const Scalar rate_target = inj_controls.surface_rate; const EvalWell& injection_rate = this->primary_variables_.getTotalRate(); control_eq = injection_rate - rate_target; @@ -358,20 +344,20 @@ assembleControlEqInj(const SingleWellState& well_state, template void -CompWell:: -assembleSourceTerm(const Scalar dt) +CompWell::assembleSourceTerm(const Scalar dt) { // calculating the injection mass rate for each component const EvalWell total_surface_rate = this->primary_variables_.getTotalRate(); const EvalWell density = this->surface_conditions_.density(); const EvalWell total_mass_rate = total_surface_rate * density; std::array component_mass_rates; - for (unsigned comp_idx = 0; comp_idx < FluidSystem::numComponents; ++comp_idx) { + for (unsigned comp_idx = 0; comp_idx < FluidSystem::numComponents; ++comp_idx) { component_mass_rates[comp_idx] = total_mass_rate * this->surface_conditions_.massFraction(comp_idx); } for (unsigned comp_idx = 0; comp_idx < FluidSystem::numComponents; ++comp_idx) { - const EvalWell residual = (this->new_component_masses_[comp_idx] - this->component_masses_[comp_idx]) / dt - component_mass_rates[comp_idx]; + const EvalWell residual = (this->new_component_masses_[comp_idx] - this->component_masses_[comp_idx]) / dt + - component_mass_rates[comp_idx]; // let us put it in the well equation for (int pvIdx = 0; pvIdx < PrimaryVariables::numWellEq; ++pvIdx) { this->well_equations_.D()[0][0][comp_idx][pvIdx] += residual.derivative(pvIdx + PrimaryVariables::numResEq); @@ -382,10 +368,7 @@ assembleSourceTerm(const Scalar dt) template bool -CompWell:: -iterateWellEq(const Simulator& simulator, - const Scalar dt, - SingleWellState& well_state) +CompWell::iterateWellEq(const Simulator& simulator, const Scalar dt, SingleWellState& well_state) { constexpr int max_iter = 200; @@ -413,29 +396,25 @@ iterateWellEq(const Simulator& simulator, template void -CompWell:: -solveEqAndUpdateWellState(SingleWellState& well_state) +CompWell::solveEqAndUpdateWellState(SingleWellState& well_state) { - BVectorWell dx_well(1); + BVectorWell dx_well(1); - this->well_equations_.solve(dx_well); + this->well_equations_.solve(dx_well); this->updateWellState(dx_well, well_state); } -template +template void -CompWell:: -apply(BVector& r) const +CompWell::apply(BVector& r) const { this->well_equations_.apply(r); } template void -CompWell:: -recoverWellSolutionAndUpdateWellState(const BVector& x, - SingleWellState& well_state) +CompWell::recoverWellSolutionAndUpdateWellState(const BVector& x, SingleWellState& well_state) { BVectorWell xw(1); @@ -446,17 +425,14 @@ recoverWellSolutionAndUpdateWellState(const BVector& x, template void -CompWell:: -updatePrimaryVariablesNewton(const BVectorWell& dwells) +CompWell::updatePrimaryVariablesNewton(const BVectorWell& dwells) { this->primary_variables_.updateNewton(dwells); } template void -CompWell:: -updateWellState(const CompWell::BVectorWell& xw, - SingleWellState& well_state) +CompWell::updateWellState(const CompWell::BVectorWell& xw, SingleWellState& well_state) { updatePrimaryVariablesNewton(xw); updateWellStateFromPrimaryVariables(well_state); @@ -464,8 +440,7 @@ updateWellState(const CompWell::BVectorWell& xw, template void -CompWell:: -updateWellStateFromPrimaryVariables(SingleWellState& well_state) const +CompWell::updateWellStateFromPrimaryVariables(SingleWellState& well_state) const { well_state.bhp = this->primary_variables_.getBhp().value(); @@ -489,8 +464,7 @@ updateWellStateFromPrimaryVariables(SingleWellState& well_state) const template bool -CompWell:: -getConvergence() const +CompWell::getConvergence() const { bool converged = true; for (const auto& val : this->well_equations_.residual()[0]) { @@ -501,17 +475,14 @@ getConvergence() const template void -CompWell:: -addWellContributions(SparseMatrixAdapter&) const +CompWell::addWellContributions(SparseMatrixAdapter&) const { assert(false); } template void -CompWell:: -updateWellControl(const SummaryState& summary_state, - SingleWellState& well_state) const +CompWell::updateWellControl(const SummaryState& summary_state, SingleWellState& well_state) const { std::string from; if (this->well_ecl_.isInjector()) { @@ -534,7 +505,8 @@ updateWellControl(const SummaryState& summary_state, } } - if (!changed && production_controls.hasControl(Well::ProducerCMode::ORAT) && current_control != WellProducerCMode::ORAT) { + if (!changed && production_controls.hasControl(Well::ProducerCMode::ORAT) + && current_control != WellProducerCMode::ORAT) { const Scalar current_rate = -well_state.surface_phase_rates[FluidSystem::oilPhaseIdx]; if (current_rate > production_controls.oil_rate) { well_state.production_cmode = WellProducerCMode::ORAT; @@ -542,7 +514,8 @@ updateWellControl(const SummaryState& summary_state, } } - if (!changed && production_controls.hasControl(Well::ProducerCMode::WRAT) && current_control != WellProducerCMode::WRAT) { + if (!changed && production_controls.hasControl(Well::ProducerCMode::WRAT) + && current_control != WellProducerCMode::WRAT) { const Scalar current_rate = -well_state.surface_phase_rates[FluidSystem::waterPhaseIdx]; if (current_rate > production_controls.water_rate) { well_state.production_cmode = WellProducerCMode::WRAT; @@ -550,7 +523,8 @@ updateWellControl(const SummaryState& summary_state, } } - if (!changed && production_controls.hasControl(Well::ProducerCMode::GRAT) && current_control != WellProducerCMode::GRAT) { + if (!changed && production_controls.hasControl(Well::ProducerCMode::GRAT) + && current_control != WellProducerCMode::GRAT) { const Scalar current_rate = -well_state.surface_phase_rates[FluidSystem::gasPhaseIdx]; if (current_rate > production_controls.gas_rate) { well_state.production_cmode = WellProducerCMode::GRAT; @@ -569,12 +543,13 @@ updateWellControl(const SummaryState& summary_state, changed = true; } } - if (!changed && injection_controls.hasControl(Well::InjectorCMode::RATE) && current_control != WellInjectorCMode::RATE) { + if (!changed && injection_controls.hasControl(Well::InjectorCMode::RATE) + && current_control != WellInjectorCMode::RATE) { // InjectorType injector_type = injection_controls.injector_type; const Scalar rate_limit = injection_controls.surface_rate; // TODO: hack to get the injection rate - const Scalar current_rate = std::accumulate(well_state.surface_phase_rates.begin(), - well_state.surface_phase_rates.end(), 0.0); + const Scalar current_rate + = std::accumulate(well_state.surface_phase_rates.begin(), well_state.surface_phase_rates.end(), 0.0); if (current_rate > rate_limit) { well_state.injection_cmode = WellInjectorCMode::RATE; changed = true; @@ -596,10 +571,10 @@ updateWellControl(const SummaryState& summary_state, template template void -CompWell:: -updateSurfanceCondition_(const StandardCond& surface_cond, FluidState& fluid_state) +CompWell::updateSurfanceCondition_(const StandardCond& surface_cond, FluidState& fluid_state) { - static_assert(std::is_same_v || std::is_same_v, "Unsupported type in CompWell::updateSurfanceCondition_"); + static_assert(std::is_same_v || std::is_same_v, + "Unsupported type in CompWell::updateSurfanceCondition_"); fluid_state.setTemperature(surface_cond.temperature); fluid_state.setPressure(FluidSystem::oilPhaseIdx, surface_cond.pressure); @@ -612,30 +587,33 @@ updateSurfanceCondition_(const StandardCond& surface_cond, FluidState& fluid_ flashFluidState_(fluid_state); for (unsigned compidx = 0; compidx < FluidSystem::numComponents; ++compidx) { - this->surface_conditions_.mass_fractions_[FluidSystem::oilPhaseIdx][compidx] = - fluid_state.massFraction(FluidSystem::oilPhaseIdx, compidx); - this->surface_conditions_.mass_fractions_[FluidSystem::gasPhaseIdx][compidx] = - fluid_state.massFraction(FluidSystem::gasPhaseIdx, compidx); + this->surface_conditions_.mass_fractions_[FluidSystem::oilPhaseIdx][compidx] + = fluid_state.massFraction(FluidSystem::oilPhaseIdx, compidx); + this->surface_conditions_.mass_fractions_[FluidSystem::gasPhaseIdx][compidx] + = fluid_state.massFraction(FluidSystem::gasPhaseIdx, compidx); } const auto& density_oil = fluid_state.density(FluidSystem::oilPhaseIdx); const auto& density_gas = fluid_state.density(FluidSystem::gasPhaseIdx); this->surface_conditions_.surface_densities_[FluidSystem::oilPhaseIdx] = density_oil; this->surface_conditions_.surface_densities_[FluidSystem::gasPhaseIdx] = density_gas; - this->surface_conditions_.volume_fractions_[FluidSystem::oilPhaseIdx] = fluid_state.saturation(FluidSystem::oilPhaseIdx); - this->surface_conditions_.volume_fractions_[FluidSystem::gasPhaseIdx] = fluid_state.saturation(FluidSystem::gasPhaseIdx); + this->surface_conditions_.volume_fractions_[FluidSystem::oilPhaseIdx] + = fluid_state.saturation(FluidSystem::oilPhaseIdx); + this->surface_conditions_.volume_fractions_[FluidSystem::gasPhaseIdx] + = fluid_state.saturation(FluidSystem::gasPhaseIdx); } template template void -CompWell:: -flashFluidState_(FluidState& fluid_state) +CompWell::flashFluidState_(FluidState& fluid_state) { - static_assert(std::is_same_v || std::is_same_v, "Unsupported type in CompWell::flashFluidState_"); + static_assert(std::is_same_v || std::is_same_v, + "Unsupported type in CompWell::flashFluidState_"); bool single_phase = false; if constexpr (std::is_same_v) { - single_phase = PTFlash::flash_solve_scalar_(fluid_state, "ssi", 1.e-6, CompositionalConfig::EOSType::PR); + single_phase = PTFlash::flash_solve_scalar_( + fluid_state, "ssi", 1.e-6, CompositionalConfig::EOSType::PR); } else { // EvalWell single_phase = PTFlash::solve(fluid_state, "ssi", 1.e-6, CompositionalConfig::EOSType::PR); } @@ -643,11 +621,13 @@ flashFluidState_(FluidState& fluid_state) constexpr Scalar R = Constants::R; typename FluidSystem::template ParameterCache param_cache {CompositionalConfig::EOSType::PR}; param_cache.updatePhase(fluid_state, FluidSystem::oilPhaseIdx); - const auto Z_L = (param_cache.molarVolume(FluidSystem::oilPhaseIdx) * fluid_state.pressure(FluidSystem::oilPhaseIdx) )/ - (R * fluid_state.temperature(FluidSystem::oilPhaseIdx)); + const auto Z_L + = (param_cache.molarVolume(FluidSystem::oilPhaseIdx) * fluid_state.pressure(FluidSystem::oilPhaseIdx)) + / (R * fluid_state.temperature(FluidSystem::oilPhaseIdx)); param_cache.updatePhase(fluid_state, FluidSystem::gasPhaseIdx); - const auto Z_V = (param_cache.molarVolume(FluidSystem::gasPhaseIdx) * fluid_state.pressure(FluidSystem::gasPhaseIdx) )/ - (R * fluid_state.temperature(FluidSystem::gasPhaseIdx)); + const auto Z_V + = (param_cache.molarVolume(FluidSystem::gasPhaseIdx) * fluid_state.pressure(FluidSystem::gasPhaseIdx)) + / (R * fluid_state.temperature(FluidSystem::gasPhaseIdx)); auto L = fluid_state.L(); if (single_phase) { @@ -660,7 +640,7 @@ flashFluidState_(FluidState& fluid_state) fluid_state.setLvalue(L); } } - T So = Opm::max((L * Z_L / ( L * Z_L + (1 - L) * Z_V)), 0.0); + T So = Opm::max((L * Z_L / (L * Z_L + (1 - L) * Z_V)), 0.0); T Sg = Opm::max(1 - So, 0.0); T sumS = So + Sg; So /= sumS; @@ -672,8 +652,10 @@ flashFluidState_(FluidState& fluid_state) fluid_state.setCompressFactor(FluidSystem::oilPhaseIdx, Z_L); fluid_state.setCompressFactor(FluidSystem::gasPhaseIdx, Z_V); - fluid_state.setDensity(FluidSystem::oilPhaseIdx, FluidSystem::density(fluid_state, param_cache, FluidSystem::oilPhaseIdx)); - fluid_state.setDensity(FluidSystem::gasPhaseIdx, FluidSystem::density(fluid_state, param_cache, FluidSystem::gasPhaseIdx)); + fluid_state.setDensity(FluidSystem::oilPhaseIdx, + FluidSystem::density(fluid_state, param_cache, FluidSystem::oilPhaseIdx)); + fluid_state.setDensity(FluidSystem::gasPhaseIdx, + FluidSystem::density(fluid_state, param_cache, FluidSystem::gasPhaseIdx)); } } // end of namespace Opm diff --git a/flowexperimental/comp/wells/SingleCompWellState.hpp b/flowexperimental/comp/wells/SingleCompWellState.hpp index 093fceb84f8..532a949ce62 100644 --- a/flowexperimental/comp/wells/SingleCompWellState.hpp +++ b/flowexperimental/comp/wells/SingleCompWellState.hpp @@ -27,16 +27,15 @@ #include -namespace Opm { +namespace Opm +{ template class CompConnectionData { public: CompConnectionData() = default; - CompConnectionData(std::size_t num_connection, - std::size_t num_phases, - std::size_t num_components); + CompConnectionData(std::size_t num_connection, std::size_t num_phases, std::size_t num_components); CompConnectionData(const std::vector>& connections, const std::size_t num_phases, @@ -68,9 +67,9 @@ class SingleCompWellState std::string name; bool producer; - WellStatus status{WellStatus::OPEN}; - Scalar bhp{0}; - Scalar temperature{0}; + WellStatus status {WellStatus::OPEN}; + Scalar bhp {0}; + Scalar temperature {0}; std::vector surface_phase_rates; std::vector phase_fractions; // V or L @@ -78,12 +77,12 @@ class SingleCompWellState // WZMF std::vector total_molar_fractions; // WXMF WYMF and WAMF - std::vector > phase_molar_fractions; + std::vector> phase_molar_fractions; CompConnectionData connection_data; - WellInjectorCMode injection_cmode{WellInjectorCMode::CMODE_UNDEFINED}; - WellProducerCMode production_cmode{WellProducerCMode::CMODE_UNDEFINED}; + WellInjectorCMode injection_cmode {WellInjectorCMode::CMODE_UNDEFINED}; + WellProducerCMode production_cmode {WellProducerCMode::CMODE_UNDEFINED}; // TODO: the function can be reorganized so that we do not need to have initSingleInjector // and initSingleProducer, but we split when update the targets diff --git a/flowexperimental/comp/wells/SingleCompWellState_impl.hpp b/flowexperimental/comp/wells/SingleCompWellState_impl.hpp index 7730500dcad..fb5ab63078e 100644 --- a/flowexperimental/comp/wells/SingleCompWellState_impl.hpp +++ b/flowexperimental/comp/wells/SingleCompWellState_impl.hpp @@ -17,30 +17,29 @@ along with OPM. If not, see . */ -namespace Opm { +namespace Opm +{ template -CompConnectionData:: -CompConnectionData(std::size_t num_connection, - std::size_t num_phases, - std::size_t num_components) - : pressure(num_connection) - , surface_phase_rates(num_connection * num_phases) - , reservoir_phase_rates(num_connection * num_phases) - , total_molar_fractions(num_connection * num_components) - , transmissibility_factor(num_connection) - , satnum_id(num_connection) - , ecl_index(num_connection) +CompConnectionData::CompConnectionData(std::size_t num_connection, + std::size_t num_phases, + std::size_t num_components) + : pressure(num_connection) + , surface_phase_rates(num_connection * num_phases) + , reservoir_phase_rates(num_connection * num_phases) + , total_molar_fractions(num_connection * num_components) + , transmissibility_factor(num_connection) + , satnum_id(num_connection) + , ecl_index(num_connection) { } template -CompConnectionData:: -CompConnectionData(const std::vector>& connections, - const std::size_t num_phases, - const CompositionalConfig& comp_config) - : CompConnectionData(connections.size(), num_phases, comp_config.numComps()) +CompConnectionData::CompConnectionData(const std::vector>& connections, + const std::size_t num_phases, + const CompositionalConfig& comp_config) + : CompConnectionData(connections.size(), num_phases, comp_config.numComps()) { for (std::size_t con = 0; con < connections.size(); ++con) { this->transmissibility_factor[con] = connections[con].connection_transmissibility_factor; @@ -50,27 +49,25 @@ CompConnectionData(const std::vector>& connections, } template -SingleCompWellState:: -SingleCompWellState(const std::string& well_name, - const CompositionalConfig& comp_config, - const Scalar temperature_arg, - const std::vector>& connections, - bool is_producer) - : name(well_name) - , producer(is_producer) - , temperature(temperature_arg) - , surface_phase_rates(FluidSystem::numPhases) - , phase_fractions(FluidSystem::numPhases) - , reservoir_phase_rates(FluidSystem::numPhases) - , total_molar_fractions(comp_config.numComps()) - , connection_data(connections, FluidSystem::numPhases, comp_config) +SingleCompWellState::SingleCompWellState(const std::string& well_name, + const CompositionalConfig& comp_config, + const Scalar temperature_arg, + const std::vector>& connections, + bool is_producer) + : name(well_name) + , producer(is_producer) + , temperature(temperature_arg) + , surface_phase_rates(FluidSystem::numPhases) + , phase_fractions(FluidSystem::numPhases) + , reservoir_phase_rates(FluidSystem::numPhases) + , total_molar_fractions(comp_config.numComps()) + , connection_data(connections, FluidSystem::numPhases, comp_config) { } template -void SingleCompWellState:: -update_injector_targets(const Well& well, - const SummaryState& st) +void +SingleCompWellState::update_injector_targets(const Well& well, const SummaryState& st) { const auto& inj_controls = well.injectionControls(st); const bool cmode_is_undefined = (inj_controls.cmode == Well::InjectorCMode::CMODE_UNDEFINED); @@ -95,29 +92,29 @@ update_injector_targets(const Well& well, } switch (inj_controls.injector_type) { - case InjectorType::WATER: - assert(FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)); - this->surface_phase_rates[FluidSystem::waterPhaseIdx] = inj_surf_rate; - break; - case InjectorType::GAS: - assert(FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)); - this->surface_phase_rates[FluidSystem::gasPhaseIdx] = inj_surf_rate; - break; - case InjectorType::OIL: - assert(FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)); - this->surface_phase_rates[FluidSystem::oilPhaseIdx] = inj_surf_rate; - break; - case InjectorType::MULTI: - // Not currently handled, keep zero init. - break; + case InjectorType::WATER: + assert(FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)); + this->surface_phase_rates[FluidSystem::waterPhaseIdx] = inj_surf_rate; + break; + case InjectorType::GAS: + assert(FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)); + this->surface_phase_rates[FluidSystem::gasPhaseIdx] = inj_surf_rate; + break; + case InjectorType::OIL: + assert(FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)); + this->surface_phase_rates[FluidSystem::oilPhaseIdx] = inj_surf_rate; + break; + case InjectorType::MULTI: + // Not currently handled, keep zero init. + break; } } template -void SingleCompWellState:: -update_producer_targets(const Well& well, - const std::vector>& cell_mole_fractions, - const SummaryState& st) +void +SingleCompWellState::update_producer_targets(const Well& well, + const std::vector>& cell_mole_fractions, + const SummaryState& st) { const auto& prod_controls = well.productionControls(st); @@ -146,8 +143,7 @@ update_producer_targets(const Well& well, template typename SingleCompWellState::Scalar -SingleCompWellState:: -get_total_surface_rate() const +SingleCompWellState::get_total_surface_rate() const { return std::accumulate(surface_phase_rates.begin(), surface_phase_rates.end(), Scalar(0)); } diff --git a/flowexperimental/flowexp.hpp b/flowexperimental/flowexp.hpp index 9f996c7e676..507315a7d43 100644 --- a/flowexperimental/flowexp.hpp +++ b/flowexperimental/flowexp.hpp @@ -46,24 +46,26 @@ #include -namespace Opm { +namespace Opm +{ template class FlowExpProblem; } -namespace Opm::Properties { - -namespace TTag { +namespace Opm::Properties +{ -struct FlowExpTypeTag +namespace TTag { - using InheritsFrom = std::tuple; -}; -} + struct FlowExpTypeTag { + using InheritsFrom = std::tuple; + }; + +} // namespace TTag // Set the problem class -template +template struct Problem { using type = FlowExpProblem; }; @@ -71,59 +73,60 @@ struct Problem { // Enable experimental features for flowexp: flowexp is the research simulator of the OPM // project. If you're looking for a more stable "production quality" simulator, consider // using `flow` -template +template struct EnableExperiments { static constexpr bool value = true; }; // use flow's well model for now -template +template struct WellModel { using type = BlackoilWellModel; }; -template +template struct NewtonMethod { using type = FlowExpNewtonMethod; }; // flow's well model only works with surface volumes -template +template struct BlackoilConserveSurfaceVolume { static constexpr bool value = true; }; // the values for the residual are for the whole cell instead of for a cubic meter of the cell -template +template struct UseVolumetricResidual { static constexpr bool value = false; }; // by default use flow's aquifer model for now -template +template struct AquiferModel { using type = BlackoilAquiferModel; }; // use flow's linear solver backend for now -template +template struct LinearSolverSplice { using type = TTag::FlowIstlSolver; }; -template<> +template <> struct LinearSolverBackend { using type = ISTLSolver; }; -template +template struct LinearSolverBackend { using type = ISTLSolver; }; } // namespace Opm::Properties -namespace Opm { +namespace Opm +{ template class FlowExpProblem : public FlowProblemBlackoil //, public FvBaseProblem @@ -137,11 +140,9 @@ class FlowExpProblem : public FlowProblemBlackoil //, public FvBaseProb OPM_TIMEBLOCK(problemWriteOutput); // use the generic code to prepare the output fields and to // write the desired VTK files. - if (Parameters::Get() || - this->simulator().episodeWillBeOver()) - { - // \Note: the SimulatorTimer does not carry any useful information, so PRT file (if it gets output) will contain wrong - // timing information. + if (Parameters::Get() || this->simulator().episodeWillBeOver()) { + // \Note: the SimulatorTimer does not carry any useful information, so PRT file (if it gets output) will + // contain wrong timing information. ParentType::writeOutput(verbose); } } @@ -207,6 +208,6 @@ class FlowExpProblem : public FlowProblemBlackoil //, public FvBaseProb using ParentType::FlowProblemBlackoil; }; -} +} // namespace Opm #endif diff --git a/flowexperimental/flowexp_blackoil.cpp b/flowexperimental/flowexp_blackoil.cpp index 9eaeff746d4..e16d610a595 100644 --- a/flowexperimental/flowexp_blackoil.cpp +++ b/flowexperimental/flowexp_blackoil.cpp @@ -16,66 +16,62 @@ You should have received a copy of the GNU General Public License along with OPM. If not, see . */ -#include "config.h" #include "FlowExpNewtonMethod.hpp" +#include "config.h" #include "flowexp.hpp" #include #include -#include #include +#include #include "BlackOilIntensiveQuantitiesGlobalIndex.hpp" #include "FIBlackOilModelNoCache.hpp" -namespace Opm::Properties { -namespace TTag { -struct FlowExpProblemBlackOil +namespace Opm::Properties { - using InheritsFrom = std::tuple; -}; -} - -template -struct Model +namespace TTag { + struct FlowExpProblemBlackOil { + using InheritsFrom = std::tuple; + }; +} // namespace TTag + +template +struct Model { using type = FIBlackOilModelNoCache; }; -template -struct IntensiveQuantities -{ +template +struct IntensiveQuantities { using type = BlackOilIntensiveQuantitiesGlobalIndex; }; // Set the problem class -template -struct Problem -{ +template +struct Problem { using type = FlowExpProblem; }; -template -struct EnableDiffusion -{ +template +struct EnableDiffusion { static constexpr bool value = false; }; -template -struct EnableDisgasInWater -{ +template +struct EnableDisgasInWater { static constexpr bool value = false; }; -template -struct Simulator -{ +template +struct Simulator { using type = Opm::Simulator; }; } // namespace Opm::Properties -int main(int argc, char** argv) +int +main(int argc, char** argv) { using TypeTag = Opm::Properties::TTag::FlowExpProblemBlackOil; Opm::registerEclTimeSteppingParameters(); diff --git a/opm/models/blackoil/blackoilbioeffectsparams.cpp b/opm/models/blackoil/blackoilbioeffectsparams.cpp index 20ffd44ae33..29bd9663a60 100644 --- a/opm/models/blackoil/blackoilbioeffectsparams.cpp +++ b/opm/models/blackoil/blackoilbioeffectsparams.cpp @@ -38,15 +38,16 @@ #include #include -namespace Opm { +namespace Opm +{ #if HAVE_ECL_INPUT -template -template -void BlackOilBioeffectsParams:: -initFromState(const EclipseState& eclState) +template +template +void +BlackOilBioeffectsParams::initFromState(const EclipseState& eclState) { - // some sanity checks: + // some sanity checks: // if biofilm is enabled, the BIOFILM keyword must be present, // if biofilm is disabled the keyword must not be present, // if MICP is enabled, the MICP keyword must be present, and @@ -57,20 +58,17 @@ initFromState(const EclipseState& eclState) throw std::runtime_error("Non-trivial MICP treatment requested at compile time, but " "the deck does not contain the MICP keyword"); } - } - else { + } else { if (!eclState.runspec().biof()) { throw std::runtime_error("Non-trivial Biofilm effects requested at compile time, but " "the deck does not contain the BIOFILM keyword"); } } - } - else { + } else { if (eclState.runspec().biof()) { throw std::runtime_error("Biofilm effects disabled at compile time, but the deck " "contains the BIOFILM keyword"); - } - else if (eclState.runspec().micp()) { + } else if (eclState.runspec().micp()) { throw std::runtime_error("MICP treatment disabled at compile time, but the deck " "contains the MICP keyword"); } @@ -88,8 +86,7 @@ initFromState(const EclipseState& eclState) if (biofilmTables.empty()) { if constexpr (enableMICP) { throw std::runtime_error("MICP requires the BIOFPARA keyword"); - } - else { + } else { throw std::runtime_error("BIOFILM requires the BIOFPARA keyword"); } } @@ -133,19 +130,23 @@ initFromState(const EclipseState& eclState) bioDiffCoefficient_[pvtRegionIdx].resize(BlackOilBioeffectsParams::numDiffCoef, 0.0); if (!diffMICPTables.empty()) { const DiffMICPTable& diffMICPTable = diffMICPTables.getTable(pvtRegionIdx); - bioDiffCoefficient_[pvtRegionIdx][BlackOilBioeffectsParams::micrDiffIdx] = diffMICPTable.getMicrobialDiffusion().front(); - bioDiffCoefficient_[pvtRegionIdx][BlackOilBioeffectsParams::oxygDiffIdx] = diffMICPTable.getOxygenDiffusion().front(); - bioDiffCoefficient_[pvtRegionIdx][BlackOilBioeffectsParams::ureaDiffIdx] = diffMICPTable.getUreaDiffusion().front(); + bioDiffCoefficient_[pvtRegionIdx][BlackOilBioeffectsParams::micrDiffIdx] + = diffMICPTable.getMicrobialDiffusion().front(); + bioDiffCoefficient_[pvtRegionIdx][BlackOilBioeffectsParams::oxygDiffIdx] + = diffMICPTable.getOxygenDiffusion().front(); + bioDiffCoefficient_[pvtRegionIdx][BlackOilBioeffectsParams::ureaDiffIdx] + = diffMICPTable.getUreaDiffusion().front(); } } - + if constexpr (!enableMICP) { const TableContainer& pcfactTables = tableManager.getPcfactTables(); if (!pcfactTables.empty()) { pcfactTable_.resize(numSatRegions); for (size_t i = 0; i < pcfactTables.size(); ++i) { const PcfactTable& pcfactTable = pcfactTables.getTable(i); - pcfactTable_[i].setXYContainers(pcfactTable.getPorosityChangeColumn(), pcfactTable.getPcMultiplierColumn()); + pcfactTable_[i].setXYContainers(pcfactTable.getPorosityChangeColumn(), + pcfactTable.getPcMultiplierColumn()); } } } @@ -154,24 +155,24 @@ initFromState(const EclipseState& eclState) if (permfactTables.empty()) { if constexpr (enableMICP) { throw std::runtime_error("MICP requires the PERMFACT keyword"); - } - else { + } else { throw std::runtime_error("BIOFILM requires the PERMFACT keyword"); } } permfactTable_.resize(numSatRegions); for (std::size_t i = 0; i < permfactTables.size(); ++i) { const PermfactTable& permfactTable = permfactTables.getTable(i); - permfactTable_[i].setXYContainers(permfactTable.getPorosityChangeColumn(), permfactTable.getPermeabilityMultiplierColumn()); + permfactTable_[i].setXYContainers(permfactTable.getPorosityChangeColumn(), + permfactTable.getPermeabilityMultiplierColumn()); } } #endif -#define INSTANTIATE_TYPE(T) \ - template struct BlackOilBioeffectsParams; \ - template void BlackOilBioeffectsParams::initFromState(const EclipseState&); \ - template void BlackOilBioeffectsParams::initFromState(const EclipseState&); \ - template void BlackOilBioeffectsParams::initFromState(const EclipseState&); +#define INSTANTIATE_TYPE(T) \ + template struct BlackOilBioeffectsParams; \ + template void BlackOilBioeffectsParams::initFromState(const EclipseState&); \ + template void BlackOilBioeffectsParams::initFromState(const EclipseState&); \ + template void BlackOilBioeffectsParams::initFromState(const EclipseState&); INSTANTIATE_TYPE(double) diff --git a/opm/models/blackoil/blackoilbioeffectsparams.hpp b/opm/models/blackoil/blackoilbioeffectsparams.hpp index b8e4343379a..8e0a66fd36f 100644 --- a/opm/models/blackoil/blackoilbioeffectsparams.hpp +++ b/opm/models/blackoil/blackoilbioeffectsparams.hpp @@ -32,18 +32,18 @@ #include -namespace Opm { +namespace Opm +{ #if HAVE_ECL_INPUT class EclipseState; #endif //! \brief Struct holding the parameters for the BlackOilBioeffectsModule class. -template -struct BlackOilBioeffectsParams -{ +template +struct BlackOilBioeffectsParams { #if HAVE_ECL_INPUT - template + template void initFromState(const EclipseState& eclState); #endif @@ -57,21 +57,21 @@ struct BlackOilBioeffectsParams std::vector permfactTable_; std::vector pcfactTable_; - std::vector densityBiofilm_{}; - std::vector densityCalcite_{}; - std::vector detachmentRate_{}; - std::vector detachmentExponent_{}; - std::vector halfVelocityGrowth_{}; - std::vector halfVelocityUrea_{}; - std::vector maximumGrowthRate_{}; - std::vector maximumUreaUtilization_{}; - std::vector microbialAttachmentRate_{}; - std::vector microbialDeathRate_{}; - std::vector oxygenConsumptionFactor_{}; - std::vector yieldGrowthCoefficient_{}; - std::vector yieldUreaToCalciteCoefficient_{}; - - std::vector> bioDiffCoefficient_{}; + std::vector densityBiofilm_ {}; + std::vector densityCalcite_ {}; + std::vector detachmentRate_ {}; + std::vector detachmentExponent_ {}; + std::vector halfVelocityGrowth_ {}; + std::vector halfVelocityUrea_ {}; + std::vector maximumGrowthRate_ {}; + std::vector maximumUreaUtilization_ {}; + std::vector microbialAttachmentRate_ {}; + std::vector microbialDeathRate_ {}; + std::vector oxygenConsumptionFactor_ {}; + std::vector yieldGrowthCoefficient_ {}; + std::vector yieldUreaToCalciteCoefficient_ {}; + + std::vector> bioDiffCoefficient_ {}; }; } // namespace Opm diff --git a/opm/models/blackoil/blackoilbrineparams.cpp b/opm/models/blackoil/blackoilbrineparams.cpp index e155e98545d..bea4f69dc1a 100644 --- a/opm/models/blackoil/blackoilbrineparams.cpp +++ b/opm/models/blackoil/blackoilbrineparams.cpp @@ -26,25 +26,26 @@ #if HAVE_ECL_INPUT #include -#include #include #include +#include #include -#include #include +#include #endif #include #include #include -namespace Opm { +namespace Opm +{ #if HAVE_ECL_INPUT -template -template -void BlackOilBrineParams:: -initFromState(const EclipseState& eclState) +template +template +void +BlackOilBrineParams::initFromState(const EclipseState& eclState) { // some sanity checks: if brine are enabled, the BRINE keyword must be // present, if brine are disabled the keyword must not be present. @@ -53,8 +54,7 @@ initFromState(const EclipseState& eclState) throw std::runtime_error("Non-trivial brine treatment requested at compile time, but " "the deck does not contain the BRINE keyword"); } - } - else { + } else { if (eclState.runspec().phases().active(Phase::BRINE)) { throw std::runtime_error("Brine treatment disabled at compile time, but the deck " "contains the BRINE keyword"); @@ -91,7 +91,8 @@ initFromState(const EclipseState& eclState) permfactTable_.resize(numSatRegions); for (std::size_t i = 0; i < permfactTables.size(); ++i) { const PermfactTable& permfactTable = permfactTables.getTable(i); - permfactTable_[i].setXYContainers(permfactTable.getPorosityChangeColumn(), permfactTable.getPermeabilityMultiplierColumn()); + permfactTable_[i].setXYContainers(permfactTable.getPorosityChangeColumn(), + permfactTable.getPermeabilityMultiplierColumn()); } const TableContainer& saltsolTables = tableManager.getSaltsolTables(); @@ -100,7 +101,7 @@ initFromState(const EclipseState& eclState) saltdenTable_.resize(numPvtRegions); assert(numPvtRegions == saltsolTables.size()); for (unsigned pvtRegionIdx = 0; pvtRegionIdx < numPvtRegions; ++pvtRegionIdx) { - const SaltsolTable& saltsolTable = saltsolTables.getTable(pvtRegionIdx ); + const SaltsolTable& saltsolTable = saltsolTables.getTable(pvtRegionIdx); saltsolTable_[pvtRegionIdx] = saltsolTable.getSaltsolColumn().front(); saltdenTable_[pvtRegionIdx] = saltsolTable.getSaltdenColumn().front(); } @@ -111,19 +112,20 @@ initFromState(const EclipseState& eclState) pcfactTable_.resize(numSatRegions); for (std::size_t i = 0; i < pcfactTables.size(); ++i) { const PcfactTable& pcfactTable = pcfactTables.getTable(i); - pcfactTable_[i].setXYContainers(pcfactTable.getPorosityChangeColumn(), pcfactTable.getPcMultiplierColumn()); + pcfactTable_[i].setXYContainers(pcfactTable.getPorosityChangeColumn(), + pcfactTable.getPcMultiplierColumn()); } } - } + } } #endif -#define INSTANTIATE_TYPE(T) \ - template struct BlackOilBrineParams; \ - template void BlackOilBrineParams::initFromState(const EclipseState&); \ - template void BlackOilBrineParams::initFromState(const EclipseState&); \ - template void BlackOilBrineParams::initFromState(const EclipseState&); \ - template void BlackOilBrineParams::initFromState(const EclipseState&); +#define INSTANTIATE_TYPE(T) \ + template struct BlackOilBrineParams; \ + template void BlackOilBrineParams::initFromState(const EclipseState&); \ + template void BlackOilBrineParams::initFromState(const EclipseState&); \ + template void BlackOilBrineParams::initFromState(const EclipseState&); \ + template void BlackOilBrineParams::initFromState(const EclipseState&); INSTANTIATE_TYPE(double) diff --git a/opm/models/blackoil/blackoilbrineparams.hpp b/opm/models/blackoil/blackoilbrineparams.hpp index dafa838d2da..3105bcca583 100644 --- a/opm/models/blackoil/blackoilbrineparams.hpp +++ b/opm/models/blackoil/blackoilbrineparams.hpp @@ -32,18 +32,18 @@ #include -namespace Opm { +namespace Opm +{ #if HAVE_ECL_INPUT class EclipseState; #endif //! \brief Struct holding the parameters for the BlackoilBrineModule class. -template -struct BlackOilBrineParams -{ +template +struct BlackOilBrineParams { #if HAVE_ECL_INPUT - template + template void initFromState(const EclipseState& eclState); #endif diff --git a/opm/models/blackoil/blackoilextboparams.cpp b/opm/models/blackoil/blackoilextboparams.cpp index efd27d0e4ca..4f8236bb978 100644 --- a/opm/models/blackoil/blackoilextboparams.cpp +++ b/opm/models/blackoil/blackoilextboparams.cpp @@ -26,26 +26,27 @@ #if HAVE_ECL_INPUT #include -#include -#include +#include #include #include -#include -#include #include +#include +#include +#include #include #endif #include #include -namespace Opm { +namespace Opm +{ #if HAVE_ECL_INPUT -template -template -void BlackOilExtboParams:: -initFromState(const EclipseState& eclState) +template +template +void +BlackOilExtboParams::initFromState(const EclipseState& eclState) { // some sanity checks: if extended BO is enabled, the PVTSOL keyword must be // present, if extended BO is disabled the keyword must not be present. @@ -54,8 +55,7 @@ initFromState(const EclipseState& eclState) throw std::runtime_error("Extended black oil treatment requested at compile " "time, but the deck does not contain the PVTSOL keyword"); } - } - else { + } else { if (!enableExtbo && eclState.runspec().phases().active(Phase::ZFRACTION)) { throw std::runtime_error("Extended black oil treatment disabled at compile time, but the deck " "contains the PVTSOL keyword"); @@ -73,17 +73,17 @@ initFromState(const EclipseState& eclState) std::size_t numPvtRegions = pvtsolTables.size(); - BO_.resize(numPvtRegions, Tabulated2DFunction{Tabulated2DFunction::InterpolationPolicy::LeftExtreme}); - BG_.resize(numPvtRegions, Tabulated2DFunction{Tabulated2DFunction::InterpolationPolicy::LeftExtreme}); - RS_.resize(numPvtRegions, Tabulated2DFunction{Tabulated2DFunction::InterpolationPolicy::LeftExtreme}); - RV_.resize(numPvtRegions, Tabulated2DFunction{Tabulated2DFunction::InterpolationPolicy::LeftExtreme}); - X_.resize(numPvtRegions, Tabulated2DFunction{Tabulated2DFunction::InterpolationPolicy::LeftExtreme}); - Y_.resize(numPvtRegions, Tabulated2DFunction{Tabulated2DFunction::InterpolationPolicy::LeftExtreme}); - VISCO_.resize(numPvtRegions, Tabulated2DFunction{Tabulated2DFunction::InterpolationPolicy::LeftExtreme}); - VISCG_.resize(numPvtRegions, Tabulated2DFunction{Tabulated2DFunction::InterpolationPolicy::LeftExtreme}); + BO_.resize(numPvtRegions, Tabulated2DFunction {Tabulated2DFunction::InterpolationPolicy::LeftExtreme}); + BG_.resize(numPvtRegions, Tabulated2DFunction {Tabulated2DFunction::InterpolationPolicy::LeftExtreme}); + RS_.resize(numPvtRegions, Tabulated2DFunction {Tabulated2DFunction::InterpolationPolicy::LeftExtreme}); + RV_.resize(numPvtRegions, Tabulated2DFunction {Tabulated2DFunction::InterpolationPolicy::LeftExtreme}); + X_.resize(numPvtRegions, Tabulated2DFunction {Tabulated2DFunction::InterpolationPolicy::LeftExtreme}); + Y_.resize(numPvtRegions, Tabulated2DFunction {Tabulated2DFunction::InterpolationPolicy::LeftExtreme}); + VISCO_.resize(numPvtRegions, Tabulated2DFunction {Tabulated2DFunction::InterpolationPolicy::LeftExtreme}); + VISCG_.resize(numPvtRegions, Tabulated2DFunction {Tabulated2DFunction::InterpolationPolicy::LeftExtreme}); - PBUB_RS_.resize(numPvtRegions, Tabulated2DFunction{Tabulated2DFunction::InterpolationPolicy::LeftExtreme}); - PBUB_RV_.resize(numPvtRegions, Tabulated2DFunction{Tabulated2DFunction::InterpolationPolicy::LeftExtreme}); + PBUB_RS_.resize(numPvtRegions, Tabulated2DFunction {Tabulated2DFunction::InterpolationPolicy::LeftExtreme}); + PBUB_RV_.resize(numPvtRegions, Tabulated2DFunction {Tabulated2DFunction::InterpolationPolicy::LeftExtreme}); zLim_.resize(numPvtRegions); @@ -97,9 +97,9 @@ initFromState(const EclipseState& eclState) const auto& saturatedTable = pvtsolTable.getSaturatedTable(); assert(saturatedTable.numRows() > 1); - std::vector oilCmp(saturatedTable.numRows(), -4.0e-9); //Default values used in [*] - std::vector gasCmp(saturatedTable.numRows(), -0.08); //-------------"------------- - zLim_[regionIdx] = 0.7; //-------------"------------- + std::vector oilCmp(saturatedTable.numRows(), -4.0e-9); // Default values used in [*] + std::vector gasCmp(saturatedTable.numRows(), -0.08); //-------------"------------- + zLim_[regionIdx] = 0.7; //-------------"------------- std::vector zArg(saturatedTable.numRows(), 0.0); for (unsigned outerIdx = 0; outerIdx < saturatedTable.numRows(); ++outerIdx) { @@ -144,17 +144,19 @@ initFromState(const EclipseState& eclState) Scalar cmpFactor = (bo - bo0) / (po - po0); oilCmp[outerIdx] = cmpFactor; zLim_[regionIdx] = ZCO2; - //std::cout << "### cmpFactorOil: " << cmpFactor << " zLim: " << zLim_[regionIdx] << std::endl; + // std::cout << "### cmpFactorOil: " << cmpFactor << " zLim: " << zLim_[regionIdx] << + // std::endl; } break; } else if (bo0 == bo) { // This is undersaturated gas-phase for ZCO2 > zLim ... // Here we assume tabulated bo to be constant extrapolated beyond dew point - if (innerIdx+1 < numRows && ZCO2<1.0 && extractCmpFromPvt) { + if (innerIdx + 1 < numRows && ZCO2 < 1.0 && extractCmpFromPvt) { Scalar rvNxt = underSaturatedTable.get("RV", innerIdx + 1) + innerIdx * 1.0e-10; Scalar bgNxt = underSaturatedTable.get("B_G", innerIdx + 1); Scalar cmpFactor = (bgNxt - bg) / (rvNxt - rv); gasCmp[outerIdx] = cmpFactor; - //std::cout << "### cmpFactorGas: " << cmpFactor << " zLim: " << zLim_[regionIdx] << std::endl; + // std::cout << "### cmpFactorGas: " << cmpFactor << " zLim: " << zLim_[regionIdx] << + // std::endl; } BO_[regionIdx].appendSamplePoint(outerIdx, po, bo); @@ -183,7 +185,7 @@ initFromState(const EclipseState& eclState) VISCO_[regionIdx].appendSamplePoint(outerIdx, po, mo); VISCG_[regionIdx].appendSamplePoint(outerIdx, po, mg); - // rs,rv -> pressure + // rs,rv -> pressure PBUB_RS_[regionIdx].appendSamplePoint(outerIdx, rs, po); PBUB_RV_[regionIdx].appendSamplePoint(outerIdx, rv, po); } @@ -192,7 +194,7 @@ initFromState(const EclipseState& eclState) gasCmp_[regionIdx].setXYContainers(zArg, gasCmp, /*sortInput=*/false); } - // Reference density for pure z-component taken from kw SDENSITY + // Reference density for pure z-component taken from kw SDENSITY const auto& sdensityTables = eclState.getTableManager().getSolventDensityTables(); if (sdensityTables.size() == numPvtRegions) { zReferenceDensity_.resize(numPvtRegions); @@ -200,15 +202,14 @@ initFromState(const EclipseState& eclState) Scalar rhoRefS = sdensityTables[regionIdx].getSolventDensityColumn().front(); zReferenceDensity_[regionIdx] = rhoRefS; } - } - else + } else throw std::runtime_error("Extbo: kw SDENSITY is missing or not aligned with NTPVT\n"); } #endif -#define INSTANTIATE_TYPE(T) \ - template struct BlackOilExtboParams; \ - template void BlackOilExtboParams::initFromState(const EclipseState&); \ +#define INSTANTIATE_TYPE(T) \ + template struct BlackOilExtboParams; \ + template void BlackOilExtboParams::initFromState(const EclipseState&); \ template void BlackOilExtboParams::initFromState(const EclipseState&); INSTANTIATE_TYPE(double) diff --git a/opm/models/blackoil/blackoilextboparams.hpp b/opm/models/blackoil/blackoilextboparams.hpp index 656596d32ef..9717191e10d 100644 --- a/opm/models/blackoil/blackoilextboparams.hpp +++ b/opm/models/blackoil/blackoilextboparams.hpp @@ -37,21 +37,21 @@ #include -namespace Opm { +namespace Opm +{ #if HAVE_ECL_INPUT class EclipseState; #endif //! \brief Struct holding the parameters for the BlackoilExtboModule class. -template -struct BlackOilExtboParams -{ +template +struct BlackOilExtboParams { using TabulatedFunction = Tabulated1DFunction; using Tabulated2DFunction = UniformXTabulated2DFunction; #if HAVE_ECL_INPUT - template + template void initFromState(const EclipseState& eclState); #endif diff --git a/opm/models/blackoil/blackoilfoamparams.cpp b/opm/models/blackoil/blackoilfoamparams.cpp index 71f3d779b7d..e7514515f11 100644 --- a/opm/models/blackoil/blackoilfoamparams.cpp +++ b/opm/models/blackoil/blackoilfoamparams.cpp @@ -33,13 +33,14 @@ #include #include -namespace Opm { +namespace Opm +{ #if HAVE_ECL_INPUT -template -template -void BlackOilFoamParams:: -initFromState(const EclipseState& eclState) +template +template +void +BlackOilFoamParams::initFromState(const EclipseState& eclState) { // some sanity checks: if foam is enabled, the FOAM keyword must be // present, if foam is disabled the keyword must not be present. @@ -48,8 +49,7 @@ initFromState(const EclipseState& eclState) throw std::runtime_error("Non-trivial foam treatment requested at compile time, but " "the deck does not contain the FOAM keyword"); } - } - else { + } else { if (eclState.runspec().phases().active(Phase::FOAM)) { throw std::runtime_error("Foam treatment disabled at compile time, but the deck " "contains the FOAM keyword"); @@ -127,8 +127,9 @@ initFromState(const EclipseState& eclState) } #endif -template -void BlackOilFoamParams::setNumSatRegions(unsigned numRegions) +template +void +BlackOilFoamParams::setNumSatRegions(unsigned numRegions) { foamCoefficients_.resize(numRegions); foamRockDensity_.resize(numRegions); @@ -136,9 +137,9 @@ void BlackOilFoamParams::setNumSatRegions(unsigned numRegions) adsorbedFoamTable_.resize(numRegions); } -#define INSTANTIATE_TYPE(T) \ - template struct BlackOilFoamParams; \ - template void BlackOilFoamParams::initFromState(const EclipseState&); \ +#define INSTANTIATE_TYPE(T) \ + template struct BlackOilFoamParams; \ + template void BlackOilFoamParams::initFromState(const EclipseState&); \ template void BlackOilFoamParams::initFromState(const EclipseState&); INSTANTIATE_TYPE(double) diff --git a/opm/models/blackoil/blackoilfoamparams.hpp b/opm/models/blackoil/blackoilfoamparams.hpp index 99275d383c6..cd2425c3ab3 100644 --- a/opm/models/blackoil/blackoilfoamparams.hpp +++ b/opm/models/blackoil/blackoilfoamparams.hpp @@ -32,7 +32,8 @@ #include -namespace Opm { +namespace Opm +{ enum class Phase; @@ -41,13 +42,12 @@ class EclipseState; #endif //! \brief Struct holding the parameters for the BlackoilFoamModule class. -template -struct BlackOilFoamParams -{ +template +struct BlackOilFoamParams { using TabulatedFunction = Tabulated1DFunction; #if HAVE_ECL_INPUT - template + template void initFromState(const EclipseState& eclState); #endif @@ -62,21 +62,21 @@ struct BlackOilFoamParams // "Modeling techniques for foam flow in porous media", SPE Journal, 20(03):453–470, jun 2015. // The constants are provided by various deck keywords as shown in the comments below. struct FoamCoefficients { - Scalar fm_min = 1e-20; // FOAMFSC - Scalar fm_mob = 1.0; // FOAMFRM + Scalar fm_min = 1e-20; // FOAMFSC + Scalar fm_mob = 1.0; // FOAMFRM - Scalar fm_surf = 1.0; // FOAMFSC - Scalar ep_surf = 1.0; // FOAMFSC + Scalar fm_surf = 1.0; // FOAMFSC + Scalar ep_surf = 1.0; // FOAMFSC - Scalar fm_oil = 1.0; // FOAMFSO - Scalar fl_oil = 0.0; // FOAMFSO - Scalar ep_oil = 0.0; // FOAMFSO + Scalar fm_oil = 1.0; // FOAMFSO + Scalar fl_oil = 0.0; // FOAMFSO + Scalar ep_oil = 0.0; // FOAMFSO - Scalar fm_cap = 1.0; // FOAMFCN - Scalar ep_cap = 0.0; // FOAMFCN + Scalar fm_cap = 1.0; // FOAMFCN + Scalar ep_cap = 0.0; // FOAMFCN - Scalar fm_dry = 1.0; // FOAMFSW - Scalar ep_dry = 0.0; // FOAMFSW + Scalar fm_dry = 1.0; // FOAMFSW + Scalar ep_dry = 0.0; // FOAMFSW }; std::vector foamRockDensity_; diff --git a/opm/models/blackoil/blackoilnewtonmethod.hpp b/opm/models/blackoil/blackoilnewtonmethod.hpp index 184b418dd0a..5695a85ff82 100644 --- a/opm/models/blackoil/blackoilnewtonmethod.hpp +++ b/opm/models/blackoil/blackoilnewtonmethod.hpp @@ -42,14 +42,16 @@ #include #include -namespace Opm::Properties { +namespace Opm::Properties +{ template struct DiscNewtonMethod; } // namespace Opm::Properties -namespace Opm { +namespace Opm +{ /*! * \ingroup BlackOilModel @@ -75,7 +77,8 @@ class BlackOilNewtonMethod : public GetPropType(); public: - explicit BlackOilNewtonMethod(Simulator& simulator) : ParentType(simulator) + explicit BlackOilNewtonMethod(Simulator& simulator) + : ParentType(simulator) { bparams_.read(); } @@ -104,7 +107,9 @@ class BlackOilNewtonMethod : public GetPropType; @@ -125,8 +130,7 @@ class BlackOilNewtonMethod : public GetPropTypesimulator_.model().newtonMethod().endIterMsg() - << ", num switched=" << numPriVarsSwitched_; + this->simulator_.model().newtonMethod().endIterMsg() << ", num switched=" << numPriVarsSwitched_; ParentType::endIteration_(uCurrentIter, uLastIter); } @@ -156,13 +159,9 @@ class BlackOilNewtonMethod : public GetPropType currentValue[ Indices::waterSwitchIdx]) { - delta = currentValue[ Indices::waterSwitchIdx]; + } else { + // Ensure Rvw and Rsw factor does not become negative + if (delta > currentValue[Indices::waterSwitchIdx]) { + delta = currentValue[Indices::waterSwitchIdx]; } } else if (pvIdx == Indices::compositionSwitchIdx) { @@ -285,47 +278,39 @@ class BlackOilNewtonMethod : public GetPropType currentValue[Indices::compositionSwitchIdx]) { delta = currentValue[Indices::compositionSwitchIdx]; } } - } - else if (enableSolvent && pvIdx == Indices::solventSaturationIdx) { + } else if (enableSolvent && pvIdx == Indices::solventSaturationIdx) { // solvent saturation updates are also subject to the Appleyard chop if (currentValue.primaryVarsMeaningSolvent() == PrimaryVariables::SolventMeaning::Ss) { delta *= satAlpha; - } - else { + } else { // Ensure Rssolw factor does not become negative if (delta > currentValue[Indices::solventSaturationIdx]) { delta = currentValue[Indices::solventSaturationIdx]; } } - } - else if (enableExtbo && pvIdx == Indices::zFractionIdx) { + } else if (enableExtbo && pvIdx == Indices::zFractionIdx) { // z fraction updates are also subject to the Appleyard chop - const auto& curr = currentValue[Indices::zFractionIdx]; // or currentValue[pvIdx] given the block condition - delta = std::clamp(delta, curr - Scalar{1.0}, curr); - } - else if (enablePolymerWeight && pvIdx == Indices::polymerMoleWeightIdx) { + const auto& curr + = currentValue[Indices::zFractionIdx]; // or currentValue[pvIdx] given the block condition + delta = std::clamp(delta, curr - Scalar {1.0}, curr); + } else if (enablePolymerWeight && pvIdx == Indices::polymerMoleWeightIdx) { const double sign = delta >= 0. ? 1. : -1.; // maximum change of polymer molecular weight, the unit is MDa. // applying this limit to stabilize the simulation. The value itself is still experimental. const Scalar maxMolarWeightChange = 100.0; delta = sign * std::min(std::abs(delta), maxMolarWeightChange); delta *= satAlpha; - } - else if (enableEnergy && pvIdx == Indices::temperatureIdx) { + } else if (enableEnergy && pvIdx == Indices::temperatureIdx) { const double sign = delta >= 0. ? 1. : -1.; delta = sign * std::min(std::abs(delta), bparams_.maxTempChange_); - } - else if (enableBrine && pvIdx == Indices::saltConcentrationIdx && - enableSaltPrecipitation && - currentValue.primaryVarsMeaningBrine() == PrimaryVariables::BrineMeaning::Sp) - { + } else if (enableBrine && pvIdx == Indices::saltConcentrationIdx && enableSaltPrecipitation + && currentValue.primaryVarsMeaningBrine() == PrimaryVariables::BrineMeaning::Sp) { const Scalar maxSaltSaturationChange = 0.1; const Scalar sign = delta >= 0. ? 1. : -1.; delta = sign * std::min(std::abs(delta), maxSaltSaturationChange); @@ -337,22 +322,22 @@ class BlackOilNewtonMethod : public GetPropTypeproblem().referencePorosity(globalDofIdx, 0) - 1e-8); + nextValue[pvIdx] = std::clamp( + nextValue[pvIdx], Scalar {0.0}, this->problem().referencePorosity(globalDofIdx, 0) - 1e-8); } if constexpr (enableMICP) { if (pvIdx == Indices::oxygenConcentrationIdx) { - nextValue[pvIdx] = std::max(nextValue[pvIdx], Scalar{0.0}); + nextValue[pvIdx] = std::max(nextValue[pvIdx], Scalar {0.0}); } if (pvIdx == Indices::ureaConcentrationIdx) { - nextValue[pvIdx] = std::max(nextValue[pvIdx], Scalar{0.0}); + nextValue[pvIdx] = std::max(nextValue[pvIdx], Scalar {0.0}); } if (pvIdx == Indices::calciteConcentrationIdx) { - nextValue[pvIdx] = std::clamp(nextValue[pvIdx], Scalar{0.0}, - this->problem().referencePorosity(globalDofIdx, 0) - 1e-8); + nextValue[pvIdx] = std::clamp( + nextValue[pvIdx], Scalar {0.0}, this->problem().referencePorosity(globalDofIdx, 0) - 1e-8); } } } @@ -426,12 +408,9 @@ class BlackOilNewtonMethod : public GetPropTypeproblem(), - globalDofIdx, - bparams_.waterSaturationMax_, - bparams_.waterOnlyThreshold_); + } else { + wasSwitched_[globalDofIdx] = nextValue.adaptPrimaryVariables( + this->problem(), globalDofIdx, bparams_.waterSaturationMax_, bparams_.waterOnlyThreshold_); } if (wasSwitched_[globalDofIdx]) { @@ -445,13 +424,13 @@ class BlackOilNewtonMethod : public GetPropType bparams_{}; + BlackoilNewtonParams bparams_ {}; // keep track of cells where the primary variable meaning has changed // to detect and hinder oscillations - std::vector wasSwitched_{}; + std::vector wasSwitched_ {}; }; } // namespace Opm diff --git a/opm/models/blackoil/blackoilnewtonmethodparams.cpp b/opm/models/blackoil/blackoilnewtonmethodparams.cpp index 7e1fa1a5a90..ad73ba11af7 100644 --- a/opm/models/blackoil/blackoilnewtonmethodparams.cpp +++ b/opm/models/blackoil/blackoilnewtonmethodparams.cpp @@ -26,38 +26,33 @@ #include -namespace Opm { +namespace Opm +{ -template -void BlackoilNewtonParams::registerParameters() +template +void +BlackoilNewtonParams::registerParameters() { - Parameters::Register> - ("Maximum relative change of pressure in a single iteration"); - Parameters::Register> - ("Maximum absolute change of any saturation in a single iteration"); - Parameters::Register> - ("The threshold value for the primary variable switching conditions " - "after its meaning has switched to hinder oscillations"); - Parameters::Register - ("Option for doing saturation projection"); - Parameters::Register> - ("Maximum absolute change of temperature in a single iteration"); - Parameters::Register> - ("Maximum absolute temperature"); - Parameters::Register> - ("Minimum absolute temperature"); - Parameters::Register> - ("Maximum absolute pressure"); - Parameters::Register> - ("Minimum absolute pressure"); - Parameters::Register> - ("Maximum water saturation"); - Parameters::Register> - ("Cells with water saturation above or equal is considered one-phase water only"); + Parameters::Register>("Maximum relative change of pressure in a single iteration"); + Parameters::Register>("Maximum absolute change of any saturation in a single iteration"); + Parameters::Register>( + "The threshold value for the primary variable switching conditions " + "after its meaning has switched to hinder oscillations"); + Parameters::Register("Option for doing saturation projection"); + Parameters::Register>( + "Maximum absolute change of temperature in a single iteration"); + Parameters::Register>("Maximum absolute temperature"); + Parameters::Register>("Minimum absolute temperature"); + Parameters::Register>("Maximum absolute pressure"); + Parameters::Register>("Minimum absolute pressure"); + Parameters::Register>("Maximum water saturation"); + Parameters::Register>( + "Cells with water saturation above or equal is considered one-phase water only"); } -template -void BlackoilNewtonParams::read() +template +void +BlackoilNewtonParams::read() { priVarOscilationThreshold_ = Parameters::Get>(); dpMaxRel_ = Parameters::Get>(); diff --git a/opm/models/blackoil/blackoilnewtonmethodparams.hpp b/opm/models/blackoil/blackoilnewtonmethodparams.hpp index 7289e98a40a..04b757f0929 100644 --- a/opm/models/blackoil/blackoilnewtonmethodparams.hpp +++ b/opm/models/blackoil/blackoilnewtonmethodparams.hpp @@ -28,50 +28,73 @@ #ifndef EWOMS_BLACK_OIL_NEWTON_METHOD_PARAMETERS_HH #define EWOMS_BLACK_OIL_NEWTON_METHOD_PARAMETERS_HH -namespace Opm::Parameters { +namespace Opm::Parameters +{ -template -struct DpMaxRel { static constexpr Scalar value = 0.3; }; +template +struct DpMaxRel { + static constexpr Scalar value = 0.3; +}; -template -struct DsMax { static constexpr Scalar value = 0.2; }; +template +struct DsMax { + static constexpr Scalar value = 0.2; +}; -template -struct PriVarOscilationThreshold { static constexpr Scalar value = 1e-5; }; +template +struct PriVarOscilationThreshold { + static constexpr Scalar value = 1e-5; +}; -struct ProjectSaturations { static constexpr bool value = false; }; +struct ProjectSaturations { + static constexpr bool value = false; +}; -template -struct MaxTemperatureChange { static constexpr Scalar value = 5.0; }; // Kelvin +template +struct MaxTemperatureChange { + static constexpr Scalar value = 5.0; +}; // Kelvin -template -struct TemperatureMax { static constexpr Scalar value = 1e9; }; // Kelvin +template +struct TemperatureMax { + static constexpr Scalar value = 1e9; +}; // Kelvin -template -struct TemperatureMin { static constexpr Scalar value = 0.0; }; // Kelvin +template +struct TemperatureMin { + static constexpr Scalar value = 0.0; +}; // Kelvin -template -struct PressureMax { static constexpr Scalar value = 1e99; }; +template +struct PressureMax { + static constexpr Scalar value = 1e99; +}; -template -struct PressureMin { static constexpr Scalar value = -1e99; }; +template +struct PressureMin { + static constexpr Scalar value = -1e99; +}; -template -struct MaximumWaterSaturation { static constexpr Scalar value = 1.0; }; +template +struct MaximumWaterSaturation { + static constexpr Scalar value = 1.0; +}; -template -struct WaterOnlyThreshold { static constexpr Scalar value = 1.0; }; +template +struct WaterOnlyThreshold { + static constexpr Scalar value = 1.0; +}; } // namespace Opm::Parameters -namespace Opm { +namespace Opm +{ /*! * \brief Struct holding the parameters for BlackoilNewtonMethod. */ -template -struct BlackoilNewtonParams -{ +template +struct BlackoilNewtonParams { //! \brief Registers the parameters in parameter system. static void registerParameters(); diff --git a/opm/models/blackoil/blackoilpolymerparams.cpp b/opm/models/blackoil/blackoilpolymerparams.cpp index 5c01c5d712d..6a4350ac9a3 100644 --- a/opm/models/blackoil/blackoilpolymerparams.cpp +++ b/opm/models/blackoil/blackoilpolymerparams.cpp @@ -38,9 +38,10 @@ copyright holders. #include #include -namespace { +namespace +{ -template +template std::vector> convertVecToVec(const std::vector>& input) { @@ -53,15 +54,16 @@ convertVecToVec(const std::vector>& input) return output; } -} +} // namespace -namespace Opm { +namespace Opm +{ #if HAVE_ECL_INPUT -template -template -void BlackOilPolymerParams:: -initFromState(const EclipseState& eclState) +template +template +void +BlackOilPolymerParams::initFromState(const EclipseState& eclState) { // some sanity checks: if polymers are enabled, the POLYMER keyword must be // present, if polymers are disabled the keyword must not be present. @@ -70,8 +72,7 @@ initFromState(const EclipseState& eclState) throw std::runtime_error("Non-trivial polymer treatment requested at compile time, but " "the deck does not contain the POLYMER keyword"); } - } - else { + } else { if (eclState.runspec().phases().active(Phase::POLYMER)) { throw std::runtime_error("Polymer treatment disabled at compile time, but the deck " "contains the POLYMER keyword"); @@ -83,8 +84,7 @@ initFromState(const EclipseState& eclState) throw std::runtime_error("Polymer molecular weight tracking is enabled at compile time, but " "the deck does not contain the POLYMW keyword"); } - } - else { + } else { if (eclState.runspec().phases().active(Phase::POLYMW)) { throw std::runtime_error("Polymer molecular weight tracking is disabled at compile time, but the deck " "contains the POLYMW keyword"); @@ -105,7 +105,7 @@ initFromState(const EclipseState& eclState) unsigned numSatRegions = tableManager.getTabdims().getNumSatTables(); setNumSatRegions(numSatRegions); - // initialize the objects which deal with the PLYROCK keyword + // initialize the objects which deal with the PLYROCK keyword const auto& plyrockTables = tableManager.getPlyrockTables(); if (!plyrockTables.empty()) { assert(numSatRegions == plyrockTables.size()); @@ -118,12 +118,11 @@ initFromState(const EclipseState& eclState) static_cast(plyrockTable.getAdsorbtionIndexColumn()[0]), plyrockTable.getMaxAdsorbtionColumn()[0]); } - } - else { + } else { throw std::runtime_error("PLYROCK must be specified in POLYMER runs\n"); } - // initialize the objects which deal with the PLYADS keyword + // initialize the objects which deal with the PLYADS keyword const auto& plyadsTables = tableManager.getPlyadsTables(); if (!plyadsTables.empty()) { assert(numSatRegions == plyadsTables.size()); @@ -134,8 +133,7 @@ initFromState(const EclipseState& eclState) const auto& ads = plyadsTable.getAdsorbedPolymerColumn(); plyadsAdsorbedPolymer_[satRegionIdx].setXYContainers(c, ads); } - } - else { + } else { throw std::runtime_error("PLYADS must be specified in POLYMER runs\n"); } @@ -143,15 +141,14 @@ initFromState(const EclipseState& eclState) unsigned numPvtRegions = tableManager.getTabdims().getNumPVTTables(); plyviscViscosityMultiplierTable_.resize(numPvtRegions); - // initialize the objects which deal with the PLYVISC keyword + // initialize the objects which deal with the PLYVISC keyword const auto& plyviscTables = tableManager.getPlyviscTables(); if (!plyviscTables.empty()) { // different viscosity model is used for POLYMW if constexpr (enablePolymerMolarWeight) { OpmLog::warning("PLYVISC should not be used in POLYMW runs, " "it will have no effect. A viscosity model based on PLYVMH is used instead.\n"); - } - else { + } else { assert(numPvtRegions == plyviscTables.size()); for (unsigned pvtRegionIdx = 0; pvtRegionIdx < numPvtRegions; ++pvtRegionIdx) { const auto& plyadsTable = plyviscTables.template getTable(pvtRegionIdx); @@ -161,12 +158,11 @@ initFromState(const EclipseState& eclState) plyviscViscosityMultiplierTable_[pvtRegionIdx].setXYContainers(c, visc); } } - } - else if constexpr (!enablePolymerMolarWeight) { + } else if constexpr (!enablePolymerMolarWeight) { throw std::runtime_error("PLYVISC must be specified in POLYMER runs\n"); } - // initialize the objects which deal with the PLYMAX keyword + // initialize the objects which deal with the PLYMAX keyword const auto& plymaxTables = tableManager.getPlymaxTables(); const unsigned numMixRegions = plymaxTables.size(); setNumMixRegions(numMixRegions, enablePolymerMolarWeight); @@ -175,24 +171,21 @@ initFromState(const EclipseState& eclState) const auto& plymaxTable = plymaxTables.template getTable(mixRegionIdx); plymaxMaxConcentration_[mixRegionIdx] = plymaxTable.getPolymerConcentrationColumn()[0]; } - } - else { + } else { throw std::runtime_error("PLYMAX must be specified in POLYMER runs\n"); } if (!eclState.getTableManager().getPlmixparTable().empty()) { if constexpr (enablePolymerMolarWeight) { OpmLog::warning("PLMIXPAR should not be used in POLYMW runs, it will have no effect.\n"); - } - else { + } else { const auto& plmixparTable = eclState.getTableManager().getPlmixparTable(); // initialize the objects which deal with the PLMIXPAR keyword for (unsigned mixRegionIdx = 0; mixRegionIdx < numMixRegions; ++mixRegionIdx) { plymixparToddLongstaff_[mixRegionIdx] = plmixparTable[mixRegionIdx].todd_langstaff; } } - } - else if constexpr (!enablePolymerMolarWeight) { + } else if constexpr (!enablePolymerMolarWeight) { throw std::runtime_error("PLMIXPAR must be specified in POLYMER runs\n"); } @@ -215,9 +208,10 @@ initFromState(const EclipseState& eclState) auto waterVelocity = plyshlogTable.getWaterVelocityColumn().vectorCopy(); auto shearMultiplier = plyshlogTable.getShearMultiplierColumn().vectorCopy(); - // do the unit version here for the waterVelocity + // do the unit version here for the waterVelocity UnitSystem unitSystem = eclState.getDeckUnitSystem(); - double siFactor = hasShrate_? unitSystem.parse("1/Time").getSIScaling() : unitSystem.parse("Length/Time").getSIScaling(); + double siFactor = hasShrate_ ? unitSystem.parse("1/Time").getSIScaling() + : unitSystem.parse("Length/Time").getSIScaling(); for (std::size_t i = 0; i < waterVelocity.size(); ++i) { waterVelocity[i] *= siFactor; // for plyshlog the input must be stored as logarithms @@ -225,7 +219,8 @@ initFromState(const EclipseState& eclState) waterVelocity[i] = std::log(waterVelocity[i]); } - Scalar refViscMult = plyviscViscosityMultiplierTable_[pvtRegionIdx].eval(plyshlogRefPolymerConcentration, /*extrapolate=*/true); + Scalar refViscMult = plyviscViscosityMultiplierTable_[pvtRegionIdx].eval(plyshlogRefPolymerConcentration, + /*extrapolate=*/true); // convert the table using referece conditions for (std::size_t i = 0; i < waterVelocity.size(); ++i) { shearMultiplier[i] *= refViscMult; @@ -250,12 +245,10 @@ initFromState(const EclipseState& eclState) shrate_.resize(numPvtRegions); for (unsigned pvtRegionIdx = 0; pvtRegionIdx < numPvtRegions; ++pvtRegionIdx) { if (shrateTable.empty()) { - shrate_[pvtRegionIdx] = 4.8; //default; - } - else if (shrateTable.size() == numPvtRegions) { + shrate_[pvtRegionIdx] = 4.8; // default; + } else if (shrateTable.size() == numPvtRegions) { shrate_[pvtRegionIdx] = shrateTable[pvtRegionIdx].rate; - } - else { + } else { throw std::runtime_error("SHRATE must either have 0 or number of NUMPVT entries\n"); } } @@ -271,12 +264,11 @@ initFromState(const EclipseState& eclState) plyvmhCoefficients_[regionIdx].gamma = plyvmhTable[regionIdx].gamma; plyvmhCoefficients_[regionIdx].kappa = plyvmhTable[regionIdx].kappa; } - } - else { + } else { throw std::runtime_error("PLYVMH keyword must be specified in POLYMW rus \n"); } - // handling PLYMWINJ keyword + // handling PLYMWINJ keyword const auto& plymwinjTables = tableManager.getPlymwinjTables(); for (const auto& table : plymwinjTables) { const int tableNumber = table.first; @@ -296,7 +288,7 @@ initFromState(const EclipseState& eclState) } } - // handling SKPRWAT keyword + // handling SKPRWAT keyword const auto& skprwatTables = tableManager.getSkprwatTables(); for (const auto& table : skprwatTables) { const int tableNumber = table.first; @@ -316,7 +308,7 @@ initFromState(const EclipseState& eclState) } } - // handling SKPRPOLY keyword + // handling SKPRPOLY keyword const auto& skprpolyTables = tableManager.getSkprpolyTables(); for (const auto& table : skprpolyTables) { const int tableNumber = table.first; @@ -329,16 +321,11 @@ initFromState(const EclipseState& eclState) const std::vector tp(throughput.begin(), throughput.end()); const std::vector wv(watervelocity.begin(), watervelocity.end()); const auto sp = convertVecToVec(skinpressure); - SkprpolyTable tablefunc { - refPolymerConcentration, - TabulatedTwoDFunction(tp, wv, sp, true, false) - }; + SkprpolyTable tablefunc {refPolymerConcentration, TabulatedTwoDFunction(tp, wv, sp, true, false)}; skprpolyTables_[tableNumber] = std::move(tablefunc); } else { - SkprpolyTable tablefunc { - refPolymerConcentration, - TabulatedTwoDFunction(throughput, watervelocity, skinpressure, true, false) - }; + SkprpolyTable tablefunc {refPolymerConcentration, + TabulatedTwoDFunction(throughput, watervelocity, skinpressure, true, false)}; skprpolyTables_[tableNumber] = std::move(tablefunc); } } @@ -346,9 +333,9 @@ initFromState(const EclipseState& eclState) } #endif // HAVE_ECL_INPUT -template -void BlackOilPolymerParams:: -setNumSatRegions(unsigned numRegions) +template +void +BlackOilPolymerParams::setNumSatRegions(unsigned numRegions) { plyrockDeadPoreVolume_.resize(numRegions); plyrockResidualResistanceFactor_.resize(numRegions); @@ -358,9 +345,9 @@ setNumSatRegions(unsigned numRegions) plyadsAdsorbedPolymer_.resize(numRegions); } -template -void BlackOilPolymerParams:: -setNumMixRegions(unsigned numRegions, bool enablePolymerMolarWeight) +template +void +BlackOilPolymerParams::setNumMixRegions(unsigned numRegions, bool enablePolymerMolarWeight) { plymaxMaxConcentration_.resize(numRegions); plymixparToddLongstaff_.resize(numRegions); @@ -370,14 +357,14 @@ setNumMixRegions(unsigned numRegions, bool enablePolymerMolarWeight) } } -template -void BlackOilPolymerParams:: -setPlyrock(unsigned satRegionIdx, - const Scalar& plyrockDeadPoreVolume, - const Scalar& plyrockResidualResistanceFactor, - const Scalar& plyrockRockDensityFactor, - const Scalar& plyrockAdsorbtionIndex, - const Scalar& plyrockMaxAdsorbtion) +template +void +BlackOilPolymerParams::setPlyrock(unsigned satRegionIdx, + const Scalar& plyrockDeadPoreVolume, + const Scalar& plyrockResidualResistanceFactor, + const Scalar& plyrockRockDensityFactor, + const Scalar& plyrockAdsorbtionIndex, + const Scalar& plyrockMaxAdsorbtion) { plyrockDeadPoreVolume_[satRegionIdx] = plyrockDeadPoreVolume; plyrockResidualResistanceFactor_[satRegionIdx] = plyrockResidualResistanceFactor; @@ -386,11 +373,11 @@ setPlyrock(unsigned satRegionIdx, plyrockMaxAdsorbtion_[satRegionIdx] = plyrockMaxAdsorbtion; } -#define INSTANTIATE_TYPE(T) \ - template struct BlackOilPolymerParams; \ - template void BlackOilPolymerParams::initFromState(const EclipseState&); \ - template void BlackOilPolymerParams::initFromState(const EclipseState&); \ - template void BlackOilPolymerParams::initFromState(const EclipseState&); +#define INSTANTIATE_TYPE(T) \ + template struct BlackOilPolymerParams; \ + template void BlackOilPolymerParams::initFromState(const EclipseState&); \ + template void BlackOilPolymerParams::initFromState(const EclipseState&); \ + template void BlackOilPolymerParams::initFromState(const EclipseState&); INSTANTIATE_TYPE(double) diff --git a/opm/models/blackoil/blackoilpolymerparams.hpp b/opm/models/blackoil/blackoilpolymerparams.hpp index e21c9978ba7..6b7152936b9 100644 --- a/opm/models/blackoil/blackoilpolymerparams.hpp +++ b/opm/models/blackoil/blackoilpolymerparams.hpp @@ -28,20 +28,21 @@ #ifndef OPM_BLACK_OIL_POLYMER_PARAMS_HPP #define OPM_BLACK_OIL_POLYMER_PARAMS_HPP -#include #include +#include #include #include -namespace Opm { +namespace Opm +{ #if HAVE_ECL_INPUT class EclipseState; #endif //! \brief Struct holding the parameters for the BlackOilPolymerModule class. -template +template struct BlackOilPolymerParams { using TabulatedFunction = Tabulated1DFunction; using TabulatedTwoDFunction = IntervalTabulated2DFunction; @@ -49,7 +50,7 @@ struct BlackOilPolymerParams { enum AdsorptionBehaviour { Desorption = 1, NoDesorption = 2 }; #if HAVE_ECL_INPUT - template + template void initFromState(const EclipseState& eclState); #endif @@ -94,26 +95,26 @@ struct BlackOilPolymerParams { TabulatedTwoDFunction table_func; }; - std::vector plyrockDeadPoreVolume_{}; - std::vector plyrockResidualResistanceFactor_{}; - std::vector plyrockRockDensityFactor_{}; - std::vector plyrockAdsorbtionIndex_{}; - std::vector plyrockMaxAdsorbtion_{}; - std::vector plyadsAdsorbedPolymer_{}; - std::vector plyviscViscosityMultiplierTable_{}; - std::vector plymaxMaxConcentration_{}; - std::vector plymixparToddLongstaff_{}; - std::vector> plyshlogShearEffectRefMultiplier_{}; - std::vector> plyshlogShearEffectRefLogVelocity_{}; - std::vector shrate_{}; + std::vector plyrockDeadPoreVolume_ {}; + std::vector plyrockResidualResistanceFactor_ {}; + std::vector plyrockRockDensityFactor_ {}; + std::vector plyrockAdsorbtionIndex_ {}; + std::vector plyrockMaxAdsorbtion_ {}; + std::vector plyadsAdsorbedPolymer_ {}; + std::vector plyviscViscosityMultiplierTable_ {}; + std::vector plymaxMaxConcentration_ {}; + std::vector plymixparToddLongstaff_ {}; + std::vector> plyshlogShearEffectRefMultiplier_ {}; + std::vector> plyshlogShearEffectRefLogVelocity_ {}; + std::vector shrate_ {}; bool hasShrate_ = false; bool hasPlyshlog_ = false; - std::vector plyvmhCoefficients_{}; - std::map plymwinjTables_{}; - std::map skprwatTables_{}; + std::vector plyvmhCoefficients_ {}; + std::map plymwinjTables_ {}; + std::map skprwatTables_ {}; - std::map skprpolyTables_{}; + std::map skprpolyTables_ {}; }; } // namespace Opm diff --git a/opm/models/blackoil/blackoilsolventparams.cpp b/opm/models/blackoil/blackoilsolventparams.cpp index 606bddce7d5..5ada0068a70 100644 --- a/opm/models/blackoil/blackoilsolventparams.cpp +++ b/opm/models/blackoil/blackoilsolventparams.cpp @@ -26,23 +26,24 @@ #if HAVE_ECL_INPUT #include -#include -#include +#include #include #include -#include -#include #include +#include +#include +#include #include #endif -namespace Opm { +namespace Opm +{ #if HAVE_ECL_INPUT -template -template -void BlackOilSolventParams:: -initFromState(const EclipseState& eclState, const Schedule& schedule) +template +template +void +BlackOilSolventParams::initFromState(const EclipseState& eclState, const Schedule& schedule) { // some sanity checks: if solvents are enabled, the SOLVENT keyword must be // present, if solvents are disabled the keyword must not be present. @@ -116,8 +117,7 @@ initFromState(const EclipseState& eclState, const Schedule& schedule) sof2Table.getKroColumn(), /*sortInput=*/true); } - } - else if (eclState.runspec().phases().active(Phase::OIL)) { + } else if (eclState.runspec().phases().active(Phase::OIL)) { throw std::runtime_error("SOF2 must be specified in MISCIBLE (SOLVENT and OIL) runs\n"); } @@ -135,8 +135,7 @@ initFromState(const EclipseState& eclState, const Schedule& schedule) const auto& misc = miscTable.getMiscibilityColumn(); misc_[miscRegionIdx].setXYContainers(solventFraction, misc); } - } - else { + } else { throw std::runtime_error("MISC must be specified in MISCIBLE (SOLVENT) runs\n"); } @@ -155,10 +154,9 @@ initFromState(const EclipseState& eclState, const Schedule& schedule) pmisc_[regionIdx].setXYContainers(po, pmisc); } - } - else { - std::vector x = {0.0,1.0e20}; - std::vector y = {1.0,1.0}; + } else { + std::vector x = {0.0, 1.0e20}; + std::vector y = {1.0, 1.0}; TabulatedFunction constant = TabulatedFunction(2, x, y); for (unsigned regionIdx = 0; regionIdx < numMiscRegions; ++regionIdx) { pmisc_[regionIdx] = constant; @@ -184,10 +182,9 @@ initFromState(const EclipseState& eclState, const Schedule& schedule) msfnKrsg_[regionIdx].setXYContainers(Ssg, krsg); msfnKro_[regionIdx].setXYContainers(Ssg, kro); } - } - else { - std::vector x = {0.0,1.0}; - std::vector y = {1.0,0.0}; + } else { + std::vector x = {0.0, 1.0}; + std::vector y = {1.0, 0.0}; TabulatedFunction unit = TabulatedFunction(2, x, x); TabulatedFunction invUnit = TabulatedFunction(2, x, y); @@ -210,11 +207,10 @@ initFromState(const EclipseState& eclState, const Schedule& schedule) sorwmis_[regionIdx].setXYContainers(sw, sorwmis); } - } - else { + } else { // default - std::vector x = {0.0,1.0}; - std::vector y = {0.0,0.0}; + std::vector x = {0.0, 1.0}; + std::vector y = {0.0, 0.0}; TabulatedFunction zero = TabulatedFunction(2, x, y); for (unsigned regionIdx = 0; regionIdx < numMiscRegions; ++regionIdx) { sorwmis_[regionIdx] = zero; @@ -236,11 +232,10 @@ initFromState(const EclipseState& eclState, const Schedule& schedule) sgcwmis_[regionIdx].setXYContainers(sw, sgcwmis); } - } - else { + } else { // default - std::vector x = {0.0,1.0}; - std::vector y = {0.0,0.0}; + std::vector x = {0.0, 1.0}; + std::vector y = {0.0, 0.0}; TabulatedFunction zero = TabulatedFunction(2, x, y); for (unsigned regionIdx = 0; regionIdx < numMiscRegions; ++regionIdx) sgcwmis_[regionIdx] = zero; @@ -258,8 +253,7 @@ initFromState(const EclipseState& eclState, const Schedule& schedule) tlMixParamViscosity_[regionIdx] = tlp.viscosity_parameter; tlMixParamDensity_[regionIdx] = tlp.density_parameter; } - } - else + } else throw std::runtime_error("TLMIXPAR must be specified in MISCIBLE (SOLVENT) runs\n"); // resize the attributes of the object @@ -277,23 +271,20 @@ initFromState(const EclipseState& eclState, const Schedule& schedule) tlPMixTable_[regionIdx].setXYContainers(po, tlpmixpa); } - } - else { + } else { // if empty keyword. Try to use the pmisc table as default. if (!pmisc_.empty()) { tlPMixTable_ = pmisc_; - } - else { + } else { throw std::invalid_argument("If the pressure dependent TL values in " "TLPMIXPA is defaulted (no entries), then " "the PMISC tables must be specified."); } } - } - else { + } else { // default - std::vector x = {0.0,1.0e20}; - std::vector y = {1.0,1.0}; + std::vector x = {0.0, 1.0e20}; + std::vector y = {1.0, 1.0}; TabulatedFunction ones = TabulatedFunction(2, x, y); for (unsigned regionIdx = 0; regionIdx < numMiscRegions; ++regionIdx) tlPMixTable_[regionIdx] = ones; @@ -302,27 +293,27 @@ initFromState(const EclipseState& eclState, const Schedule& schedule) } #endif -template -void BlackOilSolventParams:: -setNumSatRegions(unsigned numRegions) +template +void +BlackOilSolventParams::setNumSatRegions(unsigned numRegions) { ssfnKrg_.resize(numRegions); ssfnKrs_.resize(numRegions); } -template -void BlackOilSolventParams:: -setMsfn(unsigned satRegionIdx, - const TabulatedFunction& msfnKrsg, - const TabulatedFunction& msfnKro) +template +void +BlackOilSolventParams::setMsfn(unsigned satRegionIdx, + const TabulatedFunction& msfnKrsg, + const TabulatedFunction& msfnKro) { msfnKrsg_[satRegionIdx] = msfnKrsg; msfnKro_[satRegionIdx] = msfnKro; } -#define INSTANTIATE_TYPE(T) \ - template struct BlackOilSolventParams; \ - template void BlackOilSolventParams::initFromState(const EclipseState&, const Schedule&); \ +#define INSTANTIATE_TYPE(T) \ + template struct BlackOilSolventParams; \ + template void BlackOilSolventParams::initFromState(const EclipseState&, const Schedule&); \ template void BlackOilSolventParams::initFromState(const EclipseState&, const Schedule&); INSTANTIATE_TYPE(double) diff --git a/opm/models/blackoil/blackoilsolventparams.hpp b/opm/models/blackoil/blackoilsolventparams.hpp index bafd975818d..f6ac51bcf67 100644 --- a/opm/models/blackoil/blackoilsolventparams.hpp +++ b/opm/models/blackoil/blackoilsolventparams.hpp @@ -28,15 +28,16 @@ #ifndef OPM_BLACK_OIL_SOLVENT_PARAMS_HPP #define OPM_BLACK_OIL_SOLVENT_PARAMS_HPP -#include -#include -#include #include #include +#include +#include +#include #include -namespace Opm { +namespace Opm +{ #if HAVE_ECL_INPUT class EclipseState; @@ -44,9 +45,8 @@ class Schedule; #endif //! \brief Struct holding the parameters for the BlackOilSolventModule class. -template -struct BlackOilSolventParams -{ +template +struct BlackOilSolventParams { using BrineCo2Pvt = ::Opm::BrineCo2Pvt; using BrineH2Pvt = ::Opm::BrineH2Pvt; using Co2GasPvt = ::Opm::Co2GasPvt; @@ -55,29 +55,29 @@ struct BlackOilSolventParams using TabulatedFunction = Tabulated1DFunction; #if HAVE_ECL_INPUT - template + template void initFromState(const EclipseState& eclState, const Schedule& schedule); #endif - BrineCo2Pvt brineCo2Pvt_{}; - BrineH2Pvt brineH2Pvt_{}; - Co2GasPvt co2GasPvt_{}; - H2GasPvt h2GasPvt_{}; - SolventPvt solventPvt_{}; - - std::vector ssfnKrg_{}; // the krg(Fs) column of the SSFN table - std::vector ssfnKrs_{}; // the krs(Fs) column of the SSFN table - std::vector sof2Krn_{}; // the krn(Sn) column of the SOF2 table - std::vector misc_{}; // the misc(Ss) column of the MISC table - std::vector pmisc_{}; // the pmisc(pg) column of the PMISC table - std::vector msfnKrsg_{}; // the krsg(Ssg) column of the MSFN table - std::vector msfnKro_{}; // the kro(Ssg) column of the MSFN table - std::vector sorwmis_{}; // the sorwmis(Sw) column of the SORWMIS table - std::vector sgcwmis_{}; // the sgcwmis(Sw) column of the SGCWMIS table - - std::vector tlMixParamViscosity_{}; // Todd-Longstaff mixing parameter for viscosity - std::vector tlMixParamDensity_{}; // Todd-Longstaff mixing parameter for density - std::vector tlPMixTable_{}; // the tlpmixpa(Po) column of the TLPMIXPA table + BrineCo2Pvt brineCo2Pvt_ {}; + BrineH2Pvt brineH2Pvt_ {}; + Co2GasPvt co2GasPvt_ {}; + H2GasPvt h2GasPvt_ {}; + SolventPvt solventPvt_ {}; + + std::vector ssfnKrg_ {}; // the krg(Fs) column of the SSFN table + std::vector ssfnKrs_ {}; // the krs(Fs) column of the SSFN table + std::vector sof2Krn_ {}; // the krn(Sn) column of the SOF2 table + std::vector misc_ {}; // the misc(Ss) column of the MISC table + std::vector pmisc_ {}; // the pmisc(pg) column of the PMISC table + std::vector msfnKrsg_ {}; // the krsg(Ssg) column of the MSFN table + std::vector msfnKro_ {}; // the kro(Ssg) column of the MSFN table + std::vector sorwmis_ {}; // the sorwmis(Sw) column of the SORWMIS table + std::vector sgcwmis_ {}; // the sgcwmis(Sw) column of the SGCWMIS table + + std::vector tlMixParamViscosity_ {}; // Todd-Longstaff mixing parameter for viscosity + std::vector tlMixParamDensity_ {}; // Todd-Longstaff mixing parameter for density + std::vector tlPMixTable_ {}; // the tlpmixpa(Po) column of the TLPMIXPA table bool isMiscible_ = false; bool rsSolw_active_ = false; @@ -96,9 +96,7 @@ struct BlackOilSolventParams * * The index of specified here must be in range [0, numSatRegions) */ - void setMsfn(unsigned satRegionIdx, - const TabulatedFunction& msfnKrsg, - const TabulatedFunction& msfnKro); + void setMsfn(unsigned satRegionIdx, const TabulatedFunction& msfnKrsg, const TabulatedFunction& msfnKro); }; } // namespace Opm diff --git a/opm/models/io/restart.cpp b/opm/models/io/restart.cpp index 983d25c606e..d900f6d928e 100644 --- a/opm/models/io/restart.cpp +++ b/opm/models/io/restart.cpp @@ -24,18 +24,16 @@ #include #include -namespace Opm { +namespace Opm +{ -std::string Restart::restartFileName_(int rank, - const std::string& outputDir, - const std::string& simName, - double t) +std::string +Restart::restartFileName_(int rank, const std::string& outputDir, const std::string& simName, double t) { std::string dir = outputDir; if (dir == ".") { dir = ""; - } - else if (!dir.empty() && dir.back() != '/') { + } else if (!dir.empty() && dir.back() != '/') { dir += "/"; } @@ -44,17 +42,20 @@ std::string Restart::restartFileName_(int rank, return oss.str(); } -void Restart::serializeSectionBegin(const std::string& cookie) +void +Restart::serializeSectionBegin(const std::string& cookie) { outStream_ << cookie << "\n"; } -void Restart::serializeSectionEnd() +void +Restart::serializeSectionEnd() { outStream_ << "\n"; } -void Restart::deserializeSectionBegin(const std::string& cookie) +void +Restart::deserializeSectionBegin(const std::string& cookie) { if (!inStream_.good()) { throw std::runtime_error("Encountered unexpected EOF in restart file."); @@ -62,11 +63,12 @@ void Restart::deserializeSectionBegin(const std::string& cookie) std::string buf; std::getline(inStream_, buf); if (buf != cookie) { - throw std::runtime_error("Could not start section '"+cookie+"'"); + throw std::runtime_error("Could not start section '" + cookie + "'"); } } -void Restart::deserializeSectionEnd() +void +Restart::deserializeSectionEnd() { std::string dummy; std::getline(inStream_, dummy); @@ -77,23 +79,25 @@ void Restart::deserializeSectionEnd() } } -void Restart::deserializeEnd() +void +Restart::deserializeEnd() { inStream_.close(); } -void Restart::serializeEnd() +void +Restart::serializeEnd() { outStream_.close(); } -void Restart::openInputStream(const std::string& cookie) +void +Restart::openInputStream(const std::string& cookie) { // open input file and read magic cookie inStream_.open(fileName_.c_str()); if (!inStream_.good()) { - throw std::runtime_error("Restart file '" + fileName_ + - "' could not be opened properly"); + throw std::runtime_error("Restart file '" + fileName_ + "' could not be opened properly"); } // make sure that we don't open an empty file @@ -108,7 +112,8 @@ void Restart::openInputStream(const std::string& cookie) deserializeSectionEnd(); } -void Restart::openOutputStream(const std::string& cookie) +void +Restart::openOutputStream(const std::string& cookie) { outStream_.open(fileName_); outStream_.precision(20); diff --git a/opm/models/io/restart.hpp b/opm/models/io/restart.hpp index 1fdfe1b1c71..1b22728b757 100644 --- a/opm/models/io/restart.hpp +++ b/opm/models/io/restart.hpp @@ -36,7 +36,8 @@ #include #include -namespace Opm { +namespace Opm +{ /*! * \brief Load or save a state of a problem to/from the harddisk. @@ -73,17 +74,16 @@ class Restart /*! * \brief Return the restart file name. */ - static std::string restartFileName_(int rank, - const std::string& outputDir, - const std::string& simName, - double t); + static std::string restartFileName_(int rank, const std::string& outputDir, const std::string& simName, double t); public: /*! * \brief Returns the name of the file which is (de-)serialized. */ const std::string& fileName() const - { return fileName_; } + { + return fileName_; + } /*! * \brief Write the current state of the model to disk. @@ -104,7 +104,9 @@ class Restart * \brief The output stream to write the serialized data. */ std::ostream& serializeStream() - { return outStream_; } + { + return outStream_; + } /*! * \brief Start a new section in the serialized output. @@ -146,9 +148,8 @@ class Restart template void deserializeBegin(Simulator& simulator, Scalar t) { - fileName_ = restartFileName_(simulator.gridView().comm().rank(), - simulator.problem().outputDir(), - simulator.problem().name(), t); + fileName_ = restartFileName_( + simulator.gridView().comm().rank(), simulator.problem().outputDir(), simulator.problem().name(), t); openInputStream(magicRestartCookie_(simulator.gridView())); } @@ -157,7 +158,9 @@ class Restart * deserialized. */ std::istream& deserializeStream() - { return inStream_; } + { + return inStream_; + } /*! * \brief Start reading a new section of the restart file. diff --git a/opm/models/io/vtkblackoilbioeffectsmodule.hpp b/opm/models/io/vtkblackoilbioeffectsmodule.hpp index d424a7c851e..dc72cf8df9b 100644 --- a/opm/models/io/vtkblackoilbioeffectsmodule.hpp +++ b/opm/models/io/vtkblackoilbioeffectsmodule.hpp @@ -42,7 +42,8 @@ #include #include -namespace Opm { +namespace Opm +{ /*! * \ingroup Vtk * @@ -136,25 +137,20 @@ class VtkBlackOilBioeffectsModule : public BaseOutputModule const unsigned globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, /*timeIdx=*/0); if (params_.microbialConcentrationOutput_) { - microbialConcentration_[globalDofIdx] = - scalarValue(intQuants.microbialConcentration()); + microbialConcentration_[globalDofIdx] = scalarValue(intQuants.microbialConcentration()); } if (params_.biofilmConcentrationOutput_) { - biofilmConcentration_[globalDofIdx] = - scalarValue(intQuants.biofilmConcentration()); + biofilmConcentration_[globalDofIdx] = scalarValue(intQuants.biofilmConcentration()); } if constexpr (enableMICP) { if (params_.oxygenConcentrationOutput_) { - oxygenConcentration_[globalDofIdx] = - scalarValue(intQuants.oxygenConcentration()); + oxygenConcentration_[globalDofIdx] = scalarValue(intQuants.oxygenConcentration()); } if (params_.ureaConcentrationOutput_) { - ureaConcentration_[globalDofIdx] = - scalarValue(intQuants.ureaConcentration()); + ureaConcentration_[globalDofIdx] = scalarValue(intQuants.ureaConcentration()); } if (params_.calciteConcentrationOutput_) { - calciteConcentration_[globalDofIdx] = - scalarValue(intQuants.calciteConcentration()); + calciteConcentration_[globalDofIdx] = scalarValue(intQuants.calciteConcentration()); } } } @@ -172,37 +168,34 @@ class VtkBlackOilBioeffectsModule : public BaseOutputModule } if (params_.microbialConcentrationOutput_) { - this->commitScalarBuffer_(baseWriter, "microbial concentration", - microbialConcentration_, BufferType::Dof); + this->commitScalarBuffer_( + baseWriter, "microbial concentration", microbialConcentration_, BufferType::Dof); } if (params_.biofilmConcentrationOutput_) { - this->commitScalarBuffer_(baseWriter, "biofilm fraction", - biofilmConcentration_, BufferType::Dof); + this->commitScalarBuffer_(baseWriter, "biofilm fraction", biofilmConcentration_, BufferType::Dof); } if constexpr (enableMICP) { if (params_.oxygenConcentrationOutput_) { - this->commitScalarBuffer_(baseWriter, "oxygen concentration", - oxygenConcentration_, BufferType::Dof); + this->commitScalarBuffer_( + baseWriter, "oxygen concentration", oxygenConcentration_, BufferType::Dof); } if (params_.ureaConcentrationOutput_) { - this->commitScalarBuffer_(baseWriter, "urea concentration", - ureaConcentration_, BufferType::Dof); + this->commitScalarBuffer_(baseWriter, "urea concentration", ureaConcentration_, BufferType::Dof); } if (params_.calciteConcentrationOutput_) { - this->commitScalarBuffer_(baseWriter, "calcite fraction", - calciteConcentration_, BufferType::Dof); + this->commitScalarBuffer_(baseWriter, "calcite fraction", calciteConcentration_, BufferType::Dof); } } } } private: - VtkBlackOilBioeffectsParams params_{}; - ScalarBuffer microbialConcentration_{}; - ScalarBuffer oxygenConcentration_{}; - ScalarBuffer ureaConcentration_{}; - ScalarBuffer biofilmConcentration_{}; - ScalarBuffer calciteConcentration_{}; + VtkBlackOilBioeffectsParams params_ {}; + ScalarBuffer microbialConcentration_ {}; + ScalarBuffer oxygenConcentration_ {}; + ScalarBuffer ureaConcentration_ {}; + ScalarBuffer biofilmConcentration_ {}; + ScalarBuffer calciteConcentration_ {}; }; } // namespace Opm diff --git a/opm/models/io/vtkblackoilbioeffectsparams.cpp b/opm/models/io/vtkblackoilbioeffectsparams.cpp index 559e302968d..2858dfd8863 100644 --- a/opm/models/io/vtkblackoilbioeffectsparams.cpp +++ b/opm/models/io/vtkblackoilbioeffectsparams.cpp @@ -26,28 +26,31 @@ #include -namespace Opm { +namespace Opm +{ -void VtkBlackOilBioeffectsParams::registerParameters(const bool isMICP) +void +VtkBlackOilBioeffectsParams::registerParameters(const bool isMICP) { - Parameters::Register - ("Include the concentration of the microbial component in the water phase " - "in the VTK output files"); - Parameters::Register - ("Include the biofilm volume fraction in the VTK output files"); + Parameters::Register( + "Include the concentration of the microbial component in the water phase " + "in the VTK output files"); + Parameters::Register( + "Include the biofilm volume fraction in the VTK output files"); if (isMICP) { - Parameters::Register - ("Include the concentration of the oxygen component in the water phase " + Parameters::Register( + "Include the concentration of the oxygen component in the water phase " "in the VTK output files"); - Parameters::Register - ("Include the concentration of the urea component in the water phase " + Parameters::Register( + "Include the concentration of the urea component in the water phase " "in the VTK output files"); - Parameters::Register - ("Include the calcite volume fraction in the VTK output files"); + Parameters::Register( + "Include the calcite volume fraction in the VTK output files"); } } -void VtkBlackOilBioeffectsParams::read(const bool isMICP) +void +VtkBlackOilBioeffectsParams::read(const bool isMICP) { microbialConcentrationOutput_ = Parameters::Get(); biofilmConcentrationOutput_ = Parameters::Get(); diff --git a/opm/models/io/vtkblackoilbioeffectsparams.hpp b/opm/models/io/vtkblackoilbioeffectsparams.hpp index 78dcc16233d..38b558ecc5d 100644 --- a/opm/models/io/vtkblackoilbioeffectsparams.hpp +++ b/opm/models/io/vtkblackoilbioeffectsparams.hpp @@ -27,24 +27,35 @@ #ifndef OPM_VTK_BLACK_OIL_BIOEFFECTS_PARAMS_HPP #define OPM_VTK_BLACK_OIL_BIOEFFECTS_PARAMS_HPP -namespace Opm::Parameters { +namespace Opm::Parameters +{ // set default values for what quantities to output -struct VtkWriteMicrobialConcentration { static constexpr bool value = true; }; -struct VtkWriteOxygenConcentration { static constexpr bool value = true; }; -struct VtkWriteUreaConcentration { static constexpr bool value = true; }; -struct VtkWriteBiofilmConcentration { static constexpr bool value = true; }; -struct VtkWriteCalciteConcentration { static constexpr bool value = true; }; +struct VtkWriteMicrobialConcentration { + static constexpr bool value = true; +}; +struct VtkWriteOxygenConcentration { + static constexpr bool value = true; +}; +struct VtkWriteUreaConcentration { + static constexpr bool value = true; +}; +struct VtkWriteBiofilmConcentration { + static constexpr bool value = true; +}; +struct VtkWriteCalciteConcentration { + static constexpr bool value = true; +}; } // namespace Opm::Parameters -namespace Opm { +namespace Opm +{ /*! * \brief Struct holding the parameters for VtkBlackOilBioeffectsModule. */ -struct VtkBlackOilBioeffectsParams -{ +struct VtkBlackOilBioeffectsParams { //! \brief Registers the parameters in parameter system. static void registerParameters(const bool isMICP); diff --git a/opm/models/io/vtkblackoilenergymodule.hpp b/opm/models/io/vtkblackoilenergymodule.hpp index 01edb3338c9..37a279c5fa5 100644 --- a/opm/models/io/vtkblackoilenergymodule.hpp +++ b/opm/models/io/vtkblackoilenergymodule.hpp @@ -42,7 +42,8 @@ #include #include -namespace Opm { +namespace Opm +{ /*! * \ingroup Vtk @@ -133,25 +134,23 @@ class VtkBlackOilEnergyModule : public BaseOutputModule const unsigned globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, /*timeIdx=*/0); if (params_.rockInternalEnergyOutput_) { - rockInternalEnergy_[globalDofIdx] = - scalarValue(intQuants.rockInternalEnergy()); + rockInternalEnergy_[globalDofIdx] = scalarValue(intQuants.rockInternalEnergy()); } if (params_.totalThermalConductivityOutput_) { - totalThermalConductivity_[globalDofIdx] = - scalarValue(intQuants.totalThermalConductivity()); + totalThermalConductivity_[globalDofIdx] = scalarValue(intQuants.totalThermalConductivity()); } for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { if (FluidSystem::phaseIsActive(phaseIdx)) { if (params_.fluidInternalEnergiesOutput_) { - fluidInternalEnergies_[phaseIdx][globalDofIdx] = - scalarValue(intQuants.fluidState().internalEnergy(phaseIdx)); + fluidInternalEnergies_[phaseIdx][globalDofIdx] + = scalarValue(intQuants.fluidState().internalEnergy(phaseIdx)); } if (params_.fluidEnthalpiesOutput_) { - fluidEnthalpies_[phaseIdx][globalDofIdx] = - scalarValue(intQuants.fluidState().enthalpy(phaseIdx)); + fluidEnthalpies_[phaseIdx][globalDofIdx] + = scalarValue(intQuants.fluidState().enthalpy(phaseIdx)); } } } @@ -170,34 +169,32 @@ class VtkBlackOilEnergyModule : public BaseOutputModule } if (params_.rockInternalEnergyOutput_) { - this->commitScalarBuffer_(baseWriter, "volumetric internal energy rock", - rockInternalEnergy_, BufferType::Dof); + this->commitScalarBuffer_( + baseWriter, "volumetric internal energy rock", rockInternalEnergy_, BufferType::Dof); } if (params_.totalThermalConductivityOutput_) { - this->commitScalarBuffer_(baseWriter, "total thermal conductivity", - totalThermalConductivity_, BufferType::Dof); + this->commitScalarBuffer_( + baseWriter, "total thermal conductivity", totalThermalConductivity_, BufferType::Dof); } if (params_.fluidInternalEnergiesOutput_) { - this->commitPhaseBuffer_(baseWriter, "internal energy_%s", - fluidInternalEnergies_, BufferType::Dof); + this->commitPhaseBuffer_(baseWriter, "internal energy_%s", fluidInternalEnergies_, BufferType::Dof); } if (params_.fluidEnthalpiesOutput_) { - this->commitPhaseBuffer_(baseWriter, "enthalpy_%s", - fluidEnthalpies_, BufferType::Dof); + this->commitPhaseBuffer_(baseWriter, "enthalpy_%s", fluidEnthalpies_, BufferType::Dof); } } } private: - VtkBlackoilEnergyParams params_{}; + VtkBlackoilEnergyParams params_ {}; - ScalarBuffer rockInternalEnergy_{}; - ScalarBuffer totalThermalConductivity_{}; - PhaseBuffer fluidInternalEnergies_{}; - PhaseBuffer fluidEnthalpies_{}; + ScalarBuffer rockInternalEnergy_ {}; + ScalarBuffer totalThermalConductivity_ {}; + PhaseBuffer fluidInternalEnergies_ {}; + PhaseBuffer fluidEnthalpies_ {}; }; } // namespace Opm diff --git a/opm/models/io/vtkblackoilenergyparams.cpp b/opm/models/io/vtkblackoilenergyparams.cpp index f668f6fa58b..e9942532d82 100644 --- a/opm/models/io/vtkblackoilenergyparams.cpp +++ b/opm/models/io/vtkblackoilenergyparams.cpp @@ -26,23 +26,25 @@ #include -namespace Opm { +namespace Opm +{ -void VtkBlackoilEnergyParams::registerParameters() +void +VtkBlackoilEnergyParams::registerParameters() { - Parameters::Register - ("Include the volumetric internal energy of rock " - "in the VTK output files"); - Parameters::Register - ("Include the total thermal conductivity of the medium and the fluids " - "in the VTK output files"); - Parameters::Register - ("Include the internal energies of the fluids in the VTK output files"); - Parameters::Register - ("Include the enthalpies of the fluids in the VTK output files"); + Parameters::Register("Include the volumetric internal energy of rock " + "in the VTK output files"); + Parameters::Register( + "Include the total thermal conductivity of the medium and the fluids " + "in the VTK output files"); + Parameters::Register( + "Include the internal energies of the fluids in the VTK output files"); + Parameters::Register( + "Include the enthalpies of the fluids in the VTK output files"); } -void VtkBlackoilEnergyParams::read() +void +VtkBlackoilEnergyParams::read() { rockInternalEnergyOutput_ = Parameters::Get(); totalThermalConductivityOutput_ = Parameters::Get(); diff --git a/opm/models/io/vtkblackoilenergyparams.hpp b/opm/models/io/vtkblackoilenergyparams.hpp index 3fceb437b93..74f94720512 100644 --- a/opm/models/io/vtkblackoilenergyparams.hpp +++ b/opm/models/io/vtkblackoilenergyparams.hpp @@ -27,23 +27,32 @@ #ifndef OPM_VTK_BLACK_OIL_ENERGY_PARAMS_HPP #define OPM_VTK_BLACK_OIL_ENERGY_PARAMS_HPP -namespace Opm::Parameters { +namespace Opm::Parameters +{ // set default values for what quantities to output -struct VtkWriteRockInternalEnergy { static constexpr bool value = true; }; -struct VtkWriteTotalThermalConductivity { static constexpr bool value = true; }; -struct VtkWriteFluidInternalEnergies { static constexpr bool value = true; }; -struct VtkWriteFluidEnthalpies { static constexpr bool value = true; }; +struct VtkWriteRockInternalEnergy { + static constexpr bool value = true; +}; +struct VtkWriteTotalThermalConductivity { + static constexpr bool value = true; +}; +struct VtkWriteFluidInternalEnergies { + static constexpr bool value = true; +}; +struct VtkWriteFluidEnthalpies { + static constexpr bool value = true; +}; } // namespace Opm::Parameters -namespace Opm { +namespace Opm +{ /*! * \brief Struct holding the parameters for VtkBlackoilEnergyOutputModule. */ -struct VtkBlackoilEnergyParams -{ +struct VtkBlackoilEnergyParams { //! \brief Registers the parameters in parameter system. static void registerParameters(); diff --git a/opm/models/io/vtkblackoilmodule.hpp b/opm/models/io/vtkblackoilmodule.hpp index 31e0018f6d8..f5333fc7701 100644 --- a/opm/models/io/vtkblackoilmodule.hpp +++ b/opm/models/io/vtkblackoilmodule.hpp @@ -45,7 +45,8 @@ #include #include -namespace Opm { +namespace Opm +{ /*! * \ingroup Vtk @@ -157,11 +158,9 @@ class VtkBlackOilModule : public BaseOutputModule const auto& primaryVars = elemCtx.primaryVars(dofIdx, /*timeIdx=*/0); const unsigned pvtRegionIdx = elemCtx.primaryVars(dofIdx, /*timeIdx=*/0).pvtRegionIndex(); - const Scalar SoMax = - FluidSystem::phaseIsActive(oilPhaseIdx) - ? std::max(getValue(fs.saturation(oilPhaseIdx)), - elemCtx.problem().maxOilSaturation(globalDofIdx)) - : 0.0; + const Scalar SoMax = FluidSystem::phaseIsActive(oilPhaseIdx) + ? std::max(getValue(fs.saturation(oilPhaseIdx)), elemCtx.problem().maxOilSaturation(globalDofIdx)) + : 0.0; if (FluidSystem::phaseIsActive(gasPhaseIdx) && FluidSystem::phaseIsActive(oilPhaseIdx)) { const Scalar x_oG = getValue(fs.moleFraction(oilPhaseIdx, gasCompIdx)); @@ -171,19 +170,13 @@ class VtkBlackOilModule : public BaseOutputModule const Scalar Rs = FluidSystem::convertXoGToRs(X_oG, pvtRegionIdx); const Scalar Rv = FluidSystem::convertXgOToRv(X_gO, pvtRegionIdx); - const Scalar RsSat = - FluidSystem::template saturatedDissolutionFactor(fs, - oilPhaseIdx, - pvtRegionIdx, - SoMax); + const Scalar RsSat = FluidSystem::template saturatedDissolutionFactor( + fs, oilPhaseIdx, pvtRegionIdx, SoMax); const Scalar X_oG_sat = FluidSystem::convertRsToXoG(RsSat, pvtRegionIdx); const Scalar x_oG_sat = FluidSystem::convertXoGToxoG(X_oG_sat, pvtRegionIdx); - const Scalar RvSat = - FluidSystem::template saturatedDissolutionFactor(fs, - gasPhaseIdx, - pvtRegionIdx, - SoMax); + const Scalar RvSat = FluidSystem::template saturatedDissolutionFactor( + fs, gasPhaseIdx, pvtRegionIdx, SoMax); const Scalar X_gO_sat = FluidSystem::convertRvToXgO(RvSat, pvtRegionIdx); const Scalar x_gO_sat = FluidSystem::convertXgOToxgO(X_gO_sat, pvtRegionIdx); if (params_.gasDissolutionFactorOutput_) { @@ -193,12 +186,12 @@ class VtkBlackOilModule : public BaseOutputModule oilVaporizationFactor_[globalDofIdx] = Rv; } if (params_.oilSaturationPressureOutput_) { - oilSaturationPressure_[globalDofIdx] = - FluidSystem::template saturationPressure(fs, oilPhaseIdx, pvtRegionIdx); + oilSaturationPressure_[globalDofIdx] + = FluidSystem::template saturationPressure(fs, oilPhaseIdx, pvtRegionIdx); } if (params_.gasSaturationPressureOutput_) { - gasSaturationPressure_[globalDofIdx] = - FluidSystem::template saturationPressure(fs, gasPhaseIdx, pvtRegionIdx); + gasSaturationPressure_[globalDofIdx] + = FluidSystem::template saturationPressure(fs, gasPhaseIdx, pvtRegionIdx); } if (params_.saturatedOilGasDissolutionFactorOutput_) { saturatedOilGasDissolutionFactor_[globalDofIdx] = RsSat; @@ -209,39 +202,37 @@ class VtkBlackOilModule : public BaseOutputModule if (params_.saturationRatiosOutput_) { if (x_oG_sat <= 0.0) { oilSaturationRatio_[globalDofIdx] = 1.0; - } - else { + } else { oilSaturationRatio_[globalDofIdx] = x_oG / x_oG_sat; } if (x_gO_sat <= 0.0) { gasSaturationRatio_[globalDofIdx] = 1.0; - } - else { + } else { gasSaturationRatio_[globalDofIdx] = x_gO / x_gO_sat; } } } if (params_.oilFormationVolumeFactorOutput_) { - oilFormationVolumeFactor_[globalDofIdx] = - 1.0 / FluidSystem::template inverseFormationVolumeFactor(fs, oilPhaseIdx, pvtRegionIdx); + oilFormationVolumeFactor_[globalDofIdx] = 1.0 + / FluidSystem::template inverseFormationVolumeFactor( + fs, oilPhaseIdx, pvtRegionIdx); } if (params_.gasFormationVolumeFactorOutput_) { - gasFormationVolumeFactor_[globalDofIdx] = - 1.0 / FluidSystem::template inverseFormationVolumeFactor(fs, gasPhaseIdx, pvtRegionIdx); + gasFormationVolumeFactor_[globalDofIdx] = 1.0 + / FluidSystem::template inverseFormationVolumeFactor( + fs, gasPhaseIdx, pvtRegionIdx); } if (params_.waterFormationVolumeFactorOutput_) { - waterFormationVolumeFactor_[globalDofIdx] = - 1.0 / FluidSystem::template inverseFormationVolumeFactor(fs, waterPhaseIdx, pvtRegionIdx); + waterFormationVolumeFactor_[globalDofIdx] = 1.0 + / FluidSystem::template inverseFormationVolumeFactor( + fs, waterPhaseIdx, pvtRegionIdx); } if (params_.primaryVarsMeaningOutput_) { - primaryVarsMeaningWater_[globalDofIdx] = - static_cast(primaryVars.primaryVarsMeaningWater()); - primaryVarsMeaningGas_[globalDofIdx] = - static_cast(primaryVars.primaryVarsMeaningGas()); - primaryVarsMeaningPressure_[globalDofIdx] = - static_cast(primaryVars.primaryVarsMeaningPressure()); + primaryVarsMeaningWater_[globalDofIdx] = static_cast(primaryVars.primaryVarsMeaningWater()); + primaryVarsMeaningGas_[globalDofIdx] = static_cast(primaryVars.primaryVarsMeaningGas()); + primaryVarsMeaningPressure_[globalDofIdx] = static_cast(primaryVars.primaryVarsMeaningPressure()); } } } @@ -256,76 +247,64 @@ class VtkBlackOilModule : public BaseOutputModule } if (params_.gasDissolutionFactorOutput_) { - this->commitScalarBuffer_(baseWriter, "R_s", - gasDissolutionFactor_, BufferType::Dof); + this->commitScalarBuffer_(baseWriter, "R_s", gasDissolutionFactor_, BufferType::Dof); } if (params_.oilVaporizationFactorOutput_) { - this->commitScalarBuffer_(baseWriter, "R_v", - oilVaporizationFactor_, BufferType::Dof); + this->commitScalarBuffer_(baseWriter, "R_v", oilVaporizationFactor_, BufferType::Dof); } if (params_.oilFormationVolumeFactorOutput_) { - this->commitScalarBuffer_(baseWriter, "B_o", - oilFormationVolumeFactor_, BufferType::Dof); + this->commitScalarBuffer_(baseWriter, "B_o", oilFormationVolumeFactor_, BufferType::Dof); } if (params_.gasFormationVolumeFactorOutput_) { - this->commitScalarBuffer_(baseWriter, "B_g", - gasFormationVolumeFactor_, BufferType::Dof); + this->commitScalarBuffer_(baseWriter, "B_g", gasFormationVolumeFactor_, BufferType::Dof); } if (params_.waterFormationVolumeFactorOutput_) { - this->commitScalarBuffer_(baseWriter, "B_w", - waterFormationVolumeFactor_, BufferType::Dof); + this->commitScalarBuffer_(baseWriter, "B_w", waterFormationVolumeFactor_, BufferType::Dof); } if (params_.oilSaturationPressureOutput_) { - this->commitScalarBuffer_(baseWriter, "p_o,sat", - oilSaturationPressure_, BufferType::Dof); + this->commitScalarBuffer_(baseWriter, "p_o,sat", oilSaturationPressure_, BufferType::Dof); } if (params_.gasSaturationPressureOutput_) { - this->commitScalarBuffer_(baseWriter, "p_g,sat", - gasSaturationPressure_, BufferType::Dof); + this->commitScalarBuffer_(baseWriter, "p_g,sat", gasSaturationPressure_, BufferType::Dof); } if (params_.saturatedOilGasDissolutionFactorOutput_) { - this->commitScalarBuffer_(baseWriter, "R_s,sat", - saturatedOilGasDissolutionFactor_, BufferType::Dof); + this->commitScalarBuffer_(baseWriter, "R_s,sat", saturatedOilGasDissolutionFactor_, BufferType::Dof); } if (params_.saturatedGasOilVaporizationFactorOutput_) { - this->commitScalarBuffer_(baseWriter, "R_v,sat", - saturatedGasOilVaporizationFactor_, BufferType::Dof); + this->commitScalarBuffer_(baseWriter, "R_v,sat", saturatedGasOilVaporizationFactor_, BufferType::Dof); } if (params_.saturationRatiosOutput_) { - this->commitScalarBuffer_(baseWriter, "saturation ratio_oil", - oilSaturationRatio_, BufferType::Dof); - this->commitScalarBuffer_(baseWriter, "saturation ratio_gas", - gasSaturationRatio_, BufferType::Dof); + this->commitScalarBuffer_(baseWriter, "saturation ratio_oil", oilSaturationRatio_, BufferType::Dof); + this->commitScalarBuffer_(baseWriter, "saturation ratio_gas", gasSaturationRatio_, BufferType::Dof); } if (params_.primaryVarsMeaningOutput_) { - this->commitScalarBuffer_(baseWriter, "primary vars meaning water", - primaryVarsMeaningWater_, BufferType::Dof); - this->commitScalarBuffer_(baseWriter, "primary vars meaning gas", - primaryVarsMeaningGas_, BufferType::Dof); - this->commitScalarBuffer_(baseWriter, "primary vars meaning pressure", - primaryVarsMeaningPressure_, BufferType::Dof); + this->commitScalarBuffer_( + baseWriter, "primary vars meaning water", primaryVarsMeaningWater_, BufferType::Dof); + this->commitScalarBuffer_(baseWriter, "primary vars meaning gas", primaryVarsMeaningGas_, BufferType::Dof); + this->commitScalarBuffer_( + baseWriter, "primary vars meaning pressure", primaryVarsMeaningPressure_, BufferType::Dof); } } private: - VtkBlackoilParams params_{}; - ScalarBuffer gasDissolutionFactor_{}; - ScalarBuffer oilVaporizationFactor_{}; - ScalarBuffer oilFormationVolumeFactor_{}; - ScalarBuffer gasFormationVolumeFactor_{}; - ScalarBuffer waterFormationVolumeFactor_{}; - ScalarBuffer oilSaturationPressure_{}; - ScalarBuffer gasSaturationPressure_{}; - - ScalarBuffer saturatedOilGasDissolutionFactor_{}; - ScalarBuffer saturatedGasOilVaporizationFactor_{}; - ScalarBuffer oilSaturationRatio_{}; - ScalarBuffer gasSaturationRatio_{}; - - ScalarBuffer primaryVarsMeaningPressure_{}; - ScalarBuffer primaryVarsMeaningWater_{}; - ScalarBuffer primaryVarsMeaningGas_{}; + VtkBlackoilParams params_ {}; + ScalarBuffer gasDissolutionFactor_ {}; + ScalarBuffer oilVaporizationFactor_ {}; + ScalarBuffer oilFormationVolumeFactor_ {}; + ScalarBuffer gasFormationVolumeFactor_ {}; + ScalarBuffer waterFormationVolumeFactor_ {}; + ScalarBuffer oilSaturationPressure_ {}; + ScalarBuffer gasSaturationPressure_ {}; + + ScalarBuffer saturatedOilGasDissolutionFactor_ {}; + ScalarBuffer saturatedGasOilVaporizationFactor_ {}; + ScalarBuffer oilSaturationRatio_ {}; + ScalarBuffer gasSaturationRatio_ {}; + + ScalarBuffer primaryVarsMeaningPressure_ {}; + ScalarBuffer primaryVarsMeaningWater_ {}; + ScalarBuffer primaryVarsMeaningGas_ {}; }; } // namespace Opm diff --git a/opm/models/io/vtkblackoilparams.cpp b/opm/models/io/vtkblackoilparams.cpp index 90c93fbcf0f..ccb2ec3fc88 100644 --- a/opm/models/io/vtkblackoilparams.cpp +++ b/opm/models/io/vtkblackoilparams.cpp @@ -26,45 +26,48 @@ #include -namespace Opm { +namespace Opm +{ -void VtkBlackoilParams::registerParameters() +void +VtkBlackoilParams::registerParameters() { - Parameters::Register - ("Include the gas dissolution factor (R_s) of the observed oil " - "in the VTK output files"); - Parameters::Register - ("Include the oil vaporization factor (R_v) of the observed gas " - "in the VTK output files"); - Parameters::Register - ("Include the oil formation volume factor (B_o) in the VTK output files"); - Parameters::Register - ("Include the gas formation volume factor (B_g) in the " - "VTK output files"); - Parameters::Register - ("Include the water formation volume factor (B_w) in the " - "VTK output files"); - Parameters::Register - ("Include the saturation pressure of oil (p_o,sat) in the " - "VTK output files"); - Parameters::Register - ("Include the saturation pressure of gas (p_g,sat) in the " - "VTK output files"); - Parameters::Register - ("Include the gas dissolution factor (R_s,sat) of gas saturated " - "oil in the VTK output files"); - Parameters::Register - ("Include the oil vaporization factor (R_v,sat) of oil saturated " - "gas in the VTK output files"); - Parameters::Register - ("Write the ratio of the actually and maximum dissolved component of " - "the mixtures"); - Parameters::Register - ("Include how the primary variables should be interpreted to the " - "VTK output files"); + Parameters::Register( + "Include the gas dissolution factor (R_s) of the observed oil " + "in the VTK output files"); + Parameters::Register( + "Include the oil vaporization factor (R_v) of the observed gas " + "in the VTK output files"); + Parameters::Register( + "Include the oil formation volume factor (B_o) in the VTK output files"); + Parameters::Register( + "Include the gas formation volume factor (B_g) in the " + "VTK output files"); + Parameters::Register( + "Include the water formation volume factor (B_w) in the " + "VTK output files"); + Parameters::Register( + "Include the saturation pressure of oil (p_o,sat) in the " + "VTK output files"); + Parameters::Register( + "Include the saturation pressure of gas (p_g,sat) in the " + "VTK output files"); + Parameters::Register( + "Include the gas dissolution factor (R_s,sat) of gas saturated " + "oil in the VTK output files"); + Parameters::Register( + "Include the oil vaporization factor (R_v,sat) of oil saturated " + "gas in the VTK output files"); + Parameters::Register( + "Write the ratio of the actually and maximum dissolved component of " + "the mixtures"); + Parameters::Register( + "Include how the primary variables should be interpreted to the " + "VTK output files"); } -void VtkBlackoilParams::read() +void +VtkBlackoilParams::read() { gasDissolutionFactorOutput_ = Parameters::Get(); oilVaporizationFactorOutput_ = Parameters::Get(); diff --git a/opm/models/io/vtkblackoilparams.hpp b/opm/models/io/vtkblackoilparams.hpp index 5fc29074b6b..605ed3c493e 100644 --- a/opm/models/io/vtkblackoilparams.hpp +++ b/opm/models/io/vtkblackoilparams.hpp @@ -27,30 +27,53 @@ #ifndef OPM_VTK_BLACK_OIL_PARAMS_HPP #define OPM_VTK_BLACK_OIL_PARAMS_HPP -namespace Opm::Parameters { +namespace Opm::Parameters +{ // set default values for what quantities to output -struct VtkWriteGasDissolutionFactor { static constexpr bool value = false; }; -struct VtkWriteOilVaporizationFactor { static constexpr bool value = false; }; -struct VtkWriteOilFormationVolumeFactor { static constexpr bool value = false; }; -struct VtkWriteGasFormationVolumeFactor { static constexpr bool value = false; }; -struct VtkWriteWaterFormationVolumeFactor { static constexpr bool value = false; }; -struct VtkWriteOilSaturationPressure { static constexpr bool value = false; }; -struct VtkWriteGasSaturationPressure { static constexpr bool value = false; }; -struct VtkWriteSaturationRatios { static constexpr bool value = false; }; -struct VtkWriteSaturatedOilGasDissolutionFactor { static constexpr bool value = false; }; -struct VtkWriteSaturatedGasOilVaporizationFactor { static constexpr bool value = false; }; -struct VtkWritePrimaryVarsMeaning { static constexpr bool value = false; }; +struct VtkWriteGasDissolutionFactor { + static constexpr bool value = false; +}; +struct VtkWriteOilVaporizationFactor { + static constexpr bool value = false; +}; +struct VtkWriteOilFormationVolumeFactor { + static constexpr bool value = false; +}; +struct VtkWriteGasFormationVolumeFactor { + static constexpr bool value = false; +}; +struct VtkWriteWaterFormationVolumeFactor { + static constexpr bool value = false; +}; +struct VtkWriteOilSaturationPressure { + static constexpr bool value = false; +}; +struct VtkWriteGasSaturationPressure { + static constexpr bool value = false; +}; +struct VtkWriteSaturationRatios { + static constexpr bool value = false; +}; +struct VtkWriteSaturatedOilGasDissolutionFactor { + static constexpr bool value = false; +}; +struct VtkWriteSaturatedGasOilVaporizationFactor { + static constexpr bool value = false; +}; +struct VtkWritePrimaryVarsMeaning { + static constexpr bool value = false; +}; } // namespace Opm::Parameters -namespace Opm { +namespace Opm +{ /*! * \brief Struct holding the parameters for VtkBlackoilOutputModule. */ -struct VtkBlackoilParams -{ +struct VtkBlackoilParams { //! \brief Registers the parameters in parameter system. static void registerParameters(); diff --git a/opm/models/io/vtkblackoilpolymermodule.hpp b/opm/models/io/vtkblackoilpolymermodule.hpp index c877dd3a8f2..c63255f8e2b 100644 --- a/opm/models/io/vtkblackoilpolymermodule.hpp +++ b/opm/models/io/vtkblackoilpolymermodule.hpp @@ -42,14 +42,17 @@ #include #include -namespace Opm::Properties::TTag { +namespace Opm::Properties::TTag +{ // create new type tag for the VTK multi-phase output -struct VtkBlackOilPolymer {}; +struct VtkBlackOilPolymer { +}; } // namespace Opm::Properties::TTag -namespace Opm { +namespace Opm +{ /*! * \ingroup Vtk @@ -143,33 +146,27 @@ class VtkBlackOilPolymerModule : public BaseOutputModule const unsigned globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, /*timeIdx=*/0); if (params_.polymerConcentrationOutput_) { - polymerConcentration_[globalDofIdx] = - scalarValue(intQuants.polymerConcentration()); + polymerConcentration_[globalDofIdx] = scalarValue(intQuants.polymerConcentration()); } if (params_.polymerDeadPoreVolumeOutput_) { - polymerDeadPoreVolume_[globalDofIdx] = - scalarValue(intQuants.polymerDeadPoreVolume()); + polymerDeadPoreVolume_[globalDofIdx] = scalarValue(intQuants.polymerDeadPoreVolume()); } if (params_.polymerRockDensityOutput_) { - polymerRockDensity_[globalDofIdx] = - scalarValue(intQuants.polymerRockDensity()); + polymerRockDensity_[globalDofIdx] = scalarValue(intQuants.polymerRockDensity()); } if (params_.polymerAdsorptionOutput_) { - polymerAdsorption_[globalDofIdx] = - scalarValue(intQuants.polymerAdsorption()); + polymerAdsorption_[globalDofIdx] = scalarValue(intQuants.polymerAdsorption()); } if (params_.polymerViscosityCorrectionOutput_) { - polymerViscosityCorrection_[globalDofIdx] = - scalarValue(intQuants.polymerViscosityCorrection()); + polymerViscosityCorrection_[globalDofIdx] = scalarValue(intQuants.polymerViscosityCorrection()); } if (params_.waterViscosityCorrectionOutput_) { - waterViscosityCorrection_[globalDofIdx] = - scalarValue(intQuants.waterViscosityCorrection()); + waterViscosityCorrection_[globalDofIdx] = scalarValue(intQuants.waterViscosityCorrection()); } } } @@ -186,45 +183,42 @@ class VtkBlackOilPolymerModule : public BaseOutputModule } if (params_.polymerConcentrationOutput_) { - this->commitScalarBuffer_(baseWriter, "polymer concentration", - polymerConcentration_, BufferType::Dof); + this->commitScalarBuffer_(baseWriter, "polymer concentration", polymerConcentration_, BufferType::Dof); } if (params_.polymerDeadPoreVolumeOutput_) { - this->commitScalarBuffer_(baseWriter, "dead pore volume fraction", - polymerDeadPoreVolume_, BufferType::Dof); + this->commitScalarBuffer_( + baseWriter, "dead pore volume fraction", polymerDeadPoreVolume_, BufferType::Dof); } if (params_.polymerRockDensityOutput_) { - this->commitScalarBuffer_(baseWriter, "polymer rock density", - polymerRockDensity_, BufferType::Dof); + this->commitScalarBuffer_(baseWriter, "polymer rock density", polymerRockDensity_, BufferType::Dof); } if (params_.polymerAdsorptionOutput_) { - this->commitScalarBuffer_(baseWriter, "polymer adsorption", - polymerAdsorption_, BufferType::Dof); + this->commitScalarBuffer_(baseWriter, "polymer adsorption", polymerAdsorption_, BufferType::Dof); } if (params_.polymerViscosityCorrectionOutput_) { - this->commitScalarBuffer_(baseWriter, "polymer viscosity correction", - polymerViscosityCorrection_, BufferType::Dof); + this->commitScalarBuffer_( + baseWriter, "polymer viscosity correction", polymerViscosityCorrection_, BufferType::Dof); } if (params_.waterViscosityCorrectionOutput_) { - this->commitScalarBuffer_(baseWriter, "water viscosity correction", - waterViscosityCorrection_, BufferType::Dof); + this->commitScalarBuffer_( + baseWriter, "water viscosity correction", waterViscosityCorrection_, BufferType::Dof); } } } private: - VtkBlackoilPolymerParams params_{}; - ScalarBuffer polymerConcentration_{}; - ScalarBuffer polymerDeadPoreVolume_{}; - ScalarBuffer polymerRockDensity_{}; - ScalarBuffer polymerAdsorption_{}; - ScalarBuffer polymerViscosityCorrection_{}; - ScalarBuffer waterViscosityCorrection_{}; + VtkBlackoilPolymerParams params_ {}; + ScalarBuffer polymerConcentration_ {}; + ScalarBuffer polymerDeadPoreVolume_ {}; + ScalarBuffer polymerRockDensity_ {}; + ScalarBuffer polymerAdsorption_ {}; + ScalarBuffer polymerViscosityCorrection_ {}; + ScalarBuffer waterViscosityCorrection_ {}; }; } // namespace Opm diff --git a/opm/models/io/vtkblackoilpolymerparams.cpp b/opm/models/io/vtkblackoilpolymerparams.cpp index f33830e9752..b89e5f39df6 100644 --- a/opm/models/io/vtkblackoilpolymerparams.cpp +++ b/opm/models/io/vtkblackoilpolymerparams.cpp @@ -26,31 +26,32 @@ #include -namespace Opm { +namespace Opm +{ -void VtkBlackoilPolymerParams::registerParameters() +void +VtkBlackoilPolymerParams::registerParameters() { - Parameters::Register - ("Include the concentration of the polymer component in the water phase " - "in the VTK output files"); - Parameters::Register - ("Include the fraction of the \"dead\" pore volume " - "in the VTK output files"); - Parameters::Register - ("Include the amount of already adsorbed polymer component" - "in the VTK output files"); - Parameters::Register - ("Include the adsorption rate of the polymer component" - "in the VTK output files"); - Parameters::Register - ("Include the viscosity correction of the polymer component " - "in the VTK output files"); - Parameters::Register - ("Include the viscosity correction of the water component " - "due to polymers in the VTK output files"); + Parameters::Register( + "Include the concentration of the polymer component in the water phase " + "in the VTK output files"); + Parameters::Register("Include the fraction of the \"dead\" pore volume " + "in the VTK output files"); + Parameters::Register( + "Include the amount of already adsorbed polymer component" + "in the VTK output files"); + Parameters::Register("Include the adsorption rate of the polymer component" + "in the VTK output files"); + Parameters::Register( + "Include the viscosity correction of the polymer component " + "in the VTK output files"); + Parameters::Register( + "Include the viscosity correction of the water component " + "due to polymers in the VTK output files"); } -void VtkBlackoilPolymerParams::read() +void +VtkBlackoilPolymerParams::read() { polymerConcentrationOutput_ = Parameters::Get(); polymerDeadPoreVolumeOutput_ = Parameters::Get(); diff --git a/opm/models/io/vtkblackoilpolymerparams.hpp b/opm/models/io/vtkblackoilpolymerparams.hpp index df866b29ac1..9a1fe4ad4c4 100644 --- a/opm/models/io/vtkblackoilpolymerparams.hpp +++ b/opm/models/io/vtkblackoilpolymerparams.hpp @@ -27,25 +27,38 @@ #ifndef OPM_VTK_BLACK_OIL_POLYMER_PARAMS_HPP #define OPM_VTK_BLACK_OIL_POLYMER_PARAMS_HPP -namespace Opm::Parameters { +namespace Opm::Parameters +{ // set default values for what quantities to output -struct VtkWritePolymerConcentration { static constexpr bool value = true; }; -struct VtkWritePolymerDeadPoreVolume { static constexpr bool value = true; }; -struct VtkWritePolymerViscosityCorrection { static constexpr bool value = true; }; -struct VtkWriteWaterViscosityCorrection { static constexpr bool value = true; }; -struct VtkWritePolymerRockDensity { static constexpr bool value = true; }; -struct VtkWritePolymerAdsorption { static constexpr bool value = true; }; +struct VtkWritePolymerConcentration { + static constexpr bool value = true; +}; +struct VtkWritePolymerDeadPoreVolume { + static constexpr bool value = true; +}; +struct VtkWritePolymerViscosityCorrection { + static constexpr bool value = true; +}; +struct VtkWriteWaterViscosityCorrection { + static constexpr bool value = true; +}; +struct VtkWritePolymerRockDensity { + static constexpr bool value = true; +}; +struct VtkWritePolymerAdsorption { + static constexpr bool value = true; +}; } // namespace Opm::Parameters -namespace Opm { +namespace Opm +{ /*! * \brief Struct holding the parameters for VtkBlackoilPolymerModule. */ -struct VtkBlackoilPolymerParams -{ +struct VtkBlackoilPolymerParams { //! \brief Registers the parameters in parameter system. static void registerParameters(); diff --git a/opm/models/io/vtkblackoilsolventmodule.hpp b/opm/models/io/vtkblackoilsolventmodule.hpp index b28261a0603..4a6c787b018 100644 --- a/opm/models/io/vtkblackoilsolventmodule.hpp +++ b/opm/models/io/vtkblackoilsolventmodule.hpp @@ -42,7 +42,8 @@ #include #include -namespace Opm { +namespace Opm +{ /*! * \ingroup Vtk @@ -134,28 +135,23 @@ class VtkBlackOilSolventModule : public BaseOutputModule const unsigned globalDofIdx = elemCtx.globalSpaceIndex(dofIdx, /*timeIdx=*/0); if (params_.solventSaturationOutput_) { - solventSaturation_[globalDofIdx] = - Toolbox::scalarValue(intQuants.solventSaturation()); + solventSaturation_[globalDofIdx] = Toolbox::scalarValue(intQuants.solventSaturation()); } if (params_.solventRswOutput_) { - solventRsw_[globalDofIdx] = - Toolbox::scalarValue(intQuants.rsSolw()); + solventRsw_[globalDofIdx] = Toolbox::scalarValue(intQuants.rsSolw()); } if (params_.solventDensityOutput_) { - solventDensity_[globalDofIdx] = - Toolbox::scalarValue(intQuants.solventDensity()); + solventDensity_[globalDofIdx] = Toolbox::scalarValue(intQuants.solventDensity()); } if (params_.solventViscosityOutput_) { - solventViscosity_[globalDofIdx] = - Toolbox::scalarValue(intQuants.solventViscosity()); + solventViscosity_[globalDofIdx] = Toolbox::scalarValue(intQuants.solventViscosity()); } if (params_.solventMobilityOutput_) { - solventMobility_[globalDofIdx] = - Toolbox::scalarValue(intQuants.solventMobility()); + solventMobility_[globalDofIdx] = Toolbox::scalarValue(intQuants.solventMobility()); } } } @@ -172,39 +168,34 @@ class VtkBlackOilSolventModule : public BaseOutputModule } if (params_.solventSaturationOutput_) { - this->commitScalarBuffer_(baseWriter, "saturation_solvent", - solventSaturation_, BufferType::Dof); + this->commitScalarBuffer_(baseWriter, "saturation_solvent", solventSaturation_, BufferType::Dof); } if (params_.solventRswOutput_) { - this->commitScalarBuffer_(baseWriter, "dissolved_solvent", - solventRsw_, BufferType::Dof); + this->commitScalarBuffer_(baseWriter, "dissolved_solvent", solventRsw_, BufferType::Dof); } if (params_.solventDensityOutput_) { - this->commitScalarBuffer_(baseWriter, "density_solvent", - solventDensity_, BufferType::Dof); + this->commitScalarBuffer_(baseWriter, "density_solvent", solventDensity_, BufferType::Dof); } if (params_.solventViscosityOutput_) { - this->commitScalarBuffer_(baseWriter, "viscosity_solvent", - solventViscosity_, BufferType::Dof); + this->commitScalarBuffer_(baseWriter, "viscosity_solvent", solventViscosity_, BufferType::Dof); } if (params_.solventMobilityOutput_) { - this->commitScalarBuffer_(baseWriter, "mobility_solvent", - solventMobility_, BufferType::Dof); + this->commitScalarBuffer_(baseWriter, "mobility_solvent", solventMobility_, BufferType::Dof); } } } private: - VtkBlackOilSolventParams params_{}; - ScalarBuffer solventSaturation_{}; - ScalarBuffer solventRsw_{}; - ScalarBuffer solventDensity_{}; - ScalarBuffer solventViscosity_{}; - ScalarBuffer solventMobility_{}; + VtkBlackOilSolventParams params_ {}; + ScalarBuffer solventSaturation_ {}; + ScalarBuffer solventRsw_ {}; + ScalarBuffer solventDensity_ {}; + ScalarBuffer solventViscosity_ {}; + ScalarBuffer solventMobility_ {}; }; } // namespace Opm diff --git a/opm/models/io/vtkblackoilsolventparams.cpp b/opm/models/io/vtkblackoilsolventparams.cpp index a3ef8cd822c..91119d36636 100644 --- a/opm/models/io/vtkblackoilsolventparams.cpp +++ b/opm/models/io/vtkblackoilsolventparams.cpp @@ -26,28 +26,27 @@ #include -namespace Opm { +namespace Opm +{ -void VtkBlackOilSolventParams::registerParameters() +void +VtkBlackOilSolventParams::registerParameters() { - Parameters::Register - ("Include the \"saturation\" of the solvent component " - "in the VTK output files"); - Parameters::Register - ("Include the \"dissolved volume in water\" of the solvent component " - "in the VTK output files"); - Parameters::Register - ("Include the \"density\" of the solvent component " - "in the VTK output files"); - Parameters::Register - ("Include the \"viscosity\" of the solvent component " - "in the VTK output files"); - Parameters::Register - ("Include the \"mobility\" of the solvent component " - "in the VTK output files"); + Parameters::Register("Include the \"saturation\" of the solvent component " + "in the VTK output files"); + Parameters::Register( + "Include the \"dissolved volume in water\" of the solvent component " + "in the VTK output files"); + Parameters::Register("Include the \"density\" of the solvent component " + "in the VTK output files"); + Parameters::Register("Include the \"viscosity\" of the solvent component " + "in the VTK output files"); + Parameters::Register("Include the \"mobility\" of the solvent component " + "in the VTK output files"); } -void VtkBlackOilSolventParams::read() +void +VtkBlackOilSolventParams::read() { solventSaturationOutput_ = Parameters::Get(); solventRswOutput_ = Parameters::Get(); diff --git a/opm/models/io/vtkblackoilsolventparams.hpp b/opm/models/io/vtkblackoilsolventparams.hpp index 7637e546c31..ab778e837c4 100644 --- a/opm/models/io/vtkblackoilsolventparams.hpp +++ b/opm/models/io/vtkblackoilsolventparams.hpp @@ -27,24 +27,35 @@ #ifndef OPM_VTK_BLACK_OIL_SOLVENT_PARAMS_HPP #define OPM_VTK_BLACK_OIL_SOLVENT_PARAMS_HPP -namespace Opm::Parameters { +namespace Opm::Parameters +{ // set default values for what quantities to output -struct VtkWriteSolventSaturation { static constexpr bool value = true; }; -struct VtkWriteSolventRsw { static constexpr bool value = true; }; -struct VtkWriteSolventDensity { static constexpr bool value = true; }; -struct VtkWriteSolventViscosity { static constexpr bool value = true; }; -struct VtkWriteSolventMobility { static constexpr bool value = true; }; +struct VtkWriteSolventSaturation { + static constexpr bool value = true; +}; +struct VtkWriteSolventRsw { + static constexpr bool value = true; +}; +struct VtkWriteSolventDensity { + static constexpr bool value = true; +}; +struct VtkWriteSolventViscosity { + static constexpr bool value = true; +}; +struct VtkWriteSolventMobility { + static constexpr bool value = true; +}; } // namespace Opm::Parameters -namespace Opm { +namespace Opm +{ /*! * \brief Struct holding the parameters for VtkBlackoilPolymerModule. */ -struct VtkBlackOilSolventParams -{ +struct VtkBlackOilSolventParams { //! \brief Registers the parameters in parameter system. static void registerParameters(); diff --git a/opm/models/io/vtkcompositionmodule.hpp b/opm/models/io/vtkcompositionmodule.hpp index 502c4304d08..ba1117051d4 100644 --- a/opm/models/io/vtkcompositionmodule.hpp +++ b/opm/models/io/vtkcompositionmodule.hpp @@ -38,7 +38,8 @@ #include #include -namespace Opm { +namespace Opm +{ /*! * \ingroup Vtk @@ -149,8 +150,8 @@ class VtkCompositionModule : public BaseOutputModule } if (params_.fugacityCoeffOutput_) { - fugacityCoeff_[phaseIdx][compIdx][I] = - Toolbox::value(fs.fugacityCoefficient(phaseIdx, compIdx)); + fugacityCoeff_[phaseIdx][compIdx][I] + = Toolbox::value(fs.fugacityCoefficient(phaseIdx, compIdx)); } } } @@ -161,10 +162,8 @@ class VtkCompositionModule : public BaseOutputModule Scalar totalMass = 0; for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { totalMass += Toolbox::value(fs.density(phaseIdx)) * Toolbox::value(fs.saturation(phaseIdx)); - compMass += - Toolbox::value(fs.density(phaseIdx)) * - Toolbox::value(fs.saturation(phaseIdx)) * - Toolbox::value(fs.massFraction(phaseIdx, compIdx)); + compMass += Toolbox::value(fs.density(phaseIdx)) * Toolbox::value(fs.saturation(phaseIdx)) + * Toolbox::value(fs.massFraction(phaseIdx, compIdx)); } totalMassFrac_[compIdx][I] = compMass / totalMass; } @@ -172,13 +171,10 @@ class VtkCompositionModule : public BaseOutputModule Scalar compMoles = 0; Scalar totalMoles = 0; for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { - totalMoles += - Toolbox::value(fs.molarDensity(phaseIdx)) * - Toolbox::value(fs.saturation(phaseIdx)); - compMoles += - Toolbox::value(fs.molarDensity(phaseIdx)) * - Toolbox::value(fs.saturation(phaseIdx)) * - Toolbox::value(fs.moleFraction(phaseIdx, compIdx)); + totalMoles + += Toolbox::value(fs.molarDensity(phaseIdx)) * Toolbox::value(fs.saturation(phaseIdx)); + compMoles += Toolbox::value(fs.molarDensity(phaseIdx)) * Toolbox::value(fs.saturation(phaseIdx)) + * Toolbox::value(fs.moleFraction(phaseIdx, compIdx)); } totalMoleFrac_[compIdx][I] = compMoles / totalMoles; } @@ -199,46 +195,39 @@ class VtkCompositionModule : public BaseOutputModule } if (params_.moleFracOutput_) { - this->commitPhaseComponentBuffer_(baseWriter, "moleFrac_%s^%s", - moleFrac_, BufferType::Dof); + this->commitPhaseComponentBuffer_(baseWriter, "moleFrac_%s^%s", moleFrac_, BufferType::Dof); } if (params_.massFracOutput_) { - this->commitPhaseComponentBuffer_(baseWriter, "massFrac_%s^%s", - massFrac_, BufferType::Dof); + this->commitPhaseComponentBuffer_(baseWriter, "massFrac_%s^%s", massFrac_, BufferType::Dof); } if (params_.molarityOutput_) { - this->commitPhaseComponentBuffer_(baseWriter, "molarity_%s^%s", - molarity_, BufferType::Dof); + this->commitPhaseComponentBuffer_(baseWriter, "molarity_%s^%s", molarity_, BufferType::Dof); } if (params_.totalMassFracOutput_) { - this->commitComponentBuffer_(baseWriter, "totalMassFrac^%s", - totalMassFrac_, BufferType::Dof); + this->commitComponentBuffer_(baseWriter, "totalMassFrac^%s", totalMassFrac_, BufferType::Dof); } if (params_.totalMoleFracOutput_) { - this->commitComponentBuffer_(baseWriter, "totalMoleFrac^%s", - totalMoleFrac_, BufferType::Dof); + this->commitComponentBuffer_(baseWriter, "totalMoleFrac^%s", totalMoleFrac_, BufferType::Dof); } if (params_.fugacityOutput_) { - this->commitComponentBuffer_(baseWriter, "fugacity^%s", - fugacity_, BufferType::Dof); + this->commitComponentBuffer_(baseWriter, "fugacity^%s", fugacity_, BufferType::Dof); } if (params_.fugacityCoeffOutput_) { - this->commitPhaseComponentBuffer_(baseWriter, "fugacityCoeff_%s^%s", - fugacityCoeff_, BufferType::Dof); + this->commitPhaseComponentBuffer_(baseWriter, "fugacityCoeff_%s^%s", fugacityCoeff_, BufferType::Dof); } } private: - VtkCompositionParams params_{}; - PhaseComponentBuffer moleFrac_{}; - PhaseComponentBuffer massFrac_{}; - PhaseComponentBuffer molarity_{}; - ComponentBuffer totalMassFrac_{}; - ComponentBuffer totalMoleFrac_{}; - - ComponentBuffer fugacity_{}; - PhaseComponentBuffer fugacityCoeff_{}; + VtkCompositionParams params_ {}; + PhaseComponentBuffer moleFrac_ {}; + PhaseComponentBuffer massFrac_ {}; + PhaseComponentBuffer molarity_ {}; + ComponentBuffer totalMassFrac_ {}; + ComponentBuffer totalMoleFrac_ {}; + + ComponentBuffer fugacity_ {}; + PhaseComponentBuffer fugacityCoeff_ {}; }; } // namespace Opm diff --git a/opm/models/io/vtkcompositionparams.cpp b/opm/models/io/vtkcompositionparams.cpp index 0da6dc51f25..e6e115a59f7 100644 --- a/opm/models/io/vtkcompositionparams.cpp +++ b/opm/models/io/vtkcompositionparams.cpp @@ -26,27 +26,26 @@ #include -namespace Opm { +namespace Opm +{ -void VtkCompositionParams::registerParameters() +void +VtkCompositionParams::registerParameters() { - Parameters::Register - ("Include mass fractions in the VTK output files"); - Parameters::Register - ("Include mole fractions in the VTK output files"); - Parameters::Register - ("Include total mass fractions in the VTK output files"); - Parameters::Register - ("Include total mole fractions in the VTK output files"); - Parameters::Register - ("Include component molarities in the VTK output files"); - Parameters::Register - ("Include component fugacities in the VTK output files"); - Parameters::Register - ("Include component fugacity coefficients in the VTK output files"); + Parameters::Register("Include mass fractions in the VTK output files"); + Parameters::Register("Include mole fractions in the VTK output files"); + Parameters::Register( + "Include total mass fractions in the VTK output files"); + Parameters::Register( + "Include total mole fractions in the VTK output files"); + Parameters::Register("Include component molarities in the VTK output files"); + Parameters::Register("Include component fugacities in the VTK output files"); + Parameters::Register( + "Include component fugacity coefficients in the VTK output files"); } -void VtkCompositionParams::read() +void +VtkCompositionParams::read() { massFracOutput_ = Parameters::Get(); moleFracOutput_ = Parameters::Get(); diff --git a/opm/models/io/vtkcompositionparams.hpp b/opm/models/io/vtkcompositionparams.hpp index c16b23fdb68..83e4587446e 100644 --- a/opm/models/io/vtkcompositionparams.hpp +++ b/opm/models/io/vtkcompositionparams.hpp @@ -27,26 +27,41 @@ #ifndef OPM_VTK_COMPOSITION_PARAMS_HPP #define OPM_VTK_COMPOSITION_PARAMS_HPP -namespace Opm::Parameters { +namespace Opm::Parameters +{ // set default values for what quantities to output -struct VtkWriteMassFractions { static constexpr bool value = false; }; -struct VtkWriteMoleFractions { static constexpr bool value = true; }; -struct VtkWriteTotalMassFractions { static constexpr bool value = false; }; -struct VtkWriteTotalMoleFractions { static constexpr bool value = false; }; -struct VtkWriteMolarities { static constexpr bool value = false; }; -struct VtkWriteFugacities { static constexpr bool value = false; }; -struct VtkWriteFugacityCoeffs { static constexpr bool value = false; }; +struct VtkWriteMassFractions { + static constexpr bool value = false; +}; +struct VtkWriteMoleFractions { + static constexpr bool value = true; +}; +struct VtkWriteTotalMassFractions { + static constexpr bool value = false; +}; +struct VtkWriteTotalMoleFractions { + static constexpr bool value = false; +}; +struct VtkWriteMolarities { + static constexpr bool value = false; +}; +struct VtkWriteFugacities { + static constexpr bool value = false; +}; +struct VtkWriteFugacityCoeffs { + static constexpr bool value = false; +}; -} // namespace Opm::Properties +} // namespace Opm::Parameters -namespace Opm { +namespace Opm +{ /*! * \brief Struct holding the parameters for VtkCompositionModule. */ -struct VtkCompositionParams -{ +struct VtkCompositionParams { //! \brief Registers the parameters in parameter system. static void registerParameters(); diff --git a/opm/models/io/vtkdiffusionmodule.hpp b/opm/models/io/vtkdiffusionmodule.hpp index 7ba034761b5..0c0937d40f8 100644 --- a/opm/models/io/vtkdiffusionmodule.hpp +++ b/opm/models/io/vtkdiffusionmodule.hpp @@ -37,10 +37,11 @@ #include #include -#include #include +#include -namespace Opm { +namespace Opm +{ /*! * \ingroup Vtk @@ -127,12 +128,12 @@ class VtkDiffusionModule : public BaseOutputModule } for (unsigned compIdx = 0; compIdx < numComponents; ++compIdx) { if (params_.diffusionCoefficientOutput_) { - diffusionCoefficient_[phaseIdx][compIdx][I] = - Toolbox::value(intQuants.diffusionCoefficient(phaseIdx, compIdx)); + diffusionCoefficient_[phaseIdx][compIdx][I] + = Toolbox::value(intQuants.diffusionCoefficient(phaseIdx, compIdx)); } if (params_.effectiveDiffusionCoefficientOutput_) { - effectiveDiffusionCoefficient_[phaseIdx][compIdx][I] = - Toolbox::value(intQuants.effectiveDiffusionCoefficient(phaseIdx, compIdx)); + effectiveDiffusionCoefficient_[phaseIdx][compIdx][I] + = Toolbox::value(intQuants.effectiveDiffusionCoefficient(phaseIdx, compIdx)); } } } @@ -152,22 +153,20 @@ class VtkDiffusionModule : public BaseOutputModule this->commitPhaseBuffer_(baseWriter, "tortuosity", tortuosity_, BufferType::Dof); } if (params_.diffusionCoefficientOutput_) { - this->commitPhaseComponentBuffer_(baseWriter, "diffusionCoefficient", - diffusionCoefficient_, BufferType::Dof); + this->commitPhaseComponentBuffer_( + baseWriter, "diffusionCoefficient", diffusionCoefficient_, BufferType::Dof); } if (params_.effectiveDiffusionCoefficientOutput_) { - this->commitPhaseComponentBuffer_(baseWriter, - "effectiveDiffusionCoefficient", - effectiveDiffusionCoefficient_, - BufferType::Dof); + this->commitPhaseComponentBuffer_( + baseWriter, "effectiveDiffusionCoefficient", effectiveDiffusionCoefficient_, BufferType::Dof); } } private: - VtkDiffusionParams params_{}; - PhaseBuffer tortuosity_{}; - PhaseComponentBuffer diffusionCoefficient_{}; - PhaseComponentBuffer effectiveDiffusionCoefficient_{}; + VtkDiffusionParams params_ {}; + PhaseBuffer tortuosity_ {}; + PhaseComponentBuffer diffusionCoefficient_ {}; + PhaseComponentBuffer effectiveDiffusionCoefficient_ {}; }; } // namespace Opm diff --git a/opm/models/io/vtkdiffusionparams.cpp b/opm/models/io/vtkdiffusionparams.cpp index da78bc43107..cea1ec9f11d 100644 --- a/opm/models/io/vtkdiffusionparams.cpp +++ b/opm/models/io/vtkdiffusionparams.cpp @@ -26,21 +26,23 @@ #include -namespace Opm { +namespace Opm +{ -void VtkDiffusionParams::registerParameters() +void +VtkDiffusionParams::registerParameters() { - Parameters::Register - ("Include the tortuosity for each phase in the VTK output files"); - Parameters::Register - ("Include the molecular diffusion coefficients in " - "the VTK output files"); - Parameters::Register - ("Include the effective molecular diffusion " - "coefficients the medium in the VTK output files"); + Parameters::Register( + "Include the tortuosity for each phase in the VTK output files"); + Parameters::Register("Include the molecular diffusion coefficients in " + "the VTK output files"); + Parameters::Register( + "Include the effective molecular diffusion " + "coefficients the medium in the VTK output files"); } -void VtkDiffusionParams::read() +void +VtkDiffusionParams::read() { tortuosityOutput_ = Parameters::Get(); diffusionCoefficientOutput_ = Parameters::Get(); diff --git a/opm/models/io/vtkdiffusionparams.hpp b/opm/models/io/vtkdiffusionparams.hpp index 4347321a276..6f35b6b33d7 100644 --- a/opm/models/io/vtkdiffusionparams.hpp +++ b/opm/models/io/vtkdiffusionparams.hpp @@ -28,22 +28,29 @@ #ifndef OPM_VTK_DIFFUSION_PARAMS_HPP #define OPM_VTK_DIFFUSION_PARAMS_HPP -namespace Opm::Parameters { +namespace Opm::Parameters +{ // set default values for what quantities to output -struct VtkWriteTortuosities { static constexpr bool value = false; }; -struct VtkWriteDiffusionCoefficients { static constexpr bool value = false; }; -struct VtkWriteEffectiveDiffusionCoefficients { static constexpr bool value = false; }; +struct VtkWriteTortuosities { + static constexpr bool value = false; +}; +struct VtkWriteDiffusionCoefficients { + static constexpr bool value = false; +}; +struct VtkWriteEffectiveDiffusionCoefficients { + static constexpr bool value = false; +}; } // namespace Opm::Parameters -namespace Opm { +namespace Opm +{ /*! * \brief Struct holding the parameters for VtkDiffusionModule. */ -struct VtkDiffusionParams -{ +struct VtkDiffusionParams { //! \brief Registers the parameters in parameter system. static void registerParameters(); diff --git a/opm/models/io/vtkdiscretefracturemodule.hpp b/opm/models/io/vtkdiscretefracturemodule.hpp index bd70f4fee71..75ae83bed01 100644 --- a/opm/models/io/vtkdiscretefracturemodule.hpp +++ b/opm/models/io/vtkdiscretefracturemodule.hpp @@ -37,16 +37,17 @@ #include #include -#include #include +#include #include #include #include -#include #include +#include -namespace Opm { +namespace Opm +{ /*! * \ingroup Vtk @@ -183,8 +184,7 @@ class VtkDiscreteFractureModule : public BaseOutputModule } if (params_.relativePermeabilityOutput_) { Valgrind::CheckDefined(intQuants.fractureRelativePermeability(phaseIdx)); - fractureRelativePermeability_[phaseIdx][I] = - intQuants.fractureRelativePermeability(phaseIdx); + fractureRelativePermeability_[phaseIdx][I] = intQuants.fractureRelativePermeability(phaseIdx); } if (params_.volumeFractionOutput_) { Valgrind::CheckDefined(intQuants.fractureVolume()); @@ -209,8 +209,7 @@ class VtkDiscreteFractureModule : public BaseOutputModule } for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { - Scalar weight = std::max(Scalar{1e-16}, - std::abs(extQuants.fractureVolumeFlux(phaseIdx))); + Scalar weight = std::max(Scalar {1e-16}, std::abs(extQuants.fractureVolumeFlux(phaseIdx))); Valgrind::CheckDefined(extQuants.extrusionFactor()); assert(extQuants.extrusionFactor() > 0); weight *= extQuants.extrusionFactor(); @@ -240,33 +239,29 @@ class VtkDiscreteFractureModule : public BaseOutputModule } if (params_.saturationOutput_) { - this->commitPhaseBuffer_(baseWriter, "fractureSaturation_%s", - fractureSaturation_, BufferType::Dof); + this->commitPhaseBuffer_(baseWriter, "fractureSaturation_%s", fractureSaturation_, BufferType::Dof); } if (params_.mobilityOutput_) { - this->commitPhaseBuffer_(baseWriter, "fractureMobility_%s", - fractureMobility_, BufferType::Dof); + this->commitPhaseBuffer_(baseWriter, "fractureMobility_%s", fractureMobility_, BufferType::Dof); } if (params_.relativePermeabilityOutput_) { - this->commitPhaseBuffer_(baseWriter, "fractureRelativePerm_%s", - fractureRelativePermeability_, BufferType::Dof); + this->commitPhaseBuffer_( + baseWriter, "fractureRelativePerm_%s", fractureRelativePermeability_, BufferType::Dof); } if (params_.porosityOutput_) { - this->commitScalarBuffer_(baseWriter, "fracturePorosity", - fracturePorosity_, BufferType::Dof); + this->commitScalarBuffer_(baseWriter, "fracturePorosity", fracturePorosity_, BufferType::Dof); } if (params_.intrinsicPermeabilityOutput_) { - this->commitScalarBuffer_(baseWriter, "fractureIntrinsicPerm", - fractureIntrinsicPermeability_, BufferType::Dof); + this->commitScalarBuffer_( + baseWriter, "fractureIntrinsicPerm", fractureIntrinsicPermeability_, BufferType::Dof); } if (params_.volumeFractionOutput_) { // divide the fracture volume by the total volume of the finite volumes for (unsigned I = 0; I < fractureVolumeFraction_.size(); ++I) { fractureVolumeFraction_[I] /= this->simulator_.model().dofTotalVolume(I); } - this->commitScalarBuffer_(baseWriter, "fractureVolumeFraction", - fractureVolumeFraction_, BufferType::Dof); + this->commitScalarBuffer_(baseWriter, "fractureVolumeFraction", fractureVolumeFraction_, BufferType::Dof); } if (params_.velocityOutput_) { @@ -275,8 +270,8 @@ class VtkDiscreteFractureModule : public BaseOutputModule // first, divide the velocity field by the // respective finite volume's surface area for (unsigned dofIdx = 0; dofIdx < nDof; ++dofIdx) { - fractureVelocity_[phaseIdx][dofIdx] /= - std::max(1e-20, fractureVelocityWeight_[phaseIdx][dofIdx]); + fractureVelocity_[phaseIdx][dofIdx] + /= std::max(1e-20, fractureVelocityWeight_[phaseIdx][dofIdx]); } // commit the phase velocity char name[512]; @@ -288,20 +283,20 @@ class VtkDiscreteFractureModule : public BaseOutputModule } private: - VtkDiscreteFractureParams params_{}; - PhaseBuffer fractureSaturation_{}; - PhaseBuffer fractureMobility_{}; - PhaseBuffer fractureRelativePermeability_{}; + VtkDiscreteFractureParams params_ {}; + PhaseBuffer fractureSaturation_ {}; + PhaseBuffer fractureMobility_ {}; + PhaseBuffer fractureRelativePermeability_ {}; - ScalarBuffer fracturePorosity_{}; - ScalarBuffer fractureVolumeFraction_{}; - ScalarBuffer fractureIntrinsicPermeability_{}; + ScalarBuffer fracturePorosity_ {}; + ScalarBuffer fractureVolumeFraction_ {}; + ScalarBuffer fractureIntrinsicPermeability_ {}; - PhaseVectorBuffer fractureVelocity_{}; - PhaseBuffer fractureVelocityWeight_{}; + PhaseVectorBuffer fractureVelocity_ {}; + PhaseBuffer fractureVelocityWeight_ {}; - PhaseVectorBuffer potentialGradient_{}; - PhaseBuffer potentialWeight_{}; + PhaseVectorBuffer potentialGradient_ {}; + PhaseBuffer potentialWeight_ {}; }; } // namespace Opm diff --git a/opm/models/io/vtkdiscretefractureparams.cpp b/opm/models/io/vtkdiscretefractureparams.cpp index 9f1c075ec89..49b9eefc277 100644 --- a/opm/models/io/vtkdiscretefractureparams.cpp +++ b/opm/models/io/vtkdiscretefractureparams.cpp @@ -26,29 +26,30 @@ #include -namespace Opm { +namespace Opm +{ -void VtkDiscreteFractureParams::registerParameters() +void +VtkDiscreteFractureParams::registerParameters() { - Parameters::Register - ("Include the phase saturations in the VTK output files"); - Parameters::Register - ("Include the phase mobilities in the VTK output files"); - Parameters::Register - ("Include the phase relative permeabilities in the " - "VTK output files"); - Parameters::Register - ("Include the porosity in the VTK output files"); - Parameters::Register - ("Include the intrinsic permeability in the VTK output files"); - Parameters::Register - ("Include in the filter velocities of the phases in the VTK output files"); - Parameters::Register - ("Add the fraction of the total volume which is " - "occupied by fractures in the VTK output"); + Parameters::Register( + "Include the phase saturations in the VTK output files"); + Parameters::Register( + "Include the phase mobilities in the VTK output files"); + Parameters::Register( + "Include the phase relative permeabilities in the " + "VTK output files"); + Parameters::Register("Include the porosity in the VTK output files"); + Parameters::Register( + "Include the intrinsic permeability in the VTK output files"); + Parameters::Register( + "Include in the filter velocities of the phases in the VTK output files"); + Parameters::Register("Add the fraction of the total volume which is " + "occupied by fractures in the VTK output"); } -void VtkDiscreteFractureParams::read() +void +VtkDiscreteFractureParams::read() { saturationOutput_ = Parameters::Get(); mobilityOutput_ = Parameters::Get(); diff --git a/opm/models/io/vtkdiscretefractureparams.hpp b/opm/models/io/vtkdiscretefractureparams.hpp index 7afdedff7bb..c31b6fdcb16 100644 --- a/opm/models/io/vtkdiscretefractureparams.hpp +++ b/opm/models/io/vtkdiscretefractureparams.hpp @@ -27,26 +27,41 @@ #ifndef OPM_VTK_DISCRETE_FRACTURE_PARAMS_HPP #define OPM_VTK_DISCRETE_FRACTURE_PARAMS_HPP -namespace Opm::Parameters { +namespace Opm::Parameters +{ // set default values for what quantities to output -struct VtkWriteFractureSaturations { static constexpr bool value = true; }; -struct VtkWriteFractureMobilities { static constexpr bool value = false; }; -struct VtkWriteFractureRelativePermeabilities { static constexpr bool value = true; }; -struct VtkWriteFracturePorosity { static constexpr bool value = true; }; -struct VtkWriteFractureIntrinsicPermeabilities { static constexpr bool value = false; }; -struct VtkWriteFractureFilterVelocities { static constexpr bool value = false; }; -struct VtkWriteFractureVolumeFraction { static constexpr bool value = true; }; +struct VtkWriteFractureSaturations { + static constexpr bool value = true; +}; +struct VtkWriteFractureMobilities { + static constexpr bool value = false; +}; +struct VtkWriteFractureRelativePermeabilities { + static constexpr bool value = true; +}; +struct VtkWriteFracturePorosity { + static constexpr bool value = true; +}; +struct VtkWriteFractureIntrinsicPermeabilities { + static constexpr bool value = false; +}; +struct VtkWriteFractureFilterVelocities { + static constexpr bool value = false; +}; +struct VtkWriteFractureVolumeFraction { + static constexpr bool value = true; +}; } // namespace Opm::Parameters -namespace Opm { +namespace Opm +{ /*! * \brief Struct holding the parameters for VtkDiscreteFractureModule. */ -struct VtkDiscreteFractureParams -{ +struct VtkDiscreteFractureParams { //! \brief Registers the parameters in parameter system. static void registerParameters(); diff --git a/opm/models/io/vtkenergymodule.hpp b/opm/models/io/vtkenergymodule.hpp index 39c22bfad69..f170af5ff21 100644 --- a/opm/models/io/vtkenergymodule.hpp +++ b/opm/models/io/vtkenergymodule.hpp @@ -38,7 +38,8 @@ #include #include -namespace Opm { +namespace Opm +{ /*! * \ingroup Vtk @@ -153,31 +154,27 @@ class VtkEnergyModule : public BaseOutputModule } if (params_.solidInternalEnergyOutput_) { - this->commitScalarBuffer_(baseWriter, "internalEnergySolid", - solidInternalEnergy_, BufferType::Dof); + this->commitScalarBuffer_(baseWriter, "internalEnergySolid", solidInternalEnergy_, BufferType::Dof); } if (params_.thermalConductivityOutput_) { - this->commitScalarBuffer_(baseWriter, "thermalConductivity", - thermalConductivity_, BufferType::Dof); + this->commitScalarBuffer_(baseWriter, "thermalConductivity", thermalConductivity_, BufferType::Dof); } if (params_.enthalpyOutput_) { - this->commitPhaseBuffer_(baseWriter, "enthalpy_%s", - enthalpy_, BufferType::Dof); + this->commitPhaseBuffer_(baseWriter, "enthalpy_%s", enthalpy_, BufferType::Dof); } if (params_.internalEnergyOutput_) { - this->commitPhaseBuffer_(baseWriter, "internalEnergy_%s", - internalEnergy_, BufferType::Dof); + this->commitPhaseBuffer_(baseWriter, "internalEnergy_%s", internalEnergy_, BufferType::Dof); } } private: - VtkEnergyParams params_{}; - PhaseBuffer enthalpy_{}; - PhaseBuffer internalEnergy_{}; + VtkEnergyParams params_ {}; + PhaseBuffer enthalpy_ {}; + PhaseBuffer internalEnergy_ {}; - ScalarBuffer thermalConductivity_{}; - ScalarBuffer solidInternalEnergy_{}; + ScalarBuffer thermalConductivity_ {}; + ScalarBuffer solidInternalEnergy_ {}; }; } // namespace Opm diff --git a/opm/models/io/vtkenergyparams.cpp b/opm/models/io/vtkenergyparams.cpp index 4cc297ee185..d7ab2227251 100644 --- a/opm/models/io/vtkenergyparams.cpp +++ b/opm/models/io/vtkenergyparams.cpp @@ -26,25 +26,24 @@ #include -namespace Opm { +namespace Opm +{ -void VtkEnergyParams::registerParameters() +void +VtkEnergyParams::registerParameters() { - Parameters::Register - ("Include the volumetric internal energy of solid" - "matrix in the VTK output files"); - Parameters::Register - ("Include the total thermal conductivity of the" - "medium in the VTK output files"); - Parameters::Register - ("Include the specific enthalpy of the phases in " - "the VTK output files"); - Parameters::Register - ("Include the specific internal energy of the " - "phases in the VTK output files"); + Parameters::Register("Include the volumetric internal energy of solid" + "matrix in the VTK output files"); + Parameters::Register("Include the total thermal conductivity of the" + "medium in the VTK output files"); + Parameters::Register("Include the specific enthalpy of the phases in " + "the VTK output files"); + Parameters::Register("Include the specific internal energy of the " + "phases in the VTK output files"); } -void VtkEnergyParams::read() +void +VtkEnergyParams::read() { solidInternalEnergyOutput_ = Parameters::Get(); thermalConductivityOutput_ = Parameters::Get(); diff --git a/opm/models/io/vtkenergyparams.hpp b/opm/models/io/vtkenergyparams.hpp index 5590fbdf4be..e808c81ec70 100644 --- a/opm/models/io/vtkenergyparams.hpp +++ b/opm/models/io/vtkenergyparams.hpp @@ -27,23 +27,32 @@ #ifndef OPM_VTK_ENERGY_PARAMS_HPP #define OPM_VTK_ENERGY_PARAMS_HPP -namespace Opm::Parameters { +namespace Opm::Parameters +{ // set default values for what quantities to output -struct VtkWriteSolidInternalEnergy { static constexpr bool value = false; }; -struct VtkWriteThermalConductivity { static constexpr bool value = false; }; -struct VtkWriteInternalEnergies { static constexpr bool value = false; }; -struct VtkWriteEnthalpies { static constexpr bool value = false; }; +struct VtkWriteSolidInternalEnergy { + static constexpr bool value = false; +}; +struct VtkWriteThermalConductivity { + static constexpr bool value = false; +}; +struct VtkWriteInternalEnergies { + static constexpr bool value = false; +}; +struct VtkWriteEnthalpies { + static constexpr bool value = false; +}; } // namespace Opm::Parameters -namespace Opm { +namespace Opm +{ /*! * \brief Struct holding the parameters for VtkEnergyModule. */ -struct VtkEnergyParams -{ +struct VtkEnergyParams { //! \brief Registers the parameters in parameter system. static void registerParameters(); diff --git a/opm/models/io/vtkmultiphasemodule.hpp b/opm/models/io/vtkmultiphasemodule.hpp index 533671f37d3..b201e5f9b53 100644 --- a/opm/models/io/vtkmultiphasemodule.hpp +++ b/opm/models/io/vtkmultiphasemodule.hpp @@ -48,7 +48,8 @@ #include #include -namespace Opm { +namespace Opm +{ /*! * \ingroup Vtk @@ -68,7 +69,7 @@ namespace Opm { * - Porosity of the medium * - Norm of the intrinsic permeability of the medium */ -template +template class VtkMultiPhaseModule : public BaseOutputModule { using ParentType = BaseOutputModule; @@ -152,9 +153,9 @@ class VtkMultiPhaseModule : public BaseOutputModule if (params_.velocityOutput_) { const std::size_t nDof = this->simulator_.model().numGridDof(); - for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) { + for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { velocity_[phaseIdx].resize(nDof); - for (unsigned dofIdx = 0; dofIdx < nDof; ++ dofIdx) { + for (unsigned dofIdx = 0; dofIdx < nDof; ++dofIdx) { velocity_[phaseIdx][dofIdx].resize(dimWorld); velocity_[phaseIdx][dofIdx] = 0.0; } @@ -164,9 +165,9 @@ class VtkMultiPhaseModule : public BaseOutputModule if (params_.potentialGradientOutput_) { const std::size_t nDof = this->simulator_.model().numGridDof(); - for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++ phaseIdx) { + for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { potentialGradient_[phaseIdx].resize(nDof); - for (unsigned dofIdx = 0; dofIdx < nDof; ++ dofIdx) { + for (unsigned dofIdx = 0; dofIdx < nDof; ++dofIdx) { potentialGradient_[phaseIdx][dofIdx].resize(dimWorld); potentialGradient_[phaseIdx][dofIdx] = 0.0; } @@ -271,8 +272,7 @@ class VtkMultiPhaseModule : public BaseOutputModule const unsigned J = elemCtx.globalSpaceIndex(j, /*timeIdx=*/0); for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { - Scalar weight = std::max(Scalar{1e-16}, - std::abs(getValue(extQuants.volumeFlux(phaseIdx)))); + Scalar weight = std::max(Scalar {1e-16}, std::abs(getValue(extQuants.volumeFlux(phaseIdx)))); Valgrind::CheckDefined(extQuants.extrusionFactor()); assert(extQuants.extrusionFactor() > 0); weight *= extQuants.extrusionFactor(); @@ -307,8 +307,7 @@ class VtkMultiPhaseModule : public BaseOutputModule } if (params_.extrusionFactorOutput_) { - this->commitScalarBuffer_(baseWriter, "extrusionFactor", - extrusionFactor_, BufferType::Dof); + this->commitScalarBuffer_(baseWriter, "extrusionFactor", extrusionFactor_, BufferType::Dof); } if (params_.pressureOutput_) { this->commitPhaseBuffer_(baseWriter, "pressure_%s", pressure_, BufferType::Dof); @@ -323,23 +322,20 @@ class VtkMultiPhaseModule : public BaseOutputModule this->commitPhaseBuffer_(baseWriter, "mobility_%s", mobility_, BufferType::Dof); } if (params_.relativePermeabilityOutput_) { - this->commitPhaseBuffer_(baseWriter, "relativePerm_%s", - relativePermeability_, BufferType::Dof); + this->commitPhaseBuffer_(baseWriter, "relativePerm_%s", relativePermeability_, BufferType::Dof); } if (params_.viscosityOutput_) { this->commitPhaseBuffer_(baseWriter, "viscosity_%s", viscosity_, BufferType::Dof); } if (params_.averageMolarMassOutput_) { - this->commitPhaseBuffer_(baseWriter, "averageMolarMass_%s", - averageMolarMass_, BufferType::Dof); + this->commitPhaseBuffer_(baseWriter, "averageMolarMass_%s", averageMolarMass_, BufferType::Dof); } if (params_.porosityOutput_) { this->commitScalarBuffer_(baseWriter, "porosity", porosity_, BufferType::Dof); } if (params_.intrinsicPermeabilityOutput_) { - this->commitTensorBuffer_(baseWriter, "intrinsicPerm", - intrinsicPermeability_, BufferType::Dof); + this->commitTensorBuffer_(baseWriter, "intrinsicPerm", intrinsicPermeability_, BufferType::Dof); } if (params_.velocityOutput_) { @@ -370,9 +366,7 @@ class VtkMultiPhaseModule : public BaseOutputModule char name[512]; snprintf(name, 512, "gradP_%s", FluidSystem::phaseName(phaseIdx).data()); - DiscBaseOutputModule::attachVectorDofData_(baseWriter, - potentialGradient_[phaseIdx], - name); + DiscBaseOutputModule::attachVectorDofData_(baseWriter, potentialGradient_[phaseIdx], name); } } } @@ -391,24 +385,24 @@ class VtkMultiPhaseModule : public BaseOutputModule } private: - VtkMultiPhaseParams params_{}; - ScalarBuffer extrusionFactor_{}; - PhaseBuffer pressure_{}; - PhaseBuffer density_{}; - PhaseBuffer saturation_{}; - PhaseBuffer mobility_{}; - PhaseBuffer relativePermeability_{}; - PhaseBuffer viscosity_{}; - PhaseBuffer averageMolarMass_{}; - - ScalarBuffer porosity_{}; - TensorBuffer intrinsicPermeability_{}; - - PhaseVectorBuffer velocity_{}; - PhaseBuffer velocityWeight_{}; - - PhaseVectorBuffer potentialGradient_{}; - PhaseBuffer potentialWeight_{}; + VtkMultiPhaseParams params_ {}; + ScalarBuffer extrusionFactor_ {}; + PhaseBuffer pressure_ {}; + PhaseBuffer density_ {}; + PhaseBuffer saturation_ {}; + PhaseBuffer mobility_ {}; + PhaseBuffer relativePermeability_ {}; + PhaseBuffer viscosity_ {}; + PhaseBuffer averageMolarMass_ {}; + + ScalarBuffer porosity_ {}; + TensorBuffer intrinsicPermeability_ {}; + + PhaseVectorBuffer velocity_ {}; + PhaseBuffer velocityWeight_ {}; + + PhaseVectorBuffer potentialGradient_ {}; + PhaseBuffer potentialWeight_ {}; }; } // namespace Opm diff --git a/opm/models/io/vtkmultiphaseparams.cpp b/opm/models/io/vtkmultiphaseparams.cpp index ed2ae98bce4..17a49ad040e 100644 --- a/opm/models/io/vtkmultiphaseparams.cpp +++ b/opm/models/io/vtkmultiphaseparams.cpp @@ -26,37 +26,35 @@ #include -namespace Opm { +namespace Opm +{ -void VtkMultiPhaseParams::registerParameters() +void +VtkMultiPhaseParams::registerParameters() { - Parameters::Register - ("Include the extrusion factor of the degrees of freedom into the VTK output files"); - Parameters::Register - ("Include the phase pressures in the VTK output files"); - Parameters::Register - ("Include the phase densities in the VTK output files"); - Parameters::Register - ("Include the phase saturations in the VTK output files"); - Parameters::Register - ("Include the phase mobilities in the VTK output files"); - Parameters::Register - ("Include the phase relative permeabilities in the VTK output files"); - Parameters::Register - ("Include component phase viscosities in the VTK output files"); - Parameters::Register - ("Include the average phase mass in the VTK output files"); - Parameters::Register - ("Include the porosity in the VTK output files"); - Parameters::Register - ("Include the intrinsic permeability in the VTK output files"); - Parameters::Register - ("Include in the filter velocities of the phases the VTK output files"); - Parameters::Register - ("Include the phase pressure potential gradients in the VTK output files"); + Parameters::Register( + "Include the extrusion factor of the degrees of freedom into the VTK output files"); + Parameters::Register("Include the phase pressures in the VTK output files"); + Parameters::Register("Include the phase densities in the VTK output files"); + Parameters::Register("Include the phase saturations in the VTK output files"); + Parameters::Register("Include the phase mobilities in the VTK output files"); + Parameters::Register( + "Include the phase relative permeabilities in the VTK output files"); + Parameters::Register( + "Include component phase viscosities in the VTK output files"); + Parameters::Register( + "Include the average phase mass in the VTK output files"); + Parameters::Register("Include the porosity in the VTK output files"); + Parameters::Register( + "Include the intrinsic permeability in the VTK output files"); + Parameters::Register( + "Include in the filter velocities of the phases the VTK output files"); + Parameters::Register( + "Include the phase pressure potential gradients in the VTK output files"); } -void VtkMultiPhaseParams::read() +void +VtkMultiPhaseParams::read() { extrusionFactorOutput_ = Parameters::Get(); pressureOutput_ = Parameters::Get(); diff --git a/opm/models/io/vtkmultiphaseparams.hpp b/opm/models/io/vtkmultiphaseparams.hpp index d9089e73e2d..5d9fa23021d 100644 --- a/opm/models/io/vtkmultiphaseparams.hpp +++ b/opm/models/io/vtkmultiphaseparams.hpp @@ -27,31 +27,56 @@ #ifndef OPM_VTK_MULTI_PHASE_PARAMS_HPP #define OPM_VTK_MULTI_PHASE_PARAMS_HPP -namespace Opm::Parameters { +namespace Opm::Parameters +{ // set default values for what quantities to output -struct VtkWriteExtrusionFactor { static constexpr bool value = false; }; -struct VtkWritePressures { static constexpr bool value = true; }; -struct VtkWriteDensities { static constexpr bool value = true; }; -struct VtkWriteSaturations { static constexpr bool value = true; }; -struct VtkWriteMobilities { static constexpr bool value = false; }; -struct VtkWriteRelativePermeabilities { static constexpr bool value = true; }; -struct VtkWriteViscosities { static constexpr bool value = false; }; -struct VtkWriteAverageMolarMasses { static constexpr bool value = false; }; -struct VtkWritePorosity { static constexpr bool value = true; }; -struct VtkWriteIntrinsicPermeabilities { static constexpr bool value = false; }; -struct VtkWritePotentialGradients { static constexpr bool value = false; }; -struct VtkWriteFilterVelocities { static constexpr bool value = false; }; +struct VtkWriteExtrusionFactor { + static constexpr bool value = false; +}; +struct VtkWritePressures { + static constexpr bool value = true; +}; +struct VtkWriteDensities { + static constexpr bool value = true; +}; +struct VtkWriteSaturations { + static constexpr bool value = true; +}; +struct VtkWriteMobilities { + static constexpr bool value = false; +}; +struct VtkWriteRelativePermeabilities { + static constexpr bool value = true; +}; +struct VtkWriteViscosities { + static constexpr bool value = false; +}; +struct VtkWriteAverageMolarMasses { + static constexpr bool value = false; +}; +struct VtkWritePorosity { + static constexpr bool value = true; +}; +struct VtkWriteIntrinsicPermeabilities { + static constexpr bool value = false; +}; +struct VtkWritePotentialGradients { + static constexpr bool value = false; +}; +struct VtkWriteFilterVelocities { + static constexpr bool value = false; +}; } // namespace Opm::Parameters -namespace Opm { +namespace Opm +{ /*! * \brief Struct holding the parameters for VtkMultiPhaseModule. */ -struct VtkMultiPhaseParams -{ +struct VtkMultiPhaseParams { //! \brief Registers the parameters in parameter system. static void registerParameters(); diff --git a/opm/models/io/vtkphasepresencemodule.hpp b/opm/models/io/vtkphasepresencemodule.hpp index fc31d7134e2..fedb0bea0eb 100644 --- a/opm/models/io/vtkphasepresencemodule.hpp +++ b/opm/models/io/vtkphasepresencemodule.hpp @@ -30,20 +30,21 @@ #include #include -#include #include +#include #include #include -namespace Opm { +namespace Opm +{ /*! * \ingroup Vtk * * \brief VTK output module for the fluid composition */ -template +template class VtkPhasePresenceModule : public BaseOutputModule { using ParentType = BaseOutputModule; @@ -115,14 +116,13 @@ class VtkPhasePresenceModule : public BaseOutputModule } if (params_.phasePresenceOutput_) { - this->commitScalarBuffer_(baseWriter, "phase presence", phasePresence_, - ParentType::BufferType::Dof); + this->commitScalarBuffer_(baseWriter, "phase presence", phasePresence_, ParentType::BufferType::Dof); } } private: - VtkPhasePresenceParams params_{}; - ScalarBuffer phasePresence_{}; + VtkPhasePresenceParams params_ {}; + ScalarBuffer phasePresence_ {}; }; } // namespace Opm diff --git a/opm/models/io/vtkphasepresenceparams.cpp b/opm/models/io/vtkphasepresenceparams.cpp index 7a8c6f6bcf9..e9ca7afe273 100644 --- a/opm/models/io/vtkphasepresenceparams.cpp +++ b/opm/models/io/vtkphasepresenceparams.cpp @@ -26,16 +26,18 @@ #include -namespace Opm { +namespace Opm +{ -void VtkPhasePresenceParams::registerParameters() +void +VtkPhasePresenceParams::registerParameters() { - Parameters::Register - ("Include the phase presence pseudo primary " - "variable in the VTK output files"); + Parameters::Register("Include the phase presence pseudo primary " + "variable in the VTK output files"); } -void VtkPhasePresenceParams::read() +void +VtkPhasePresenceParams::read() { phasePresenceOutput_ = Parameters::Get(); } diff --git a/opm/models/io/vtkphasepresenceparams.hpp b/opm/models/io/vtkphasepresenceparams.hpp index 2a66e0d3613..8f1717fd5c6 100644 --- a/opm/models/io/vtkphasepresenceparams.hpp +++ b/opm/models/io/vtkphasepresenceparams.hpp @@ -27,19 +27,22 @@ #ifndef OPM_VTK_PHASE_PRESENCE_PARAMS_HPP #define OPM_VTK_PHASE_PRESENCE_PARAMS_HPP -namespace Opm::Parameters { +namespace Opm::Parameters +{ -struct VtkWritePhasePresence { static constexpr bool value = false; }; +struct VtkWritePhasePresence { + static constexpr bool value = false; +}; } // namespace Opm::Parameters -namespace Opm { +namespace Opm +{ /*! * \brief Struct holding the parameters for VtkPhasePresenceModule. */ -struct VtkPhasePresenceParams -{ +struct VtkPhasePresenceParams { //! \brief Registers the parameters in parameter system. static void registerParameters(); diff --git a/opm/models/io/vtkprimaryvarsmodule.hpp b/opm/models/io/vtkprimaryvarsmodule.hpp index da02c71e33c..854d1a5878c 100644 --- a/opm/models/io/vtkprimaryvarsmodule.hpp +++ b/opm/models/io/vtkprimaryvarsmodule.hpp @@ -36,14 +36,15 @@ #include #include -namespace Opm { +namespace Opm +{ /*! * \ingroup Vtk * * \brief VTK output module for the fluid composition */ -template +template class VtkPrimaryVarsModule : public BaseOutputModule { using ParentType = BaseOutputModule; @@ -150,10 +151,10 @@ class VtkPrimaryVarsModule : public BaseOutputModule } private: - VtkPrimaryVarsParams params_{}; - EqBuffer primaryVars_{}; - ScalarBuffer processRank_{}; - ScalarBuffer dofIndex_{}; + VtkPrimaryVarsParams params_ {}; + EqBuffer primaryVars_ {}; + ScalarBuffer processRank_ {}; + ScalarBuffer dofIndex_ {}; }; } // namespace Opm diff --git a/opm/models/io/vtkprimaryvarsparams.cpp b/opm/models/io/vtkprimaryvarsparams.cpp index f3ebfe36660..ac219016e47 100644 --- a/opm/models/io/vtkprimaryvarsparams.cpp +++ b/opm/models/io/vtkprimaryvarsparams.cpp @@ -26,19 +26,20 @@ #include -namespace Opm { +namespace Opm +{ -void VtkPrimaryVarsParams::registerParameters() +void +VtkPrimaryVarsParams::registerParameters() { - Parameters::Register - ("Include the primary variables into the VTK output files"); - Parameters::Register - ("Include the MPI process rank into the VTK output files"); - Parameters::Register - ("Include the index of the degrees of freedom into the VTK output files"); + Parameters::Register("Include the primary variables into the VTK output files"); + Parameters::Register("Include the MPI process rank into the VTK output files"); + Parameters::Register( + "Include the index of the degrees of freedom into the VTK output files"); } -void VtkPrimaryVarsParams::read() +void +VtkPrimaryVarsParams::read() { primaryVarsOutput_ = Parameters::Get(); processRankOutput_ = Parameters::Get(); diff --git a/opm/models/io/vtkprimaryvarsparams.hpp b/opm/models/io/vtkprimaryvarsparams.hpp index 94519ec19b6..56d045fc3ba 100644 --- a/opm/models/io/vtkprimaryvarsparams.hpp +++ b/opm/models/io/vtkprimaryvarsparams.hpp @@ -27,21 +27,28 @@ #ifndef OPM_VTK_PRIMARY_VARS_PARAMS_HPP #define OPM_VTK_PRIMARY_VARS_PARAMS_HPP -namespace Opm::Parameters { +namespace Opm::Parameters +{ -struct VtkWritePrimaryVars { static constexpr bool value = false; }; -struct VtkWriteProcessRank { static constexpr bool value = false; }; -struct VtkWriteDofIndex { static constexpr bool value = false; }; +struct VtkWritePrimaryVars { + static constexpr bool value = false; +}; +struct VtkWriteProcessRank { + static constexpr bool value = false; +}; +struct VtkWriteDofIndex { + static constexpr bool value = false; +}; } // namespace Opm::Parameters -namespace Opm { +namespace Opm +{ /*! * \brief Struct holding the parameters for VtkPrimaryPhaseModule. */ -struct VtkPrimaryVarsParams -{ +struct VtkPrimaryVarsParams { //! \brief Registers the parameters in parameter system. static void registerParameters(); diff --git a/opm/models/io/vtkptflashmodule.hpp b/opm/models/io/vtkptflashmodule.hpp index c1db7f023af..c127455117c 100644 --- a/opm/models/io/vtkptflashmodule.hpp +++ b/opm/models/io/vtkptflashmodule.hpp @@ -38,7 +38,8 @@ #include #include -namespace Opm { +namespace Opm +{ /*! * \ingroup Vtk @@ -49,7 +50,7 @@ namespace Opm { * L, liquid fraction in the two-phase system */ template -class VtkPTFlashModule: public BaseOutputModule +class VtkPTFlashModule : public BaseOutputModule { using ParentType = BaseOutputModule; @@ -141,14 +142,14 @@ class VtkPTFlashModule: public BaseOutputModule this->commitComponentBuffer_(baseWriter, "K^%s", K_, BufferType::Dof); } if (params_.LOutput_) { - this->commitScalarBuffer_(baseWriter, "L", L_, BufferType::Dof); + this->commitScalarBuffer_(baseWriter, "L", L_, BufferType::Dof); } } private: - VtkPtFlashParams params_{}; - ComponentBuffer K_{}; - ScalarBuffer L_{}; + VtkPtFlashParams params_ {}; + ComponentBuffer K_ {}; + ScalarBuffer L_ {}; }; } // namespace Opm diff --git a/opm/models/io/vtkptflashparams.cpp b/opm/models/io/vtkptflashparams.cpp index 38ef51f044d..7898b60b89a 100644 --- a/opm/models/io/vtkptflashparams.cpp +++ b/opm/models/io/vtkptflashparams.cpp @@ -26,17 +26,20 @@ #include -namespace Opm { +namespace Opm +{ -void VtkPtFlashParams::registerParameters() +void +VtkPtFlashParams::registerParameters() { - Parameters::Register - ("Include liquid mole fractions (L) in the VTK output files"); - Parameters::Register - ("Include equilibrium constants (K) in the VTK output files"); + Parameters::Register( + "Include liquid mole fractions (L) in the VTK output files"); + Parameters::Register( + "Include equilibrium constants (K) in the VTK output files"); } -void VtkPtFlashParams::read() +void +VtkPtFlashParams::read() { LOutput_ = Parameters::Get(); equilConstOutput_ = Parameters::Get(); diff --git a/opm/models/io/vtkptflashparams.hpp b/opm/models/io/vtkptflashparams.hpp index 96c587ad696..69b723aa170 100644 --- a/opm/models/io/vtkptflashparams.hpp +++ b/opm/models/io/vtkptflashparams.hpp @@ -27,21 +27,26 @@ #ifndef OPM_VTK_PTFLASH_PARAMS_HPP #define OPM_VTK_PTFLASH_PARAMS_HPP -namespace Opm::Parameters { +namespace Opm::Parameters +{ // set default values for what quantities to output -struct VtkWriteLiquidMoleFractions { static constexpr bool value = false; }; -struct VtkWriteEquilibriumConstants { static constexpr bool value = false; }; +struct VtkWriteLiquidMoleFractions { + static constexpr bool value = false; +}; +struct VtkWriteEquilibriumConstants { + static constexpr bool value = false; +}; } // namespace Opm::Parameters -namespace Opm { +namespace Opm +{ /*! * \brief Struct holding the parameters for VtkPtFlashModule. */ -struct VtkPtFlashParams -{ +struct VtkPtFlashParams { //! \brief Registers the parameters in parameter system. static void registerParameters(); diff --git a/opm/models/io/vtktemperaturemodule.hpp b/opm/models/io/vtktemperaturemodule.hpp index ba1a0b1c396..e408c17eaa7 100644 --- a/opm/models/io/vtktemperaturemodule.hpp +++ b/opm/models/io/vtktemperaturemodule.hpp @@ -38,7 +38,8 @@ #include #include -namespace Opm { +namespace Opm +{ /*! * \ingroup Vtk @@ -46,7 +47,7 @@ namespace Opm { * \brief VTK output module for the temperature in which assume * thermal equilibrium */ -template +template class VtkTemperatureModule : public BaseOutputModule { using ParentType = BaseOutputModule; @@ -121,14 +122,13 @@ class VtkTemperatureModule : public BaseOutputModule } if (params_.temperatureOutput_) { - this->commitScalarBuffer_(baseWriter, "temperature", temperature_, - ParentType::BufferType::Dof); + this->commitScalarBuffer_(baseWriter, "temperature", temperature_, ParentType::BufferType::Dof); } } private: - VtkTemperatureParams params_{}; - ScalarBuffer temperature_{}; + VtkTemperatureParams params_ {}; + ScalarBuffer temperature_ {}; }; } // namespace Opm diff --git a/opm/models/io/vtktemperatureparams.cpp b/opm/models/io/vtktemperatureparams.cpp index 62be2a67915..970e9428162 100644 --- a/opm/models/io/vtktemperatureparams.cpp +++ b/opm/models/io/vtktemperatureparams.cpp @@ -26,15 +26,17 @@ #include -namespace Opm { +namespace Opm +{ -void VtkTemperatureParams::registerParameters() +void +VtkTemperatureParams::registerParameters() { - Parameters::Register - ("Include the temperature in the VTK output files"); + Parameters::Register("Include the temperature in the VTK output files"); } -void VtkTemperatureParams::read() +void +VtkTemperatureParams::read() { temperatureOutput_ = Parameters::Get(); } diff --git a/opm/models/io/vtktemperatureparams.hpp b/opm/models/io/vtktemperatureparams.hpp index 3a9a138b2e1..064646bd0c8 100644 --- a/opm/models/io/vtktemperatureparams.hpp +++ b/opm/models/io/vtktemperatureparams.hpp @@ -27,20 +27,23 @@ #ifndef OPM_VTK_TEMPERATURE_PARAMS_HPP #define OPM_VTK_TEMPERATURE_PARAMS_HPP -namespace Opm::Parameters { +namespace Opm::Parameters +{ // set default values for what quantities to output -struct VtkWriteTemperature { static constexpr bool value = true; }; +struct VtkWriteTemperature { + static constexpr bool value = true; +}; } // namespace Opm::Parameters -namespace Opm { +namespace Opm +{ /*! * \brief Struct holding the parameters for VtkTemperatureModule. */ -struct VtkTemperatureParams -{ +struct VtkTemperatureParams { //! \brief Registers the parameters in parameter system. static void registerParameters(); diff --git a/opm/models/nonlinear/newtonmethodparams.cpp b/opm/models/nonlinear/newtonmethodparams.cpp index 9a3eea5df60..2c1f8b80787 100644 --- a/opm/models/nonlinear/newtonmethodparams.cpp +++ b/opm/models/nonlinear/newtonmethodparams.cpp @@ -30,31 +30,28 @@ #include #endif -namespace Opm { +namespace Opm +{ -template -void NewtonMethodParams::registerParameters() +template +void +NewtonMethodParams::registerParameters() { - Parameters::Register - ("Specify whether the Newton method should inform " - "the user about its progress or not"); - Parameters::Register - ("Write the convergence behaviour of the Newton " - "method to a VTK file"); - Parameters::Register - ("The 'optimum' number of Newton iterations per time step"); - Parameters::Register - ("The maximum number of Newton iterations per time step"); - Parameters::Register> - ("The maximum raw error tolerated by the Newton" - "method for considering a solution to be converged"); - Parameters::Register> - ("The maximum error tolerated by the Newton " - "method to which does not cause an abort"); + Parameters::Register("Specify whether the Newton method should inform " + "the user about its progress or not"); + Parameters::Register("Write the convergence behaviour of the Newton " + "method to a VTK file"); + Parameters::Register("The 'optimum' number of Newton iterations per time step"); + Parameters::Register("The maximum number of Newton iterations per time step"); + Parameters::Register>("The maximum raw error tolerated by the Newton" + "method for considering a solution to be converged"); + Parameters::Register>("The maximum error tolerated by the Newton " + "method to which does not cause an abort"); } -template -void NewtonMethodParams::read() +template +void +NewtonMethodParams::read() { verbose_ = Parameters::Get(); writeConvergence_ = Parameters::Get(); diff --git a/opm/models/nonlinear/newtonmethodparams.hpp b/opm/models/nonlinear/newtonmethodparams.hpp index b49d176285d..dedb7aa28d6 100644 --- a/opm/models/nonlinear/newtonmethodparams.hpp +++ b/opm/models/nonlinear/newtonmethodparams.hpp @@ -23,15 +23,20 @@ #ifndef OPM_NEWTON_METHOD_PARAMS_HPP #define OPM_NEWTON_METHOD_PARAMS_HPP -namespace Opm::Parameters { +namespace Opm::Parameters +{ //! The maximum error which may occur in a simulation before the //! Newton method for the time step is aborted -template -struct NewtonMaxError { static constexpr Scalar value = 1e100; }; +template +struct NewtonMaxError { + static constexpr Scalar value = 1e100; +}; //! Number of maximum iterations for the Newton method. -struct NewtonMaxIterations { static constexpr int value = 20; }; +struct NewtonMaxIterations { + static constexpr int value = 20; +}; /*! * \brief The number of iterations at which the Newton method @@ -41,7 +46,9 @@ struct NewtonMaxIterations { static constexpr int value = 20; }; * is to scale the last time-step size by the deviation of the * number of iterations used from the target steps. */ -struct NewtonTargetIterations { static constexpr int value = 10; }; +struct NewtonTargetIterations { + static constexpr int value = 10; +}; /*! * \brief The value for the error below which convergence is declared @@ -49,26 +56,32 @@ struct NewtonTargetIterations { static constexpr int value = 10; }; * This value can (and for the porous media models will) be changed to account for grid * scaling and other effects. */ -template -struct NewtonTolerance { static constexpr Scalar value = 1e-8; }; +template +struct NewtonTolerance { + static constexpr Scalar value = 1e-8; +}; //! Specifies whether the Newton method should print messages or not -struct NewtonVerbose { static constexpr bool value = true; }; +struct NewtonVerbose { + static constexpr bool value = true; +}; //! Specifies whether the convergence rate and the global residual //! gets written out to disk for every Newton iteration -struct NewtonWriteConvergence { static constexpr bool value = false; }; +struct NewtonWriteConvergence { + static constexpr bool value = false; +}; } // end namespace Opm::Parameters -namespace Opm { +namespace Opm +{ /*! * \brief Struct holding the parameters for NewtonMethod. */ -template -struct NewtonMethodParams -{ +template +struct NewtonMethodParams { //! \brief Registers the parameters in parameter system. static void registerParameters(); diff --git a/opm/models/parallel/tasklets.cpp b/opm/models/parallel/tasklets.cpp index a235f1029c2..05ec433801d 100644 --- a/opm/models/parallel/tasklets.cpp +++ b/opm/models/parallel/tasklets.cpp @@ -31,7 +31,8 @@ #include #include -namespace Opm { +namespace Opm +{ thread_local TaskletRunner* TaskletRunner::taskletRunner_ = nullptr; thread_local int TaskletRunner::workerThreadIndex_ = -1; @@ -43,12 +44,14 @@ TaskletRunner::BarrierTasklet::BarrierTasklet(unsigned numWorkers) numWaiting_ = 0; } -void TaskletRunner::BarrierTasklet::run() +void +TaskletRunner::BarrierTasklet::run() { wait(); } -void TaskletRunner::BarrierTasklet::wait() +void +TaskletRunner::BarrierTasklet::wait() { std::unique_lock lock(barrierMutex_); @@ -56,11 +59,8 @@ void TaskletRunner::BarrierTasklet::wait() if (numWaiting_ >= numWorkers_ + 1) { lock.unlock(); barrierCondition_.notify_all(); - } - else { - const auto& areAllWaiting = - [this]() -> bool - { return this->numWaiting_ >= this->numWorkers_ + 1; }; + } else { + const auto& areAllWaiting = [this]() -> bool { return this->numWaiting_ >= this->numWorkers_ + 1; }; barrierCondition_.wait(lock, /*predicate=*/areAllWaiting); } @@ -86,19 +86,22 @@ TaskletRunner::~TaskletRunner() } } -bool TaskletRunner::failure() const +bool +TaskletRunner::failure() const { return this->failureFlag_.load(std::memory_order_relaxed); } -int TaskletRunner::workerThreadIndex() const +int +TaskletRunner::workerThreadIndex() const { if (TaskletRunner::taskletRunner_ != this) return -1; return TaskletRunner::workerThreadIndex_; } -void TaskletRunner::dispatch(std::shared_ptr tasklet) +void +TaskletRunner::dispatch(std::shared_ptr tasklet) { if (threads_.empty()) { // run the tasklet immediately in synchronous mode. @@ -106,19 +109,16 @@ void TaskletRunner::dispatch(std::shared_ptr tasklet) tasklet->dereference(); try { tasklet->run(); - } - catch (const std::exception& e) { + } catch (const std::exception& e) { std::cerr << "ERROR: Uncaught std::exception when running tasklet: " << e.what() << ". Trying to continue.\n"; failureFlag_.store(true, std::memory_order_relaxed); - } - catch (...) { + } catch (...) { std::cerr << "ERROR: Uncaught exception (general type) when running tasklet. Trying to continue.\n"; failureFlag_.store(true, std::memory_order_relaxed); } } - } - else { + } else { // lock mutex for the tasklet queue to make sure that nobody messes with the // task queue taskletQueueMutex_.lock(); @@ -132,7 +132,8 @@ void TaskletRunner::dispatch(std::shared_ptr tasklet) } } -void TaskletRunner::barrier() +void +TaskletRunner::barrier() { unsigned numWorkers = threads_.size(); if (numWorkers == 0) @@ -146,7 +147,8 @@ void TaskletRunner::barrier() barrierTasklet->wait(); } -void TaskletRunner::startWorkerThread_(TaskletRunner* taskletRunner, int workerThreadIndex) +void +TaskletRunner::startWorkerThread_(TaskletRunner* taskletRunner, int workerThreadIndex) { TaskletRunner::taskletRunner_ = taskletRunner; TaskletRunner::workerThreadIndex_ = workerThreadIndex; @@ -154,7 +156,8 @@ void TaskletRunner::startWorkerThread_(TaskletRunner* taskletRunner, int workerT taskletRunner->run_(); } -void TaskletRunner::run_() +void +TaskletRunner::run_() { while (true) { @@ -162,9 +165,7 @@ void TaskletRunner::run_() // mutex for access to taskletQueue_ std::unique_lock lock(taskletQueueMutex_); - const auto& workIsAvailable = - [this]() -> bool - { return !taskletQueue_.empty(); }; + const auto& workIsAvailable = [this]() -> bool { return !taskletQueue_.empty(); }; if (!workIsAvailable()) workAvailableCondition_.wait(lock, /*predicate=*/workIsAvailable); @@ -175,7 +176,7 @@ void TaskletRunner::run_() // if tasklet is an end marker, terminate the thread and DO NOT remove the // tasklet. if (tasklet->isEndMarker()) { - if(taskletQueue_.size() > 1) + if (taskletQueue_.size() > 1) throw std::logic_error("TaskletRunner: Not all queued tasklets were executed"); taskletQueueMutex_.unlock(); return; @@ -191,12 +192,10 @@ void TaskletRunner::run_() // execute tasklet try { tasklet->run(); - } - catch (const std::exception& e) { + } catch (const std::exception& e) { std::cerr << "ERROR: Uncaught std::exception when running tasklet: " << e.what() << ".\n"; failureFlag_.store(true, std::memory_order_relaxed); - } - catch (...) { + } catch (...) { std::cerr << "ERROR: Uncaught exception when running tasklet.\n"; failureFlag_.store(true, std::memory_order_relaxed); } diff --git a/opm/models/parallel/tasklets.hpp b/opm/models/parallel/tasklets.hpp index 7dd217a72c2..a620f1ada96 100644 --- a/opm/models/parallel/tasklets.hpp +++ b/opm/models/parallel/tasklets.hpp @@ -34,7 +34,8 @@ #include #include -namespace Opm { +namespace Opm +{ /*! * \brief The base class for tasklets. @@ -46,17 +47,27 @@ class TaskletInterface public: explicit TaskletInterface(int refCount = 1) : referenceCount_(refCount) - {} + { + } - virtual ~TaskletInterface() {} + virtual ~TaskletInterface() + { + } virtual void run() = 0; - virtual bool isEndMarker () const { return false; } + virtual bool isEndMarker() const + { + return false; + } void dereference() - { -- referenceCount_; } + { + --referenceCount_; + } int referenceCount() const - { return referenceCount_; } + { + return referenceCount_; + } private: int referenceCount_; @@ -74,10 +85,13 @@ class FunctionRunnerTasklet : public TaskletInterface FunctionRunnerTasklet(int numInvocations, const Fn& fn) : TaskletInterface(numInvocations) , fn_(fn) - {} + { + } void run() override - { fn_(); } + { + fn_(); + } private: const Fn& fn_; @@ -115,10 +129,13 @@ class TaskletRunner { public: void run() override - {} + { + } bool isEndMarker() const override - { return true; } + { + return true; + } }; public: @@ -155,7 +172,9 @@ class TaskletRunner * \brief Returns the number of worker threads for the tasklet runner. */ int numWorkerThreads() const - { return threads_.size(); } + { + return threads_.size(); + } /*! * \brief Add a new tasklet. @@ -168,7 +187,7 @@ class TaskletRunner * \brief Convenience method to construct a new function runner tasklet and dispatch it immediately. */ template - std::shared_ptr > dispatchFunction(Fn &fn, int numInvocations = 1) + std::shared_ptr> dispatchFunction(Fn& fn, int numInvocations = 1) { using Tasklet = FunctionRunnerTasklet; auto tasklet = std::make_shared(numInvocations, fn); @@ -199,8 +218,8 @@ class TaskletRunner //! do the work until the queue received an end tasklet void run_(); - std::vector > threads_; - std::queue > taskletQueue_; + std::vector> threads_; + std::queue> taskletQueue_; std::mutex taskletQueueMutex_; std::condition_variable workAvailableCondition_; diff --git a/opm/models/parallel/threadmanager.cpp b/opm/models/parallel/threadmanager.cpp index ea85c408975..b63da32cdf9 100644 --- a/opm/models/parallel/threadmanager.cpp +++ b/opm/models/parallel/threadmanager.cpp @@ -30,18 +30,20 @@ #include #include -namespace Opm { +namespace Opm +{ int ThreadManager::numThreads_ = 1; -void ThreadManager::registerParameters() +void +ThreadManager::registerParameters() { - Parameters::Register - ("The maximum number of threads to be instantiated per process " - "('-1' means 'automatic')"); + Parameters::Register("The maximum number of threads to be instantiated per process " + "('-1' means 'automatic')"); } -void ThreadManager::init(bool queryCommandLineParameter) +void +ThreadManager::init(bool queryCommandLineParameter) { if (queryCommandLineParameter) { numThreads_ = Parameters::Get(); @@ -50,7 +52,8 @@ void ThreadManager::init(bool queryCommandLineParameter) #if !defined(_OPENMP) if (numThreads_ != 1 && numThreads_ != -1) { throw std::invalid_argument("OpenMP is not available. The only valid values for " - "threads-per-process is 1 and -1 but it is "+std::to_string(numThreads_)+"!"); + "threads-per-process is 1 and -1 but it is " + + std::to_string(numThreads_) + "!"); } numThreads_ = 1; #elif !defined NDEBUG && defined DUNE_INTERFACECHECK @@ -81,7 +84,8 @@ void ThreadManager::init(bool queryCommandLineParameter) #endif } -unsigned ThreadManager::threadId() +unsigned +ThreadManager::threadId() { #ifdef _OPENMP return static_cast(omp_get_thread_num()); diff --git a/opm/models/parallel/threadmanager.hpp b/opm/models/parallel/threadmanager.hpp index 8b12345d876..51f35ad8fa0 100644 --- a/opm/models/parallel/threadmanager.hpp +++ b/opm/models/parallel/threadmanager.hpp @@ -27,7 +27,8 @@ #ifndef OPM_THREAD_MANAGER_HPP #define OPM_THREAD_MANAGER_HPP -namespace Opm { +namespace Opm +{ /*! * \brief Simplifies multi-threaded capabilities. @@ -64,7 +65,9 @@ class ThreadManager * \brief Return the maximum number of threads of the current process. */ static unsigned maxThreads() - { return static_cast(numThreads_); } + { + return static_cast(numThreads_); + } /*! * \brief Return the index of the current OpenMP thread diff --git a/opm/models/utils/parametersystem.cpp b/opm/models/utils/parametersystem.cpp index 62f2fb75773..a33c12d29c5 100644 --- a/opm/models/utils/parametersystem.cpp +++ b/opm/models/utils/parametersystem.cpp @@ -49,10 +49,10 @@ #include #include -namespace { - -struct ParamInfo +namespace { + +struct ParamInfo { std::string paramName; std::string paramTypeName; std::string typeTagName; @@ -62,28 +62,33 @@ struct ParamInfo bool operator==(const ParamInfo& other) const { - return other.paramName == paramName - && other.paramTypeName == paramTypeName - && other.typeTagName == typeTagName + return other.paramName == paramName && other.paramTypeName == paramTypeName && other.typeTagName == typeTagName && other.usageString == usageString; } }; -struct MetaData -{ +struct MetaData { using type = Dune::ParameterTree; static Dune::ParameterTree& tree() - { return *storage_().tree; } + { + return *storage_().tree; + } static std::map& mutableRegistry() - { return storage_().registry; } + { + return storage_().registry; + } static const std::map& registry() - { return storage_().registry; } + { + return storage_().registry; + } static bool& registrationOpen() - { return storage_().registrationOpen; } + { + return storage_().registrationOpen; + } static void clear() { @@ -97,8 +102,7 @@ struct MetaData // member functions of the ParameterMetaData property class triggers a bug in clang // 3.5's address sanitizer which causes these variables to be initialized multiple // times... - struct Storage_ - { + struct Storage_ { Storage_() : tree(std::make_unique()) , registrationOpen(true) @@ -118,9 +122,8 @@ struct MetaData }; -void getFlattenedKeyList(std::vector& dest, - const Dune::ParameterTree& tree, - const std::string& prefix = "") +void +getFlattenedKeyList(std::vector& dest, const Dune::ParameterTree& tree, const std::string& prefix = "") { // add the keys of the current sub-structure for (const auto& valueKey : tree.getValueKeys()) { @@ -135,16 +138,17 @@ void getFlattenedKeyList(std::vector& dest, } } -std::string parseKey(std::string& s) +std::string +parseKey(std::string& s) { - auto it = std::find_if(s.begin(), s.end(), - [](const char ch) { return std::isspace(ch) || ch == '='; }); + auto it = std::find_if(s.begin(), s.end(), [](const char ch) { return std::isspace(ch) || ch == '='; }); std::string ret {s.begin(), it}; s.erase(s.begin(), it); return ret; } -std::string parseQuotedValue(std::string& s, const std::string& errorPrefix) +std::string +parseQuotedValue(std::string& s, const std::string& errorPrefix) { if (s.empty() || s[0] != '"') { throw std::runtime_error(errorPrefix + "Expected quoted string"); @@ -161,38 +165,46 @@ std::string parseQuotedValue(std::string& s, const std::string& errorPrefix) } switch (s[i]) { - case 'n': result += '\n'; break; - case 'r': result += '\r'; break; - case 't': result += '\t'; break; - case '"': result += '"'; break; - case '\\': result += '\\'; break; - default: throw std::runtime_error(errorPrefix + - "Unknown escape character '\\" + s[i] + "'"); + case 'n': + result += '\n'; + break; + case 'r': + result += '\r'; + break; + case 't': + result += '\t'; + break; + case '"': + result += '"'; + break; + case '\\': + result += '\\'; + break; + default: + throw std::runtime_error(errorPrefix + "Unknown escape character '\\" + s[i] + "'"); } - } - else if (s[i] == '"') { + } else if (s[i] == '"') { break; - } - else { + } else { result += s[i]; } } - s = s.substr(i+1); + s = s.substr(i + 1); return result; } -std::string parseUnquotedValue(std::string& s, const std::string&) +std::string +parseUnquotedValue(std::string& s, const std::string&) { auto it = std::find_if(s.begin(), s.end(), ::isspace); - std::string ret{s.begin(), it}; + std::string ret {s.begin(), it}; s.erase(s.begin(), it); return ret; } -void printParamList(std::ostream& os, - const std::vector& keyList, - bool printDefaults = false) +void +printParamList(std::ostream& os, const std::vector& keyList, bool printDefaults = false) { const Dune::ParameterTree& tree = MetaData::tree(); @@ -210,8 +222,8 @@ void printParamList(std::ostream& os, } } -void printParamUsage(std::ostream& os, - const ParamInfo& paramInfo) +void +printParamUsage(std::ostream& os, const ParamInfo& paramInfo) { std::string paramMessage; @@ -233,34 +245,27 @@ void printParamUsage(std::ostream& os, // add the =VALUE_TYPE part bool isString = false; - if (paramInfo.paramTypeName == Dune::className() - || paramInfo.paramTypeName == "const char *") - { + if (paramInfo.paramTypeName == Dune::className() || paramInfo.paramTypeName == "const char *") { paramMessage += "=STRING"; isString = true; - } - else if (paramInfo.paramTypeName == Dune::className() - || paramInfo.paramTypeName == Dune::className() - || paramInfo.paramTypeName == Dune::className() + } else if (paramInfo.paramTypeName == Dune::className() + || paramInfo.paramTypeName == Dune::className() + || paramInfo.paramTypeName == Dune::className() #if HAVE_QUAD - || paramInfo.paramTypeName == Dune::className() + || paramInfo.paramTypeName == Dune::className() #endif // HAVE_QUAD - ) { + ) { paramMessage += "=SCALAR"; - } - else if (paramInfo.paramTypeName == Dune::className() - || paramInfo.paramTypeName == Dune::className() - || paramInfo.paramTypeName == Dune::className() - || paramInfo.paramTypeName == Dune::className()) { + } else if (paramInfo.paramTypeName == Dune::className() + || paramInfo.paramTypeName == Dune::className() + || paramInfo.paramTypeName == Dune::className() + || paramInfo.paramTypeName == Dune::className()) { paramMessage += "=INTEGER"; - } - else if (paramInfo.paramTypeName == Dune::className()) { + } else if (paramInfo.paramTypeName == Dune::className()) { paramMessage += "=BOOLEAN"; - } - else if (paramInfo.paramTypeName.empty()) { + } else if (paramInfo.paramTypeName.empty()) { // the parameter is a flag. Do nothing! - } - else { + } else { // unknown type paramMessage += "=VALUE"; } @@ -283,17 +288,14 @@ void printParamUsage(std::ostream& os, if (paramInfo.paramTypeName == "bool") { if (paramInfo.defaultValue == "0") { paramMessage += "false"; - } - else { + } else { paramMessage += "true"; } - } - else if (isString) { + } else if (isString) { paramMessage += "\""; paramMessage += paramInfo.defaultValue; paramMessage += "\""; - } - else { + } else { paramMessage += paramInfo.defaultValue; } } @@ -305,16 +307,14 @@ void printParamUsage(std::ostream& os, os << paramMessage; } -void removeLeadingSpace(std::string& s) +void +removeLeadingSpace(std::string& s) { - s.erase(s.begin(), - std::find_if(s.begin(), s.end(), - [](const char ch) { return !std::isspace(ch); })); + s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](const char ch) { return !std::isspace(ch); })); } -std::string transformKey(const std::string& s, - bool capitalizeFirstLetter, - const std::string& errorPrefix = "") +std::string +transformKey(const std::string& s, bool capitalizeFirstLetter, const std::string& errorPrefix = "") { std::string result; @@ -323,14 +323,13 @@ std::string transformKey(const std::string& s, } if (!std::isalpha(s[0])) { - throw std::runtime_error(errorPrefix +" Parameter name '" + s + - "' is invalid: First character must be a letter"); + throw std::runtime_error(errorPrefix + " Parameter name '" + s + + "' is invalid: First character must be a letter"); } if (capitalizeFirstLetter) { result += static_cast(std::toupper(s[0])); - } - else { + } else { result += s[0]; } @@ -341,11 +340,9 @@ std::string transformKey(const std::string& s, throw std::runtime_error(errorPrefix + "Invalid parameter name '" + s + "'"); } result += static_cast(std::toupper(s[i])); - } - else if (!std::isalnum(s[i])) { + } else if (!std::isalnum(s[i])) { throw std::runtime_error(errorPrefix + "Invalid parameter name '" + s + "'"); - } - else { + } else { result += s[i]; } } @@ -355,144 +352,146 @@ std::string transformKey(const std::string& s, } // anonymous namespace -namespace Opm::Parameters { - -namespace detail { +namespace Opm::Parameters +{ -template -ParamType Get_(const std::string& paramName, ParamType defaultValue, - bool errorIfNotRegistered) +namespace detail { - if (errorIfNotRegistered) { - if (MetaData::registrationOpen()) { - throw std::runtime_error("Parameters can only be retrieved after _all_ of them have " - "been registered."); - } - if (MetaData::registry().find(paramName) == MetaData::registry().end()) { - throw std::runtime_error("Accessing parameter " + paramName + - " without prior registration is not allowed."); + template + ParamType Get_(const std::string& paramName, ParamType defaultValue, bool errorIfNotRegistered) + { + if (errorIfNotRegistered) { + if (MetaData::registrationOpen()) { + throw std::runtime_error("Parameters can only be retrieved after _all_ of them have " + "been registered."); + } + + if (MetaData::registry().find(paramName) == MetaData::registry().end()) { + throw std::runtime_error("Accessing parameter " + paramName + + " without prior registration is not allowed."); + } } - } - const std::string& defVal = MetaData::mutableRegistry()[paramName].defaultValue; - if constexpr (std::is_same_v) { - defaultValue = defVal; - } - else if constexpr (std::is_same_v) { - defaultValue = defVal == "1"; - } + const std::string& defVal = MetaData::mutableRegistry()[paramName].defaultValue; + if constexpr (std::is_same_v) { + defaultValue = defVal; + } else if constexpr (std::is_same_v) { + defaultValue = defVal == "1"; + } #if HAVE_QUAD - else if constexpr (std::is_same_v) { - defaultValue = std::strtold(defVal.data(), nullptr); - } + else if constexpr (std::is_same_v) { + defaultValue = std::strtold(defVal.data(), nullptr); + } #endif #if !HAVE_FLOATING_POINT_FROM_CHARS - else if constexpr (std::is_floating_point_v) { - defaultValue = std::strtod(defVal.c_str(), nullptr); - } + else if constexpr (std::is_floating_point_v) { + defaultValue = std::strtod(defVal.c_str(), nullptr); + } #endif // !HAVE_FLOATING_POINT_FROM_CHARS - else { - std::from_chars(defVal.data(), defVal.data() + defVal.size(), defaultValue); - } - - // prefix the parameter name by the model's GroupName. E.g. If - // the model specifies its group name to be 'Stokes', in an - // INI file this would result in something like: - // - // [Stokes] - // NewtonWriteConvergence = true - // retrieve actual parameter from the parameter tree - return MetaData::tree().template get(paramName, defaultValue); -} - -void Hide_(const std::string& paramName) -{ - if (!MetaData::registrationOpen()) { - throw std::logic_error("Parameter '" + paramName + "' declared as hidden" - " when parameter registration was already closed."); - } + else { + std::from_chars(defVal.data(), defVal.data() + defVal.size(), defaultValue); + } - auto paramInfoIt = MetaData::mutableRegistry().find(paramName); - if (paramInfoIt == MetaData::mutableRegistry().end()) { - throw std::logic_error("Tried to declare unknown parameter '" + - paramName + "' hidden."); + // prefix the parameter name by the model's GroupName. E.g. If + // the model specifies its group name to be 'Stokes', in an + // INI file this would result in something like: + // + // [Stokes] + // NewtonWriteConvergence = true + // retrieve actual parameter from the parameter tree + return MetaData::tree().template get(paramName, defaultValue); } - auto& paramInfo = paramInfoIt->second; - paramInfo.isHidden = true; -} - -bool IsSet_(const std::string& paramName, bool errorIfNotRegistered) -{ - if (errorIfNotRegistered) { - if (MetaData::registrationOpen()) { - throw std::runtime_error("Parameters can only be checked after _all_ of them have " - "been registered."); + void Hide_(const std::string& paramName) + { + if (!MetaData::registrationOpen()) { + throw std::logic_error("Parameter '" + paramName + + "' declared as hidden" + " when parameter registration was already closed."); } - if (MetaData::registry().find(paramName) == MetaData::registry().end()) { - throw std::runtime_error("Accessing parameter " + std::string(paramName) + - " without prior registration is not allowed."); + auto paramInfoIt = MetaData::mutableRegistry().find(paramName); + if (paramInfoIt == MetaData::mutableRegistry().end()) { + throw std::logic_error("Tried to declare unknown parameter '" + paramName + "' hidden."); } + + auto& paramInfo = paramInfoIt->second; + paramInfo.isHidden = true; } - // check whether the parameter is in the parameter tree - return MetaData::tree().hasKey(paramName); -} + bool IsSet_(const std::string& paramName, bool errorIfNotRegistered) + { + if (errorIfNotRegistered) { + if (MetaData::registrationOpen()) { + throw std::runtime_error("Parameters can only be checked after _all_ of them have " + "been registered."); + } -void Register_(const std::string& paramName, - const std::string& paramTypeName, - const std::string& defaultValue, - const char* usageString) -{ - if (!MetaData::registrationOpen()) { - throw std::logic_error("Parameter registration was already closed before " - "the parameter '" + paramName + "' was registered."); + if (MetaData::registry().find(paramName) == MetaData::registry().end()) { + throw std::runtime_error("Accessing parameter " + std::string(paramName) + + " without prior registration is not allowed."); + } + } + + // check whether the parameter is in the parameter tree + return MetaData::tree().hasKey(paramName); } - ParamInfo paramInfo; - paramInfo.paramName = paramName; - paramInfo.paramTypeName = paramTypeName; - paramInfo.usageString = usageString; - paramInfo.defaultValue = defaultValue; - paramInfo.isHidden = false; - if (MetaData::registry().find(paramName) != MetaData::registry().end()) { - // allow to register a parameter twice, but only if the - // parameter name, type and usage string are exactly the same. - if (MetaData::registry().at(paramName) == paramInfo) { - return; + void Register_(const std::string& paramName, + const std::string& paramTypeName, + const std::string& defaultValue, + const char* usageString) + { + if (!MetaData::registrationOpen()) { + throw std::logic_error("Parameter registration was already closed before " + "the parameter '" + + paramName + "' was registered."); + } + + ParamInfo paramInfo; + paramInfo.paramName = paramName; + paramInfo.paramTypeName = paramTypeName; + paramInfo.usageString = usageString; + paramInfo.defaultValue = defaultValue; + paramInfo.isHidden = false; + if (MetaData::registry().find(paramName) != MetaData::registry().end()) { + // allow to register a parameter twice, but only if the + // parameter name, type and usage string are exactly the same. + if (MetaData::registry().at(paramName) == paramInfo) { + return; + } + throw std::logic_error("Parameter " + paramName + " registered twice with non-matching characteristics."); } - throw std::logic_error("Parameter " + paramName + - " registered twice with non-matching characteristics."); - } - MetaData::mutableRegistry()[paramName] = paramInfo; -} + MetaData::mutableRegistry()[paramName] = paramInfo; + } -void SetDefault_(const std::string& paramName, - const std::string& paramValue) -{ - if (MetaData::registry().find(paramName) == MetaData::registry().end()) { - throw std::runtime_error("Accessing parameter " + paramName + - " without prior registration is not allowed."); + void SetDefault_(const std::string& paramName, const std::string& paramValue) + { + if (MetaData::registry().find(paramName) == MetaData::registry().end()) { + throw std::runtime_error("Accessing parameter " + paramName + + " without prior registration is not allowed."); + } + MetaData::mutableRegistry()[paramName].defaultValue = paramValue; } - MetaData::mutableRegistry()[paramName].defaultValue = paramValue; -} } // namespace detail -void reset() +void +reset() { MetaData::clear(); } -bool IsRegistrationOpen() +bool +IsRegistrationOpen() { return MetaData::registrationOpen(); } -void endRegistration() +void +endRegistration() { if (!MetaData::registrationOpen()) { throw std::logic_error("Parameter registration was already closed. It is only possible " @@ -502,8 +501,8 @@ void endRegistration() MetaData::registrationOpen() = false; } -void getLists(std::vector& usedParams, - std::vector& unusedParams) +void +getLists(std::vector& usedParams, std::vector& unusedParams) { usedParams.clear(); unusedParams.clear(); @@ -521,18 +520,15 @@ void getLists(std::vector& usedParams, if (MetaData::registry().find(key) == MetaData::registry().end()) { // key was not registered unusedParams.emplace_back(key, MetaData::tree()[key]); - } - else { + } else { // key was registered usedParams.emplace_back(key, MetaData::tree()[key]); } } } -void printUsage(const std::string& helpPreamble, - std::ostream& os, - const std::string& errorMsg, - const bool showAll) +void +printUsage(const std::string& helpPreamble, std::ostream& os, const std::string& errorMsg, const bool showAll) { if (!errorMsg.empty()) { os << errorMsg << "\n\n"; @@ -560,7 +556,8 @@ void printUsage(const std::string& helpPreamble, } } -bool parseParameterFile(const std::string& fileName, bool overwrite) +bool +parseParameterFile(const std::string& fileName, bool overwrite) { std::set seenKeys; std::ifstream ifs(fileName); @@ -591,30 +588,29 @@ bool parseParameterFile(const std::string& fileName, bool overwrite) std::string canonicalKey = transformKey(key, /*capitalizeFirst=*/true, errorPrefix); if (seenKeys.count(canonicalKey) > 0) { - throw std::runtime_error(errorPrefix + "Parameter '" + canonicalKey + - "' seen multiple times in the same file"); + throw std::runtime_error(errorPrefix + "Parameter '" + canonicalKey + + "' seen multiple times in the same file"); } seenKeys.insert(canonicalKey); // deal with the equals sign removeLeadingSpace(curLine); if (curLine.empty() || curLine[0] != '=') { - throw std::runtime_error(errorPrefix+"Syntax error, expecting 'key=value'"); + throw std::runtime_error(errorPrefix + "Syntax error, expecting 'key=value'"); } curLine = curLine.substr(1); removeLeadingSpace(curLine); if (curLine.empty() || curLine[0] == '#' || curLine[0] == ';') { - throw std::runtime_error(errorPrefix+"Syntax error, expecting 'key=value'"); + throw std::runtime_error(errorPrefix + "Syntax error, expecting 'key=value'"); } // get the value std::string value; if (curLine[0] == '"') { value = parseQuotedValue(curLine, errorPrefix); - } - else { + } else { value = parseUnquotedValue(curLine, errorPrefix); } @@ -633,21 +629,21 @@ bool parseParameterFile(const std::string& fileName, bool overwrite) return true; } -std::string parseCommandLineOptions(int argc, - const char **argv, - const PositionalArgumentCallback& posArgCallback, - const std::string& helpPreamble) +std::string +parseCommandLineOptions(int argc, + const char** argv, + const PositionalArgumentCallback& posArgCallback, + const std::string& helpPreamble) { // handle the "--help" parameter if (!helpPreamble.empty()) { for (int i = 1; i < argc; ++i) { - if (std::string("-h") == argv[i] || - std::string("--help") == argv[i]) { + if (std::string("-h") == argv[i] || std::string("--help") == argv[i]) { printUsage(helpPreamble, std::cout, /*errorMsg=*/""); return "Help called"; } if (std::string("--help-all") == argv[i]) { - printUsage(helpPreamble, std::cout, /*errorMsg=*/"", true); + printUsage(helpPreamble, std::cout, /*errorMsg=*/"", true); return "Help called"; } } @@ -657,16 +653,15 @@ std::string parseCommandLineOptions(int argc, int numPositionalParams = 0; for (int i = 1; i < argc; ++i) { // All non-positional command line options need to start with '-' - if (strlen(argv[i]) < 4 - || argv[i][0] != '-' - || argv[i][1] != '-') - { + if (strlen(argv[i]) < 4 || argv[i][0] != '-' || argv[i][1] != '-') { std::string errorMsg; - int numHandled = posArgCallback([](const std::string& k, const std::string& v) - { - MetaData::tree()[k] = v; - }, seenKeys, errorMsg, - argc, argv, i, numPositionalParams); + int numHandled = posArgCallback([](const std::string& k, const std::string& v) { MetaData::tree()[k] = v; }, + seenKeys, + errorMsg, + argc, + argv, + i, + numPositionalParams); if (numHandled < 1) { if (!helpPreamble.empty()) { @@ -674,8 +669,7 @@ std::string parseCommandLineOptions(int argc, } return errorMsg; - } - else { + } else { ++numPositionalParams; i += numHandled - 1; continue; @@ -691,8 +685,7 @@ std::string parseCommandLineOptions(int argc, // There is nothing after the '-' if (argv[i][2] == 0 || !std::isalpha(argv[i][2])) { std::ostringstream oss; - oss << "Parameter name of argument " << i - << " ('" << argv[i] << "') " + oss << "Parameter name of argument " << i << " ('" << argv[i] << "') " << "is invalid because it does not start with a letter."; if (!helpPreamble.empty()) { @@ -708,9 +701,9 @@ std::string parseCommandLineOptions(int argc, // parse argument paramName = transformKey(parseKey(s), /*capitalizeFirst=*/true); if (seenKeys.count(paramName) > 0) { - const std::string msg = "Parameter '" + paramName + - "' specified multiple times as a " - "command line parameter"; + const std::string msg = "Parameter '" + paramName + + "' specified multiple times as a " + "command line parameter"; if (!helpPreamble.empty()) { printUsage(helpPreamble, std::cerr, msg); @@ -720,9 +713,10 @@ std::string parseCommandLineOptions(int argc, seenKeys.insert(paramName); if (s.empty() || s[0] != '=') { - const std::string msg = "Parameter '" + paramName + - "' is missing a value. " - " Please use " + argv[i] + "=value."; + const std::string msg = "Parameter '" + paramName + + "' is missing a value. " + " Please use " + + argv[i] + "=value."; if (!helpPreamble.empty()) { printUsage(helpPreamble, std::cerr, msg); @@ -738,7 +732,8 @@ std::string parseCommandLineOptions(int argc, return ""; } -void printValues(std::ostream& os) +void +printValues(std::ostream& os) { std::vector runTimeAllKeyList; std::vector runTimeKeyList; @@ -749,8 +744,7 @@ void printValues(std::ostream& os) if (MetaData::registry().find(key) == MetaData::registry().end()) { // key was not registered by the program! unknownKeyList.push_back(key); - } - else { + } else { // the key was specified at run-time runTimeKeyList.push_back(key); } @@ -787,42 +781,41 @@ void printValues(std::ostream& os) } } -bool printUnused(std::ostream& os) +bool +printUnused(std::ostream& os) { std::vector runTimeAllKeyList; std::vector unknownKeyList; getFlattenedKeyList(runTimeAllKeyList, MetaData::tree()); - std::copy_if(runTimeAllKeyList.begin(), runTimeAllKeyList.end(), + std::copy_if(runTimeAllKeyList.begin(), + runTimeAllKeyList.end(), std::back_inserter(unknownKeyList), - [](const auto& key) - { - return MetaData::registry().find(key) == MetaData::registry().end(); - }); + [](const auto& key) { return MetaData::registry().find(key) == MetaData::registry().end(); }); if (!unknownKeyList.empty()) { os << "# [unused run-time specified parameters]\n"; for (const auto& unused : unknownKeyList) { - os << unused << "=\"" - << MetaData::tree().get(unused, "") << "\"\n" << std::flush; + os << unused << "=\"" << MetaData::tree().get(unused, "") << "\"\n" << std::flush; } return true; } return false; } -namespace detail { +namespace detail +{ -template bool Get_(const std::string&, bool, bool); -template double Get_(const std::string&, double, bool); -template float Get_(const std::string&, float, bool); -template int Get_(const std::string&, int, bool); -template long Get_(const std::string&, long, bool); -template std::string Get_(const std::string&, std::string, bool); -template unsigned Get_(const std::string&, unsigned, bool); + template bool Get_(const std::string&, bool, bool); + template double Get_(const std::string&, double, bool); + template float Get_(const std::string&, float, bool); + template int Get_(const std::string&, int, bool); + template long Get_(const std::string&, long, bool); + template std::string Get_(const std::string&, std::string, bool); + template unsigned Get_(const std::string&, unsigned, bool); #if HAVE_QUAD -template quad Get_(const std::string&, quad, bool); + template quad Get_(const std::string&, quad, bool); #endif } // namespace detail diff --git a/opm/models/utils/parametersystem.hpp b/opm/models/utils/parametersystem.hpp index 1e4a4ddfc5a..2e73dbeae4c 100644 --- a/opm/models/utils/parametersystem.hpp +++ b/opm/models/utils/parametersystem.hpp @@ -42,56 +42,57 @@ #include #include -namespace Opm::Parameters { +namespace Opm::Parameters +{ -namespace detail { +namespace detail +{ -template -struct has_name : public std::false_type {}; + template + struct has_name : public std::false_type { + }; -template -struct has_name().name)>> -: public std::true_type {}; + template + struct has_name().name)>> : public std::true_type { + }; -//! get the name data member of a parameter -template -auto getParamName() -{ - if constexpr (has_name::value) { - return Parameter::name; - } else { - std::string paramName = Dune::className(); - paramName.replace(0, std::strlen("Opm::Parameters::"), ""); - const auto pos = paramName.find_first_of('<'); - if (pos != std::string::npos) { - paramName.erase(pos); + //! get the name data member of a parameter + template + auto getParamName() + { + if constexpr (has_name::value) { + return Parameter::name; + } else { + std::string paramName = Dune::className(); + paramName.replace(0, std::strlen("Opm::Parameters::"), ""); + const auto pos = paramName.find_first_of('<'); + if (pos != std::string::npos) { + paramName.erase(pos); + } + return paramName; } - return paramName; } -} -//! \brief Private implementation. -template -ParamType Get_(const std::string& paramName, ParamType defaultValue, - bool errorIfNotRegistered); + //! \brief Private implementation. + template + ParamType Get_(const std::string& paramName, ParamType defaultValue, bool errorIfNotRegistered); -//! \brief Private implementation. -void Hide_(const std::string& paramName); + //! \brief Private implementation. + void Hide_(const std::string& paramName); -//! \brief Private implementation. -bool IsSet_(const std::string& paramName, bool errorIfNotRegistered); + //! \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 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); + //! \brief Private implementation. + void SetDefault_(const std::string& paramName, const std::string& paramValue); -} +} // namespace detail //! \endcond @@ -111,8 +112,7 @@ void printUsage(const std::string& helpPreamble, const bool showAll = false); //! \brief Callback function for command line parsing. -using PositionalArgumentCallback = std::function, +using PositionalArgumentCallback = std::function, std::set&, std::string&, int, @@ -136,11 +136,10 @@ using PositionalArgumentCallback = std::function -auto Get(bool errorIfNotRegistered = true) +auto +Get(bool errorIfNotRegistered = true) { - using ParamType = std::conditional_t, std::string, + using ParamType = std::conditional_t, + std::string, std::remove_const_t>; ParamType defaultValue = Param::value; - return detail::Get_(detail::getParamName(), - defaultValue, errorIfNotRegistered); + return detail::Get_(detail::getParamName(), defaultValue, errorIfNotRegistered); } /*! @@ -209,7 +208,8 @@ auto Get(bool errorIfNotRegistered = true) * \endcode */ template -void SetDefault(decltype(Param::value) new_value) +void +SetDefault(decltype(Param::value) new_value) { const std::string paramName = detail::getParamName(); std::ostringstream oss; @@ -220,11 +220,12 @@ void SetDefault(decltype(Param::value) new_value) /*! * \brief A struct holding the key-value pair for a parameter. */ -struct Parameter -{ +struct Parameter { Parameter(const std::string& k, const std::string& v) - : key(k), value(v) - {} + : key(k) + , value(v) + { + } friend std::ostream& operator<<(std::ostream& os, const Parameter& param) { @@ -234,11 +235,10 @@ struct Parameter bool operator==(const Parameter& setting) const { - return setting.key == key - && setting.value == value; + return setting.key == key && setting.value == value; } - bool operator !=(const Parameter& setting) const + bool operator!=(const Parameter& setting) const { return !(*this == setting); } @@ -252,8 +252,7 @@ struct Parameter * The two arguments besides the TypeTag are assumed to be STL containers which store * std::pair. */ -void getLists(std::vector& usedParams, - std::vector& unusedParams); +void getLists(std::vector& usedParams, std::vector& unusedParams); /*! * \brief Reset parameter system. @@ -267,7 +266,8 @@ void reset(); * If the parameter in question has not been registered, this throws an exception. */ template -bool IsSet(bool errorIfNotRegistered = true) +bool +IsSet(bool errorIfNotRegistered = true) { return detail::IsSet_(detail::getParamName(), errorIfNotRegistered); } @@ -289,12 +289,13 @@ bool IsSet(bool errorIfNotRegistered = true) * \endcode */ template -void Register(const char* usageString) +void +Register(const char* usageString) { const std::string paramName = detail::getParamName(); const auto defaultValue = Param::value; - using ParamType = std::conditional_t, std::string, + using ParamType = std::conditional_t, + std::string, std::remove_const_t>; std::ostringstream oss; @@ -308,7 +309,8 @@ void Register(const char* usageString) * This allows to deal with unused parameters */ template -void Hide() +void +Hide() { detail::Hide_(detail::getParamName()); } diff --git a/opm/models/utils/simulatorutils.cpp b/opm/models/utils/simulatorutils.cpp index 499cc13a2f1..c64cb8969b2 100644 --- a/opm/models/utils/simulatorutils.cpp +++ b/opm/models/utils/simulatorutils.cpp @@ -40,9 +40,11 @@ #include #endif -namespace Opm { +namespace Opm +{ -std::string humanReadableTime(double timeInSeconds, bool isAmendment) +std::string +humanReadableTime(double timeInSeconds, bool isAmendment) { std::ostringstream oss; oss << std::setprecision(4); @@ -51,62 +53,42 @@ std::string humanReadableTime(double timeInSeconds, bool isAmendment) } if (timeInSeconds >= 365.25 * 24 * 60 * 60) { int years = static_cast(timeInSeconds / (365.25 * 24 * 60 * 60)); - int days = static_cast((timeInSeconds - years*(365.25 * 24 * 60 * 60)) / (24 * 60 * 60)); + int days = static_cast((timeInSeconds - years * (365.25 * 24 * 60 * 60)) / (24 * 60 * 60)); constexpr double accuracy = 1e-2; - double hours = - std::round(1.0 / accuracy * - (timeInSeconds - - years * (365.25 * 24 * 60 * 60) - - days * (24 * 60 * 60)) / (60 * 60)) - *accuracy; - - oss << years << " years, " << days << " days, " << hours << " hours"; - } - else if (timeInSeconds >= 24.0 * 60 * 60) { + double hours + = std::round(1.0 / accuracy * (timeInSeconds - years * (365.25 * 24 * 60 * 60) - days * (24 * 60 * 60)) + / (60 * 60)) + * accuracy; + + oss << years << " years, " << days << " days, " << hours << " hours"; + } else if (timeInSeconds >= 24.0 * 60 * 60) { int days = static_cast(timeInSeconds / (24 * 60 * 60)); int hours = static_cast((timeInSeconds - days * (24 * 60 * 60)) / (60 * 60)); constexpr double accuracy = 1e-2; - double minutes = - std::round(1.0 / accuracy * - (timeInSeconds - - days * (24 * 60 * 60) - - hours * (60 * 60)) / 60) - *accuracy; + double minutes + = std::round(1.0 / accuracy * (timeInSeconds - days * (24 * 60 * 60) - hours * (60 * 60)) / 60) * accuracy; oss << days << " days, " << hours << " hours, " << minutes << " minutes"; - } - else if (timeInSeconds >= 60.0 * 60) { + } else if (timeInSeconds >= 60.0 * 60) { int hours = static_cast(timeInSeconds / (60 * 60)); int minutes = static_cast((timeInSeconds - hours * (60 * 60)) / 60); constexpr double accuracy = 1e-2; - double seconds = - std::round(1.0 / accuracy * - (timeInSeconds - - hours * (60 * 60) - - minutes * 60)) - * accuracy; + double seconds = std::round(1.0 / accuracy * (timeInSeconds - hours * (60 * 60) - minutes * 60)) * accuracy; - oss << hours << " hours, " << minutes << " minutes, " << seconds << " seconds"; - } - else if (timeInSeconds >= 60.0) { + oss << hours << " hours, " << minutes << " minutes, " << seconds << " seconds"; + } else if (timeInSeconds >= 60.0) { int minutes = static_cast(timeInSeconds / 60); constexpr double accuracy = 1e-3; - double seconds = - std::round(1.0 / accuracy * - (timeInSeconds - - minutes * 60)) - * accuracy; + double seconds = std::round(1.0 / accuracy * (timeInSeconds - minutes * 60)) * accuracy; - oss << minutes << " minutes, " << seconds << " seconds"; - } - else if (!isAmendment) { + oss << minutes << " minutes, " << seconds << " seconds"; + } else if (!isAmendment) { oss << timeInSeconds << " seconds"; - } - else { + } else { return ""; } if (isAmendment) { @@ -116,7 +98,8 @@ std::string humanReadableTime(double timeInSeconds, bool isAmendment) return oss.str(); } -std::string simulatorOutputDir() +std::string +simulatorOutputDir() { std::string outputDir = Parameters::Get(); @@ -127,23 +110,21 @@ std::string simulatorOutputDir() // TODO: replace this by std::filesystem once we require c++-2017 struct stat st; if (::stat(outputDir.c_str(), &st) != 0) - throw std::runtime_error("Could not access output directory '" + outputDir + "':" + - strerror(errno)); + throw std::runtime_error("Could not access output directory '" + outputDir + "':" + strerror(errno)); if (!S_ISDIR(st.st_mode)) { - throw std::runtime_error("Path to output directory '" +outputDir + - "' exists but is not a directory"); + throw std::runtime_error("Path to output directory '" + outputDir + "' exists but is not a directory"); } if (access(outputDir.c_str(), W_OK) != 0) { - throw std::runtime_error("Output directory '" + outputDir + - "' exists but is not writeable"); + throw std::runtime_error("Output directory '" + outputDir + "' exists but is not writeable"); } return outputDir; } -template -std::vector readTimeStepFile(const std::string& file) +template +std::vector +readTimeStepFile(const std::string& file) { std::ifstream is(file); std::vector result; diff --git a/opm/models/utils/simulatorutils.hpp b/opm/models/utils/simulatorutils.hpp index 73365f70477..da7df675503 100644 --- a/opm/models/utils/simulatorutils.hpp +++ b/opm/models/utils/simulatorutils.hpp @@ -27,14 +27,15 @@ #include #include -namespace Opm { +namespace Opm +{ /*! -* \brief Given a time step size in seconds, return it in a format which is more -* easily parsable by humans. -* -* e.g. 874000.0 will become "10.12 days" -*/ + * \brief Given a time step size in seconds, return it in a format which is more + * easily parsable by humans. + * + * e.g. 874000.0 will become "10.12 days" + */ std::string humanReadableTime(double timeInSeconds, bool isAmendment = true); /*! @@ -46,7 +47,7 @@ std::string simulatorOutputDir(); * \brief Read explicitly defined time steps from file. * \param file File to read */ -template +template std::vector readTimeStepFile(const std::string& file); } // namespace Opm diff --git a/opm/models/utils/terminal.cpp b/opm/models/utils/terminal.cpp index 6ccc6e0d755..b800cd59cbc 100644 --- a/opm/models/utils/terminal.cpp +++ b/opm/models/utils/terminal.cpp @@ -30,22 +30,22 @@ #include #include -#include // strsignal() +#include // strsignal() #include #include -namespace Opm { +namespace Opm +{ -std::string breakLines(const std::string& msg, - int indentWidth, - int maxWidth) +std::string +breakLines(const std::string& msg, int indentWidth, int maxWidth) { std::string result; int startInPos = 0; int inPos = 0; int lastBreakPos = 0; int ttyPos = 0; - for (; inPos < int(msg.size()); ++ inPos, ++ ttyPos) { + for (; inPos < int(msg.size()); ++inPos, ++ttyPos) { if (msg[inPos] == '\n') { result += msg.substr(startInPos, inPos - startInPos + 1); startInPos = inPos + 1; @@ -66,8 +66,7 @@ std::string breakLines(const std::string& msg, startInPos = lastBreakPos + 1; lastBreakPos = startInPos; inPos = startInPos; - } - else { + } else { result += msg.substr(startInPos, inPos - startInPos); startInPos = inPos; lastBreakPos = startInPos; @@ -87,9 +86,10 @@ std::string breakLines(const std::string& msg, return result; } -int getTtyWidth() +int +getTtyWidth() { - int ttyWidth = 10*1000; // effectively do not break lines at all. + int ttyWidth = 10 * 1000; // effectively do not break lines at all. if (isatty(STDOUT_FILENO)) { #if defined TIOCGWINSZ // This is a bit too linux specific, IMO. let's do it anyway @@ -105,7 +105,8 @@ int getTtyWidth() return ttyWidth; } -void assignResetTerminalSignalHandlers() +void +assignResetTerminalSignalHandlers() { // set the signal handlers to reset the TTY to a well defined state on unexpected // program aborts @@ -120,7 +121,8 @@ void assignResetTerminalSignalHandlers() } } -void resetTerminal() +void +resetTerminal() { // make sure stderr and stderr do not contain any unwritten data and make sure that // the TTY does not see any unfinished ANSI escape sequence. @@ -131,7 +133,7 @@ void resetTerminal() // it seems like some terminals sometimes takes their time to react, so let's // accommodate them. - usleep(/*usec=*/500*1000); + usleep(/*usec=*/500 * 1000); // this requires the 'stty' command to be available in the command search path. on // most linux systems, is the case. (but even if the system() function fails, the @@ -142,7 +144,8 @@ void resetTerminal() } } -void resetTerminal(int signum) +void +resetTerminal(int signum) { // first thing to do when a nuke hits: restore the default signal handler signal(signum, SIG_DFL); @@ -159,8 +162,7 @@ void resetTerminal(int signum) #endif if (isatty(fileno(stdout)) && isatty(fileno(stdin))) { - std::cout << "\n\nReceived signal " << signum - << " (\"" << strsignal(signum) << "\")." + std::cout << "\n\nReceived signal " << signum << " (\"" << strsignal(signum) << "\")." << " Trying to reset the terminal.\n"; resetTerminal(); diff --git a/opm/models/utils/terminal.hpp b/opm/models/utils/terminal.hpp index fe8c91cc032..2eeb617c5bf 100644 --- a/opm/models/utils/terminal.hpp +++ b/opm/models/utils/terminal.hpp @@ -25,7 +25,8 @@ #include -namespace Opm { +namespace Opm +{ /*! * \brief Break up a string in lines suitable for terminal output. @@ -34,9 +35,7 @@ namespace Opm { * \param maxWidth Maximum with of terminal * \return */ -std::string breakLines(const std::string& msg, - int indentWidth, - int maxWidth); +std::string breakLines(const std::string& msg, int indentWidth, int maxWidth); /*! * \brief Get the width of the tty we are attached to. diff --git a/opm/models/utils/timer.cpp b/opm/models/utils/timer.cpp index 77f6f631d42..e2e3bdadbb5 100644 --- a/opm/models/utils/timer.cpp +++ b/opm/models/utils/timer.cpp @@ -28,9 +28,11 @@ #include #endif -namespace Opm { +namespace Opm +{ -void Timer::TimeData::measure() +void +Timer::TimeData::measure() { // Note: On Linux -- or rather fully POSIX compliant systems -- using // clock_gettime() would be more accurate for the CPU time. @@ -43,13 +45,15 @@ Timer::Timer() halt(); } -void Timer::start() +void +Timer::start() { isStopped_ = false; startTime_.measure(); } -double Timer::stop() +double +Timer::stop() { if (!isStopped_) { TimeData stopTime; @@ -58,13 +62,10 @@ double Timer::stop() const auto& t1 = startTime_.realtimeData; const auto& t2 = stopTime.realtimeData; - std::chrono::duration dt = - std::chrono::duration_cast >(t2 - t1); + std::chrono::duration dt = std::chrono::duration_cast>(t2 - t1); realTimeElapsed_ += dt.count(); - cpuTimeElapsed_ += - static_cast(stopTime.cputimeData - - startTime_.cputimeData)/CLOCKS_PER_SEC; + cpuTimeElapsed_ += static_cast(stopTime.cputimeData - startTime_.cputimeData) / CLOCKS_PER_SEC; } isStopped_ = true; @@ -72,14 +73,16 @@ double Timer::stop() return realTimeElapsed_; } -void Timer::halt() +void +Timer::halt() { isStopped_ = true; cpuTimeElapsed_ = 0.0; realTimeElapsed_ = 0.0; } -void Timer::reset() +void +Timer::reset() { cpuTimeElapsed_ = 0.0; realTimeElapsed_ = 0.0; @@ -87,7 +90,8 @@ void Timer::reset() startTime_.measure(); } -double Timer::realTimeElapsed() const +double +Timer::realTimeElapsed() const { if (isStopped_) return realTimeElapsed_; @@ -98,13 +102,13 @@ double Timer::realTimeElapsed() const const auto& t1 = startTime_.realtimeData; const auto& t2 = stopTime.realtimeData; - std::chrono::duration dt = - std::chrono::duration_cast >(t2 - t1); + std::chrono::duration dt = std::chrono::duration_cast>(t2 - t1); return realTimeElapsed_ + dt.count(); } -double Timer::cpuTimeElapsed() const +double +Timer::cpuTimeElapsed() const { if (isStopped_) return cpuTimeElapsed_; @@ -116,10 +120,11 @@ double Timer::cpuTimeElapsed() const const auto& t1 = startTime_.cputimeData; const auto& t2 = stopTime.cputimeData; - return cpuTimeElapsed_ + static_cast(t2 - t1)/CLOCKS_PER_SEC; + return cpuTimeElapsed_ + static_cast(t2 - t1) / CLOCKS_PER_SEC; } -double Timer::globalCpuTimeElapsed() const +double +Timer::globalCpuTimeElapsed() const { double val = cpuTimeElapsed(); double globalVal = val; @@ -137,7 +142,8 @@ double Timer::globalCpuTimeElapsed() const return globalVal; } -Timer& Timer::operator+=(const Timer& other) +Timer& +Timer::operator+=(const Timer& other) { realTimeElapsed_ += other.realTimeElapsed(); cpuTimeElapsed_ += other.cpuTimeElapsed(); diff --git a/opm/models/utils/timer.hpp b/opm/models/utils/timer.hpp index 689209c665a..bdb87a3d026 100644 --- a/opm/models/utils/timer.hpp +++ b/opm/models/utils/timer.hpp @@ -30,7 +30,8 @@ #include -namespace Opm { +namespace Opm +{ /*! * \ingroup Common @@ -44,8 +45,7 @@ namespace Opm { */ class Timer { - struct TimeData - { + struct TimeData { std::chrono::high_resolution_clock::time_point realtimeData; std::clock_t cputimeData; @@ -90,7 +90,9 @@ class Timer * Its main purpose is to make the API of the class a superset of Dune::Timer */ double elapsed() const - { return realTimeElapsed(); } + { + return realTimeElapsed(); + } /*! * \brief Return the CPU time [s] used by all threads of the local process for the diff --git a/opm/simulators/aquifers/AquiferAnalytical.hpp b/opm/simulators/aquifers/AquiferAnalytical.hpp index 278705db899..7532a8287f6 100644 --- a/opm/simulators/aquifers/AquiferAnalytical.hpp +++ b/opm/simulators/aquifers/AquiferAnalytical.hpp @@ -88,9 +88,7 @@ class AquiferAnalytical : public AquiferInterface BlackoilIndices::numPhases>; // Constructor - AquiferAnalytical(const int aqID, - const std::vector& connections, - const Simulator& simulator) + AquiferAnalytical(const int aqID, const std::vector& connections, const Simulator& simulator) : AquiferInterface(aqID, simulator) , connections_(connections) { @@ -99,22 +97,18 @@ class AquiferAnalytical : public AquiferInterface void computeFaceAreaFraction(const std::vector& total_face_area) override { - assert (total_face_area.size() >= static_cast::size_type>(this->aquiferID())); + assert(total_face_area.size() >= static_cast::size_type>(this->aquiferID())); const auto tfa = total_face_area[this->aquiferID() - 1]; const auto eps_sqrt = std::sqrt(std::numeric_limits::epsilon()); if (tfa < eps_sqrt) { - this->alphai_.assign(this->size(), Scalar{0}); - } - else { + this->alphai_.assign(this->size(), Scalar {0}); + } else { std::transform(this->faceArea_connected_.begin(), this->faceArea_connected_.end(), this->alphai_.begin(), - [tfa](const Scalar area) - { - return area / tfa; - }); + [tfa](const Scalar area) { return area / tfa; }); } this->area_fraction_ = this->totalFaceArea() / tfa; @@ -166,9 +160,7 @@ class AquiferAnalytical : public AquiferInterface this->simulator_.vanguard().grid().comm()); } - void addToSource(RateVector& rates, - const unsigned cellIdx, - const unsigned timeIdx) override + void addToSource(RateVector& rates, const unsigned cellIdx, const unsigned timeIdx) override { const auto& model = this->simulator_.model(); @@ -182,13 +174,11 @@ class AquiferAnalytical : public AquiferInterface this->updateCellPressure(this->pressure_current_, idx, intQuants); this->calculateInflowRate(idx, this->simulator_); - rates[BlackoilIndices::conti0EqIdx + compIdx_()] - += this->Qai_[idx] / model.dofTotalVolume(cellIdx); + rates[BlackoilIndices::conti0EqIdx + compIdx_()] += this->Qai_[idx] / model.dofTotalVolume(cellIdx); if constexpr (enableEnergy) { auto fs = intQuants.fluidState(); - if (this->Ta0_.has_value() && this->Qai_[idx] > 0) - { + if (this->Ta0_.has_value() && this->Qai_[idx] > 0) { fs.setTemperature(this->Ta0_.value()); typedef typename std::decay::type::Scalar FsScalar; typename FluidSystem::template ParameterCache paramCache; @@ -198,9 +188,9 @@ class AquiferAnalytical : public AquiferInterface const auto& h = FluidSystem::enthalpy(fs, paramCache, this->phaseIdx_()); fs.setEnthalpy(this->phaseIdx_(), h); } - rates[BlackoilIndices::contiEnergyEqIdx] - += this->Qai_[idx] *fs.enthalpy(this->phaseIdx_()) * FluidSystem::referenceDensity( this->phaseIdx_(), intQuants.pvtRegionIndex()) / model.dofTotalVolume(cellIdx); - + rates[BlackoilIndices::contiEnergyEqIdx] += this->Qai_[idx] * fs.enthalpy(this->phaseIdx_()) + * FluidSystem::referenceDensity(this->phaseIdx_(), intQuants.pvtRegionIndex()) + / model.dofTotalVolume(cellIdx); } } @@ -209,7 +199,7 @@ class AquiferAnalytical : public AquiferInterface return this->connections_.size(); } - template + template void serializeOp(Serializer& serializer) { serializer(pressure_previous_); @@ -221,11 +211,8 @@ class AquiferAnalytical : public AquiferInterface bool operator==(const AquiferAnalytical& rhs) const { - return this->pressure_previous_ == rhs.pressure_previous_ && - this->pressure_current_ == rhs.pressure_current_ && - this->Qai_ == rhs.Qai_ && - this->rhow_ == rhs.rhow_ && - this->W_flux_ == rhs.W_flux_; + return this->pressure_previous_ == rhs.pressure_previous_ && this->pressure_current_ == rhs.pressure_current_ + && this->Qai_ == rhs.Qai_ && this->rhow_ == rhs.rhow_ && this->W_flux_ == rhs.W_flux_; } protected: @@ -251,30 +238,26 @@ class AquiferAnalytical : public AquiferInterface void initQuantities() { // We reset the cumulative flux at the start of any simulation, so, W_flux = 0 - if (! this->solution_set_from_restart_) { - W_flux_ = Scalar{0}; + if (!this->solution_set_from_restart_) { + W_flux_ = Scalar {0}; } this->initializeConnectionDepths(); this->calculateAquiferCondition(); this->calculateAquiferConstants(); - this->pressure_previous_.resize(this->size(), Scalar{0}); - this->pressure_current_.resize(this->size(), Scalar{0}); - this->Qai_.resize(this->size(), Scalar{0}); + this->pressure_previous_.resize(this->size(), Scalar {0}); + this->pressure_current_.resize(this->size(), Scalar {0}); + this->Qai_.resize(this->size(), Scalar {0}); } - void updateCellPressure(std::vector& pressure_water, - const int idx, - const IntensiveQuantities& intQuants) + void updateCellPressure(std::vector& pressure_water, const int idx, const IntensiveQuantities& intQuants) { const auto& fs = intQuants.fluidState(); pressure_water.at(idx) = fs.pressure(this->phaseIdx_()); } - void updateCellPressure(std::vector& pressure_water, - const int idx, - const IntensiveQuantities& intQuants) + void updateCellPressure(std::vector& pressure_water, const int idx, const IntensiveQuantities& intQuants) { const auto& fs = intQuants.fluidState(); pressure_water.at(idx) = fs.pressure(this->phaseIdx_()).value(); @@ -283,10 +266,10 @@ class AquiferAnalytical : public AquiferInterface void initializeConnectionMappings() { this->alphai_.resize(this->size(), 1.0); - this->faceArea_connected_.resize(this->size(), Scalar{0}); + this->faceArea_connected_.resize(this->size(), Scalar {0}); // total_face_area_ is the sum of the areas connected to an aquifer - this->total_face_area_ = Scalar{0}; + this->total_face_area_ = Scalar {0}; this->cellToConnectionIdx_.resize(this->simulator_.gridView().size(/*codim=*/0), -1); const auto& gridView = this->simulator_.vanguard().gridView(); for (std::size_t idx = 0; idx < this->size(); ++idx) { @@ -296,7 +279,7 @@ class AquiferAnalytical : public AquiferInterface continue; } - auto elemIt = gridView.template begin(); + auto elemIt = gridView.template begin(); std::advance(elemIt, cell_index); // The global_index is not part of this grid @@ -323,7 +306,7 @@ class AquiferAnalytical : public AquiferInterface for (const auto& intersection : intersections(gridView, elem)) { // Only deal with grid boundaries - if (! intersection.boundary()) { + if (!intersection.boundary()) { continue; } @@ -347,8 +330,7 @@ class AquiferAnalytical : public AquiferInterface faceDirection = FaceDir::ZPlus; break; default: - OPM_THROW(std::logic_error, - "Internal error in initialization of aquifer."); + OPM_THROW(std::logic_error, "Internal error in initialization of aquifer."); } if (faceDirection == this->connections_[idx].face_dir) { @@ -367,13 +349,12 @@ class AquiferAnalytical : public AquiferInterface const auto& gridView = this->simulator_.vanguard().gridView(); for (std::size_t idx = 0; idx < this->size(); ++idx) { - const int cell_index = this->simulator_.vanguard() - .compressedIndex(this->connections_[idx].global_index); + const int cell_index = this->simulator_.vanguard().compressedIndex(this->connections_[idx].global_index); if (cell_index < 0) { continue; } - auto elemIt = gridView.template begin(); + auto elemIt = gridView.template begin(); std::advance(elemIt, cell_index); // The global_index is not part of this grid @@ -409,19 +390,17 @@ class AquiferAnalytical : public AquiferInterface water_pressure_reservoir = fs.pressure(this->phaseIdx_()).value(); const auto water_density = fs.density(this->phaseIdx_()); - const auto gdz = - this->gravity_() * (this->cell_depth_[idx] - this->aquiferDepth()); + const auto gdz = this->gravity_() * (this->cell_depth_[idx] - this->aquiferDepth()); - pw_aquifer.push_back(this->alphai_[idx] * - (water_pressure_reservoir - water_density.value()*gdz)); + pw_aquifer.push_back(this->alphai_[idx] * (water_pressure_reservoir - water_density.value() * gdz)); } // We take the average of the calculated equilibrium pressures. const auto& comm = this->simulator_.vanguard().grid().comm(); Scalar vals[2]; - vals[0] = std::accumulate(this->alphai_.begin(), this->alphai_.end(), Scalar{0}); - vals[1] = std::accumulate(pw_aquifer.begin(), pw_aquifer.end(), Scalar{0}); + vals[0] = std::accumulate(this->alphai_.begin(), this->alphai_.end(), Scalar {0}); + vals[1] = std::accumulate(pw_aquifer.begin(), pw_aquifer.end(), Scalar {0}); comm.sum(vals, 2); @@ -441,18 +420,18 @@ class AquiferAnalytical : public AquiferInterface std::vector Qai_; std::vector alphai_; - Scalar Tc_{}; // Time constant - Scalar pa0_{}; // initial aquifer pressure - std::optional Ta0_{}; // initial aquifer temperature - Scalar rhow_{}; + Scalar Tc_ {}; // Time constant + Scalar pa0_ {}; // initial aquifer pressure + std::optional Ta0_ {}; // initial aquifer temperature + Scalar rhow_ {}; - Scalar total_face_area_{}; - Scalar area_fraction_{Scalar{1}}; + Scalar total_face_area_ {}; + Scalar area_fraction_ {Scalar {1}}; Eval W_flux_; bool solution_set_from_restart_ {false}; - bool has_active_connection_on_proc_{false}; + bool has_active_connection_on_proc_ {false}; }; } // namespace Opm diff --git a/opm/simulators/aquifers/AquiferCarterTracy.hpp b/opm/simulators/aquifers/AquiferCarterTracy.hpp index 2e27732e0af..d7602ce2bea 100644 --- a/opm/simulators/aquifers/AquiferCarterTracy.hpp +++ b/opm/simulators/aquifers/AquiferCarterTracy.hpp @@ -45,6 +45,7 @@ class AquiferCarterTracy : public AquiferAnalytical using typename Base::BlackoilIndices; using typename Base::ElementContext; + using typename Base::ElementMapper; using typename Base::Eval; using typename Base::FluidState; using typename Base::FluidSystem; @@ -52,14 +53,14 @@ class AquiferCarterTracy : public AquiferAnalytical using typename Base::RateVector; using typename Base::Scalar; using typename Base::Simulator; - using typename Base::ElementMapper; AquiferCarterTracy(const std::vector& connections, const Simulator& simulator, const AquiferCT::AQUCT_data& aquct_data) : Base(aquct_data.aquiferID, connections, simulator) , aquct_data_(aquct_data) - {} + { + } static AquiferCarterTracy serializationTestObject(const Simulator& simulator) { @@ -113,14 +114,15 @@ class AquiferCarterTracy : public AquiferAnalytical } else { aquCT->waterDensity = this->rhow_; aquCT->timeConstant = this->Tc_; - const auto x = this->aquct_data_.porosity * this->aquct_data_.total_compr * this->aquct_data_.inner_radius * this->aquct_data_.inner_radius; - aquCT->waterViscosity = this->Tc_ * this->aquct_data_.permeability / x; + const auto x = this->aquct_data_.porosity * this->aquct_data_.total_compr * this->aquct_data_.inner_radius + * this->aquct_data_.inner_radius; + aquCT->waterViscosity = this->Tc_ * this->aquct_data_.permeability / x; } return data; } - template + template void serializeOp(Serializer& serializer) { serializer(static_cast(*this)); @@ -131,10 +133,9 @@ class AquiferCarterTracy : public AquiferAnalytical bool operator==(const AquiferCarterTracy& rhs) const { - return static_cast&>(*this) == rhs && - this->fluxValue_ == rhs.fluxValue_ && - this->dimensionless_time_ == rhs.dimensionless_time_ && - this->dimensionless_pressure_ == rhs.dimensionless_pressure_; + return static_cast&>(*this) == rhs && this->fluxValue_ == rhs.fluxValue_ + && this->dimensionless_time_ == rhs.dimensionless_time_ + && this->dimensionless_pressure_ == rhs.dimensionless_pressure_; } protected: @@ -143,10 +144,10 @@ class AquiferCarterTracy : public AquiferAnalytical Scalar beta_; // Influx constant // TODO: it is possible it should be a AD variable - Scalar fluxValue_{0}; // value of flux + Scalar fluxValue_ {0}; // value of flux - Scalar dimensionless_time_{0}; - Scalar dimensionless_pressure_{0}; + Scalar dimensionless_time_ {0}; + Scalar dimensionless_pressure_ {0}; void assignRestartData(const data::AquiferData& xaq) override { @@ -154,50 +155,40 @@ class AquiferCarterTracy : public AquiferAnalytical this->rhow_ = this->aquct_data_.waterDensity(); } - std::pair - getInfluenceTableValues(const Scalar td_plus_dt) + std::pair getInfluenceTableValues(const Scalar td_plus_dt) { // We use the opm-common numeric linear interpolator - this->dimensionless_pressure_ = - linearInterpolation(this->aquct_data_.dimensionless_time, - this->aquct_data_.dimensionless_pressure, - this->dimensionless_time_); + this->dimensionless_pressure_ = linearInterpolation( + this->aquct_data_.dimensionless_time, this->aquct_data_.dimensionless_pressure, this->dimensionless_time_); - const auto PItd = - linearInterpolation(this->aquct_data_.dimensionless_time, - this->aquct_data_.dimensionless_pressure, - td_plus_dt); + const auto PItd = linearInterpolation( + this->aquct_data_.dimensionless_time, this->aquct_data_.dimensionless_pressure, td_plus_dt); - const auto PItdprime = - linearInterpolationDerivative(this->aquct_data_.dimensionless_time, - this->aquct_data_.dimensionless_pressure, - td_plus_dt); + const auto PItdprime = linearInterpolationDerivative( + this->aquct_data_.dimensionless_time, this->aquct_data_.dimensionless_pressure, td_plus_dt); return std::make_pair(PItd, PItdprime); } Scalar dpai(const int idx) const { - const auto gdz = - this->gravity_() * (this->cell_depth_.at(idx) - this->aquiferDepth()); + const auto gdz = this->gravity_() * (this->cell_depth_.at(idx) - this->aquiferDepth()); - const auto dp = this->pa0_ + this->rhow_*gdz - - this->pressure_previous_.at(idx); + const auto dp = this->pa0_ + this->rhow_ * gdz - this->pressure_previous_.at(idx); return dp; } // This function implements Eqs 5.8 and 5.9 of the EclipseTechnicalDescription - std::pair - calculateEqnConstants(const int idx, const Simulator& simulator) + std::pair calculateEqnConstants(const int idx, const Simulator& simulator) { const Scalar td_plus_dt = (simulator.timeStepSize() + simulator.time()) / this->Tc_; this->dimensionless_time_ = simulator.time() / this->Tc_; const auto [PItd, PItdprime] = this->getInfluenceTableValues(td_plus_dt); - const auto denom = this->Tc_ * (PItd - this->dimensionless_time_*PItdprime); - const auto a = (this->beta_*dpai(idx) - this->fluxValue_*PItdprime) / denom; + const auto denom = this->Tc_ * (PItd - this->dimensionless_time_ * PItdprime); + const auto a = (this->beta_ * dpai(idx) - this->fluxValue_ * PItdprime) / denom; const auto b = this->beta_ / denom; return std::make_pair(a, b); @@ -213,15 +204,13 @@ class AquiferCarterTracy : public AquiferAnalytical { const auto [a, b] = this->calculateEqnConstants(idx, simulator); - this->Qai_.at(idx) = this->alphai_.at(idx) * - (a - b*(this->pressure_current_.at(idx) - this->pressure_previous_.at(idx))); + this->Qai_.at(idx) + = this->alphai_.at(idx) * (a - b * (this->pressure_current_.at(idx) - this->pressure_previous_.at(idx))); } void calculateAquiferConstants() override { - this->Tc_ = this->co2store_or_h2store_() - ? this->timeConstantCO2Store() - : this->aquct_data_.timeConstant(); + this->Tc_ = this->co2store_or_h2store_() ? this->timeConstantCO2Store() : this->aquct_data_.timeConstant(); this->beta_ = this->aquct_data_.influxConstant(); } @@ -232,12 +221,10 @@ class AquiferCarterTracy : public AquiferAnalytical return; } - if (! this->aquct_data_.initial_pressure.has_value()) { - this->aquct_data_.initial_pressure = - this->calculateReservoirEquilibrium(); + if (!this->aquct_data_.initial_pressure.has_value()) { + this->aquct_data_.initial_pressure = this->calculateReservoirEquilibrium(); - const auto& tables = this->simulator_.vanguard() - .eclState().getTableManager(); + const auto& tables = this->simulator_.vanguard().eclState().getTableManager(); this->aquct_data_.finishInitialisation(tables); } @@ -247,9 +234,7 @@ class AquiferCarterTracy : public AquiferAnalytical this->Ta0_ = this->aquct_data_.initial_temperature.value(); } - this->rhow_ = this->co2store_or_h2store_() - ? this->waterDensityCO2Store() - : this->aquct_data_.waterDensity(); + this->rhow_ = this->co2store_or_h2store_() ? this->waterDensityCO2Store() : this->aquct_data_.waterDensity(); } Scalar aquiferDepth() const override @@ -263,24 +248,20 @@ class AquiferCarterTracy : public AquiferAnalytical const Scalar press = this->aquct_data_.initial_pressure.value(); const auto temp = this->reservoirTemperatureCO2Store(); - auto waterViscosity = Scalar { 0 }; + auto waterViscosity = Scalar {0}; if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)) { - const auto rs = Scalar { 0 }; // no dissolved CO2 - waterViscosity = FluidSystem::oilPvt() - .viscosity(pvtRegionIdx(), temp, press, rs); - } - else if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) { - const auto salt = Scalar { 0 }; - const auto rsw = Scalar { 0 }; - waterViscosity = FluidSystem::waterPvt() - .viscosity(pvtRegionIdx(), temp, press, rsw, salt); - } - else { + const auto rs = Scalar {0}; // no dissolved CO2 + waterViscosity = FluidSystem::oilPvt().viscosity(pvtRegionIdx(), temp, press, rs); + } else if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) { + const auto salt = Scalar {0}; + const auto rsw = Scalar {0}; + waterViscosity = FluidSystem::waterPvt().viscosity(pvtRegionIdx(), temp, press, rsw, salt); + } else { OPM_THROW(std::runtime_error, "water or oil phase is needed to run CO2Store."); } - const auto x = this->aquct_data_.porosity * this->aquct_data_.total_compr - * this->aquct_data_.inner_radius * this->aquct_data_.inner_radius; + const auto x = this->aquct_data_.porosity * this->aquct_data_.total_compr * this->aquct_data_.inner_radius + * this->aquct_data_.inner_radius; return waterViscosity * x / this->aquct_data_.permeability; } @@ -294,30 +275,25 @@ class AquiferCarterTracy : public AquiferAnalytical const auto& pvt = FluidSystem::oilPvt(); const auto reg = this->pvtRegionIdx(); - const auto rs = Scalar { 0 }; // no dissolved CO2 - return pvt.inverseFormationVolumeFactor(reg, temp, press, rs) - * pvt.oilReferenceDensity(reg); - } - else if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) { + const auto rs = Scalar {0}; // no dissolved CO2 + return pvt.inverseFormationVolumeFactor(reg, temp, press, rs) * pvt.oilReferenceDensity(reg); + } else if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) { const auto& pvt = FluidSystem::waterPvt(); const auto reg = this->pvtRegionIdx(); - const auto salinity = Scalar { 0 }; - const auto rsw = Scalar { 0 }; + const auto salinity = Scalar {0}; + const auto rsw = Scalar {0}; - return pvt.inverseFormationVolumeFactor(reg, temp, press, rsw, salinity) - * pvt.waterReferenceDensity(reg); - } - else { + return pvt.inverseFormationVolumeFactor(reg, temp, press, rsw, salinity) * pvt.waterReferenceDensity(reg); + } else { OPM_THROW(std::runtime_error, "water or oil phase is needed to run CO2Store."); } } Scalar reservoirTemperatureCO2Store() const { - return this->aquct_data_.initial_temperature.has_value() - ? this->aquct_data_.initial_temperature.value() - : FluidSystem::reservoirTemperature(); + return this->aquct_data_.initial_temperature.has_value() ? this->aquct_data_.initial_temperature.value() + : FluidSystem::reservoirTemperature(); } }; // class AquiferCarterTracy diff --git a/opm/simulators/aquifers/AquiferConstantFlux.hpp b/opm/simulators/aquifers/AquiferConstantFlux.hpp index cb8b9755d28..34d02d2c25a 100644 --- a/opm/simulators/aquifers/AquiferConstantFlux.hpp +++ b/opm/simulators/aquifers/AquiferConstantFlux.hpp @@ -32,9 +32,10 @@ #include #include -namespace Opm { +namespace Opm +{ -template +template class AquiferConstantFlux : public AquiferInterface { public: @@ -49,12 +50,12 @@ class AquiferConstantFlux : public AquiferInterface using Eval = DenseAd::Evaluation; AquiferConstantFlux(const std::vector& connections, - const Simulator& simulator, - const SingleAquiferFlux& aquifer) + const Simulator& simulator, + const SingleAquiferFlux& aquifer) : AquiferInterface(aquifer.id, simulator) - , connections_ (connections) - , aquifer_data_ (aquifer) - , connection_flux_ (connections_.size(), Eval{0}) + , connections_(connections) + , aquifer_data_(aquifer) + , connection_flux_(connections_.size(), Eval {0}) { this->total_face_area_ = this->initializeConnections(); } @@ -69,10 +70,9 @@ class AquiferConstantFlux : public AquiferInterface void computeFaceAreaFraction(const std::vector& total_face_area) override { - assert (total_face_area.size() >= static_cast::size_type>(this->aquiferID())); + assert(total_face_area.size() >= static_cast::size_type>(this->aquiferID())); - this->area_fraction_ = this->totalFaceArea() - / total_face_area[this->aquiferID() - 1]; + this->area_fraction_ = this->totalFaceArea() / total_face_area[this->aquiferID() - 1]; } Scalar totalFaceArea() const override @@ -96,16 +96,17 @@ class AquiferConstantFlux : public AquiferInterface } void initialSolutionApplied() override - {} + { + } void beginTimeStep() override - {} + { + } void endTimeStep() override { this->flux_rate_ = this->totalFluxRate(); - this->cumulative_flux_ += - this->flux_rate_ * this->simulator_.timeStepSize(); + this->cumulative_flux_ += this->flux_rate_ * this->simulator_.timeStepSize(); } data::AquiferData aquiferData() const override @@ -126,9 +127,7 @@ class AquiferConstantFlux : public AquiferInterface return data; } - void addToSource(RateVector& rates, - const unsigned cellIdx, - [[maybe_unused]] const unsigned timeIdx) override + void addToSource(RateVector& rates, const unsigned cellIdx, [[maybe_unused]] const unsigned timeIdx) override { const int idx = this->cellToConnectionIdx_[cellIdx]; if (idx < 0) { @@ -141,11 +140,10 @@ class AquiferConstantFlux : public AquiferInterface this->connection_flux_[idx] = fw * this->connections_[idx].effective_facearea; - rates[BlackoilIndices::conti0EqIdx + compIdx_()] - += this->connection_flux_[idx] / model.dofTotalVolume(cellIdx); + rates[BlackoilIndices::conti0EqIdx + compIdx_()] += this->connection_flux_[idx] / model.dofTotalVolume(cellIdx); } - template + template void serializeOp(Serializer& serializer) { serializer(cumulative_flux_); @@ -160,24 +158,22 @@ class AquiferConstantFlux : public AquiferInterface const std::vector& connections_; SingleAquiferFlux aquifer_data_; - std::vector connection_flux_{}; - std::vector cellToConnectionIdx_{}; - Scalar flux_rate_{}; - Scalar cumulative_flux_{}; - Scalar total_face_area_{0.0}; - Scalar area_fraction_{1.0}; + std::vector connection_flux_ {}; + std::vector cellToConnectionIdx_ {}; + Scalar flux_rate_ {}; + Scalar cumulative_flux_ {}; + Scalar total_face_area_ {0.0}; + Scalar area_fraction_ {1.0}; Scalar initializeConnections() { auto connected_face_area = 0.0; - this->cellToConnectionIdx_ - .resize(this->simulator_.gridView().size(/*codim=*/0), -1); + this->cellToConnectionIdx_.resize(this->simulator_.gridView().size(/*codim=*/0), -1); for (std::size_t idx = 0; idx < this->connections_.size(); ++idx) { const auto global_index = this->connections_[idx].global_index; - const int cell_index = this->simulator_.vanguard() - .compressedIndexForInterior(global_index); + const int cell_index = this->simulator_.vanguard().compressedIndexForInterior(global_index); if (cell_index < 0) { continue; @@ -197,12 +193,9 @@ class AquiferConstantFlux : public AquiferInterface Scalar computeFaceAreaFraction(const Scalar connected_face_area) const { - const auto tot_face_area = this->simulator_.vanguard() - .grid().comm().sum(connected_face_area); + const auto tot_face_area = this->simulator_.vanguard().grid().comm().sum(connected_face_area); - return (tot_face_area > 0.0) - ? connected_face_area / tot_face_area - : 0.0; + return (tot_face_area > 0.0) ? connected_face_area / tot_face_area : 0.0; } // TODO: this is a function from AquiferAnalytical @@ -217,14 +210,12 @@ class AquiferConstantFlux : public AquiferInterface Scalar totalFluxRate() const { return std::accumulate(this->connection_flux_.begin(), - this->connection_flux_.end(), 0.0, - [](const Scalar rate, const auto& q) - { - return rate + getValue(q); - }); + this->connection_flux_.end(), + 0.0, + [](const Scalar rate, const auto& q) { return rate + getValue(q); }); } }; } // namespace Opm -#endif //OPM_AQUIFERCONSTANTFLUX_HPP +#endif // OPM_AQUIFERCONSTANTFLUX_HPP diff --git a/opm/simulators/aquifers/AquiferFetkovich.hpp b/opm/simulators/aquifers/AquiferFetkovich.hpp index 1d496e7306a..270829230a1 100644 --- a/opm/simulators/aquifers/AquiferFetkovich.hpp +++ b/opm/simulators/aquifers/AquiferFetkovich.hpp @@ -42,6 +42,7 @@ class AquiferFetkovich : public AquiferAnalytical using typename Base::BlackoilIndices; using typename Base::ElementContext; + using typename Base::ElementMapper; using typename Base::Eval; using typename Base::FluidState; using typename Base::FluidSystem; @@ -49,7 +50,6 @@ class AquiferFetkovich : public AquiferAnalytical using typename Base::RateVector; using typename Base::Scalar; using typename Base::Simulator; - using typename Base::ElementMapper; AquiferFetkovich(const std::vector& connections, const Simulator& simulator, @@ -84,15 +84,14 @@ class AquiferFetkovich : public AquiferAnalytical data::AquiferData aquiferData() const override { // TODO: how to unify the two functions? - auto data = data::AquiferData{}; + auto data = data::AquiferData {}; data.aquiferID = this->aquiferID(); data.pressure = this->aquifer_pressure_; - data.fluxRate = std::accumulate(this->Qai_.begin(), this->Qai_.end(), 0.0, - [](const double flux, const auto& q) -> double - { - return flux + q.value(); - }); + data.fluxRate = std::accumulate(this->Qai_.begin(), + this->Qai_.end(), + 0.0, + [](const double flux, const auto& q) -> double { return flux + q.value(); }); data.volume = this->W_flux_.value(); data.initPressure = this->pa0_; @@ -104,7 +103,7 @@ class AquiferFetkovich : public AquiferAnalytical return data; } - template + template void serializeOp(Serializer& serializer) { serializer(static_cast(*this)); @@ -113,8 +112,7 @@ class AquiferFetkovich : public AquiferAnalytical bool operator==(const AquiferFetkovich& rhs) const { - return static_cast(*this) == rhs && - this->aquifer_pressure_ == rhs.aquifer_pressure_; + return static_cast(*this) == rhs && this->aquifer_pressure_ == rhs.aquifer_pressure_; } protected: @@ -124,11 +122,9 @@ class AquiferFetkovich : public AquiferAnalytical void assignRestartData(const data::AquiferData& xaq) override { - if (! xaq.typeData.is()) { - throw std::invalid_argument { - "Analytic aquifer data for unexpected aquifer " - "type passed to Fetkovich aquifer" - }; + if (!xaq.typeData.is()) { + throw std::invalid_argument {"Analytic aquifer data for unexpected aquifer " + "type passed to Fetkovich aquifer"}; } this->aquifer_pressure_ = xaq.pressure; @@ -137,11 +133,9 @@ class AquiferFetkovich : public AquiferAnalytical inline Eval dpai(int idx) { - const auto gdz = - this->gravity_() * (this->cell_depth_[idx] - this->aquiferDepth()); + const auto gdz = this->gravity_() * (this->cell_depth_[idx] - this->aquiferDepth()); - return this->aquifer_pressure_ + this->rhow_*gdz - - this->pressure_current_.at(idx); + return this->aquifer_pressure_ + this->rhow_ * gdz - this->pressure_current_.at(idx); } // This function implements Eq 5.12 of the EclipseTechnicalDescription @@ -152,8 +146,7 @@ class AquiferFetkovich : public AquiferAnalytical const auto& comm = this->simulator_.vanguard().grid().comm(); comm.sum(&Flux, 1); - const auto denom = - this->aqufetp_data_.total_compr * this->aqufetp_data_.initial_watvolume; + const auto denom = this->aqufetp_data_.total_compr * this->aqufetp_data_.initial_watvolume; return this->pa0_ - (Flux / denom); } @@ -169,8 +162,7 @@ class AquiferFetkovich : public AquiferAnalytical const Scalar td_Tc_ = simulator.timeStepSize() / this->Tc_; const Scalar coef = (1 - exp(-td_Tc_)) / td_Tc_; - this->Qai_.at(idx) = coef * this->alphai_[idx] * - this->aqufetp_data_.prod_index * dpai(idx); + this->Qai_.at(idx) = coef * this->alphai_[idx] * this->aqufetp_data_.prod_index * dpai(idx); } inline void calculateAquiferCondition() override @@ -179,12 +171,10 @@ class AquiferFetkovich : public AquiferAnalytical return; } - if (! this->aqufetp_data_.initial_pressure.has_value()) { - this->aqufetp_data_.initial_pressure = - this->calculateReservoirEquilibrium(); + if (!this->aqufetp_data_.initial_pressure.has_value()) { + this->aqufetp_data_.initial_pressure = this->calculateReservoirEquilibrium(); - const auto& tables = this->simulator_.vanguard() - .eclState().getTableManager(); + const auto& tables = this->simulator_.vanguard().eclState().getTableManager(); this->aqufetp_data_.finishInitialisation(tables); } diff --git a/opm/simulators/aquifers/AquiferGridUtils.hpp b/opm/simulators/aquifers/AquiferGridUtils.hpp index 7f3f78f3cee..263d56b0c2a 100644 --- a/opm/simulators/aquifers/AquiferGridUtils.hpp +++ b/opm/simulators/aquifers/AquiferGridUtils.hpp @@ -29,33 +29,37 @@ #include #include -namespace Opm { +namespace Opm +{ -template +template struct IsNumericalAquiferCell { explicit IsNumericalAquiferCell(const Grid&) - {} + { + } - template - bool operator()(const T&) const { return false; } + template + bool operator()(const T&) const + { + return false; + } }; -template<> +template <> struct IsNumericalAquiferCell { explicit IsNumericalAquiferCell(const Dune::CpGrid& grid) : grid_(grid) - {} + { + } - template + template bool operator()(const T& elem) const { const auto& aquiferCells = grid_.sortedNumAquiferCells(); - if (aquiferCells.empty()) - { - return false; + if (aquiferCells.empty()) { + return false; } - auto candidate = std::lower_bound(aquiferCells.begin(), - aquiferCells.end(), elem.index()); + auto candidate = std::lower_bound(aquiferCells.begin(), aquiferCells.end(), elem.index()); return candidate != aquiferCells.end() && *candidate == elem.index(); } diff --git a/opm/simulators/aquifers/AquiferInterface.hpp b/opm/simulators/aquifers/AquiferInterface.hpp index 92f18abd920..4755dd3db13 100644 --- a/opm/simulators/aquifers/AquiferInterface.hpp +++ b/opm/simulators/aquifers/AquiferInterface.hpp @@ -40,8 +40,7 @@ class AquiferInterface using Scalar = GetPropType; // Constructor - AquiferInterface(int aqID, - const Simulator& simulator) + AquiferInterface(int aqID, const Simulator& simulator) : aquiferID_(aqID) , simulator_(simulator) { @@ -63,20 +62,18 @@ class AquiferInterface virtual Scalar totalFaceArea() const = 0; template - void addToSource(RateVector& rates, - const Context& context, - const unsigned spaceIdx, - const unsigned timeIdx) + void addToSource(RateVector& rates, const Context& context, const unsigned spaceIdx, const unsigned timeIdx) { const unsigned cellIdx = context.globalSpaceIndex(spaceIdx, timeIdx); addToSource(rates, cellIdx, timeIdx); } - virtual void addToSource(RateVector& rates, - const unsigned cellIdx, - const unsigned timeIdx) = 0; + virtual void addToSource(RateVector& rates, const unsigned cellIdx, const unsigned timeIdx) = 0; - int aquiferID() const { return this->aquiferID_; } + int aquiferID() const + { + return this->aquiferID_; + } protected: bool co2store_or_h2store_() const @@ -94,7 +91,7 @@ class AquiferInterface return FluidSystem::waterPhaseIdx; } - const int aquiferID_{}; + const int aquiferID_ {}; const Simulator& simulator_; }; diff --git a/opm/simulators/aquifers/AquiferNumerical.hpp b/opm/simulators/aquifers/AquiferNumerical.hpp index 3148ef5159a..33791f1840d 100644 --- a/opm/simulators/aquifers/AquiferNumerical.hpp +++ b/opm/simulators/aquifers/AquiferNumerical.hpp @@ -58,18 +58,17 @@ class AquiferNumerical : public AquiferInterface enum { numPhases = FluidSystem::numPhases }; static constexpr int numEq = BlackoilIndices::numEq; - using Eval = DenseAd::Evaluation; + using Eval = DenseAd::Evaluation; using Toolbox = MathToolbox; using typename AquiferInterface::RateVector; // Constructor - AquiferNumerical(const SingleNumericalAquifer& aquifer, - const Simulator& simulator) + AquiferNumerical(const SingleNumericalAquifer& aquifer, const Simulator& simulator) : AquiferInterface(aquifer.id(), simulator) - , flux_rate_ (0.0) + , flux_rate_(0.0) , cumulative_flux_(0.0) - , init_pressure_ (aquifer.numCells(), 0.0) + , init_pressure_(aquifer.numCells(), 0.0) { this->cell_to_aquifer_cell_idx_.resize(this->simulator_.gridView().size(/*codim=*/0), -1); @@ -112,19 +111,20 @@ class AquiferNumerical : public AquiferInterface } if (const auto* aqData = xaqPos->second.typeData.template get(); - aqData != nullptr) - { + aqData != nullptr) { this->init_pressure_.resize(aqData->initPressure.size()); - std::copy(aqData->initPressure.begin(), - aqData->initPressure.end(), - this->init_pressure_.begin()); + std::copy(aqData->initPressure.begin(), aqData->initPressure.end(), this->init_pressure_.begin()); } this->solution_set_from_restart_ = true; } - void beginTimeStep() override {} - void addToSource(RateVector&, const unsigned, const unsigned) override {} + void beginTimeStep() override + { + } + void addToSource(RateVector&, const unsigned, const unsigned) override + { + } void endTimeStep() override { @@ -143,9 +143,7 @@ class AquiferNumerical : public AquiferInterface auto* aquNum = data.typeData.template create(); aquNum->initPressure.resize(this->init_pressure_.size()); - std::copy(this->init_pressure_.begin(), - this->init_pressure_.end(), - aquNum->initPressure.begin()); + std::copy(this->init_pressure_.begin(), this->init_pressure_.end(), aquNum->initPressure.begin()); return data; } @@ -162,14 +160,15 @@ class AquiferNumerical : public AquiferInterface } void computeFaceAreaFraction(const std::vector& /*total_face_area*/) override - {} + { + } Scalar totalFaceArea() const override { return 1.0; } - template + template void serializeOp(Serializer& serializer) { serializer(flux_rate_); @@ -180,10 +179,8 @@ class AquiferNumerical : public AquiferInterface bool operator==(const AquiferNumerical& rhs) const { - return this->flux_rate_ == rhs.flux_rate_ && - this->cumulative_flux_ == rhs.cumulative_flux_ && - this->init_pressure_ == rhs.init_pressure_ && - this->pressure_ == rhs.pressure_; + return this->flux_rate_ == rhs.flux_rate_ && this->cumulative_flux_ == rhs.cumulative_flux_ + && this->init_pressure_ == rhs.init_pressure_ && this->pressure_ == rhs.pressure_; } Scalar cumulativeFlux() const @@ -197,21 +194,18 @@ class AquiferNumerical : public AquiferInterface ElementContext elem_ctx(this->simulator_); auto elemIt = std::find_if(this->simulator_.gridView().template begin(), this->simulator_.gridView().template end(), - [&elem_ctx, this](const auto& elem) -> bool - { - elem_ctx.updateStencil(elem); + [&elem_ctx, this](const auto& elem) -> bool { + elem_ctx.updateStencil(elem); - const auto cell_index = elem_ctx - .globalSpaceIndex(/*spaceIdx=*/0, /*timeIdx=*/0); + const auto cell_index = elem_ctx.globalSpaceIndex(/*spaceIdx=*/0, /*timeIdx=*/0); - return this->cell_to_aquifer_cell_idx_[cell_index] == 0; - }); + return this->cell_to_aquifer_cell_idx_[cell_index] == 0; + }); - assert ((elemIt != this->simulator_.gridView().template end()) - && "Internal error locating numerical aquifer's connecting cell"); + assert((elemIt != this->simulator_.gridView().template end()) + && "Internal error locating numerical aquifer's connecting cell"); - this->connects_to_reservoir_ = - elemIt->partitionType() == Dune::InteriorEntity; + this->connects_to_reservoir_ = elemIt->partitionType() == Dune::InteriorEntity; } Scalar calculateAquiferPressure() const @@ -225,7 +219,7 @@ class AquiferNumerical : public AquiferInterface Scalar sum_pressure_watervolume = 0.; Scalar sum_watervolume = 0.; - ElementContext elem_ctx(this->simulator_); + ElementContext elem_ctx(this->simulator_); const auto& gridView = this->simulator_.gridView(); OPM_BEGIN_PARALLEL_TRY_CATCH(); @@ -280,7 +274,7 @@ class AquiferNumerical : public AquiferInterface { Scalar aquifer_flux = 0.0; - if (! this->connects_to_reservoir_) { + if (!this->connects_to_reservoir_) { return aquifer_flux; } @@ -318,7 +312,7 @@ class AquiferNumerical : public AquiferInterface continue; } - const Scalar water_flux = getWaterFlux(elem_ctx,face_idx); + const Scalar water_flux = getWaterFlux(elem_ctx, face_idx); const std::size_t up_id = water_flux >= 0.0 ? i : j; const auto& intQuantsIn = elem_ctx.intensiveQuantities(up_id, 0); const Scalar invB = Toolbox::value(intQuantsIn.fluidState().invB(this->phaseIdx_())); @@ -335,7 +329,7 @@ class AquiferNumerical : public AquiferInterface Scalar flux_rate_; // aquifer influx rate Scalar cumulative_flux_; // cumulative aquifer influx - std::vector init_pressure_{}; + std::vector init_pressure_ {}; Scalar pressure_; // aquifer pressure bool solution_set_from_restart_ {false}; bool connects_to_reservoir_ {false}; diff --git a/opm/simulators/aquifers/BlackoilAquiferModel.hpp b/opm/simulators/aquifers/BlackoilAquiferModel.hpp index 1138c41af96..e8ff7a1e026 100644 --- a/opm/simulators/aquifers/BlackoilAquiferModel.hpp +++ b/opm/simulators/aquifers/BlackoilAquiferModel.hpp @@ -38,11 +38,12 @@ #include -#include -#include #include +#include +#include -namespace Opm { +namespace Opm +{ /// Class for handling the blackoil aquifer model. template @@ -77,7 +78,7 @@ class BlackoilAquiferModel template void deserialize(Restarter& res); - template + template void serializeOp(Serializer& serializer); protected: @@ -104,9 +105,7 @@ class BlackoilAquiferModel template std::unique_ptr - createAnalyticAquiferPointer(const AquiferData& aqData, - const int aquiferID, - std::string_view aqType) const; + createAnalyticAquiferPointer(const AquiferData& aqData, const int aquiferID, std::string_view aqType) const; void computeConnectionAreaFraction() const; }; diff --git a/opm/simulators/aquifers/BlackoilAquiferModel_impl.hpp b/opm/simulators/aquifers/BlackoilAquiferModel_impl.hpp index 57398a11ad5..ba00f81b21c 100644 --- a/opm/simulators/aquifers/BlackoilAquiferModel_impl.hpp +++ b/opm/simulators/aquifers/BlackoilAquiferModel_impl.hpp @@ -90,7 +90,8 @@ BlackoilAquiferModel::beginEpisode() template void BlackoilAquiferModel::beginIteration() -{} +{ +} template void @@ -116,9 +117,7 @@ BlackoilAquiferModel::addToSource(RateVector& rates, template void -BlackoilAquiferModel::addToSource(RateVector& rates, - unsigned globalSpaceIdx, - unsigned timeIdx) const +BlackoilAquiferModel::addToSource(RateVector& rates, unsigned globalSpaceIdx, unsigned timeIdx) const { for (auto& aquifer : this->aquifers) { aquifer->addToSource(rates, globalSpaceIdx, timeIdx); @@ -128,7 +127,8 @@ BlackoilAquiferModel::addToSource(RateVector& rates, template void BlackoilAquiferModel::endIteration() -{} +{ +} template void @@ -148,7 +148,8 @@ BlackoilAquiferModel::endTimeStep() template void BlackoilAquiferModel::endEpisode() -{} +{ +} template template @@ -170,7 +171,8 @@ BlackoilAquiferModel::deserialize(Restarter& /* res */) // Initialize the aquifers in the deck template -void BlackoilAquiferModel::init() +void +BlackoilAquiferModel::init() { if (this->simulator_.vanguard().eclState().aquifer().active()) { this->initializeStaticAquifers(); @@ -181,8 +183,9 @@ void BlackoilAquiferModel::init() } } -template -data::Aquifers BlackoilAquiferModel::aquiferData() const +template +data::Aquifers +BlackoilAquiferModel::aquiferData() const { data::Aquifers data; for (const auto& aqu : this->aquifers) { @@ -192,10 +195,10 @@ data::Aquifers BlackoilAquiferModel::aquiferData() const return data; } -template -template -void BlackoilAquiferModel:: -serializeOp(Serializer& serializer) +template +template +void +BlackoilAquiferModel::serializeOp(Serializer& serializer) { for (auto& aiPtr : this->aquifers) { auto* ct = dynamic_cast*>(aiPtr.get()); @@ -217,23 +220,23 @@ serializeOp(Serializer& serializer) } template -void BlackoilAquiferModel::initializeRestartDynamicAquifers() +void +BlackoilAquiferModel::initializeRestartDynamicAquifers() { - const auto rstStep = this->simulator_.vanguard().eclState() - .getInitConfig().getRestartStep() - 1; + const auto rstStep = this->simulator_.vanguard().eclState().getInitConfig().getRestartStep() - 1; this->createDynamicAquifers(rstStep); } template -void BlackoilAquiferModel::initializeStaticAquifers() +void +BlackoilAquiferModel::initializeStaticAquifers() { - const auto& aquifer = - this->simulator_.vanguard().eclState().aquifer(); + const auto& aquifer = this->simulator_.vanguard().eclState().aquifer(); for (const auto& aquCT : aquifer.ct()) { - auto aquCTPtr = this->template createAnalyticAquiferPointer - >(aquCT, aquCT.aquiferID, "Carter-Tracy"); + auto aquCTPtr = this->template createAnalyticAquiferPointer>( + aquCT, aquCT.aquiferID, "Carter-Tracy"); if (aquCTPtr != nullptr) { this->aquifers.push_back(std::move(aquCTPtr)); @@ -241,8 +244,8 @@ void BlackoilAquiferModel::initializeStaticAquifers() } for (const auto& aquFetp : aquifer.fetp()) { - auto aquFetpPtr = this->template createAnalyticAquiferPointer - >(aquFetp, aquFetp.aquiferID, "Fetkovich"); + auto aquFetpPtr = this->template createAnalyticAquiferPointer>( + aquFetp, aquFetp.aquiferID, "Fetkovich"); if (aquFetpPtr != nullptr) { this->aquifers.push_back(std::move(aquFetpPtr)); @@ -251,10 +254,12 @@ void BlackoilAquiferModel::initializeStaticAquifers() for (const auto& [id, aquFlux] : aquifer.aquflux()) { // Make sure not dummy constant flux aquifers - if (! aquFlux.active) { continue; } + if (!aquFlux.active) { + continue; + } - auto aquFluxPtr = this->template createAnalyticAquiferPointer - >(aquFlux, id, "Constant Flux"); + auto aquFluxPtr + = this->template createAnalyticAquiferPointer>(aquFlux, id, "Constant Flux"); if (aquFluxPtr != nullptr) { this->aquifers.push_back(std::move(aquFluxPtr)); @@ -263,8 +268,7 @@ void BlackoilAquiferModel::initializeStaticAquifers() if (aquifer.hasNumericalAquifer()) { for (const auto& aquNum : aquifer.numericalAquifers().aquifers()) { - auto aquNumPtr = std::make_unique> - (aquNum.second, this->simulator_); + auto aquNumPtr = std::make_unique>(aquNum.second, this->simulator_); this->aquifers.push_back(std::move(aquNumPtr)); } @@ -272,79 +276,74 @@ void BlackoilAquiferModel::initializeStaticAquifers() } template -bool BlackoilAquiferModel::needRestartDynamicAquifers() const +bool +BlackoilAquiferModel::needRestartDynamicAquifers() const { - const auto& initconfig = - this->simulator_.vanguard().eclState().getInitConfig(); + const auto& initconfig = this->simulator_.vanguard().eclState().getInitConfig(); - if (! initconfig.restartRequested()) { + if (!initconfig.restartRequested()) { return false; } - return this->simulator_.vanguard() - .schedule()[initconfig.getRestartStep() - 1].hasAnalyticalAquifers(); + return this->simulator_.vanguard().schedule()[initconfig.getRestartStep() - 1].hasAnalyticalAquifers(); } template template std::unique_ptr -BlackoilAquiferModel:: -createAnalyticAquiferPointer(const AquiferData& aqData, - const int aquiferID, - std::string_view aqType) const +BlackoilAquiferModel::createAnalyticAquiferPointer(const AquiferData& aqData, + const int aquiferID, + std::string_view aqType) const { - const auto& connections = - this->simulator_.vanguard().eclState().aquifer().connections(); + const auto& connections = this->simulator_.vanguard().eclState().aquifer().connections(); - if (! connections.hasAquiferConnections(aquiferID)) { + if (!connections.hasAquiferConnections(aquiferID)) { const auto msg = fmt::format("No valid connections for {} aquifer {}. " "Aquifer {} will be ignored.", - aqType, aquiferID, aquiferID); + aqType, + aquiferID, + aquiferID); OpmLog::warning(msg); return {}; } - return std::make_unique - (connections.getConnections(aquiferID), this->simulator_, aqData); + return std::make_unique(connections.getConnections(aquiferID), this->simulator_, aqData); } template -void BlackoilAquiferModel::createDynamicAquifers(const int episode_index) +void +BlackoilAquiferModel::createDynamicAquifers(const int episode_index) { const auto& sched = this->simulator_.vanguard().schedule()[episode_index]; for (const auto& [id, aquFlux] : sched.aqufluxs) { - auto aquPos = - std::find_if(std::begin(this->aquifers), - std::end(this->aquifers), - [Id = id](const auto& aquPtr) - { - return aquPtr->aquiferID() == Id; - }); + auto aquPos = std::find_if(std::begin(this->aquifers), std::end(this->aquifers), [Id = id](const auto& aquPtr) { + return aquPtr->aquiferID() == Id; + }); if (aquPos == std::end(this->aquifers)) { // An aquifer with this 'id' does not yet exist in // the collection managed by this object. Create it. - auto aquFluxPtr = this->template createAnalyticAquiferPointer - >(aquFlux, id, "Constant Flux"); + auto aquFluxPtr = this->template createAnalyticAquiferPointer>( + aquFlux, id, "Constant Flux"); if (aquFluxPtr != nullptr) { this->aquifers.push_back(std::move(aquFluxPtr)); } - } - else { + } else { auto aquFluxPtr = dynamic_cast*>(aquPos->get()); if (aquFluxPtr == nullptr) { // If the aquifers can return types easily, we might be able // to give a better message with type information. - const auto msg = - fmt::format("Aquifer {} is updated with constant flux " - "aquifer keyword AQUFLUX at report step {}, " - "while it might be specified to be a " - "different type of aquifer before this. " - "We do not support the conversion between " - "different types of aquifer.\n", id, episode_index); + const auto msg = fmt::format("Aquifer {} is updated with constant flux " + "aquifer keyword AQUFLUX at report step {}, " + "while it might be specified to be a " + "different type of aquifer before this. " + "We do not support the conversion between " + "different types of aquifer.\n", + id, + episode_index); OPM_THROW(std::runtime_error, msg); } @@ -355,12 +354,13 @@ void BlackoilAquiferModel::createDynamicAquifers(const int episode_inde } template -void BlackoilAquiferModel::computeConnectionAreaFraction() const +void +BlackoilAquiferModel::computeConnectionAreaFraction() const { - auto maxAquID = - std::accumulate(this->aquifers.begin(), this->aquifers.end(), 0, - [](const int aquID, const auto& aquifer) - { return std::max(aquID, aquifer->aquiferID()); }); + auto maxAquID + = std::accumulate(this->aquifers.begin(), this->aquifers.end(), 0, [](const int aquID, const auto& aquifer) { + return std::max(aquID, aquifer->aquiferID()); + }); maxAquID = this->simulator_.vanguard().grid().comm().max(maxAquID); diff --git a/opm/simulators/aquifers/SupportsFaceTag.hpp b/opm/simulators/aquifers/SupportsFaceTag.hpp index 851c3d30378..07d99b663bf 100644 --- a/opm/simulators/aquifers/SupportsFaceTag.hpp +++ b/opm/simulators/aquifers/SupportsFaceTag.hpp @@ -24,20 +24,24 @@ #ifndef OPM_SUPPORTS_FACETAG_HEADER_INCLUDED #define OPM_SUPPORTS_FACETAG_HEADER_INCLUDED -namespace Dune { class CpGrid; } +namespace Dune +{ +class CpGrid; +} -namespace Opm { +namespace Opm +{ -template -class SupportsFaceTag - : public std::bool_constant -{}; +template +class SupportsFaceTag : public std::bool_constant +{ +}; -template<> -class SupportsFaceTag - : public std::bool_constant -{}; +template <> +class SupportsFaceTag : public std::bool_constant +{ +}; } // namespace Opm diff --git a/opm/simulators/flow/ActionHandler.cpp b/opm/simulators/flow/ActionHandler.cpp index 0743948acaa..63917f9d3a5 100644 --- a/opm/simulators/flow/ActionHandler.cpp +++ b/opm/simulators/flow/ActionHandler.cpp @@ -26,14 +26,14 @@ #include #include -#include #include +#include #include #include -#include #include +#include #include #include #include @@ -59,136 +59,121 @@ #include #include -namespace { - std::string formatActionDate(const Opm::TimeStampUTC& timePoint, - const int reportStep) - { - auto time_point = std::tm{}; +namespace +{ +std::string +formatActionDate(const Opm::TimeStampUTC& timePoint, const int reportStep) +{ + auto time_point = std::tm {}; - time_point.tm_year = timePoint.year() - 1900; - time_point.tm_mon = timePoint.month() - 1; - time_point.tm_mday = timePoint.day(); + time_point.tm_year = timePoint.year() - 1900; + time_point.tm_mon = timePoint.month() - 1; + time_point.tm_mday = timePoint.day(); - time_point.tm_hour = timePoint.hour(); - time_point.tm_min = timePoint.minutes(); - time_point.tm_sec = timePoint.seconds(); + time_point.tm_hour = timePoint.hour(); + time_point.tm_min = timePoint.minutes(); + time_point.tm_sec = timePoint.seconds(); - return fmt::format("{:%d-%b-%Y %H:%M:%S} (report interval {} to {})", - time_point, reportStep, reportStep + 1); - } + return fmt::format("{:%d-%b-%Y %H:%M:%S} (report interval {} to {})", time_point, reportStep, reportStep + 1); +} - void logActivePyAction(const std::string& actionName, - const std::string& timeString) - { - const auto message = - fmt::format("Action {} (Python) triggered at {}", - actionName, timeString); +void +logActivePyAction(const std::string& actionName, const std::string& timeString) +{ + const auto message = fmt::format("Action {} (Python) triggered at {}", actionName, timeString); - Opm::OpmLog::info("ACTION_TRIGGERED", message); - } + Opm::OpmLog::info("ACTION_TRIGGERED", message); +} - template - void logActiveAction(const std::string& actionName, - const WellNameRange& matchingWells, - const std::string& timeString) - { - const auto wellString = matchingWells.empty() - ? std::string{} - : fmt::format(" Well{}: {}", - matchingWells.size() != 1 ? "s" : "", - fmt::join(matchingWells, ", ")); - - const auto message = - fmt::format("Action {} triggered at {}.{}", - actionName, timeString, wellString); - - Opm::OpmLog::info("ACTION_TRIGGERED", message); - } +template +void +logActiveAction(const std::string& actionName, const WellNameRange& matchingWells, const std::string& timeString) +{ + const auto wellString = matchingWells.empty() + ? std::string {} + : fmt::format(" Well{}: {}", matchingWells.size() != 1 ? "s" : "", fmt::join(matchingWells, ", ")); - void logInactivePyAction(const std::string& actionName, - const std::string& timeString) - { - const auto message = - fmt::format("Action {} (Python) NOT triggered at {}.", - actionName, timeString); + const auto message = fmt::format("Action {} triggered at {}.{}", actionName, timeString, wellString); - Opm::OpmLog::debug("NAMED_ACTION_NOT_TRIGGERED", message); - } + Opm::OpmLog::info("ACTION_TRIGGERED", message); +} - void logInactiveAction(const std::string& actionName, - const std::string& timeString) - { - const auto message = - fmt::format("Action {} NOT triggered at {}.", - actionName, timeString); +void +logInactivePyAction(const std::string& actionName, const std::string& timeString) +{ + const auto message = fmt::format("Action {} (Python) NOT triggered at {}.", actionName, timeString); - Opm::OpmLog::debug("NAMED_ACTION_NOT_TRIGGERED", message); - } + Opm::OpmLog::debug("NAMED_ACTION_NOT_TRIGGERED", message); +} - void logInactiveActions(const int numInactive, - const std::string& timeString) - { - const auto message = - fmt::format("{} action{} NOT triggered at {}.", - numInactive, - (numInactive != 1) ? "s" : "", - timeString); +void +logInactiveAction(const std::string& actionName, const std::string& timeString) +{ + const auto message = fmt::format("Action {} NOT triggered at {}.", actionName, timeString); - Opm::OpmLog::debug("ACTION_NOT_TRIGGERED", message); - } + Opm::OpmLog::debug("NAMED_ACTION_NOT_TRIGGERED", message); +} - template - std::unordered_map - fetchWellPI(const WellModel& wellModel, - const std::vector& wellpi_wells, - const Opm::Parallel::Communication comm) - { - auto wellpi = std::unordered_map {}; +void +logInactiveActions(const int numInactive, const std::string& timeString) +{ + const auto message + = fmt::format("{} action{} NOT triggered at {}.", numInactive, (numInactive != 1) ? "s" : "", timeString); - if (wellpi_wells.empty()) { - return wellpi; - } + Opm::OpmLog::debug("ACTION_NOT_TRIGGERED", message); +} - auto wellPI = std::vector(wellpi_wells.size()); - for (auto i = 0*wellpi_wells.size(); i < wellpi_wells.size(); ++i) { - if (wellModel.hasLocalWell(wellpi_wells[i])) { - wellPI[i] = wellModel.wellPI(wellpi_wells[i]); - } - } +template +std::unordered_map +fetchWellPI(const WellModel& wellModel, + const std::vector& wellpi_wells, + const Opm::Parallel::Communication comm) +{ + auto wellpi = std::unordered_map {}; - comm.max(wellPI.data(), wellPI.size()); + if (wellpi_wells.empty()) { + return wellpi; + } - for (auto i = 0*wellpi_wells.size(); i < wellpi_wells.size(); ++i) { - wellpi.emplace(wellpi_wells[i], wellPI[i]); + auto wellPI = std::vector(wellpi_wells.size()); + for (auto i = 0 * wellpi_wells.size(); i < wellpi_wells.size(); ++i) { + if (wellModel.hasLocalWell(wellpi_wells[i])) { + wellPI[i] = wellModel.wellPI(wellpi_wells[i]); } + } - return wellpi; + comm.max(wellPI.data(), wellPI.size()); + + for (auto i = 0 * wellpi_wells.size(); i < wellpi_wells.size(); ++i) { + wellpi.emplace(wellpi_wells[i], wellPI[i]); } + + return wellpi; +} } // Anonymous namespace -namespace Opm { +namespace Opm +{ -template -ActionHandler:: -ActionHandler(EclipseState& ecl_state, - Schedule& schedule, - Action::State& actionState, - SummaryState& summaryState, - BlackoilWellModelGeneric& wellModel, - Parallel::Communication comm) +template +ActionHandler::ActionHandler(EclipseState& ecl_state, + Schedule& schedule, + Action::State& actionState, + SummaryState& summaryState, + BlackoilWellModelGeneric& wellModel, + Parallel::Communication comm) : ecl_state_(ecl_state) , schedule_(schedule) , actionState_(actionState) , summaryState_(summaryState) , wellModel_(wellModel) , comm_(comm) -{} +{ +} -template -void ActionHandler:: -applyActions(const int reportStep, - const double sim_time, - const TransFunc& transUp) +template +void +ActionHandler::applyActions(const int reportStep, const double sim_time, const TransFunc& transUp) { OPM_TIMEBLOCK(applyActions); const auto& actions = schedule_[reportStep].actions(); @@ -196,10 +181,10 @@ applyActions(const int reportStep, return; } - const Action::Context context{ summaryState_, schedule_[reportStep].wlist_manager() }; + const Action::Context context {summaryState_, schedule_[reportStep].wlist_manager()}; - const auto now = TimeStampUTC{ schedule_.getStartTime() } + std::chrono::duration(sim_time); - const auto ts = formatActionDate(now, reportStep); + const auto now = TimeStampUTC {schedule_.getStartTime()} + std::chrono::duration(sim_time); + const auto ts = formatActionDate(now, reportStep); SimulatorUpdate sim_update; @@ -209,16 +194,13 @@ applyActions(const int reportStep, // affected by the PyAction, thus we get the production indices for all wells. const std::vector wellpi_wells = schedule_[reportStep].well_order().names(); const auto wellpi = fetchWellPI(this->wellModel_, wellpi_wells, this->comm_); - auto sim_update_current = schedule_.runPyAction(reportStep, *pyaction, actionState_, - ecl_state_, summaryState_, wellpi); + auto sim_update_current + = schedule_.runPyAction(reportStep, *pyaction, actionState_, ecl_state_, summaryState_, wellpi); - if (const auto pyRes = this->actionState_.python_result(pyaction->name()); - !pyRes.has_value() || !*pyRes) - { + if (const auto pyRes = this->actionState_.python_result(pyaction->name()); !pyRes.has_value() || !*pyRes) { logInactivePyAction(pyaction->name(), ts); continue; - } - else { + } else { logActivePyAction(pyaction->name(), ts); } @@ -229,7 +211,7 @@ applyActions(const int reportStep, const auto simTime = asTimeT(now); for (const auto& action : actions.pending(this->actionState_, simTime)) { const auto actionResult = action->eval(context); - if (! actionResult.conditionSatisfied()) { + if (!actionResult.conditionSatisfied()) { ++non_triggered; logInactiveAction(action->name(), ts); continue; @@ -245,8 +227,7 @@ applyActions(const int reportStep, const std::vector wellpi_wells = action->wellpi_wells(schedule_.wellMatcher(reportStep), matches); const auto wellpi = fetchWellPI(this->wellModel_, wellpi_wells, this->comm_); - const auto sim_update_current = this->schedule_ - .applyAction(reportStep, *action, matches, wellpi, true); + const auto sim_update_current = this->schedule_.applyAction(reportStep, *action, matches, wellpi, true); sim_update.append(sim_update_current); this->actionState_.add_run(*action, simTime, actionResult); @@ -267,12 +248,12 @@ applyActions(const int reportStep, } } -template -void ActionHandler:: -applySimulatorUpdate(const int report_step, - const SimulatorUpdate& sim_update, - const TransFunc& updateTrans, - bool& commit_wellstate) +template +void +ActionHandler::applySimulatorUpdate(const int report_step, + const SimulatorUpdate& sim_update, + const TransFunc& updateTrans, + bool& commit_wellstate) { OPM_TIMEBLOCK(applySimulatorUpdate); @@ -284,25 +265,23 @@ applySimulatorUpdate(const int report_step, if (sim_update.tran_update) { const auto& keywords = schedule_[report_step].geo_keywords(); - ecl_state_.apply_schedule_keywords( keywords ); - eclBroadcast(comm_, ecl_state_.getTransMult() ); + ecl_state_.apply_schedule_keywords(keywords); + eclBroadcast(comm_, ecl_state_.getTransMult()); // re-compute transmissibility updateTrans(true); } } -template -void ActionHandler:: -evalUDQAssignments(const unsigned episodeIdx, - UDQState& udq_state) +template +void +ActionHandler::evalUDQAssignments(const unsigned episodeIdx, UDQState& udq_state) { - this->schedule_[episodeIdx].udq() - .eval_assign(this->schedule_.wellMatcher(episodeIdx), - this->schedule_[episodeIdx].group_order(), - this->schedule_.segmentMatcherFactory(episodeIdx), - this->summaryState_, - udq_state); + this->schedule_[episodeIdx].udq().eval_assign(this->schedule_.wellMatcher(episodeIdx), + this->schedule_[episodeIdx].group_order(), + this->schedule_.segmentMatcherFactory(episodeIdx), + this->summaryState_, + udq_state); } template class ActionHandler; diff --git a/opm/simulators/flow/ActionHandler.hpp b/opm/simulators/flow/ActionHandler.hpp index a30fca7e4e1..ff02153497c 100644 --- a/opm/simulators/flow/ActionHandler.hpp +++ b/opm/simulators/flow/ActionHandler.hpp @@ -31,12 +31,15 @@ #include #include -namespace Opm::Action { - class State; +namespace Opm::Action +{ +class State; } // namespace Opm::Action -namespace Opm { -template class BlackoilWellModelGeneric; +namespace Opm +{ +template +class BlackoilWellModelGeneric; class EclipseState; class Schedule; struct SimulatorUpdate; @@ -44,10 +47,11 @@ class SummaryState; class UDQState; } // namespace Opm -namespace Opm { +namespace Opm +{ //! \brief Class handling Action support in simulator -template +template class ActionHandler { public: @@ -86,9 +90,7 @@ class ActionHandler /// \param[in] updateTrans Call-back for affecting transmissibility /// updates. Typically invoked if the action triggers a keyword like /// MULTZ. - void applyActions(int reportStep, - double sim_time, - const TransFunc& updateTrans); + void applyActions(int reportStep, double sim_time, const TransFunc& updateTrans); /// \brief Evaluates UDQ assign statements. /// @@ -96,8 +98,7 @@ class ActionHandler /// /// \param[in,out] udq_state Dynamic state of all user-defined /// quantities. - void evalUDQAssignments(const unsigned episodeIdx, - UDQState& udq_state); + void evalUDQAssignments(const unsigned episodeIdx, UDQState& udq_state); /// Convey dynamic updates triggered by an action block back to the /// running simulator. diff --git a/opm/simulators/flow/AluGridCartesianIndexMapper.hpp b/opm/simulators/flow/AluGridCartesianIndexMapper.hpp index 7984b1ea6d4..675e7a59945 100644 --- a/opm/simulators/flow/AluGridCartesianIndexMapper.hpp +++ b/opm/simulators/flow/AluGridCartesianIndexMapper.hpp @@ -24,11 +24,11 @@ #ifndef OPM_ALUGRID_CARTESIAN_INDEX_MAPPER_HPP #define OPM_ALUGRID_CARTESIAN_INDEX_MAPPER_HPP -#include #include -#include +#include #include #include +#include #include #include @@ -37,24 +37,24 @@ #include #include -namespace Dune { +namespace Dune +{ /*! * \brief Interface class to access the logical Cartesian grid as used in industry * standard simulator decks. */ -//#if HAVE_MPI - template <> - class CartesianIndexMapper> +// #if HAVE_MPI +template <> +class CartesianIndexMapper> { public: - #if HAVE_MPI - using Grid = Dune::ALUGrid<3, 3, Dune::cube, Dune::nonconforming, Dune::ALUGridMPIComm>; -#else + using Grid = Dune::ALUGrid<3, 3, Dune::cube, Dune::nonconforming, Dune::ALUGridMPIComm>; +#else using Grid = Dune::ALUGrid<3, 3, Dune::cube, Dune::nonconforming, Dune::ALUGridNoComm>; -#endif //HAVE_MPI - +#endif // HAVE_MPI + // data handle for communicating global ids during load balance and communication template class GlobalIndexDataHandle : public Dune::CommDataHandleIF, int> @@ -65,7 +65,8 @@ namespace Dune { public: GlobalCellIndex() : idx_(-1) - {} + { + } GlobalCellIndex& operator=(const int index) { @@ -74,7 +75,9 @@ namespace Dune { } int index() const - { return idx_; } + { + return idx_; + } private: int idx_; @@ -84,8 +87,7 @@ namespace Dune { public: // constructor copying cartesian index to persistent container - GlobalIndexDataHandle(const GridView& gridView, - std::vector& cartesianIndex) + GlobalIndexDataHandle(const GridView& gridView, std::vector& cartesianIndex) : gridView_(gridView) , globalIndex_(gridView.grid(), 0) , cartesianIndex_(cartesianIndex) @@ -95,21 +97,27 @@ namespace Dune { } // constructor copying cartesian index to persistent container - GlobalIndexDataHandle(const GlobalIndexDataHandle& other) = delete ; + GlobalIndexDataHandle(const GlobalIndexDataHandle& other) = delete; // destrcutor writing load balanced cartesian index back to vector ~GlobalIndexDataHandle() - { finalize(); } + { + finalize(); + } bool contains(int /* dim */, int codim) const - { return codim == 0; } + { + return codim == 0; + } bool fixedsize(int /* dim */, int /* codim */) const - { return true; } + { + return true; + } //! \brief loop over all internal data handlers and call gather for //! given entity - template + template void gather(MessageBufferImp& buff, const EntityType& element) const { int globalIdx = globalIndex_[element].index(); @@ -118,13 +126,12 @@ namespace Dune { //! \brief loop over all internal data handlers and call scatter for //! given entity - template + template void scatter(MessageBufferImp& buff, const EntityType& element, std::size_t /* n */) { int globalIdx = -1; buff.read(globalIdx); - if (globalIdx >= 0) - { + if (globalIdx >= 0) { globalIndex_.resize(); globalIndex_[element] = globalIdx; } @@ -132,9 +139,11 @@ namespace Dune { //! \brief loop over all internal data handlers and return sum of data //! size of given entity - template + template std::size_t size(const EntityType& /* en */) const - { return 1; } + { + return 1; + } protected: // initialize persistent container from given vector @@ -151,13 +160,13 @@ namespace Dune { // update vector from given persistent container void finalize() { - std::vector newIndex ; + std::vector newIndex; newIndex.reserve(gridView_.indexSet().size(0)); auto it = gridView_.template begin<0>(); const auto& endIt = gridView_.template end<0>(); for (; it != endIt; ++it) - newIndex.push_back(globalIndex_[*it].index()) ; + newIndex.push_back(globalIndex_[*it].index()); cartesianIndex_.swap(newIndex); } @@ -169,7 +178,7 @@ namespace Dune { public: /** \brief dimension of the grid */ - static constexpr int dimension = Grid::dimension ; + static constexpr int dimension = Grid::dimension; /** \brief constructor taking grid */ CartesianIndexMapper(const Grid& grid, @@ -179,19 +188,26 @@ namespace Dune { , cartesianDimensions_(cartDims) , cartesianIndex_(cartesianIndex) , cartesianSize_(computeCartesianSize()) - {} + { + } /** \brief return Cartesian dimensions, i.e. number of cells in each direction */ const std::array& cartesianDimensions() const - { return cartesianDimensions_; } + { + return cartesianDimensions_; + } /** \brief return total number of cells in the logical Cartesian grid */ int cartesianSize() const - { return cartesianSize_; } + { + return cartesianSize_; + } /** \brief return number of cells in the active grid */ int compressedSize() const - { return cartesianIndex_.size(); } + { + return cartesianIndex_.size(); + } /** \brief return index of the cells in the logical Cartesian grid */ int cartesianIndex(const int compressedElementIndex) const @@ -205,7 +221,7 @@ namespace Dune { { int cartIndex = coords[0]; int factor = cartesianDimensions()[0]; - for (int i=1; i < dimension; ++i) { + for (int i = 1; i < dimension; ++i) { cartIndex += coords[i] * factor; factor *= cartesianDimensions()[i]; } @@ -222,19 +238,18 @@ namespace Dune { gc /= cartesianDimensions()[0]; coords[1] = gc % cartesianDimensions()[1]; coords[2] = gc / cartesianDimensions()[1]; - } - else if constexpr (dimension == 2) { + } else if constexpr (dimension == 2) { coords[0] = gc % cartesianDimensions()[0]; coords[1] = gc / cartesianDimensions()[0]; - } - else if constexpr (dimension == 1) - coords[0] = gc ; + } else if constexpr (dimension == 1) + coords[0] = gc; else - throw std::invalid_argument("cartesianCoordinate not implemented for dimension " + std::to_string(dimension)); + throw std::invalid_argument("cartesianCoordinate not implemented for dimension " + + std::to_string(dimension)); } template - std::unique_ptr > dataHandle(const GridView& gridView) + std::unique_ptr> dataHandle(const GridView& gridView) { using DataHandle = GlobalIndexDataHandle; assert(&grid_ == &gridView.grid()); @@ -245,15 +260,15 @@ namespace Dune { int computeCartesianSize() const { int size = cartesianDimensions()[0]; - for (int d=1; d cartesianDimensions_; std::vector cartesianIndex_; - const int cartesianSize_ ; + const int cartesianSize_; }; } // end namespace Dune diff --git a/opm/simulators/flow/AluGridLevelCartesianIndexMapper.hpp b/opm/simulators/flow/AluGridLevelCartesianIndexMapper.hpp index bebc0028c05..ef0bfa59108 100644 --- a/opm/simulators/flow/AluGridLevelCartesianIndexMapper.hpp +++ b/opm/simulators/flow/AluGridLevelCartesianIndexMapper.hpp @@ -41,18 +41,19 @@ #include #include -namespace Opm { +namespace Opm +{ // Interface class to access the local Cartesian grid of each level grid (when refinement). // Further documentation in opm/grid/common/LevelCartesianIndexMapper.hpp // -// Adapter Design Pattern: In this case, LevelCartesianIndexMapper uses the Object Adapter variant, where it holds an instance -// (here, a std::unique_ptr) of CartesianIndexMapper, the wrapped type. The goal is to provide a standardized interface, allowing -// incompatible functionality (such as Cartesian indexing in the context of refinement that may not be supported - yet -for all -// grid types, like CpGrid) to integrate smoothly within the existing conventions. +// Adapter Design Pattern: In this case, LevelCartesianIndexMapper uses the Object Adapter variant, where it holds an +// instance (here, a std::unique_ptr) of CartesianIndexMapper, the wrapped type. The goal is to provide a standardized +// interface, allowing incompatible functionality (such as Cartesian indexing in the context of refinement that may not +// be supported - yet -for all grid types, like CpGrid) to integrate smoothly within the existing conventions. // // Specialization for AluGrid -template<> +template <> class LevelCartesianIndexMapper> { @@ -60,19 +61,20 @@ class LevelCartesianIndexMapper; #else using Grid = Dune::ALUGrid<3, 3, Dune::cube, Dune::nonconforming, Dune::ALUGridNoComm>; -#endif //HAVE_MPI +#endif // HAVE_MPI - public: - static constexpr int dimension = 3 ; +public: + static constexpr int dimension = 3; explicit LevelCartesianIndexMapper(const Dune::CartesianIndexMapper& cartesianIndexMapper) - : cartesianIndexMapper_{std::make_unique>(cartesianIndexMapper)} - {} + : cartesianIndexMapper_ {std::make_unique>(cartesianIndexMapper)} + { + } - const std::array& cartesianDimensions(int level) const + const std::array& cartesianDimensions(int level) const { throwIfLevelPositive(level); - return cartesianIndexMapper_ ->cartesianDimensions(); + return cartesianIndexMapper_->cartesianDimensions(); } int cartesianSize(int level) const @@ -84,24 +86,25 @@ class LevelCartesianIndexMapper compressedSize(); + return cartesianIndexMapper_->compressedSize(); } - int cartesianIndex( const int compressedElementIndex, const int level) const + int cartesianIndex(const int compressedElementIndex, const int level) const { - throwIfLevelPositive(level);; + throwIfLevelPositive(level); + ; return cartesianIndexMapper_->cartesianIndex(compressedElementIndex); } - void cartesianCoordinate(const int compressedElementIndex, std::array& coords, int level) const + void cartesianCoordinate(const int compressedElementIndex, std::array& coords, int level) const { throwIfLevelPositive(level); cartesianIndexMapper_->cartesianCoordinate(compressedElementIndex, coords); } - private: +private: std::unique_ptr> cartesianIndexMapper_; - + void throwIfLevelPositive(int level) const { if (level) { @@ -110,6 +113,6 @@ class LevelCartesianIndexMapper #include -namespace Opm { +namespace Opm +{ template class FlowAluGridVanguard; } // namespace Opm -namespace Opm::Properties { +namespace Opm::Properties +{ -namespace TTag { -struct AluGridVanguard { - using InheritsFrom = std::tuple; -}; -} +namespace TTag +{ + struct AluGridVanguard { + using InheritsFrom = std::tuple; + }; +} // namespace TTag // declare the properties -template +template struct Vanguard { using type = Opm::FlowAluGridVanguard; }; -template +template struct Grid { #if HAVE_MPI - using type = Dune::ALUGrid<3, 3, Dune::cube, Dune::nonconforming, Dune::ALUGridMPIComm>; -#else + using type = Dune::ALUGrid<3, 3, Dune::cube, Dune::nonconforming, Dune::ALUGridMPIComm>; +#else using type = Dune::ALUGrid<3, 3, Dune::cube, Dune::nonconforming, Dune::ALUGridNoComm>; -#endif //HAVE_MPI +#endif // HAVE_MPI }; -template +template struct EquilGrid { using type = Dune::CpGrid; }; } // namespace Opm::Properties -namespace Opm { +namespace Opm +{ /*! * \ingroup BlackOilSimulator @@ -106,7 +110,7 @@ class AluGridVanguard : public FlowBaseVanguard public: using Grid = GetPropType; using EquilGrid = GetPropType; - using GridView = GetPropType; + using GridView = GetPropType; using CartesianIndexMapper = Dune::CartesianIndexMapper; using LevelCartesianIndexMapper = Opm::LevelCartesianIndexMapper; using EquilCartesianIndexMapper = Dune::CartesianIndexMapper; @@ -119,21 +123,25 @@ class AluGridVanguard : public FlowBaseVanguard explicit AluGridVanguard(Simulator& simulator) : FlowBaseVanguard(simulator) { - this->mpiRank = FlowGenericVanguard::comm().rank(); - this->callImplementationInit(); + this->mpiRank = FlowGenericVanguard::comm().rank(); + this->callImplementationInit(); } /*! * \brief Return a reference to the simulation grid. */ Grid& grid() - { return *grid_; } + { + return *grid_; + } /*! * \brief Return a reference to the simulation grid. */ const Grid& grid() const - { return *grid_; } + { + return *grid_; + } /*! * \brief Returns a refefence to the grid which should be used by the EQUIL @@ -145,7 +153,9 @@ class AluGridVanguard : public FlowBaseVanguard * same as the grid which is used for the actual simulation. */ const EquilGrid& equilGrid() const - { return *equilGrid_; } + { + return *equilGrid_; + } /*! * \brief Indicates that the initial condition has been computed and the memory used @@ -175,52 +185,46 @@ class AluGridVanguard : public FlowBaseVanguard grid().loadBalance(*dataHandle); // communicate non-interior cells values - grid().communicate(*dataHandle, - Dune::InteriorBorder_All_Interface, - Dune::ForwardCommunication ); - - if (grid().size(0)) - { - globalTrans_ = std::make_unique(this->eclState(), - this->gridView(), - this->cartesianIndexMapper(), - this->grid(), - this->cellCentroids(), - getPropValue(), - getPropValue(), - getPropValue()); + grid().communicate(*dataHandle, Dune::InteriorBorder_All_Interface, Dune::ForwardCommunication); + + if (grid().size(0)) { + globalTrans_ + = std::make_unique(this->eclState(), + this->gridView(), + this->cartesianIndexMapper(), + this->grid(), + this->cellCentroids(), + getPropValue(), + getPropValue(), + getPropValue()); // Re-ordering for ALUGrid - globalTrans_->update(false, TransmissibilityType::TransUpdateQuantities::Trans, - [&](unsigned int i) { return gridEquilIdxToGridIdx(i);}); + globalTrans_->update(false, TransmissibilityType::TransUpdateQuantities::Trans, [&](unsigned int i) { + return gridEquilIdxToGridIdx(i); + }); } - } void addLgrs() { - // do nothing: AluGrid with LGRs not supported yet! + // do nothing: AluGrid with LGRs not supported yet! } - template + template void scatterData(DataHandle& /*handle*/) const { - // not existing for this type of grid yet + // not existing for this type of grid yet } - template + template void gatherData(DataHandle& /*handle*/) const { - // not existing for this type of grid yet + // not existing for this type of grid yet } - template - void communicate (DataHandle& /*data*/, InterfaceType /*iftype*/, - CommunicationDirection /*dir*/) const + template + void communicate(DataHandle& /*data*/, InterfaceType /*iftype*/, CommunicationDirection /*dir*/) const { - // not existing for this type of grid yet + // not existing for this type of grid yet } /*! @@ -238,7 +242,9 @@ class AluGridVanguard : public FlowBaseVanguard * to the corresponding element index of the logically Cartesian index. */ const CartesianIndexMapper& cartesianIndexMapper() const - { return *cartesianIndexMapper_; } + { + return *cartesianIndexMapper_; + } /*! * \brief Returns the object which maps a global element index of the simulation grid @@ -246,13 +252,17 @@ class AluGridVanguard : public FlowBaseVanguard * No refinement is supported for AluGrid so it coincides with CartesianIndexMapper. */ const LevelCartesianIndexMapper levelCartesianIndexMapper() const - { return LevelCartesianIndexMapper(*cartesianIndexMapper_); } + { + return LevelCartesianIndexMapper(*cartesianIndexMapper_); + } /*! * \brief Returns mapper from compressed to cartesian indices for the EQUIL grid */ const EquilCartesianIndexMapper& equilCartesianIndexMapper() const - { return *equilCartesianIndexMapper_; } + { + return *equilCartesianIndexMapper_; + } /*! * \brief Get function to query cell centroids for a distributed grid. @@ -261,15 +271,14 @@ class AluGridVanguard : public FlowBaseVanguard * It is a function return the centroid for the given element * index. */ - std::function(int)> - cellCentroids() const + std::function(int)> cellCentroids() const { return this->cellCentroids_(this->cartesianIndexMapper(), false); } const TransmissibilityType& globalTransmissibility() const { - assert( globalTrans_ != nullptr ); + assert(globalTrans_ != nullptr); return *globalTrans_; } @@ -279,16 +288,18 @@ class AluGridVanguard : public FlowBaseVanguard } std::vector cellPartition() const - { + { // not required for this type of grid yet return {}; } - - unsigned int gridEquilIdxToGridIdx(unsigned int elemIndex) const { + + unsigned int gridEquilIdxToGridIdx(unsigned int elemIndex) const + { return equilGridToGrid_[elemIndex]; } - unsigned int gridIdxToEquilGridIdx(unsigned int elemIndex) const { + unsigned int gridIdxToEquilGridIdx(unsigned int elemIndex) const + { return ordering_[elemIndex]; } @@ -321,12 +332,11 @@ class AluGridVanguard : public FlowBaseVanguard this->equilGrid_ = std::make_unique(); #endif // Note: removed_cells is guaranteed to be empty on ranks other than 0. - auto removed_cells = - this->equilGrid_->processEclipseFormat(input_grid, - &this->eclState(), - /*isPeriodic=*/false, - /*flipNormals=*/false, - /*clipZ=*/false); + auto removed_cells = this->equilGrid_->processEclipseFormat(input_grid, + &this->eclState(), + /*isPeriodic=*/false, + /*flipNormals=*/false, + /*clipZ=*/false); cartesianCellId_ = this->equilGrid_->globalCell(); @@ -341,7 +351,8 @@ class AluGridVanguard : public FlowBaseVanguard factory_ = std::make_unique(); grid_ = factory_->convert(*equilGrid_, cartesianCellId_, ordering_); - OpmLog::warning("Space Filling Curve (SFC) ordering is enabled: see flow_blackoil_alugrid for more informations on disabling/enabling SFC reordering"); + OpmLog::warning("Space Filling Curve (SFC) ordering is enabled: see flow_blackoil_alugrid for more " + "informations on disabling/enabling SFC reordering"); equilGridToGrid_.resize(ordering_.size()); for (std::size_t index = 0; index < ordering_.size(); ++index) { equilGridToGrid_[ordering_[index]] = index; @@ -364,7 +375,7 @@ class AluGridVanguard : public FlowBaseVanguard std::vector cartesianCellId_; std::vector ordering_; std::vector equilGridToGrid_; - std::array cartesianDimension_; + std::array cartesianDimension_; std::unique_ptr cartesianIndexMapper_; std::unique_ptr equilCartesianIndexMapper_; std::unique_ptr factory_; diff --git a/opm/simulators/flow/Banners.cpp b/opm/simulators/flow/Banners.cpp index b164e47eb78..88edb12cb47 100644 --- a/opm/simulators/flow/Banners.cpp +++ b/opm/simulators/flow/Banners.cpp @@ -37,31 +37,36 @@ #include #include -namespace { +namespace +{ -unsigned long long getTotalSystemMemory() +unsigned long long +getTotalSystemMemory() { long pages = sysconf(_SC_PHYS_PAGES); long page_size = sysconf(_SC_PAGE_SIZE); return pages * page_size; } -} +} // namespace -namespace Opm { +namespace Opm +{ -void printPRTHeader(const int nprocs, const int nthreads, - const std::string& parameters, - std::string_view moduleVersion, - std::string_view compileTimestamp) +void +printPRTHeader(const int nprocs, + const int nthreads, + const std::string& parameters, + std::string_view moduleVersion, + std::string_view compileTimestamp) { const double megabyte = 1024 * 1024; unsigned num_cpu = std::thread::hardware_concurrency(); struct utsname arch; const char* user = getlogin(); std::time_t now = std::time(0); - struct std::tm tstruct; - char tmstr[80]; + struct std::tm tstruct; + char tmstr[80]; tstruct = *std::localtime(&now); std::strftime(tmstr, sizeof(tmstr), "%d-%m-%Y at %X", &tstruct); const double mem_size = getTotalSystemMemory() / megabyte; @@ -76,29 +81,30 @@ void printPRTHeader(const int nprocs, const int nthreads, ss << " and is part of OPM.\nFor more information visit: https://opm-project.org \n\n"; ss << "Flow Version = " << moduleVersion << "\n"; if (uname(&arch) == 0) { - ss << "Machine name = " << arch.nodename << " (Number of logical cores: " << num_cpu; - ss << ", Memory size: " << std::fixed << std::setprecision (2) << mem_size << " MB) \n"; - ss << "Operating system = " << arch.sysname << " " << arch.machine << " (Kernel: " << arch.release; - ss << ", " << arch.version << " )\n"; - ss << "Build time = " << compileTimestamp << "\n"; + ss << "Machine name = " << arch.nodename << " (Number of logical cores: " << num_cpu; + ss << ", Memory size: " << std::fixed << std::setprecision(2) << mem_size << " MB) \n"; + ss << "Operating system = " << arch.sysname << " " << arch.machine << " (Kernel: " << arch.release; + ss << ", " << arch.version << " )\n"; + ss << "Build time = " << compileTimestamp << "\n"; } if (user) { - ss << "User = " << user << std::endl; + ss << "User = " << user << std::endl; } ss << "Simulation started on " << tmstr << " hrs\n"; - ss << "Using "<< nprocs << " MPI processes with "<< nthreads <<" OMP threads on each \n"; + ss << "Using " << nprocs << " MPI processes with " << nthreads << " OMP threads on each \n"; ss << "Parameters used by Flow:\n" << parameters; OpmLog::note(ss.str()); } -void printFlowBanner(int nprocs, int nthreads, std::string_view moduleVersionName) +void +printFlowBanner(int nprocs, int nthreads, std::string_view moduleVersionName) { const int lineLen = 70; std::string banner = "This is flow "; banner += moduleVersionName; - const int bannerPreLen = (lineLen - 2 - banner.size())/2; - const int bannerPostLen = bannerPreLen + (lineLen - 2 - banner.size())%2; + const int bannerPreLen = (lineLen - 2 - banner.size()) / 2; + const int bannerPostLen = bannerPreLen + (lineLen - 2 - banner.size()) % 2; std::cout << "**********************************************************************\n"; std::cout << "* *\n"; std::cout << "*" << std::string(bannerPreLen, ' ') << banner << std::string(bannerPostLen, ' ') << "*\n"; @@ -109,14 +115,12 @@ void printFlowBanner(int nprocs, int nthreads, std::string_view moduleVersionNam std::cout << "* *\n"; std::cout << "**********************************************************************\n\n"; - std::cout << "Using "<< nprocs << " MPI processes with "<< nthreads <<" OMP threads on each \n\n"; + std::cout << "Using " << nprocs << " MPI processes with " << nthreads << " OMP threads on each \n\n"; } -void printFlowTrailer(int nprocs, - int nthreads, - const double total_setup_time, - const double deck_read_time, - const SimulatorReport& report) +void +printFlowTrailer( + int nprocs, int nthreads, const double total_setup_time, const double deck_read_time, const SimulatorReport& report) { std::ostringstream ss; ss << "\n\n================ End of simulation ===============\n\n"; diff --git a/opm/simulators/flow/Banners.hpp b/opm/simulators/flow/Banners.hpp index 55a1d3374c2..a46aed851d4 100644 --- a/opm/simulators/flow/Banners.hpp +++ b/opm/simulators/flow/Banners.hpp @@ -25,13 +25,15 @@ #include #include -namespace Opm { +namespace Opm +{ struct SimulatorReport; struct SimulatorReportSingle; // Print an ASCII-art header to the PRT and DEBUG files. -void printPRTHeader(const int nprocs, const int nthreads, +void printPRTHeader(const int nprocs, + const int nthreads, const std::string& parameters, std::string_view moduleVersion, std::string_view compileTimestamp); diff --git a/opm/simulators/flow/BaseAquiferModel.hpp b/opm/simulators/flow/BaseAquiferModel.hpp index 683e4170d9d..a4b9e1e1c72 100644 --- a/opm/simulators/flow/BaseAquiferModel.hpp +++ b/opm/simulators/flow/BaseAquiferModel.hpp @@ -35,7 +35,8 @@ #include -namespace Opm { +namespace Opm +{ /*! * \ingroup BaseAquiferModel @@ -54,14 +55,16 @@ class BaseAquiferModel public: explicit BaseAquiferModel(Simulator& simulator) : simulator_(simulator) - {} + { + } /*! * \brief Called once the problem has been fully initialized and the initial * condition has been applied. */ void initialSolutionApplied() - { } + { + } /*! * \brief Called if aquifers are being initialized from values retrieved @@ -74,45 +77,43 @@ class BaseAquiferModel */ void initFromRestart(const data::Aquifers&) { - throw std::logic_error { - "Initialization from restart data not supported " - "for base aquifer model" - }; + throw std::logic_error {"Initialization from restart data not supported " + "for base aquifer model"}; } /*! * \brief This method is called when a new episode (report step) starts. */ void beginEpisode() - { } + { + } /*! * \brief This method is called when a new time step (substep) starts. */ void beginTimeStep() - { } + { + } /*! * \brief This method is called before each Newton-Raphson iteration. */ void beginIteration() - { } + { + } /*! * \brief Add the water which enters or leaves the reservoir due to aquifiers. */ template - void addToSource(RateVector&, - const Context&, - unsigned, - unsigned) const - { } + void addToSource(RateVector&, const Context&, unsigned, unsigned) const + { + } - void addToSource(RateVector&, - unsigned, - unsigned) const - { } + void addToSource(RateVector&, unsigned, unsigned) const + { + } /*! @@ -122,7 +123,8 @@ class BaseAquiferModel * procedures. */ void endIteration() - { } + { + } /*! * \brief This method is called after each successful time step (substep). @@ -131,14 +133,16 @@ class BaseAquiferModel * algorithm converged. */ void endTimeStep() - { } + { + } /*! * \brief This method is called once an episode (report step) has been finished * successfully. */ void endEpisode() - { } + { + } /*! * \brief Write the internal state of the aquifer model to disk using an ad-hoc file @@ -146,7 +150,8 @@ class BaseAquiferModel */ template void serialize(Restarter&) - { } + { + } /*! * \brief Load the internal state of the aquifer model to disk using an ad-hoc file @@ -154,10 +159,13 @@ class BaseAquiferModel */ template void deserialize(Restarter&) - { } + { + } data::Aquifers aquiferData() const - { return data::Aquifers{}; } + { + return data::Aquifers {}; + } protected: Simulator& simulator_; diff --git a/opm/simulators/flow/BioeffectsContainer.cpp b/opm/simulators/flow/BioeffectsContainer.cpp index 25db9407524..1e2da389d36 100644 --- a/opm/simulators/flow/BioeffectsContainer.cpp +++ b/opm/simulators/flow/BioeffectsContainer.cpp @@ -34,11 +34,12 @@ #include #include -namespace Opm { +namespace Opm +{ -template -void BioeffectsContainer:: -allocate(const unsigned bufferSize, const bool isMICP) +template +void +BioeffectsContainer::allocate(const unsigned bufferSize, const bool isMICP) { cMicrobes_.resize(bufferSize, 0.0); cBiofilm_.resize(bufferSize, 0.0); @@ -50,96 +51,85 @@ allocate(const unsigned bufferSize, const bool isMICP) allocated_ = true; } -template -void BioeffectsContainer:: -assign(const unsigned globalDofIdx, - const Scalar oxygenConcentration, - const Scalar ureaConcentration, - const Scalar calciteConcentration) +template +void +BioeffectsContainer::assign(const unsigned globalDofIdx, + const Scalar oxygenConcentration, + const Scalar ureaConcentration, + const Scalar calciteConcentration) { cOxygen_[globalDofIdx] = oxygenConcentration; cUrea_[globalDofIdx] = ureaConcentration; cCalcite_[globalDofIdx] = calciteConcentration; } -template -void BioeffectsContainer:: -assign(const unsigned globalDofIdx, - const Scalar microbialConcentration, - const Scalar biofilmConcentration) +template +void +BioeffectsContainer::assign(const unsigned globalDofIdx, + const Scalar microbialConcentration, + const Scalar biofilmConcentration) { cMicrobes_[globalDofIdx] = microbialConcentration; cBiofilm_[globalDofIdx] = biofilmConcentration; } -template +template BioeffectsSolutionContainer -BioeffectsContainer:: -getSolution() const +BioeffectsContainer::getSolution() const { - return { - cMicrobes_, - cOxygen_, - cUrea_, - cBiofilm_, - cCalcite_ - }; + return {cMicrobes_, cOxygen_, cUrea_, cBiofilm_, cCalcite_}; } -template -void BioeffectsContainer:: -outputRestart(data::Solution& sol, const bool isMICP) +template +void +BioeffectsContainer::outputRestart(data::Solution& sol, const bool isMICP) { if (!this->allocated_) { return; } - using DataEntry = - std::tuple&>; + using DataEntry = std::tuple&>; auto insert = [&sol](auto& entry) { if (!std::get<2>(entry).empty()) { sol.insert(std::get(entry), - std::get(entry), - std::move(std::get<2>(entry)), - data::TargetType::RESTART_OPM_EXTENDED); + std::get(entry), + std::move(std::get<2>(entry)), + data::TargetType::RESTART_OPM_EXTENDED); } }; - - auto solutionMicrobes = DataEntry{"MICROBES", UnitSystem::measure::density, cMicrobes_}; + + auto solutionMicrobes = DataEntry {"MICROBES", UnitSystem::measure::density, cMicrobes_}; insert(solutionMicrobes); - auto solutionBiofilm = DataEntry{"BIOFILM", UnitSystem::measure::identity, cBiofilm_}; + auto solutionBiofilm = DataEntry {"BIOFILM", UnitSystem::measure::identity, cBiofilm_}; insert(solutionBiofilm); if (isMICP) { auto solutionVectors = std::array { - DataEntry{"CALCITE", UnitSystem::measure::identity, cCalcite_}, - DataEntry{"OXYGEN", UnitSystem::measure::density, cOxygen_}, - DataEntry{"UREA", UnitSystem::measure::density, cUrea_}, + DataEntry {"CALCITE", UnitSystem::measure::identity, cCalcite_}, + DataEntry {"OXYGEN", UnitSystem::measure::density, cOxygen_}, + DataEntry {"UREA", UnitSystem::measure::density, cUrea_}, }; - std::for_each(solutionVectors.begin(), solutionVectors.end(), - [&insert](auto& entry) - { insert(entry); }); + std::for_each(solutionVectors.begin(), solutionVectors.end(), [&insert](auto& entry) { insert(entry); }); } allocated_ = false; } -template -void BioeffectsContainer:: -readRestart(const unsigned globalDofIdx, - const unsigned elemIdx, - const data::Solution& sol, - const bool isMICP) +template +void +BioeffectsContainer::readRestart(const unsigned globalDofIdx, + const unsigned elemIdx, + const data::Solution& sol, + const bool isMICP) { if (this->allocated_) { return; } - auto assign = [elemIdx, globalDofIdx, &sol](const std::string& name, - ScalarBuffer& data) + auto assign = [elemIdx, globalDofIdx, &sol](const std::string& name, ScalarBuffer& data) { if (!data.empty() && sol.has(name)) { @@ -151,14 +141,12 @@ readRestart(const unsigned globalDofIdx, assign("BIOFILM", *&cBiofilm_); if (isMICP) { - const auto fields = std::array{ - std::pair{"OXYGEN", &cOxygen_}, - std::pair{"UREA", &cUrea_}, - std::pair{"CALCITE", &cCalcite_}, + const auto fields = std::array { + std::pair {"OXYGEN", &cOxygen_}, + std::pair {"UREA", &cUrea_}, + std::pair {"CALCITE", &cCalcite_}, }; - std::for_each(fields.begin(), fields.end(), - [&assign](const auto& p) - { assign(p.first, *p.second); }); + std::for_each(fields.begin(), fields.end(), [&assign](const auto& p) { assign(p.first, *p.second); }); } } diff --git a/opm/simulators/flow/BioeffectsContainer.hpp b/opm/simulators/flow/BioeffectsContainer.hpp index fb00f6de131..2915bfdb323 100644 --- a/opm/simulators/flow/BioeffectsContainer.hpp +++ b/opm/simulators/flow/BioeffectsContainer.hpp @@ -28,12 +28,17 @@ #include -namespace Opm { +namespace Opm +{ -namespace data { class Solution; } -template struct BioeffectsSolutionContainer; +namespace data +{ + class Solution; +} +template +struct BioeffectsSolutionContainer; -template +template class BioeffectsContainer { using ScalarBuffer = std::vector; @@ -46,29 +51,26 @@ class BioeffectsContainer const Scalar ureaConcentration, const Scalar calciteConcentration); - void assign(const unsigned globalDofIdx, - const Scalar microbialConcentration, - const Scalar biofilmConcentration); + void assign(const unsigned globalDofIdx, const Scalar microbialConcentration, const Scalar biofilmConcentration); BioeffectsSolutionContainer getSolution() const; void outputRestart(data::Solution& sol, const bool isMICP); - void readRestart(const unsigned globalDofIdx, - const unsigned elemIdx, - const data::Solution& sol, - const bool isMICP); + void readRestart(const unsigned globalDofIdx, const unsigned elemIdx, const data::Solution& sol, const bool isMICP); bool allocated() const - { return allocated_; } + { + return allocated_; + } private: bool allocated_ = false; - ScalarBuffer cMicrobes_{}; - ScalarBuffer cOxygen_{}; - ScalarBuffer cUrea_{}; - ScalarBuffer cBiofilm_{}; - ScalarBuffer cCalcite_{}; + ScalarBuffer cMicrobes_ {}; + ScalarBuffer cOxygen_ {}; + ScalarBuffer cUrea_ {}; + ScalarBuffer cBiofilm_ {}; + ScalarBuffer cCalcite_ {}; }; } // namespace Opm diff --git a/opm/simulators/flow/BlackoilModel.hpp b/opm/simulators/flow/BlackoilModel.hpp index 8dcfecb30c8..25a81fc6990 100644 --- a/opm/simulators/flow/BlackoilModel.hpp +++ b/opm/simulators/flow/BlackoilModel.hpp @@ -48,7 +48,8 @@ #include -namespace Opm { +namespace Opm +{ /// A model implementation for three-phase black oil. /// @@ -106,7 +107,7 @@ class BlackoilModel using Mat = typename SparseMatrixAdapter::IstlMatrix; using BVector = Dune::BlockVector; - using ComponentName = ::Opm::ComponentName; + using ComponentName = ::Opm::ComponentName; // --------- Public methods --------- @@ -123,10 +124,14 @@ class BlackoilModel const bool terminal_output); bool isParallel() const - { return grid_.comm().size() > 1; } + { + return grid_.comm().size() > 1; + } const EclipseState& eclState() const - { return simulator_.vanguard().eclState(); } + { + return simulator_.vanguard().eclState(); + } /// Called once before each time step. /// \param[in] timer simulation timer @@ -161,19 +166,22 @@ class BlackoilModel SimulatorReportSingle afterStep(const SimulatorTimerInterface&); /// Assemble the residual and Jacobian of the nonlinear system. - SimulatorReportSingle assembleReservoir(const SimulatorTimerInterface& /* timer */, - const int iterationIdx); + SimulatorReportSingle assembleReservoir(const SimulatorTimerInterface& /* timer */, const int iterationIdx); // compute the "relative" change of the solution between time steps Scalar relativeChange() const; /// Number of linear iterations used in last call to solveJacobianSystem(). int linearIterationsLastSolve() const - { return simulator_.model().newtonMethod().linearSolver().iterations (); } + { + return simulator_.model().newtonMethod().linearSolver().iterations(); + } // Obtain reference to linear solver setup time double& linearSolveSetupTime() - { return linear_solve_setup_time_; } + { + return linear_solve_setup_time_; + } /// Solve the Jacobian system Jx = r where J is the Jacobian and /// r is the residual. @@ -184,30 +192,30 @@ class BlackoilModel /// Return true if output to cout is wanted. bool terminalOutputEnabled() const - { return terminal_output_; } + { + return terminal_output_; + } - std::tuple - convergenceReduction(Parallel::Communication comm, - const Scalar pvSumLocal, - const Scalar numAquiferPvSumLocal, - std::vector& R_sum, - std::vector& maxCoeff, - std::vector& B_avg); + std::tuple convergenceReduction(Parallel::Communication comm, + const Scalar pvSumLocal, + const Scalar numAquiferPvSumLocal, + std::vector& R_sum, + std::vector& maxCoeff, + std::vector& B_avg); /// \brief Get reservoir quantities on this process needed for convergence calculations. /// \return A pair of the local pore volume of interior cells and the pore volumes /// of the cells associated with a numerical aquifer. - std::pair - localConvergenceData(std::vector& R_sum, - std::vector& maxCoeff, - std::vector& B_avg, - std::vector& maxCoeffCell); + std::pair localConvergenceData(std::vector& R_sum, + std::vector& maxCoeff, + std::vector& B_avg, + std::vector& maxCoeffCell); /// \brief Compute pore-volume/cell count split among "converged", /// "relaxed converged", "unconverged" cells based on CNV point /// measures. - std::pair, std::vector> - characteriseCnvPvSplit(const std::vector& B_avg, const double dt); + std::pair, std::vector> characteriseCnvPvSplit(const std::vector& B_avg, + const double dt); /// \brief Compute the number of Newtons required by each cell in order to /// satisfy the solution change convergence criteria at the last time step. @@ -219,13 +227,12 @@ class BlackoilModel void updateTUNING(const Tuning& tuning); - ConvergenceReport - getReservoirConvergence(const double reportTime, - const double dt, - const int iteration, - const int maxIter, - std::vector& B_avg, - std::vector& residual_norms); + ConvergenceReport getReservoirConvergence(const double reportTime, + const double dt, + const int iteration, + const int maxIter, + std::vector& B_avg, + std::vector& residual_norms); /// Compute convergence based on total mass balance (tol_mb) and maximum /// residual mass balance (tol_cnv). @@ -233,35 +240,42 @@ class BlackoilModel /// \param[in] iteration current iteration number /// \param[in] maxIter maximum number of iterations /// \param[out] residual_norms CNV residuals by phase - ConvergenceReport - getConvergence(const SimulatorTimerInterface& timer, - const int iteration, - const int maxIter, - std::vector& residual_norms); + ConvergenceReport getConvergence(const SimulatorTimerInterface& timer, + const int iteration, + const int maxIter, + std::vector& residual_norms); /// The number of active fluid phases in the model. int numPhases() const - { return Indices::numPhases; } + { + return Indices::numPhases; + } /// Wrapper required due to not following generic API - template - std::vector > - computeFluidInPlace(const T&, const std::vector& fipnum) const - { return this->computeFluidInPlace(fipnum); } + template + std::vector> computeFluidInPlace(const T&, const std::vector& fipnum) const + { + return this->computeFluidInPlace(fipnum); + } /// Should not be called - std::vector > - computeFluidInPlace(const std::vector& /*fipnum*/) const; + std::vector> computeFluidInPlace(const std::vector& /*fipnum*/) const; const Simulator& simulator() const - { return simulator_; } + { + return simulator_; + } Simulator& simulator() - { return simulator_; } + { + return simulator_; + } /// return the statistics if the nonlinearIteration() method failed const SimulatorReportSingle& failureReport() const - { return failureReport_; } + { + return failureReport_; + } /// return the statistics of local solves accumulated for this rank const SimulatorReport& localAccumulatedReports() const; @@ -273,26 +287,34 @@ class BlackoilModel void writeNonlinearIterationsPerCell(const std::filesystem::path& odir) const; const std::vector& stepReports() const - { return convergence_reports_; } + { + return convergence_reports_; + } void writePartitions(const std::filesystem::path& odir) const; /// return the StandardWells object - BlackoilWellModel& - wellModel() - { return well_model_; } + BlackoilWellModel& wellModel() + { + return well_model_; + } - const BlackoilWellModel& - wellModel() const - { return well_model_; } + const BlackoilWellModel& wellModel() const + { + return well_model_; + } void beginReportStep() - { simulator_.problem().beginEpisode(); } + { + simulator_.problem().beginEpisode(); + } void endReportStep() - { simulator_.problem().endEpisode(); } + { + simulator_.problem().endEpisode(); + } - template + template void getMaxCoeff(const unsigned cell_idx, const IntensiveQuantities& intQuants, const FluidState& fs, @@ -305,15 +327,21 @@ class BlackoilModel //! \brief Returns const reference to model parameters. const ModelParameters& param() const - { return param_; } + { + return param_; + } //! \brief Returns const reference to component names. const ComponentName& compNames() const - { return compNames_; } + { + return compNames_; + } //! \brief Returns true if an NLDD solver exists - bool hasNlddSolver() const - { return nlddSolver_ != nullptr; } + bool hasNlddSolver() const + { + return nlddSolver_ != nullptr; + } protected: // --------- Data members --------- @@ -329,7 +357,7 @@ class BlackoilModel static constexpr bool has_bioeffects_ = getPropValue(); static constexpr bool has_micp_ = Indices::enableMICP; - ModelParameters param_; + ModelParameters param_; SimulatorReportSingle failureReport_; // Well Model @@ -345,16 +373,28 @@ class BlackoilModel BVector dx_old_; std::vector convergence_reports_; - ComponentName compNames_{}; + ComponentName compNames_ {}; std::unique_ptr> nlddSolver_; //!< Non-linear DD solver BlackoilModelConvergenceMonitor conv_monitor_; private: - Scalar dpMaxRel() const { return param_.dp_max_rel_; } - Scalar dsMax() const { return param_.ds_max_; } - Scalar drMaxRel() const { return param_.dr_max_rel_; } - Scalar maxResidualAllowed() const { return param_.max_residual_allowed_; } + Scalar dpMaxRel() const + { + return param_.dp_max_rel_; + } + Scalar dsMax() const + { + return param_.ds_max_; + } + Scalar drMaxRel() const + { + return param_.dr_max_rel_; + } + Scalar maxResidualAllowed() const + { + return param_.max_residual_allowed_; + } double linear_solve_setup_time_; std::vector wasSwitched_; }; diff --git a/opm/simulators/flow/BlackoilModelConvergenceMonitor.cpp b/opm/simulators/flow/BlackoilModelConvergenceMonitor.cpp index eca67e3dacf..d3c8e47359e 100644 --- a/opm/simulators/flow/BlackoilModelConvergenceMonitor.cpp +++ b/opm/simulators/flow/BlackoilModelConvergenceMonitor.cpp @@ -27,33 +27,32 @@ #include #include -namespace Opm { +namespace Opm +{ -template -BlackoilModelConvergenceMonitor:: -BlackoilModelConvergenceMonitor(const MonitorParams& param) +template +BlackoilModelConvergenceMonitor::BlackoilModelConvergenceMonitor(const MonitorParams& param) : param_(param) , prev_distance_(std::numeric_limits::infinity()) , prev_above_tolerance_(0) { } -template -void BlackoilModelConvergenceMonitor:: -checkPenaltyCard(ConvergenceReport& report, int iteration) +template +void +BlackoilModelConvergenceMonitor::checkPenaltyCard(ConvergenceReport& report, int iteration) { const auto& current_metrics = report.reservoirConvergence(); auto distances = std::vector(current_metrics.size(), 0.0); int current_above_tolerance = 0; for (size_t i = 0; i < current_metrics.size(); ++i) { - distances[i] = std::max(std::log10(current_metrics[i].value() / - current_metrics[i].tolerance()), 0.0); - // Count number of metrics above tolerance - if (current_metrics[i].value() > current_metrics[i].tolerance()) { - current_above_tolerance++; - } + distances[i] = std::max(std::log10(current_metrics[i].value() / current_metrics[i].tolerance()), 0.0); + // Count number of metrics above tolerance + if (current_metrics[i].value() > current_metrics[i].tolerance()) { + current_above_tolerance++; } + } // use L1 norm of the distances vector double current_distance = std::accumulate(distances.begin(), distances.end(), 0.0); @@ -79,16 +78,15 @@ checkPenaltyCard(ConvergenceReport& report, int iteration) total_penaltyCard_ += report.getPenaltyCard(); if (param_.enabled_ && (total_penaltyCard_.total() > param_.cutoff_)) { - report.setReservoirFailed( - {ConvergenceReport::ReservoirFailure::Type::ConvergenceMonitorFailure, - ConvergenceReport::Severity::ConvergenceMonitorFailure, - -1}); // -1 indicates it's not specific to any component + report.setReservoirFailed({ConvergenceReport::ReservoirFailure::Type::ConvergenceMonitorFailure, + ConvergenceReport::Severity::ConvergenceMonitorFailure, + -1}); // -1 indicates it's not specific to any component } } -template -void BlackoilModelConvergenceMonitor:: -reset() +template +void +BlackoilModelConvergenceMonitor::reset() { total_penaltyCard_.reset(); prev_above_tolerance_ = 0; diff --git a/opm/simulators/flow/BlackoilModelConvergenceMonitor.hpp b/opm/simulators/flow/BlackoilModelConvergenceMonitor.hpp index 87f0a913bf0..49872be912e 100644 --- a/opm/simulators/flow/BlackoilModelConvergenceMonitor.hpp +++ b/opm/simulators/flow/BlackoilModelConvergenceMonitor.hpp @@ -27,7 +27,8 @@ #include #include -namespace Opm { +namespace Opm +{ /// Implementation of penalty cards for three-phase black oil. template diff --git a/opm/simulators/flow/BlackoilModelNldd.hpp b/opm/simulators/flow/BlackoilModelNldd.hpp index 705b9d54942..cd5188a2a61 100644 --- a/opm/simulators/flow/BlackoilModelNldd.hpp +++ b/opm/simulators/flow/BlackoilModelNldd.hpp @@ -30,12 +30,12 @@ #include -#include #include #include +#include +#include #include #include -#include #include @@ -71,9 +71,11 @@ #include #include -namespace Opm { +namespace Opm +{ -template class BlackoilModel; +template +class BlackoilModel; /// A NLDD implementation for three-phase black oil. template @@ -167,15 +169,12 @@ class BlackoilModelNldd interior[ix] = true; } - Dune::SubGridPart view{grid, std::move(seeds[index])}; + Dune::SubGridPart view {grid, std::move(seeds[index])}; // Mark the last domain for skipping if it contains isolated cells const bool skip = isolated_cells && (index == num_domains - 1); - this->domains_.emplace_back(index, - std::move(partitions[index]), - std::move(interior), - std::move(view), - skip); + this->domains_.emplace_back( + index, std::move(partitions[index]), std::move(interior), std::move(view), skip); } // Initialize storage for previous mobilities in a single flat vector @@ -215,13 +214,12 @@ class BlackoilModelNldd domain_reports_accumulated_.resize(num_domains); // Print domain distribution summary - ::Opm::printDomainDistributionSummary( - partition_vector, - domains_, - local_reports_accumulated_, - domain_reports_accumulated_, - grid, - wellModel_.numLocalWellsEnd()); + ::Opm::printDomainDistributionSummary(partition_vector, + domains_, + local_reports_accumulated_, + domain_reports_accumulated_, + grid, + wellModel_.numLocalWellsEnd()); } //! \brief Called before starting a time step. @@ -241,14 +239,12 @@ class BlackoilModelNldd SimulatorReportSingle report; if (iteration < model_.param().nldd_num_initial_newton_iter_) { - report = model_.nonlinearIterationNewton(iteration, - timer, - nonlinear_solver); + report = model_.nonlinearIterationNewton(iteration, timer, nonlinear_solver); return report; } - model_.initialLinearization(report, iteration, model_.param().newton_min_iter_, - model_.param().newton_max_iter_, timer); + model_.initialLinearization( + report, iteration, model_.param().newton_min_iter_, model_.param().newton_max_iter_, timer); if (report.converged) { return report; @@ -289,17 +285,14 @@ class BlackoilModelNldd try { switch (model_.param().local_solve_approach_) { case DomainSolveApproach::Jacobi: - solveDomainJacobi(solution, locally_solved, local_report, logger, - iteration, timer, domain); + solveDomainJacobi(solution, locally_solved, local_report, logger, iteration, timer, domain); break; default: case DomainSolveApproach::GaussSeidel: - solveDomainGaussSeidel(solution, locally_solved, local_report, logger, - iteration, timer, domain); + solveDomainGaussSeidel(solution, locally_solved, local_report, logger, iteration, timer, domain); break; } - } - catch (...) { + } catch (...) { // Something went wrong during local solves. local_report.converged = false; } @@ -308,7 +301,7 @@ class BlackoilModelNldd // i == j, at old solution for i != j. if (!local_report.converged) { // TODO: more proper treatment, including in parallel. - logger.debug(fmt::format("Convergence failure in domain {} on rank {}." , domain.index, rank_)); + logger.debug(fmt::format("Convergence failure in domain {} on rank {}.", domain.index, rank_)); } local_report.solver_time += detailTimer.stop(); domain_reports[domain.index] = local_report; @@ -322,7 +315,7 @@ class BlackoilModelNldd // Accumulate local solve data. // Putting the counts in a single array to avoid multiple // comm.sum() calls. Keeping the named vars for readability. - std::array counts{ 0, 0, 0, static_cast(domain_reports.size()), 0 }; + std::array counts {0, 0, 0, static_cast(domain_reports.size()), 0}; int& num_converged = counts[0]; int& num_converged_already = counts[1]; int& num_local_newtons = counts[2]; @@ -331,7 +324,7 @@ class BlackoilModelNldd { auto step_newtons = 0; const auto dr_size = domain_reports.size(); - for (auto i = 0*dr_size; i < dr_size; ++i) { + for (auto i = 0 * dr_size; i < dr_size; ++i) { // Reset the needsSolving flag for the next iteration domain_needs_solving_[i] = false; const auto& dr = domain_reports[i]; @@ -339,8 +332,7 @@ class BlackoilModelNldd ++num_converged; if (dr.total_newton_iterations == 0) { ++num_converged_already; - } - else { + } else { // If we needed to solve the domain, we also solve in next iteration domain_needs_solving_[i] = true; } @@ -398,8 +390,13 @@ class BlackoilModelNldd const bool is_iorank = this->rank_ == 0; if (is_iorank) { - OpmLog::debug(fmt::format("Local solves finished. Converged for {}/{} domains. {} domains were skipped. {} domains did no work. {} total local Newton iterations.\n", - num_converged, num_domains, num_skipped, num_converged_already, num_local_newtons)); + OpmLog::debug(fmt::format("Local solves finished. Converged for {}/{} domains. {} domains were skipped. {} " + "domains did no work. {} total local Newton iterations.\n", + num_converged, + num_domains, + num_skipped, + num_converged_already, + num_local_newtons)); } auto total_local_solve_time = localSolveTimer.stop(); report.local_solve_time += total_local_solve_time; @@ -432,7 +429,7 @@ class BlackoilModelNldd // this is a mutable operation that updates the well counts in the domain reports. const auto dr_size = domain_reports_accumulated_.size(); // Reset well counts before updating - for (auto i = 0*dr_size; i < dr_size; ++i) { + for (auto i = 0 * dr_size; i < dr_size; ++i) { domain_reports_accumulated_[i].success.num_wells = 0; } // Update the number of wells for each domain @@ -450,12 +447,7 @@ class BlackoilModelNldd const auto& elementMapper = this->model_.simulator().model().elementMapper(); const auto& cartMapper = this->model_.simulator().vanguard().cartesianIndexMapper(); - ::Opm::writePartitions( - odir, - domains_, - grid, - elementMapper, - cartMapper); + ::Opm::writePartitions(odir, domains_, grid, elementMapper, cartMapper); } /// Write the number of nonlinear iterations per cell to a file in ResInsight compatible format @@ -466,23 +458,17 @@ class BlackoilModelNldd const auto& cartMapper = this->model_.simulator().vanguard().cartesianIndexMapper(); ::Opm::writeNonlinearIterationsPerCell( - odir, - domains_, - domain_reports_accumulated_, - grid, - elementMapper, - cartMapper); + odir, domains_, domain_reports_accumulated_, grid, elementMapper, cartMapper); } private: //! \brief Solve the equation system for a single domain. - ConvergenceReport - solveDomain(const Domain& domain, - const SimulatorTimerInterface& timer, - SimulatorReportSingle& local_report, - DeferredLogger& logger, - [[maybe_unused]] const int global_iteration, - const bool initial_assembly_required) + ConvergenceReport solveDomain(const Domain& domain, + const SimulatorTimerInterface& timer, + SimulatorReportSingle& local_report, + DeferredLogger& logger, + [[maybe_unused]] const int global_iteration, + const bool initial_assembly_required) { auto& modelSimulator = model_.simulator(); Dune::Timer detailTimer; @@ -499,9 +485,8 @@ class BlackoilModelNldd modelSimulator.model().newtonMethod().setIterationIndex(iter); // TODO: we should have a beginIterationLocal function() // only handling the well model for now - wellModel_.assemble(modelSimulator.model().newtonMethod().numIterations(), - modelSimulator.timeStepSize(), - domain); + wellModel_.assemble( + modelSimulator.model().newtonMethod().numIterations(), modelSimulator.timeStepSize(), domain); const double tt0 = detailTimer.stop(); local_report.assemble_time += tt0; local_report.assemble_time_well += tt0; @@ -527,9 +512,8 @@ class BlackoilModelNldd // but not done the Schur complement for the wells yet. detailTimer.reset(); detailTimer.start(); - model_.wellModel().linearizeDomain(domain, - modelSimulator.model().linearizer().jacobian(), - modelSimulator.model().linearizer().residual()); + model_.wellModel().linearizeDomain( + domain, modelSimulator.model().linearizer().jacobian(), modelSimulator.model().linearizer().residual()); const double tt1 = detailTimer.stop(); local_report.assemble_time += tt1; local_report.assemble_time_well += tt1; @@ -571,9 +555,8 @@ class BlackoilModelNldd // TODO: we should have a beginIterationLocal function() // only handling the well model for now // Assemble reservoir locally. - wellModel_.assemble(modelSimulator.model().newtonMethod().numIterations(), - modelSimulator.timeStepSize(), - domain); + wellModel_.assemble( + modelSimulator.model().newtonMethod().numIterations(), modelSimulator.timeStepSize(), domain); const double tt3 = detailTimer.stop(); local_report.assemble_time += tt3; local_report.assemble_time_well += tt3; @@ -594,9 +577,8 @@ class BlackoilModelNldd // reservoir linearized equations detailTimer.reset(); detailTimer.start(); - model_.wellModel().linearizeDomain(domain, - modelSimulator.model().linearizer().jacobian(), - modelSimulator.model().linearizer().residual()); + model_.wellModel().linearizeDomain( + domain, modelSimulator.model().linearizer().jacobian(), modelSimulator.model().linearizer().residual()); const double tt2 = detailTimer.stop(); local_report.assemble_time += tt2; local_report.assemble_time_well += tt2; @@ -606,8 +588,8 @@ class BlackoilModelNldd bool oscillate = false; bool stagnate = false; const auto num_residuals = convergence_history.front().size(); - detail::detectOscillations(convergence_history, iter, num_residuals, - Scalar{0.2}, 1, oscillate, stagnate); + detail::detectOscillations( + convergence_history, iter, num_residuals, Scalar {0.2}, 1, oscillate, stagnate); if (oscillate) { damping_factor *= 0.85; logger.debug(fmt::format("| Damping factor is now {}", damping_factor)); @@ -647,8 +629,7 @@ class BlackoilModelNldd domain_matrices_[domain.index] = std::make_unique(Details::extractMatrix(main_matrix, domain.cells)); } auto& jac = *domain_matrices_[domain.index]; - auto res = Details::extractVector(modelSimulator.model().linearizer().residual(), - domain.cells); + auto res = Details::extractVector(modelSimulator.model().linearizer().residual(), domain.cells); auto x = res; // set initial guess @@ -706,10 +687,7 @@ class BlackoilModelNldd const auto& elemEndIt = gridView.template end(); IsNumericalAquiferCell isNumericalAquiferCell(gridView.grid()); - for (auto elemIt = gridView.template begin(); - elemIt != elemEndIt; - ++elemIt) - { + for (auto elemIt = gridView.template begin(); elemIt != elemEndIt; ++elemIt) { if (elemIt->partitionType() != Dune::InteriorEntity) { continue; } @@ -721,24 +699,20 @@ class BlackoilModelNldd const auto& intQuants = elemCtx.intensiveQuantities(/*spaceIdx=*/0, /*timeIdx=*/0); const auto& fs = intQuants.fluidState(); - const auto pvValue = problem.referencePorosity(cell_idx, /*timeIdx=*/0) * - model.dofTotalVolume(cell_idx); + const auto pvValue = problem.referencePorosity(cell_idx, /*timeIdx=*/0) * model.dofTotalVolume(cell_idx); pvSumLocal += pvValue; - if (isNumericalAquiferCell(elem)) - { + if (isNumericalAquiferCell(elem)) { numAquiferPvSumLocal += pvValue; } - model_.getMaxCoeff(cell_idx, intQuants, fs, modelResid, pvValue, - B_avg, R_sum, maxCoeff, maxCoeffCell); + model_.getMaxCoeff(cell_idx, intQuants, fs, modelResid, pvValue, B_avg, R_sum, maxCoeff, maxCoeffCell); } // compute local average in terms of global number of elements const int bSize = B_avg.size(); - for ( int i = 0; i; const int numComp = numEq; - Vector R_sum(numComp, 0.0 ); - Vector maxCoeff(numComp, std::numeric_limits::lowest() ); + Vector R_sum(numComp, 0.0); + Vector maxCoeff(numComp, std::numeric_limits::lowest()); std::vector maxCoeffCell(numComp, -1); - const auto [ pvSum, numAquiferPvSum] + const auto [pvSum, numAquiferPvSum] = this->localDomainConvergenceData(domain, R_sum, maxCoeff, B_avg, maxCoeffCell); auto cnvErrorPvFraction = computeCnvErrorPvLocal(domain, B_avg, dt); @@ -767,36 +741,34 @@ class BlackoilModelNldd // Default value of relaxed_max_pv_fraction_ is 0.03 and min_strict_cnv_iter_ is 0. // For each iteration, we need to determine whether to use the relaxed CNV tolerance. // To disable the usage of relaxed CNV tolerance, you can set the relaxed_max_pv_fraction_ to be 0. - const bool use_relaxed_cnv = cnvErrorPvFraction < model_.param().relaxed_max_pv_fraction_ && - iteration >= model_.param().min_strict_cnv_iter_; + const bool use_relaxed_cnv = cnvErrorPvFraction < model_.param().relaxed_max_pv_fraction_ + && iteration >= model_.param().min_strict_cnv_iter_; // Tighter bound for local convergence should increase the // likelyhood of: local convergence => global convergence const Scalar tol_cnv = model_.param().local_tolerance_scaling_cnv_ - * (use_relaxed_cnv ? model_.param().tolerance_cnv_relaxed_ - : model_.param().tolerance_cnv_); + * (use_relaxed_cnv ? model_.param().tolerance_cnv_relaxed_ : model_.param().tolerance_cnv_); const bool use_relaxed_mb = iteration >= model_.param().min_strict_mb_iter_; - const Scalar tol_mb = model_.param().local_tolerance_scaling_mb_ + const Scalar tol_mb = model_.param().local_tolerance_scaling_mb_ * (use_relaxed_mb ? model_.param().tolerance_mb_relaxed_ : model_.param().tolerance_mb_); // Finish computation std::vector CNV(numComp); std::vector mass_balance_residual(numComp); - for (int compIdx = 0; compIdx < numComp; ++compIdx ) - { - CNV[compIdx] = B_avg[compIdx] * dt * maxCoeff[compIdx]; - mass_balance_residual[compIdx] = std::abs(B_avg[compIdx]*R_sum[compIdx]) * dt / pvSum; + for (int compIdx = 0; compIdx < numComp; ++compIdx) { + CNV[compIdx] = B_avg[compIdx] * dt * maxCoeff[compIdx]; + mass_balance_residual[compIdx] = std::abs(B_avg[compIdx] * R_sum[compIdx]) * dt / pvSum; residual_norms.push_back(CNV[compIdx]); } // Create convergence report. - ConvergenceReport report{reportTime}; + ConvergenceReport report {reportTime}; using CR = ConvergenceReport; for (int compIdx = 0; compIdx < numComp; ++compIdx) { - Scalar res[2] = { mass_balance_residual[compIdx], CNV[compIdx] }; - CR::ReservoirFailure::Type types[2] = { CR::ReservoirFailure::Type::MassBalance, - CR::ReservoirFailure::Type::Cnv }; - Scalar tol[2] = { tol_mb, tol_cnv }; + Scalar res[2] = {mass_balance_residual[compIdx], CNV[compIdx]}; + CR::ReservoirFailure::Type types[2] + = {CR::ReservoirFailure::Type::MassBalance, CR::ReservoirFailure::Type::Cnv}; + Scalar tol[2] = {tol_mb, tol_cnv}; for (int ii : {0, 1}) { if (std::isnan(res[ii])) { report.setReservoirFailed({types[ii], CR::Severity::NotANumber, compIdx}); @@ -821,7 +793,10 @@ class BlackoilModelNldd if (iteration == 0) { // Log header. std::string msg = fmt::format("Domain {} on rank {}, size {}, containing cell {}\n| Iter", - domain.index, this->rank_, domain.cells.size(), domain.cells[0]); + domain.index, + this->rank_, + domain.cells.size(), + domain.cells[0]); for (int compIdx = 0; compIdx < numComp; ++compIdx) { msg += " MB("; msg += model_.compNames().name(compIdx)[0]; @@ -862,13 +837,8 @@ class BlackoilModelNldd { OPM_TIMEBLOCK(getDomainConvergence); std::vector B_avg(numEq, 0.0); - auto report = this->getDomainReservoirConvergence(timer.simulationTimeElapsed(), - timer.currentStepLength(), - iteration, - domain, - logger, - B_avg, - residual_norms); + auto report = this->getDomainReservoirConvergence( + timer.simulationTimeElapsed(), timer.currentStepLength(), iteration, domain, logger, B_avg, residual_norms); report += wellModel_.getWellConvergence(domain, B_avg, logger); return report; } @@ -892,10 +862,12 @@ class BlackoilModelNldd case DomainOrderingMeasure::AveragePressure: { // Use average pressures to order domains. for (const auto& domain : domains_) { - const Scalar press_sum = - std::accumulate(domain.cells.begin(), domain.cells.end(), Scalar{0}, - [&solution](const auto acc, const auto c) - { return acc + solution[c][Indices::pressureSwitchIdx]; }); + const Scalar press_sum = std::accumulate(domain.cells.begin(), + domain.cells.end(), + Scalar {0}, + [&solution](const auto acc, const auto c) { + return acc + solution[c][Indices::pressureSwitchIdx]; + }); const Scalar avgpress = press_sum / domain.cells.size(); measure_per_domain[domain.index] = avgpress; } @@ -904,10 +876,13 @@ class BlackoilModelNldd case DomainOrderingMeasure::MaxPressure: { // Use max pressures to order domains. for (const auto& domain : domains_) { - measure_per_domain[domain.index] = - std::accumulate(domain.cells.begin(), domain.cells.end(), Scalar{0}, - [&solution](const auto acc, const auto c) - { return std::max(acc, solution[c][Indices::pressureSwitchIdx]); }); + measure_per_domain[domain.index] + = std::accumulate(domain.cells.begin(), + domain.cells.end(), + Scalar {0}, + [&solution](const auto acc, const auto c) { + return std::max(acc, solution[c][Indices::pressureSwitchIdx]); + }); } break; } @@ -930,15 +905,15 @@ class BlackoilModelNldd // Sort by largest measure, keeping index order if equal. const auto& m = measure_per_domain; - std::stable_sort(domain_order.begin(), domain_order.end(), - [&m](const int i1, const int i2){ return m[i1] > m[i2]; }); + std::stable_sort( + domain_order.begin(), domain_order.end(), [&m](const int i1, const int i2) { return m[i1] > m[i2]; }); return domain_order; } else { throw std::logic_error("Domain solve approach must be Jacobi or Gauss-Seidel"); } } - template + template void solveDomainJacobi(GlobalEqVector& solution, GlobalEqVector& locally_solved, SimulatorReportSingle& local_report, @@ -962,7 +937,7 @@ class BlackoilModelNldd } } - template + template void solveDomainGaussSeidel(GlobalEqVector& solution, GlobalEqVector& locally_solved, SimulatorReportSingle& local_report, @@ -995,7 +970,8 @@ class BlackoilModelNldd if (mb_sum < acceptable_local_mb_sum && cnv_sum < acceptable_local_cnv_sum) { local_report.converged = true; local_report.accepted_unconverged_domains += 1; - logger.debug(fmt::format("Accepting solution in unconverged domain {} on rank {}.", domain.index, rank_)); + logger.debug( + fmt::format("Accepting solution in unconverged domain {} on rank {}.", domain.index, rank_)); logger.debug(fmt::format("Value of mb_sum: {} cnv_sum: {}", mb_sum, cnv_sum)); } else { logger.debug("Unconverged local solution."); @@ -1019,18 +995,16 @@ class BlackoilModelNldd } } - Scalar computeCnvErrorPvLocal(const Domain& domain, - const std::vector& B_avg, double dt) const + Scalar computeCnvErrorPvLocal(const Domain& domain, const std::vector& B_avg, double dt) const { - Scalar errorPV{}; + Scalar errorPV {}; const auto& simulator = model_.simulator(); const auto& model = simulator.model(); const auto& problem = simulator.problem(); const auto& residual = simulator.model().linearizer().residual(); for (const int cell_idx : domain.cells) { - const Scalar pvValue = problem.referencePorosity(cell_idx, /*timeIdx=*/0) * - model.dofTotalVolume(cell_idx); + const Scalar pvValue = problem.referencePorosity(cell_idx, /*timeIdx=*/0) * model.dofTotalVolume(cell_idx); const auto& cellResidual = residual[cell_idx]; bool cnvViolated = false; @@ -1051,38 +1025,27 @@ class BlackoilModelNldd { const auto& grid = this->model_.simulator().vanguard().grid(); - using GridView = std::remove_cv_t>; + using GridView = std::remove_cv_t>; - using Element = std::remove_cv_t::Entity>>; + using Element = std::remove_cv_t::Entity>>; const auto& param = this->model_.param(); - auto zoltan_ctrl = ZoltanPartitioningControl{}; + auto zoltan_ctrl = ZoltanPartitioningControl {}; zoltan_ctrl.domain_imbalance = param.local_domains_partition_imbalance_; - zoltan_ctrl.index = - [elementMapper = &this->model_.simulator().model().elementMapper()] - (const Element& element) - { - return elementMapper->index(element); - }; + zoltan_ctrl.index = [elementMapper = &this->model_.simulator().model().elementMapper()]( + const Element& element) { return elementMapper->index(element); }; - zoltan_ctrl.local_to_global = - [cartMapper = &this->model_.simulator().vanguard().cartesianIndexMapper()] - (const int elemIdx) - { - return cartMapper->cartesianIndex(elemIdx); - }; + zoltan_ctrl.local_to_global = [cartMapper = &this->model_.simulator().vanguard().cartesianIndexMapper()]( + const int elemIdx) { return cartMapper->cartesianIndex(elemIdx); }; // Forming the list of wells is expensive, so do this only if needed. const auto need_wells = param.local_domains_partition_method_ == "zoltan"; - const auto wells = need_wells - ? this->model_.simulator().vanguard().schedule().getWellsatEnd() - : std::vector{}; + const auto wells + = need_wells ? this->model_.simulator().vanguard().schedule().getWellsatEnd() : std::vector {}; const auto& possibleFutureConnectionSet = need_wells ? this->model_.simulator().vanguard().schedule().getPossibleFutureConnections() @@ -1094,8 +1057,11 @@ class BlackoilModelNldd ? param.num_local_domains_ : detail::countGlobalCells(grid) / default_cells_per_domain; return ::Opm::partitionCells(param.local_domains_partition_method_, - num_domains, grid.leafGridView(), wells, - possibleFutureConnectionSet, zoltan_ctrl, + num_domains, + grid.leafGridView(), + wells, + possibleFutureConnectionSet, + zoltan_ctrl, param.local_domains_partition_well_neighbor_levels_); } @@ -1179,7 +1145,8 @@ class BlackoilModelNldd // mutable because we need to update the number of wells for each domain in getDomainAccumulatedReports() mutable std::vector domain_reports_accumulated_; //!< Accumulated convergence reports per domain int rank_ = 0; //!< MPI rank of this process - // Store previous mobilities to check for changes - single flat vector indexed by (globalCellIdx * numActivePhases + activePhaseIdx) + // Store previous mobilities to check for changes - single flat vector indexed by (globalCellIdx * numActivePhases + + // activePhaseIdx) std::vector previousMobilities_; // Flag indicating if this domain should be solved in the next iteration std::vector domain_needs_solving_; diff --git a/opm/simulators/flow/BlackoilModelParameters.cpp b/opm/simulators/flow/BlackoilModelParameters.cpp index 45166a6b35b..a5cbc1ec135 100644 --- a/opm/simulators/flow/BlackoilModelParameters.cpp +++ b/opm/simulators/flow/BlackoilModelParameters.cpp @@ -29,9 +29,10 @@ #include #include -namespace Opm { +namespace Opm +{ -template +template BlackoilModelParameters::BlackoilModelParameters() { dbhp_max_rel_ = Parameters::Get>(); @@ -44,11 +45,13 @@ BlackoilModelParameters::BlackoilModelParameters() tolerance_mb_ = Parameters::Get>(); tolerance_mb_relaxed_ = std::max(tolerance_mb_, Parameters::Get>()); tolerance_energy_balance_ = Parameters::Get>(); - tolerance_energy_balance_relaxed_ = std::max(tolerance_energy_balance_, Parameters::Get>()); + tolerance_energy_balance_relaxed_ + = std::max(tolerance_energy_balance_, Parameters::Get>()); tolerance_cnv_ = Parameters::Get>(); tolerance_cnv_relaxed_ = std::max(tolerance_cnv_, Parameters::Get>()); tolerance_cnv_energy_ = Parameters::Get>(); - tolerance_cnv_energy_relaxed_ = std::max(tolerance_cnv_energy_, Parameters::Get>()); + tolerance_cnv_energy_relaxed_ + = std::max(tolerance_cnv_energy_, Parameters::Get>()); tolerance_wells_ = Parameters::Get>(); tolerance_well_control_ = Parameters::Get>(); max_welleq_iter_ = Parameters::Get(); @@ -80,7 +83,8 @@ BlackoilModelParameters::BlackoilModelParameters() use_average_density_ms_wells_ = Parameters::Get(); local_well_solver_control_switching_ = Parameters::Get(); use_implicit_ipr_ = Parameters::Get(); - check_group_constraints_inner_well_iterations_ = Parameters::Get(); + check_group_constraints_inner_well_iterations_ + = Parameters::Get(); nonlinear_solver_ = Parameters::Get(); const auto approach = Parameters::Get(); if (approach == "jacobi") { @@ -99,16 +103,19 @@ BlackoilModelParameters::BlackoilModelParameters() nldd_num_initial_newton_iter_ = Parameters::Get(); nldd_relative_mobility_change_tol_ = Parameters::Get>(); num_local_domains_ = Parameters::Get(); - local_domains_partition_imbalance_ = std::max(Scalar{1.0}, Parameters::Get>()); + local_domains_partition_imbalance_ + = std::max(Scalar {1.0}, Parameters::Get>()); local_domains_partition_method_ = Parameters::Get(); - local_domains_partition_well_neighbor_levels_ = Parameters::Get(); + local_domains_partition_well_neighbor_levels_ + = Parameters::Get(); deck_file_name_ = Parameters::Get(); network_max_strict_outer_iterations_ = Parameters::Get(); network_max_outer_iterations_ = Parameters::Get(); network_max_sub_iterations_ = Parameters::Get(); network_pressure_update_damping_factor_ = Parameters::Get>(); network_max_pressure_update_in_bars_ = Parameters::Get>(); - local_domains_ordering_ = domainOrderingMeasureFromString(Parameters::Get()); + local_domains_ordering_ + = domainOrderingMeasureFromString(Parameters::Get()); write_partitions_ = Parameters::Get(); monitor_params_.enabled_ = Parameters::Get(); @@ -119,179 +126,159 @@ BlackoilModelParameters::BlackoilModelParameters() well_group_constraints_max_iterations_ = Parameters::Get(); } -template -void BlackoilModelParameters::registerParameters() +template +void +BlackoilModelParameters::registerParameters() { - Parameters::Register> - ("Maximum relative change of the bottom-hole pressure in a single iteration"); - Parameters::Register> - ("Maximum absolute change of a well's volume fraction in a single iteration"); - Parameters::Register> - ("Injection multiplier oscillation threshold (used for multiplier dampening)"); - Parameters::Register> - ("Injection multiplier dampening factor (dampening multiplied by this each time oscillation is detected)"); - Parameters::Register> - ("Minimum injection multiplier dampening factor (maximum dampening level)"); - Parameters::Register> - ("Absolute maximum tolerated for residuals without cutting the time step size"); - Parameters::Register> - ("The fraction of the pore volume of the reservoir " - "where the volumetric error (CNV) may be violated " - "during strict Newton iterations."); - Parameters::Register> - ("Tolerated mass balance error relative to total mass present"); - Parameters::Register> - ("Relaxed tolerated mass balance error that applies for iterations " - "after the iterations with the strict tolerance"); - Parameters::Register> - ("Tolerated energy balance error relative to (scaled) total energy present"); - Parameters::Register> - ("Relaxed tolerated energy balance error that applies for iterations " - "after the iterations with the strict tolerance"); - Parameters::Register> - ("Local convergence tolerance (Maximum of local saturation errors)"); - Parameters::Register> - ("Relaxed local convergence tolerance that applies for iterations " - "after the iterations with the strict tolerance"); - Parameters::Register> - ("Local energy convergence tolerance (Maximum of local energy errors)"); - Parameters::Register> - ("Relaxed local energy convergence tolerance that applies for iterations " - "after the iterations with the strict tolerance"); - Parameters::Register> - ("Well convergence tolerance"); - Parameters::Register> - ("Tolerance for the well control equations"); - Parameters::Register - ("Maximum number of iterations to determine solution the well equations"); - Parameters::Register - ("Use the well model for multi-segment wells instead of the " - "one for single-segment wells"); - Parameters::Register> - ("Tolerance for the pressure equations for multi-segment wells"); - Parameters::Register> - ("Relaxed tolerance for the well flow residual"); - Parameters::Register> - ("Relaxed tolerance for the MSW pressure solution"); - Parameters::Register> - ("Maximum relative pressure change for a single iteration " - "of the multi-segment well model"); - Parameters::Register - ("Maximum number of inner iterations for multi-segment wells"); - Parameters::Register - ("Number of inner well iterations with strict tolerance"); - Parameters::Register - ("Number of newton iterations for which wells are checked with strict tolerance"); - Parameters::Register - ("Maximum newton iterations with inner well iterations"); - Parameters::Register - ("Shut unsolvable wells"); - Parameters::Register - ("Maximum number of inner iterations for standard wells"); - Parameters::Register - ("Maximum number of status switching (shut<->open) in inner iterations for wells"); - Parameters::Register - ("Use alternative well rate initialization procedure"); - Parameters::Register> - ("Regularization factor for wells"); - Parameters::Register> - ("Maximum time step size where single precision floating point " - "arithmetic can be used solving for the linear systems of equations"); - Parameters::Register - ("Minimum number of Newton iterations before relaxed tolerances " - "can be used for the CNV convergence criterion"); - Parameters::Register - ("Minimum number of Newton iterations before relaxed tolerances " - "can be used for the MB convergence criterion. " - "Default -1 means that the relaxed tolerance is used when maximum " - "number of Newton iterations are reached."); - Parameters::Register - ("Fully solve the well equations before each iteration of the reservoir model"); - Parameters::Register - ("Pre solve and iterate the network model at start-up"); - Parameters::Register - ("Update scaling factors for mass balance equations during the run"); - Parameters::Register - ("Try to detect and correct oscillations or stagnation during the Newton method"); - Parameters::Register - ("Explicitly specify the influences of wells between cells in " - "the Jacobian and preconditioner matrices"); - Parameters::Register - ("Enable the well operability checking"); - Parameters::Register - ("Enable the well operability checking during iterations"); - Parameters::Register - ("Maximum number of times a well can switch to the same control"); - Parameters::Register - ("Maximum number of times a group can switch to the same control"); - Parameters::Register - ("Approximate segment densitities by averaging over segment and its outlet"); - Parameters::Register - ("Allow control switching during local well solutions"); - Parameters::Register - ("Compute implict IPR for stability checks and stable solution search"); - Parameters::Register - ("Allow checking of group constraints during inner well iterations"); - Parameters::Register - ("Maximum outer iterations in network solver before relaxing tolerance"); - Parameters::Register - ("Maximum outer number of iterations in the network solver before giving up"); - Parameters::Register - ("Maximum number of sub-iterations to update network pressures (within a single well/group control update)"); - Parameters::Register> - ("Damping factor in the inner network pressure update iterations"); - Parameters::Register> - ("Maximum pressure update in the inner network pressure update iterations"); - Parameters::Register - ("Choose nonlinear solver. Valid choices are newton or nldd."); - Parameters::Register - ("Choose local solve approach. Valid choices are jacobi and gauss-seidel"); + Parameters::Register>( + "Maximum relative change of the bottom-hole pressure in a single iteration"); + Parameters::Register>( + "Maximum absolute change of a well's volume fraction in a single iteration"); + Parameters::Register>( + "Injection multiplier oscillation threshold (used for multiplier dampening)"); + Parameters::Register>( + "Injection multiplier dampening factor (dampening multiplied by this each time oscillation is detected)"); + Parameters::Register>( + "Minimum injection multiplier dampening factor (maximum dampening level)"); + Parameters::Register>( + "Absolute maximum tolerated for residuals without cutting the time step size"); + Parameters::Register>("The fraction of the pore volume of the reservoir " + "where the volumetric error (CNV) may be violated " + "during strict Newton iterations."); + Parameters::Register>( + "Tolerated mass balance error relative to total mass present"); + Parameters::Register>( + "Relaxed tolerated mass balance error that applies for iterations " + "after the iterations with the strict tolerance"); + Parameters::Register>( + "Tolerated energy balance error relative to (scaled) total energy present"); + Parameters::Register>( + "Relaxed tolerated energy balance error that applies for iterations " + "after the iterations with the strict tolerance"); + Parameters::Register>( + "Local convergence tolerance (Maximum of local saturation errors)"); + Parameters::Register>( + "Relaxed local convergence tolerance that applies for iterations " + "after the iterations with the strict tolerance"); + Parameters::Register>( + "Local energy convergence tolerance (Maximum of local energy errors)"); + Parameters::Register>( + "Relaxed local energy convergence tolerance that applies for iterations " + "after the iterations with the strict tolerance"); + Parameters::Register>("Well convergence tolerance"); + Parameters::Register>("Tolerance for the well control equations"); + Parameters::Register( + "Maximum number of iterations to determine solution the well equations"); + Parameters::Register("Use the well model for multi-segment wells instead of the " + "one for single-segment wells"); + Parameters::Register>( + "Tolerance for the pressure equations for multi-segment wells"); + Parameters::Register>("Relaxed tolerance for the well flow residual"); + Parameters::Register>("Relaxed tolerance for the MSW pressure solution"); + Parameters::Register>( + "Maximum relative pressure change for a single iteration " + "of the multi-segment well model"); + Parameters::Register("Maximum number of inner iterations for multi-segment wells"); + Parameters::Register("Number of inner well iterations with strict tolerance"); + Parameters::Register( + "Number of newton iterations for which wells are checked with strict tolerance"); + Parameters::Register( + "Maximum newton iterations with inner well iterations"); + Parameters::Register("Shut unsolvable wells"); + Parameters::Register("Maximum number of inner iterations for standard wells"); + Parameters::Register( + "Maximum number of status switching (shut<->open) in inner iterations for wells"); + Parameters::Register("Use alternative well rate initialization procedure"); + Parameters::Register>("Regularization factor for wells"); + Parameters::Register>( + "Maximum time step size where single precision floating point " + "arithmetic can be used solving for the linear systems of equations"); + Parameters::Register("Minimum number of Newton iterations before relaxed tolerances " + "can be used for the CNV convergence criterion"); + Parameters::Register( + "Minimum number of Newton iterations before relaxed tolerances " + "can be used for the MB convergence criterion. " + "Default -1 means that the relaxed tolerance is used when maximum " + "number of Newton iterations are reached."); + Parameters::Register( + "Fully solve the well equations before each iteration of the reservoir model"); + Parameters::Register("Pre solve and iterate the network model at start-up"); + Parameters::Register( + "Update scaling factors for mass balance equations during the run"); + Parameters::Register( + "Try to detect and correct oscillations or stagnation during the Newton method"); + Parameters::Register( + "Explicitly specify the influences of wells between cells in " + "the Jacobian and preconditioner matrices"); + Parameters::Register("Enable the well operability checking"); + Parameters::Register( + "Enable the well operability checking during iterations"); + Parameters::Register( + "Maximum number of times a well can switch to the same control"); + Parameters::Register( + "Maximum number of times a group can switch to the same control"); + Parameters::Register( + "Approximate segment densitities by averaging over segment and its outlet"); + Parameters::Register( + "Allow control switching during local well solutions"); + Parameters::Register( + "Compute implict IPR for stability checks and stable solution search"); + Parameters::Register( + "Allow checking of group constraints during inner well iterations"); + Parameters::Register( + "Maximum outer iterations in network solver before relaxing tolerance"); + Parameters::Register( + "Maximum outer number of iterations in the network solver before giving up"); + Parameters::Register( + "Maximum number of sub-iterations to update network pressures (within a single well/group control update)"); + Parameters::Register>( + "Damping factor in the inner network pressure update iterations"); + Parameters::Register>( + "Maximum pressure update in the inner network pressure update iterations"); + Parameters::Register("Choose nonlinear solver. Valid choices are newton or nldd."); + Parameters::Register( + "Choose local solve approach. Valid choices are jacobi and gauss-seidel"); Parameters::SetDefault(20); - Parameters::Register - ("The minimum number of Newton iterations per time step"); - Parameters::Register - ("Max iterations for local solves with NLDD nonlinear solver."); - Parameters::Register> - ("Set lower than 1.0 to use stricter convergence tolerance for local solves."); - Parameters::Register> - ("Set lower than 1.0 to use stricter convergence tolerance for local solves."); - Parameters::Register - ("Number of initial global Newton iterations when running the NLDD nonlinear solver."); - Parameters::Register> - ("Threshold for single cell relative mobility change in the NLDD solver"); - Parameters::Register - ("Number of local domains for NLDD nonlinear solver."); - Parameters::Register> - ("Subdomain partitioning imbalance tolerance. 1.03 is 3 percent imbalance."); - Parameters::Register - ("Subdomain partitioning method. Allowed values are " - "'zoltan', " - "'simple', " - "and the name of a partition file ending with '.partition'."); - Parameters::Register - ("Number of neighbor levels around wells to include in the same domain during NLDD partitioning"); - Parameters::Register - ("Subdomain ordering measure. Allowed values are " - "'maxpressure', " - "'averagepressure' " - "and 'residual'."); - Parameters::Register - ("Whether or not to emit cell partitions as a debugging aid."); + Parameters::Register("The minimum number of Newton iterations per time step"); + Parameters::Register( + "Max iterations for local solves with NLDD nonlinear solver."); + Parameters::Register>( + "Set lower than 1.0 to use stricter convergence tolerance for local solves."); + Parameters::Register>( + "Set lower than 1.0 to use stricter convergence tolerance for local solves."); + Parameters::Register( + "Number of initial global Newton iterations when running the NLDD nonlinear solver."); + Parameters::Register>( + "Threshold for single cell relative mobility change in the NLDD solver"); + Parameters::Register("Number of local domains for NLDD nonlinear solver."); + Parameters::Register>( + "Subdomain partitioning imbalance tolerance. 1.03 is 3 percent imbalance."); + Parameters::Register( + "Subdomain partitioning method. Allowed values are " + "'zoltan', " + "'simple', " + "and the name of a partition file ending with '.partition'."); + Parameters::Register( + "Number of neighbor levels around wells to include in the same domain during NLDD partitioning"); + Parameters::Register("Subdomain ordering measure. Allowed values are " + "'maxpressure', " + "'averagepressure' " + "and 'residual'."); + Parameters::Register( + "Whether or not to emit cell partitions as a debugging aid."); - Parameters::Register - ("Enable convergence monitoring"); - Parameters::Register - ("Cut off limit for convergence monitoring"); - Parameters::Register> - ("Decay factor for convergence monitoring"); + Parameters::Register("Enable convergence monitoring"); + Parameters::Register("Cut off limit for convergence monitoring"); + Parameters::Register>( + "Decay factor for convergence monitoring"); - Parameters::Register> - ("Tolerance for acceptable changes in VREP/RAIN group rates"); + Parameters::Register>( + "Tolerance for acceptable changes in VREP/RAIN group rates"); Parameters::Hide(); - Parameters::Register - ("Maximum number of iterations in the well/group switching algorithm"); + Parameters::Register( + "Maximum number of iterations in the well/group switching algorithm"); // if openMP is available, use two threads per mpi rank by default #if _OPENMP diff --git a/opm/simulators/flow/BlackoilModelParameters.hpp b/opm/simulators/flow/BlackoilModelParameters.hpp index daeb2703fda..30060a4bc74 100644 --- a/opm/simulators/flow/BlackoilModelParameters.hpp +++ b/opm/simulators/flow/BlackoilModelParameters.hpp @@ -24,159 +24,306 @@ #include -namespace Opm::Parameters { +namespace Opm::Parameters +{ -template -struct DbhpMaxRel { static constexpr Scalar value = 1.0; }; +template +struct DbhpMaxRel { + static constexpr Scalar value = 1.0; +}; -template -struct DwellFractionMax { static constexpr Scalar value = 0.2; }; +template +struct DwellFractionMax { + static constexpr Scalar value = 0.2; +}; -struct EclDeckFileName { static constexpr auto value = ""; }; +struct EclDeckFileName { + static constexpr auto value = ""; +}; -template -struct InjMultOscThreshold { static constexpr Scalar value = 0.1; }; +template +struct InjMultOscThreshold { + static constexpr Scalar value = 0.1; +}; -template -struct InjMultDampMult { static constexpr Scalar value = 0.9; }; +template +struct InjMultDampMult { + static constexpr Scalar value = 0.9; +}; -template -struct InjMultMinDampFactor { static constexpr Scalar value = 0.05; }; +template +struct InjMultMinDampFactor { + static constexpr Scalar value = 0.05; +}; -template -struct MaxResidualAllowed { static constexpr Scalar value = 1e7; }; +template +struct MaxResidualAllowed { + static constexpr Scalar value = 1e7; +}; -template -struct RelaxedMaxPvFraction { static constexpr Scalar value = 0.03; }; +template +struct RelaxedMaxPvFraction { + static constexpr Scalar value = 0.03; +}; -template -struct ToleranceMb { static constexpr Scalar value = 1e-7; }; +template +struct ToleranceMb { + static constexpr Scalar value = 1e-7; +}; -template -struct ToleranceMbRelaxed { static constexpr Scalar value = 1e-6; }; +template +struct ToleranceMbRelaxed { + static constexpr Scalar value = 1e-6; +}; -template -struct ToleranceEnergyBalance { static constexpr Scalar value = 1e-7; }; +template +struct ToleranceEnergyBalance { + static constexpr Scalar value = 1e-7; +}; -template -struct ToleranceEnergyBalanceRelaxed { static constexpr Scalar value = 1e-6; }; +template +struct ToleranceEnergyBalanceRelaxed { + static constexpr Scalar value = 1e-6; +}; -template -struct ToleranceCnv { static constexpr Scalar value = 1e-2; }; +template +struct ToleranceCnv { + static constexpr Scalar value = 1e-2; +}; -template -struct ToleranceCnvRelaxed { static constexpr Scalar value = 1.0; }; +template +struct ToleranceCnvRelaxed { + static constexpr Scalar value = 1.0; +}; -template -struct ToleranceCnvEnergy { static constexpr Scalar value = 1e-2; }; +template +struct ToleranceCnvEnergy { + static constexpr Scalar value = 1e-2; +}; -template -struct ToleranceCnvEnergyRelaxed { static constexpr Scalar value = 1.0; }; +template +struct ToleranceCnvEnergyRelaxed { + static constexpr Scalar value = 1.0; +}; -template -struct ToleranceWells { static constexpr Scalar value = 1e-4; }; +template +struct ToleranceWells { + static constexpr Scalar value = 1e-4; +}; -template -struct ToleranceWellControl { static constexpr Scalar value = 1e-7; }; +template +struct ToleranceWellControl { + static constexpr Scalar value = 1e-7; +}; -struct MaxWelleqIter { static constexpr int value = 30; }; +struct MaxWelleqIter { + static constexpr int value = 30; +}; -template -struct MaxSinglePrecisionDays { static constexpr Scalar value = 20.0; }; +template +struct MaxSinglePrecisionDays { + static constexpr Scalar value = 20.0; +}; -struct MinStrictCnvIter { static constexpr int value = -1; }; -struct MinStrictMbIter { static constexpr int value = -1; }; -struct SolveWelleqInitially { static constexpr bool value = true; }; -struct PreSolveNetwork { static constexpr bool value = true; }; -struct UpdateEquationsScaling { static constexpr bool value = false; }; -struct UseUpdateStabilization { static constexpr bool value = true; }; -struct MatrixAddWellContributions { static constexpr bool value = false; }; +struct MinStrictCnvIter { + static constexpr int value = -1; +}; +struct MinStrictMbIter { + static constexpr int value = -1; +}; +struct SolveWelleqInitially { + static constexpr bool value = true; +}; +struct PreSolveNetwork { + static constexpr bool value = true; +}; +struct UpdateEquationsScaling { + static constexpr bool value = false; +}; +struct UseUpdateStabilization { + static constexpr bool value = true; +}; +struct MatrixAddWellContributions { + static constexpr bool value = false; +}; -struct UseMultisegmentWell { static constexpr bool value = true; }; +struct UseMultisegmentWell { + static constexpr bool value = true; +}; -template -struct TolerancePressureMsWells { static constexpr Scalar value = 0.01*1e5; }; +template +struct TolerancePressureMsWells { + static constexpr Scalar value = 0.01 * 1e5; +}; -template -struct MaxPressureChangeMsWells { static constexpr Scalar value = 10*1e5; }; +template +struct MaxPressureChangeMsWells { + static constexpr Scalar value = 10 * 1e5; +}; -struct MaxNewtonIterationsWithInnerWellIterations { static constexpr int value = 8; }; -struct MaxInnerIterMsWells { static constexpr int value = 100; }; -struct MaxInnerIterWells { static constexpr int value = 50; }; -struct MaxWellStatusSwitchInInnerIterWells { static constexpr int value = 99; }; -struct ShutUnsolvableWells { static constexpr bool value = true; }; -struct AlternativeWellRateInit { static constexpr bool value = true; }; -struct StrictOuterIterWells { static constexpr int value = 6; }; -struct StrictInnerIterWells { static constexpr int value = 40; }; +struct MaxNewtonIterationsWithInnerWellIterations { + static constexpr int value = 8; +}; +struct MaxInnerIterMsWells { + static constexpr int value = 100; +}; +struct MaxInnerIterWells { + static constexpr int value = 50; +}; +struct MaxWellStatusSwitchInInnerIterWells { + static constexpr int value = 99; +}; +struct ShutUnsolvableWells { + static constexpr bool value = true; +}; +struct AlternativeWellRateInit { + static constexpr bool value = true; +}; +struct StrictOuterIterWells { + static constexpr int value = 6; +}; +struct StrictInnerIterWells { + static constexpr int value = 40; +}; -template -struct RegularizationFactorWells { static constexpr Scalar value = 100.0; }; +template +struct RegularizationFactorWells { + static constexpr Scalar value = 100.0; +}; -struct EnableWellOperabilityCheck { static constexpr bool value = true; }; -struct EnableWellOperabilityCheckIter { static constexpr bool value = false; }; -struct DebugEmitCellPartition { static constexpr bool value = false; }; +struct EnableWellOperabilityCheck { + static constexpr bool value = true; +}; +struct EnableWellOperabilityCheckIter { + static constexpr bool value = false; +}; +struct DebugEmitCellPartition { + static constexpr bool value = false; +}; -template -struct RelaxedWellFlowTol { static constexpr Scalar value = 1e-3; }; +template +struct RelaxedWellFlowTol { + static constexpr Scalar value = 1e-3; +}; -template -struct RelaxedPressureTolMsw { static constexpr Scalar value = 1e4; }; +template +struct RelaxedPressureTolMsw { + static constexpr Scalar value = 1e4; +}; -struct MaximumNumberOfWellSwitches { static constexpr int value = 3; }; -struct MaximumNumberOfGroupSwitches { static constexpr int value = 3; }; -struct UseAverageDensityMsWells { static constexpr bool value = false; }; -struct LocalWellSolveControlSwitching { static constexpr bool value = true; }; -struct UseImplicitIpr { static constexpr bool value = true; }; -struct CheckGroupConstraintsInnerWellIterations { static constexpr bool value = true; }; +struct MaximumNumberOfWellSwitches { + static constexpr int value = 3; +}; +struct MaximumNumberOfGroupSwitches { + static constexpr int value = 3; +}; +struct UseAverageDensityMsWells { + static constexpr bool value = false; +}; +struct LocalWellSolveControlSwitching { + static constexpr bool value = true; +}; +struct UseImplicitIpr { + static constexpr bool value = true; +}; +struct CheckGroupConstraintsInnerWellIterations { + static constexpr bool value = true; +}; // Network solver parameters -struct NetworkMaxStrictOuterIterations { static constexpr int value = 10; }; -struct NetworkMaxOuterIterations { static constexpr int value = 10; }; -struct NetworkMaxSubIterations { static constexpr int value = 20; }; -template -struct NetworkPressureUpdateDampingFactor { static constexpr Scalar value = 0.1; }; -template -struct NetworkMaxPressureUpdateInBars { static constexpr Scalar value = 5.0; }; -struct NonlinearSolver { static constexpr auto value = "newton"; }; -struct LocalSolveApproach { static constexpr auto value = "gauss-seidel"; }; -struct MaxLocalSolveIterations { static constexpr int value = 20; }; -struct NewtonMinIterations { static constexpr int value = 2; }; - -struct WellGroupConstraintsMaxIterations { static constexpr int value = 1; }; -template -struct LocalToleranceScalingMb { static constexpr Scalar value = 1.0; }; - -template -struct LocalToleranceScalingCnv { static constexpr Scalar value = 0.1; }; -struct NlddNumInitialNewtonIter { static constexpr int value = 1; }; -template -struct NlddRelativeMobilityChangeTol { static constexpr Scalar value = 0.1; }; -struct NumLocalDomains { static constexpr int value = 0; }; - -template -struct LocalDomainsPartitioningImbalance { static constexpr Scalar value = 1.03; }; - -struct LocalDomainsPartitioningMethod { static constexpr auto value = "zoltan"; }; -struct LocalDomainsPartitionWellNeighborLevels { static constexpr int value = 1; }; -struct LocalDomainsOrderingMeasure { static constexpr auto value = "maxpressure"; }; - -struct ConvergenceMonitoring { static constexpr bool value = false; }; -struct ConvergenceMonitoringCutOff { static constexpr int value = 6; }; -template -struct ConvergenceMonitoringDecayFactor { static constexpr Scalar value = 0.75; }; - - -template -struct NupcolGroupRateTolerance { static constexpr Scalar value = 0.001; }; +struct NetworkMaxStrictOuterIterations { + static constexpr int value = 10; +}; +struct NetworkMaxOuterIterations { + static constexpr int value = 10; +}; +struct NetworkMaxSubIterations { + static constexpr int value = 20; +}; +template +struct NetworkPressureUpdateDampingFactor { + static constexpr Scalar value = 0.1; +}; +template +struct NetworkMaxPressureUpdateInBars { + static constexpr Scalar value = 5.0; +}; +struct NonlinearSolver { + static constexpr auto value = "newton"; +}; +struct LocalSolveApproach { + static constexpr auto value = "gauss-seidel"; +}; +struct MaxLocalSolveIterations { + static constexpr int value = 20; +}; +struct NewtonMinIterations { + static constexpr int value = 2; +}; + +struct WellGroupConstraintsMaxIterations { + static constexpr int value = 1; +}; +template +struct LocalToleranceScalingMb { + static constexpr Scalar value = 1.0; +}; + +template +struct LocalToleranceScalingCnv { + static constexpr Scalar value = 0.1; +}; +struct NlddNumInitialNewtonIter { + static constexpr int value = 1; +}; +template +struct NlddRelativeMobilityChangeTol { + static constexpr Scalar value = 0.1; +}; +struct NumLocalDomains { + static constexpr int value = 0; +}; + +template +struct LocalDomainsPartitioningImbalance { + static constexpr Scalar value = 1.03; +}; + +struct LocalDomainsPartitioningMethod { + static constexpr auto value = "zoltan"; +}; +struct LocalDomainsPartitionWellNeighborLevels { + static constexpr int value = 1; +}; +struct LocalDomainsOrderingMeasure { + static constexpr auto value = "maxpressure"; +}; + +struct ConvergenceMonitoring { + static constexpr bool value = false; +}; +struct ConvergenceMonitoringCutOff { + static constexpr int value = 6; +}; +template +struct ConvergenceMonitoringDecayFactor { + static constexpr Scalar value = 0.75; +}; + + +template +struct NupcolGroupRateTolerance { + static constexpr Scalar value = 0.001; +}; } // namespace Opm::Parameters -namespace Opm { +namespace Opm +{ /// Solver parameters for the BlackoilModel. template -struct BlackoilModelParameters -{ +struct BlackoilModelParameters { public: /// Max relative change in bhp in single iteration. Scalar dbhp_max_rel_; @@ -203,11 +350,13 @@ struct BlackoilModelParameters Scalar tolerance_energy_balance_relaxed_; /// Local convergence tolerance (max of local saturation errors). Scalar tolerance_cnv_; - /// Relaxed local convergence tolerance (can be used when iter >= min_strict_cnv_iter_ && cnvViolatedPV < relaxed_max_pv_fraction_). + /// Relaxed local convergence tolerance (can be used when iter >= min_strict_cnv_iter_ && cnvViolatedPV < + /// relaxed_max_pv_fraction_). Scalar tolerance_cnv_relaxed_; /// Local energy convergence tolerance (max of local energy errors). Scalar tolerance_cnv_energy_; - /// Relaxed local energy convergence tolerance (can be used when iter >= min_strict_cnv_iter_ && cnvViolatedPV < relaxed_max_pv_fraction_). + /// Relaxed local energy convergence tolerance (can be used when iter >= min_strict_cnv_iter_ && cnvViolatedPV < + /// relaxed_max_pv_fraction_). Scalar tolerance_cnv_energy_relaxed_; /// Well convergence tolerance. Scalar tolerance_wells_; @@ -305,7 +454,7 @@ struct BlackoilModelParameters bool use_implicit_ipr_; /// Whether to allow checking/changing to group controls during inner well iterations - bool check_group_constraints_inner_well_iterations_; + bool check_group_constraints_inner_well_iterations_; /// Maximum number of iterations in the network solver before relaxing tolerance int network_max_strict_outer_iterations_; @@ -330,9 +479,9 @@ struct BlackoilModelParameters /// Nonlinear solver type: newton or nldd std::string nonlinear_solver_; - + /// 'jacobi' and 'gauss-seidel' supported - DomainSolveApproach local_solve_approach_{DomainSolveApproach::Jacobi}; + DomainSolveApproach local_solve_approach_ {DomainSolveApproach::Jacobi}; /// Maximum number of Newton iterations per time step int newton_max_iter_; @@ -345,20 +494,19 @@ struct BlackoilModelParameters Scalar local_tolerance_scaling_mb_; Scalar local_tolerance_scaling_cnv_; - int nldd_num_initial_newton_iter_{1}; + int nldd_num_initial_newton_iter_ {1}; /// Threshold for single cell relative mobility change in NLDD Scalar nldd_relative_mobility_change_tol_; - int num_local_domains_{0}; - Scalar local_domains_partition_imbalance_{1.03}; + int num_local_domains_ {0}; + Scalar local_domains_partition_imbalance_ {1.03}; std::string local_domains_partition_method_; - int local_domains_partition_well_neighbor_levels_{1}; - DomainOrderingMeasure local_domains_ordering_{DomainOrderingMeasure::MaxPressure}; + int local_domains_partition_well_neighbor_levels_ {1}; + DomainOrderingMeasure local_domains_ordering_ {DomainOrderingMeasure::MaxPressure}; - bool write_partitions_{false}; + bool write_partitions_ {false}; /// Struct holding convergence monitor params - struct ConvergenceMonitorParams - { + struct ConvergenceMonitorParams { /// Whether to enable convergence monitoring bool enabled_; /// Cut-off limit for convergence monitoring diff --git a/opm/simulators/flow/BlackoilModelProperties.hpp b/opm/simulators/flow/BlackoilModelProperties.hpp index 9cb2ecac217..c64db559d8c 100644 --- a/opm/simulators/flow/BlackoilModelProperties.hpp +++ b/opm/simulators/flow/BlackoilModelProperties.hpp @@ -27,87 +27,110 @@ #include #include -namespace Opm { -template class BlackoilAquiferModel; -template class BlackoilWellModel; -} +namespace Opm +{ +template +class BlackoilAquiferModel; +template +class BlackoilWellModel; +} // namespace Opm -namespace Opm::Properties { +namespace Opm::Properties +{ -namespace TTag { +namespace TTag +{ -struct FlowIstlSolver; -struct FlowBaseProblemBlackoil; -struct FlowProblem { using InheritsFrom = std::tuple; }; + struct FlowIstlSolver; + struct FlowBaseProblemBlackoil; + struct FlowProblem { + using InheritsFrom = std::tuple; + }; -} +} // namespace TTag // default in flow is to formulate the equations in surface volumes -template -struct BlackoilConserveSurfaceVolume -{ static constexpr bool value = true; }; +template +struct BlackoilConserveSurfaceVolume { + static constexpr bool value = true; +}; -template -struct UseVolumetricResidual -{ static constexpr bool value = false; }; +template +struct UseVolumetricResidual { + static constexpr bool value = false; +}; -template -struct AquiferModel -{ using type = BlackoilAquiferModel; }; +template +struct AquiferModel { + using type = BlackoilAquiferModel; +}; // disable all extensions supported by black oil model. this should not really be // necessary but it makes things a bit more explicit -template -struct EnablePolymer -{ static constexpr bool value = false; }; - -template -struct EnableSolvent -{ static constexpr bool value = false; }; - -template -struct EnableTemperature -{ static constexpr bool value = true; }; - -template -struct EnableEnergy -{ static constexpr bool value = false; }; - -template -struct EnableFoam -{ static constexpr bool value = false; }; - -template -struct EnableBrine -{ static constexpr bool value = false; }; - -template -struct EnableSaltPrecipitation -{ static constexpr bool value = false; }; - -template -struct EnableBioeffects -{ static constexpr bool value = false; }; - -template -struct EnableDispersion -{ static constexpr bool value = false; }; - -template -struct EnableConvectiveMixing -{ static constexpr bool value = true; }; - -template -struct WellModel -{ using type = BlackoilWellModel; }; - -template -struct LinearSolverSplice -{ using type = TTag::FlowIstlSolver; }; - -template -struct EnableDebuggingChecks -{ static constexpr bool value = false; }; +template +struct EnablePolymer { + static constexpr bool value = false; +}; + +template +struct EnableSolvent { + static constexpr bool value = false; +}; + +template +struct EnableTemperature { + static constexpr bool value = true; +}; + +template +struct EnableEnergy { + static constexpr bool value = false; +}; + +template +struct EnableFoam { + static constexpr bool value = false; +}; + +template +struct EnableBrine { + static constexpr bool value = false; +}; + +template +struct EnableSaltPrecipitation { + static constexpr bool value = false; +}; + +template +struct EnableBioeffects { + static constexpr bool value = false; +}; + +template +struct EnableDispersion { + static constexpr bool value = false; +}; + +template +struct EnableConvectiveMixing { + static constexpr bool value = true; +}; + +template +struct WellModel { + using type = BlackoilWellModel; +}; + +template +struct LinearSolverSplice { + using type = TTag::FlowIstlSolver; +}; + +template +struct EnableDebuggingChecks { + static constexpr bool value = false; +}; } // namespace Opm::Properties diff --git a/opm/simulators/flow/BlackoilModel_impl.hpp b/opm/simulators/flow/BlackoilModel_impl.hpp index bd77f1357ef..142b44764e6 100644 --- a/opm/simulators/flow/BlackoilModel_impl.hpp +++ b/opm/simulators/flow/BlackoilModel_impl.hpp @@ -39,24 +39,24 @@ #include #include #include -#include #include +#include #include -namespace Opm { +namespace Opm +{ template -BlackoilModel:: -BlackoilModel(Simulator& simulator, - const ModelParameters& param, - BlackoilWellModel& well_model, - const bool terminal_output) +BlackoilModel::BlackoilModel(Simulator& simulator, + const ModelParameters& param, + BlackoilWellModel& well_model, + const bool terminal_output) : simulator_(simulator) , grid_(simulator_.vanguard().grid()) - , param_( param ) - , well_model_ (well_model) - , terminal_output_ (terminal_output) + , param_(param) + , well_model_(well_model) + , terminal_output_(terminal_output) , current_relaxation_(1.0) , dx_old_(simulator_.model().numGridDof()) , conv_monitor_(param_.monitor_params_) @@ -75,15 +75,13 @@ BlackoilModel(Simulator& simulator, OpmLog::info("Using Newton nonlinear solver."); } } else { - OPM_THROW(std::runtime_error, "Unknown nonlinear solver option: " + - param_.nonlinear_solver_); + OPM_THROW(std::runtime_error, "Unknown nonlinear solver option: " + param_.nonlinear_solver_); } } template SimulatorReportSingle -BlackoilModel:: -prepareStep(const SimulatorTimerInterface& timer) +BlackoilModel::prepareStep(const SimulatorTimerInterface& timer) { SimulatorReportSingle report; Dune::Timer perfTimer; @@ -91,13 +89,13 @@ prepareStep(const SimulatorTimerInterface& timer) // update the solution variables in the model int lastStepFailed = timer.lastStepFailed(); if (grid_.comm().size() > 1 && grid_.comm().max(lastStepFailed) != grid_.comm().min(lastStepFailed)) { - OPM_THROW(std::runtime_error, "Misalignment of the parallel simulation run in prepareStep " + - "- the previous step succeeded on some ranks but failed on others."); + OPM_THROW(std::runtime_error, + "Misalignment of the parallel simulation run in prepareStep " + + "- the previous step succeeded on some ranks but failed on others."); } if (lastStepFailed) { simulator_.model().updateFailed(); - } - else { + } else { simulator_.model().advanceTimeLevel(); } @@ -117,7 +115,7 @@ prepareStep(const SimulatorTimerInterface& timer) if (param_.update_equations_scaling_) { OpmLog::error("Equation scaling not supported"); - //updateEquationsScaling(); + // updateEquationsScaling(); } if (hasNlddSolver()) { @@ -126,8 +124,7 @@ prepareStep(const SimulatorTimerInterface& timer) report.pre_post_time += perfTimer.stop(); - auto getIdx = [](unsigned phaseIdx) -> int - { + auto getIdx = [](unsigned phaseIdx) -> int { if (FluidSystem::phaseIsActive(phaseIdx)) { const unsigned sIdx = FluidSystem::solventComponentIndex(phaseIdx); return FluidSystem::canonicalToActiveCompIdx(sIdx); @@ -151,12 +148,11 @@ prepareStep(const SimulatorTimerInterface& timer) template void -BlackoilModel:: -initialLinearization(SimulatorReportSingle& report, - const int iteration, - const int minIter, - const int maxIter, - const SimulatorTimerInterface& timer) +BlackoilModel::initialLinearization(SimulatorReportSingle& report, + const int iteration, + const int minIter, + const int maxIter, + const SimulatorTimerInterface& timer) { // ----------- Set up reports and timer ----------- failureReport_ = SimulatorReportSingle(); @@ -169,8 +165,7 @@ initialLinearization(SimulatorReportSingle& report, try { report += assembleReservoir(timer, iteration); report.assemble_time += perfTimer.stop(); - } - catch (...) { + } catch (...) { report.assemble_time += perfTimer.stop(); failureReport_ += report; throw; // continue throwing the stick @@ -196,11 +191,9 @@ initialLinearization(SimulatorReportSingle& report, OPM_THROW_NOLOG(NumericalProblem, "Too large residual found!"); } else if (severity == ConvergenceReport::Severity::ConvergenceMonitorFailure) { failureReport_ += report; - OPM_THROW_PROBLEM(ConvergenceMonitorFailure, - fmt::format( - "Total penalty count exceeded cut-off-limit of {}", - param_.monitor_params_.cutoff_ - )); + OPM_THROW_PROBLEM( + ConvergenceMonitorFailure, + fmt::format("Total penalty count exceeded cut-off-limit of {}", param_.monitor_params_.cutoff_)); } } report.update_time += perfTimer.stop(); @@ -210,10 +203,9 @@ initialLinearization(SimulatorReportSingle& report, template template SimulatorReportSingle -BlackoilModel:: -nonlinearIteration(const int iteration, - const SimulatorTimerInterface& timer, - NonlinearSolverType& nonlinear_solver) +BlackoilModel::nonlinearIteration(const int iteration, + const SimulatorTimerInterface& timer, + NonlinearSolverType& nonlinear_solver) { if (iteration == 0) { // For each iteration we store in a vector the norms of the residual of @@ -227,16 +219,10 @@ nonlinearIteration(const int iteration, } SimulatorReportSingle result; - if (this->param_.nonlinear_solver_ != "nldd") - { - result = this->nonlinearIterationNewton(iteration, - timer, - nonlinear_solver); - } - else { - result = this->nlddSolver_->nonlinearIterationNldd(iteration, - timer, - nonlinear_solver); + if (this->param_.nonlinear_solver_ != "nldd") { + result = this->nonlinearIterationNewton(iteration, timer, nonlinear_solver); + } else { + result = this->nlddSolver_->nonlinearIterationNldd(iteration, timer, nonlinear_solver); } auto& rst_conv = simulator_.problem().eclWriter().mutableOutputModule().getConv(); @@ -248,20 +234,15 @@ nonlinearIteration(const int iteration, template template SimulatorReportSingle -BlackoilModel:: -nonlinearIterationNewton(const int iteration, - const SimulatorTimerInterface& timer, - NonlinearSolverType& nonlinear_solver) +BlackoilModel::nonlinearIterationNewton(const int iteration, + const SimulatorTimerInterface& timer, + NonlinearSolverType& nonlinear_solver) { // ----------- Set up reports and timer ----------- SimulatorReportSingle report; Dune::Timer perfTimer; - this->initialLinearization(report, - iteration, - this->param_.newton_min_iter_, - this->param_.newton_max_iter_, - timer); + this->initialLinearization(report, iteration, this->param_.newton_min_iter_, this->param_.newton_max_iter_, timer); // ----------- If not converged, solve linear system and do Newton update ----------- if (!report.converged) { @@ -288,8 +269,7 @@ nonlinearIterationNewton(const int iteration, report.linear_solve_setup_time += linear_solve_setup_time_; report.linear_solve_time += perfTimer.stop(); report.total_linear_iterations += linearIterationsLastSolve(); - } - catch (...) { + } catch (...) { report.linear_solve_setup_time += linear_solve_setup_time_; report.linear_solve_time += perfTimer.stop(); report.total_linear_iterations += linearIterationsLastSolve(); @@ -310,17 +290,14 @@ nonlinearIterationNewton(const int iteration, // Stabilize the nonlinear update. bool isOscillate = false; bool isStagnate = false; - nonlinear_solver.detectOscillations(residual_norms_history_, - residual_norms_history_.size() - 1, - isOscillate, - isStagnate); + nonlinear_solver.detectOscillations( + residual_norms_history_, residual_norms_history_.size() - 1, isOscillate, isStagnate); if (isOscillate) { current_relaxation_ -= nonlinear_solver.relaxIncrement(); - current_relaxation_ = std::max(current_relaxation_, - nonlinear_solver.relaxMax()); + current_relaxation_ = std::max(current_relaxation_, nonlinear_solver.relaxMax()); if (terminalOutputEnabled()) { - std::string msg = " Oscillating behavior detected: Relaxation set to " - + std::to_string(current_relaxation_); + std::string msg + = " Oscillating behavior detected: Relaxation set to " + std::to_string(current_relaxation_); OpmLog::info(msg); } } @@ -340,8 +317,7 @@ nonlinearIterationNewton(const int iteration, template SimulatorReportSingle -BlackoilModel:: -afterStep(const SimulatorTimerInterface&) +BlackoilModel::afterStep(const SimulatorTimerInterface&) { SimulatorReportSingle report; Dune::Timer perfTimer; @@ -353,9 +329,7 @@ afterStep(const SimulatorTimerInterface&) template SimulatorReportSingle -BlackoilModel:: -assembleReservoir(const SimulatorTimerInterface& /* timer */, - const int iterationIdx) +BlackoilModel::assembleReservoir(const SimulatorTimerInterface& /* timer */, const int iterationIdx) { // -------- Mass balance equations -------- simulator_.model().newtonMethod().setIterationIndex(iterationIdx); @@ -367,8 +341,7 @@ assembleReservoir(const SimulatorTimerInterface& /* timer */, template typename BlackoilModel::Scalar -BlackoilModel:: -relativeChange() const +BlackoilModel::relativeChange() const { Scalar resultDelta = 0.0; Scalar resultDenom = 0.0; @@ -382,20 +355,16 @@ relativeChange() const Scalar pressureNew; pressureNew = priVarsNew[Indices::pressureSwitchIdx]; - Scalar saturationsNew[FluidSystem::numPhases] = { 0.0 }; + Scalar saturationsNew[FluidSystem::numPhases] = {0.0}; Scalar oilSaturationNew = 1.0; - if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx) && - FluidSystem::numActivePhases() > 1 && - priVarsNew.primaryVarsMeaningWater() == PrimaryVariables::WaterMeaning::Sw) - { + if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx) && FluidSystem::numActivePhases() > 1 + && priVarsNew.primaryVarsMeaningWater() == PrimaryVariables::WaterMeaning::Sw) { saturationsNew[FluidSystem::waterPhaseIdx] = priVarsNew[Indices::waterSwitchIdx]; oilSaturationNew -= saturationsNew[FluidSystem::waterPhaseIdx]; } - if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx) && - FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx) && - priVarsNew.primaryVarsMeaningGas() == PrimaryVariables::GasMeaning::Sg) - { + if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx) && FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx) + && priVarsNew.primaryVarsMeaningGas() == PrimaryVariables::GasMeaning::Sg) { assert(Indices::compositionSwitchIdx >= 0); saturationsNew[FluidSystem::gasPhaseIdx] = priVarsNew[Indices::compositionSwitchIdx]; oilSaturationNew -= saturationsNew[FluidSystem::gasPhaseIdx]; @@ -410,36 +379,33 @@ relativeChange() const Scalar pressureOld; pressureOld = priVarsOld[Indices::pressureSwitchIdx]; - Scalar saturationsOld[FluidSystem::numPhases] = { 0.0 }; + Scalar saturationsOld[FluidSystem::numPhases] = {0.0}; Scalar oilSaturationOld = 1.0; // NB fix me! adding pressures changes to saturation changes does not make sense Scalar tmp = pressureNew - pressureOld; - resultDelta += tmp*tmp; - resultDenom += pressureNew*pressureNew; + resultDelta += tmp * tmp; + resultDenom += pressureNew * pressureNew; if (FluidSystem::numActivePhases() > 1) { if (priVarsOld.primaryVarsMeaningWater() == PrimaryVariables::WaterMeaning::Sw) { - saturationsOld[FluidSystem::waterPhaseIdx] = - priVarsOld[Indices::waterSwitchIdx]; + saturationsOld[FluidSystem::waterPhaseIdx] = priVarsOld[Indices::waterSwitchIdx]; oilSaturationOld -= saturationsOld[FluidSystem::waterPhaseIdx]; } - if (priVarsOld.primaryVarsMeaningGas() == PrimaryVariables::GasMeaning::Sg) - { - assert(Indices::compositionSwitchIdx >= 0 ); - saturationsOld[FluidSystem::gasPhaseIdx] = - priVarsOld[Indices::compositionSwitchIdx]; + if (priVarsOld.primaryVarsMeaningGas() == PrimaryVariables::GasMeaning::Sg) { + assert(Indices::compositionSwitchIdx >= 0); + saturationsOld[FluidSystem::gasPhaseIdx] = priVarsOld[Indices::compositionSwitchIdx]; oilSaturationOld -= saturationsOld[FluidSystem::gasPhaseIdx]; } if (FluidSystem::phaseIsActive(FluidSystem::oilPhaseIdx)) { saturationsOld[FluidSystem::oilPhaseIdx] = oilSaturationOld; } - for (unsigned phaseIdx = 0; phaseIdx < FluidSystem::numPhases; ++ phaseIdx) { + for (unsigned phaseIdx = 0; phaseIdx < FluidSystem::numPhases; ++phaseIdx) { Scalar tmpSat = saturationsNew[phaseIdx] - saturationsOld[phaseIdx]; - resultDelta += tmpSat*tmpSat; - resultDenom += saturationsNew[phaseIdx]*saturationsNew[phaseIdx]; + resultDelta += tmpSat * tmpSat; + resultDenom += saturationsNew[phaseIdx] * saturationsNew[phaseIdx]; assert(std::isfinite(resultDelta)); assert(std::isfinite(resultDenom)); } @@ -454,8 +420,7 @@ relativeChange() const template void -BlackoilModel:: -solveJacobianSystem(BVector& x) +BlackoilModel::solveJacobianSystem(BVector& x) { auto& jacobian = simulator_.model().linearizer().jacobian().istlMatrix(); auto& residual = simulator_.model().linearizer().residual(); @@ -496,8 +461,7 @@ solveJacobianSystem(BVector& x) linear_solve_setup_time_ = setupTimes[fastest_solver]; x = x_trial[fastest_solver]; linSolver.setActiveSolver(fastest_solver); - } - else { + } else { // set initial guess x = 0.0; @@ -516,8 +480,7 @@ solveJacobianSystem(BVector& x) template void -BlackoilModel:: -updateSolution(const BVector& dx) +BlackoilModel::updateSolution(const BVector& dx) { OPM_TIMEBLOCK(updateSolution); auto& newtonMethod = simulator_.model().newtonMethod(); @@ -538,15 +501,13 @@ updateSolution(const BVector& dx) } template -std::tuple::Scalar, - typename BlackoilModel::Scalar> -BlackoilModel:: -convergenceReduction(Parallel::Communication comm, - const Scalar pvSumLocal, - const Scalar numAquiferPvSumLocal, - std::vector< Scalar >& R_sum, - std::vector< Scalar >& maxCoeff, - std::vector< Scalar >& B_avg) +std::tuple::Scalar, typename BlackoilModel::Scalar> +BlackoilModel::convergenceReduction(Parallel::Communication comm, + const Scalar pvSumLocal, + const Scalar numAquiferPvSumLocal, + std::vector& R_sum, + std::vector& maxCoeff, + std::vector& B_avg) { OPM_TIMEBLOCK(convergenceReduction); // Compute total pore volume (use only owned entries) @@ -555,26 +516,26 @@ convergenceReduction(Parallel::Communication comm, if (comm.size() > 1) { // global reduction - std::vector< Scalar > sumBuffer; - std::vector< Scalar > maxBuffer; + std::vector sumBuffer; + std::vector maxBuffer; const int numComp = B_avg.size(); - sumBuffer.reserve( 2*numComp + 2 ); // +2 for (numAquifer)pvSum - maxBuffer.reserve( numComp ); + sumBuffer.reserve(2 * numComp + 2); // +2 for (numAquifer)pvSum + maxBuffer.reserve(numComp); for (int compIdx = 0; compIdx < numComp; ++compIdx) { sumBuffer.push_back(B_avg[compIdx]); sumBuffer.push_back(R_sum[compIdx]); - maxBuffer.push_back(maxCoeff[ compIdx]); + maxBuffer.push_back(maxCoeff[compIdx]); } // Compute total pore volume - sumBuffer.push_back( pvSum ); - sumBuffer.push_back( numAquiferPvSum ); + sumBuffer.push_back(pvSum); + sumBuffer.push_back(numAquiferPvSum); // compute global sum - comm.sum( sumBuffer.data(), sumBuffer.size() ); + comm.sum(sumBuffer.data(), sumBuffer.size()); // compute global max - comm.max( maxBuffer.data(), maxBuffer.size() ); + comm.max(maxBuffer.data(), maxBuffer.size()); // restore values to local variables for (int compIdx = 0, buffIdx = 0; compIdx < numComp; ++compIdx, ++buffIdx) { @@ -589,7 +550,7 @@ convergenceReduction(Parallel::Communication comm, } // restore global pore volume - pvSum = sumBuffer[sumBuffer.size()-2]; + pvSum = sumBuffer[sumBuffer.size() - 2]; numAquiferPvSum = sumBuffer.back(); } @@ -598,13 +559,11 @@ convergenceReduction(Parallel::Communication comm, } template -std::pair::Scalar, - typename BlackoilModel::Scalar> -BlackoilModel:: -localConvergenceData(std::vector& R_sum, - std::vector& maxCoeff, - std::vector& B_avg, - std::vector& maxCoeffCell) +std::pair::Scalar, typename BlackoilModel::Scalar> +BlackoilModel::localConvergenceData(std::vector& R_sum, + std::vector& maxCoeff, + std::vector& B_avg, + std::vector& maxCoeffCell) { OPM_TIMEBLOCK(localConvergenceData); Scalar pvSumLocal = 0.0; @@ -626,16 +585,14 @@ localConvergenceData(std::vector& R_sum, const auto& intQuants = elemCtx.intensiveQuantities(/*spaceIdx=*/0, /*timeIdx=*/0); const auto& fs = intQuants.fluidState(); - const auto pvValue = problem.referencePorosity(cell_idx, /*timeIdx=*/0) * - model.dofTotalVolume(cell_idx); + const auto pvValue = problem.referencePorosity(cell_idx, /*timeIdx=*/0) * model.dofTotalVolume(cell_idx); pvSumLocal += pvValue; if (isNumericalAquiferCell(elem)) { numAquiferPvSumLocal += pvValue; } - this->getMaxCoeff(cell_idx, intQuants, fs, residual, pvValue, - B_avg, R_sum, maxCoeff, maxCoeffCell); + this->getMaxCoeff(cell_idx, intQuants, fs, residual, pvValue, B_avg, R_sum, maxCoeff, maxCoeffCell); } OPM_END_PARALLEL_TRY_CATCH("BlackoilModel::localConvergenceData() failed: ", grid_.comm()); @@ -651,32 +608,30 @@ localConvergenceData(std::vector& R_sum, template std::pair, std::vector> -BlackoilModel:: -characteriseCnvPvSplit(const std::vector& B_avg, const double dt) +BlackoilModel::characteriseCnvPvSplit(const std::vector& B_avg, const double dt) { OPM_TIMEBLOCK(computeCnvErrorPv); // 0: cnv <= tolerance_cnv // 1: tolerance_cnv < cnv <= tolerance_cnv_relaxed // 2: tolerance_cnv_relaxed < cnv - constexpr auto numPvGroups = std::vector::size_type{3}; + constexpr auto numPvGroups = std::vector::size_type {3}; auto cnvPvSplit = std::pair, std::vector> { - std::piecewise_construct, - std::forward_as_tuple(numPvGroups), - std::forward_as_tuple(numPvGroups) - }; - - auto maxCNV = [&B_avg, dt](const auto& residual, const double pvol) - { - return (dt / pvol) * - std::inner_product(residual.begin(), residual.end(), - B_avg.begin(), Scalar{0}, - [](const Scalar m, const auto& x) - { - using std::abs; - return std::max(m, abs(x)); - }, std::multiplies<>{}); + std::piecewise_construct, std::forward_as_tuple(numPvGroups), std::forward_as_tuple(numPvGroups)}; + + auto maxCNV = [&B_avg, dt](const auto& residual, const double pvol) { + return (dt / pvol) + * std::inner_product( + residual.begin(), + residual.end(), + B_avg.begin(), + Scalar {0}, + [](const Scalar m, const auto& x) { + using std::abs; + return std::max(m, abs(x)); + }, + std::multiplies<> {}); }; auto& [splitPV, cellCntPV] = cnvPvSplit; @@ -700,22 +655,19 @@ characteriseCnvPvSplit(const std::vector& B_avg, const double dt) elemCtx.updatePrimaryStencil(elem); const unsigned cell_idx = elemCtx.globalSpaceIndex(/*spaceIdx=*/0, /*timeIdx=*/0); - const auto pvValue = problem.referencePorosity(cell_idx, /*timeIdx=*/0) - * model.dofTotalVolume(cell_idx); + const auto pvValue = problem.referencePorosity(cell_idx, /*timeIdx=*/0) * model.dofTotalVolume(cell_idx); const auto maxCnv = maxCNV(residual[cell_idx], pvValue); - const auto ix = (maxCnv > this->param_.tolerance_cnv_) - + (maxCnv > this->param_.tolerance_cnv_relaxed_); + const auto ix = (maxCnv > this->param_.tolerance_cnv_) + (maxCnv > this->param_.tolerance_cnv_relaxed_); splitPV[ix] += static_cast(pvValue); ++cellCntPV[ix]; } - OPM_END_PARALLEL_TRY_CATCH("BlackoilModel::characteriseCnvPvSplit() failed: ", - this->grid_.comm()); + OPM_END_PARALLEL_TRY_CATCH("BlackoilModel::characteriseCnvPvSplit() failed: ", this->grid_.comm()); - this->grid_.comm().sum(splitPV .data(), splitPV .size()); + this->grid_.comm().sum(splitPV.data(), splitPV.size()); this->grid_.comm().sum(cellCntPV.data(), cellCntPV.size()); return cnvPvSplit; @@ -723,8 +675,7 @@ characteriseCnvPvSplit(const std::vector& B_avg, const double dt) template void -BlackoilModel:: -updateTUNING(const Tuning& tuning) +BlackoilModel::updateTUNING(const Tuning& tuning) { this->param_.tolerance_cnv_ = tuning.TRGCNV; this->param_.tolerance_cnv_relaxed_ = tuning.XXXCNV; @@ -736,37 +687,31 @@ updateTUNING(const Tuning& tuning) template ConvergenceReport -BlackoilModel:: -getReservoirConvergence(const double reportTime, - const double dt, - const int iteration, - const int maxIter, - std::vector& B_avg, - std::vector& residual_norms) +BlackoilModel::getReservoirConvergence(const double reportTime, + const double dt, + const int iteration, + const int maxIter, + std::vector& B_avg, + std::vector& residual_norms) { OPM_TIMEBLOCK(getReservoirConvergence); using Vector = std::vector; - ConvergenceReport report{reportTime}; + ConvergenceReport report {reportTime}; const int numComp = numEq; - Vector R_sum(numComp, Scalar{0}); + Vector R_sum(numComp, Scalar {0}); Vector maxCoeff(numComp, std::numeric_limits::lowest()); std::vector maxCoeffCell(numComp, -1); - const auto [pvSumLocal, numAquiferPvSumLocal] = - this->localConvergenceData(R_sum, maxCoeff, B_avg, maxCoeffCell); + const auto [pvSumLocal, numAquiferPvSumLocal] = this->localConvergenceData(R_sum, maxCoeff, B_avg, maxCoeffCell); // compute global sum and max of quantities - const auto& [pvSum, numAquiferPvSum] = - this->convergenceReduction(this->grid_.comm(), - pvSumLocal, - numAquiferPvSumLocal, - R_sum, maxCoeff, B_avg); + const auto& [pvSum, numAquiferPvSum] + = this->convergenceReduction(this->grid_.comm(), pvSumLocal, numAquiferPvSumLocal, R_sum, maxCoeff, B_avg); - report.setCnvPoreVolSplit(this->characteriseCnvPvSplit(B_avg, dt), - pvSum - numAquiferPvSum); + report.setCnvPoreVolSplit(this->characteriseCnvPvSplit(B_avg, dt), pvSum - numAquiferPvSum); // For each iteration, we need to determine whether to use the // relaxed tolerances. To disable the usage of relaxed @@ -775,12 +720,10 @@ getReservoirConvergence(const double reportTime, // relaxed tolerance for the mass balance for the last // iterations. For positive values we use the relaxed tolerance // after the given number of iterations - const bool relax_final_iteration_mb = - this->param_.min_strict_mb_iter_ < 0 && iteration == maxIter; + const bool relax_final_iteration_mb = this->param_.min_strict_mb_iter_ < 0 && iteration == maxIter; - const bool use_relaxed_mb = relax_final_iteration_mb || - (this->param_.min_strict_mb_iter_ >= 0 && - iteration >= this->param_.min_strict_mb_iter_); + const bool use_relaxed_mb = relax_final_iteration_mb + || (this->param_.min_strict_mb_iter_ >= 0 && iteration >= this->param_.min_strict_mb_iter_); // If min_strict_cnv_iter = -1 we use a relaxed tolerance for // the cnv for the last iterations. For positive values we use @@ -788,37 +731,27 @@ getReservoirConvergence(const double reportTime, // We also use relaxed tolerances for cells with total // pore-volume less than relaxed_max_pv_fraction_. Default // value of relaxed_max_pv_fraction_ is 0.03 - const bool relax_final_iteration_cnv = - this->param_.min_strict_cnv_iter_ < 0 && iteration == maxIter; + const bool relax_final_iteration_cnv = this->param_.min_strict_cnv_iter_ < 0 && iteration == maxIter; - const bool relax_iter_cnv = - this->param_.min_strict_cnv_iter_ >= 0 && - iteration >= this->param_.min_strict_cnv_iter_; + const bool relax_iter_cnv + = this->param_.min_strict_cnv_iter_ >= 0 && iteration >= this->param_.min_strict_cnv_iter_; // Note trailing parentheses here, just before the final // semicolon. This is an immediately invoked function // expression which calculates a single boolean value. - const auto relax_pv_fraction_cnv = - [&report, this, eligible = pvSum - numAquiferPvSum]() - { + const auto relax_pv_fraction_cnv = [&report, this, eligible = pvSum - numAquiferPvSum]() { const auto& cnvPvSplit = report.cnvPvSplit().first; // [1]: tol < cnv <= relaxed // [2]: relaxed < cnv - return static_cast(cnvPvSplit[1] + cnvPvSplit[2]) < - this->param_.relaxed_max_pv_fraction_ * eligible; + return static_cast(cnvPvSplit[1] + cnvPvSplit[2]) < this->param_.relaxed_max_pv_fraction_ * eligible; }(); - const bool use_relaxed_cnv = relax_final_iteration_cnv - || relax_pv_fraction_cnv - || relax_iter_cnv; + const bool use_relaxed_cnv = relax_final_iteration_cnv || relax_pv_fraction_cnv || relax_iter_cnv; - if ((relax_final_iteration_mb || relax_final_iteration_cnv) && - this->terminal_output_) - { - std::string message = - "Number of newton iterations reached its maximum " - "try to continue with relaxed tolerances:"; + if ((relax_final_iteration_mb || relax_final_iteration_cnv) && this->terminal_output_) { + std::string message = "Number of newton iterations reached its maximum " + "try to continue with relaxed tolerances:"; if (relax_final_iteration_mb) { message += fmt::format(" MB: {:.1e}", param_.tolerance_mb_relaxed_); @@ -832,24 +765,24 @@ getReservoirConvergence(const double reportTime, } const auto tol_cnv = use_relaxed_cnv ? param_.tolerance_cnv_relaxed_ : param_.tolerance_cnv_; - const auto tol_mb = use_relaxed_mb ? param_.tolerance_mb_relaxed_ : param_.tolerance_mb_; + const auto tol_mb = use_relaxed_mb ? param_.tolerance_mb_relaxed_ : param_.tolerance_mb_; const auto tol_cnv_energy = use_relaxed_cnv ? param_.tolerance_cnv_energy_relaxed_ : param_.tolerance_cnv_energy_; const auto tol_eb = use_relaxed_mb ? param_.tolerance_energy_balance_relaxed_ : param_.tolerance_energy_balance_; // Finish computation std::vector CNV(numComp); std::vector mass_balance_residual(numComp); - for (int compIdx = 0; compIdx < numComp; ++compIdx) - { - CNV[compIdx] = B_avg[compIdx] * dt * maxCoeff[compIdx]; - mass_balance_residual[compIdx] = std::abs(B_avg[compIdx]*R_sum[compIdx]) * dt / pvSum; + for (int compIdx = 0; compIdx < numComp; ++compIdx) { + CNV[compIdx] = B_avg[compIdx] * dt * maxCoeff[compIdx]; + mass_balance_residual[compIdx] = std::abs(B_avg[compIdx] * R_sum[compIdx]) * dt / pvSum; residual_norms.push_back(CNV[compIdx]); } using CR = ConvergenceReport; for (int compIdx = 0; compIdx < numComp; ++compIdx) { const Scalar res[2] = { - mass_balance_residual[compIdx], CNV[compIdx], + mass_balance_residual[compIdx], + CNV[compIdx], }; const CR::ReservoirFailure::Type types[2] = { @@ -857,7 +790,10 @@ getReservoirConvergence(const double reportTime, CR::ReservoirFailure::Type::Cnv, }; - Scalar tol[2] = { tol_mb, tol_cnv, }; + Scalar tol[2] = { + tol_mb, + tol_cnv, + }; if (has_energy_ && compIdx == contiEnergyEqIdx) { tol[0] = tol_eb; tol[1] = tol_cnv_energy; @@ -869,20 +805,17 @@ getReservoirConvergence(const double reportTime, if (this->terminal_output_) { OpmLog::debug("NaN residual for " + this->compNames_.name(compIdx) + " equation."); } - } - else if (res[ii] > maxResidualAllowed()) { + } else if (res[ii] > maxResidualAllowed()) { report.setReservoirFailed({types[ii], CR::Severity::TooLarge, compIdx}); if (this->terminal_output_) { OpmLog::debug("Too large residual for " + this->compNames_.name(compIdx) + " equation."); } - } - else if (res[ii] < 0.0) { + } else if (res[ii] < 0.0) { report.setReservoirFailed({types[ii], CR::Severity::Normal, compIdx}); if (this->terminal_output_) { OpmLog::debug("Negative residual for " + this->compNames_.name(compIdx) + " equation."); } - } - else if (res[ii] > tol[ii]) { + } else if (res[ii] > tol[ii]) { report.setReservoirFailed({types[ii], CR::Severity::Normal, compIdx}); } @@ -937,12 +870,11 @@ getReservoirConvergence(const double reportTime, template void -BlackoilModel:: -convergencePerCell(const std::vector& B_avg, - const double dt, - const double tol_cnv, - const double tol_cnv_energy, - const int iteration) +BlackoilModel::convergencePerCell(const std::vector& B_avg, + const double dt, + const double tol_cnv, + const double tol_cnv_energy, + const int iteration) { auto& rst_conv = simulator_.problem().eclWriter().mutableOutputModule().getConv(); if (!rst_conv.hasConv()) { @@ -965,8 +897,8 @@ convergencePerCell(const std::vector& B_avg, elemCtx.updatePrimaryStencil(elem); const unsigned cell_idx = elemCtx.globalSpaceIndex(/*spaceIdx=*/0, /*timeIdx=*/0); - const auto pvValue = simulator_.problem().referencePorosity(cell_idx, /*timeIdx=*/0) * - simulator_.model().dofTotalVolume(cell_idx); + const auto pvValue = simulator_.problem().referencePorosity(cell_idx, /*timeIdx=*/0) + * simulator_.model().dofTotalVolume(cell_idx); for (int compIdx = 0; compIdx < numComp; ++compIdx) { const auto tol = (has_energy_ && compIdx == contiEnergyEqIdx) ? tol_cnv_energy : tol_cnv; const Scalar cnv = std::abs(B_avg[compIdx] * residual[cell_idx][compIdx]) * dt / pvValue; @@ -977,29 +909,26 @@ convergencePerCell(const std::vector& B_avg, } ++idx; } - OPM_END_PARALLEL_TRY_CATCH("BlackoilModel::convergencePerCell() failed: ", - this->grid_.comm()); + OPM_END_PARALLEL_TRY_CATCH("BlackoilModel::convergencePerCell() failed: ", this->grid_.comm()); rst_conv.updateNewton(convNewt); } template ConvergenceReport -BlackoilModel:: -getConvergence(const SimulatorTimerInterface& timer, - const int iteration, - const int maxIter, - std::vector& residual_norms) +BlackoilModel::getConvergence(const SimulatorTimerInterface& timer, + const int iteration, + const int maxIter, + std::vector& residual_norms) { OPM_TIMEBLOCK(getConvergence); // Get convergence reports for reservoir and wells. std::vector B_avg(numEq, 0.0); - auto report = getReservoirConvergence(timer.simulationTimeElapsed(), - timer.currentStepLength(), - iteration, maxIter, B_avg, residual_norms); + auto report = getReservoirConvergence( + timer.simulationTimeElapsed(), timer.currentStepLength(), iteration, maxIter, B_avg, residual_norms); { OPM_TIMEBLOCK(getWellConvergence); report += wellModel().getWellConvergence(B_avg, - /*checkWellGroupControlsAndNetwork*/report.converged()); + /*checkWellGroupControlsAndNetwork*/ report.converged()); } conv_monitor_.checkPenaltyCard(report, iteration); @@ -1008,21 +937,19 @@ getConvergence(const SimulatorTimerInterface& timer, } template -std::vector::Scalar> > -BlackoilModel:: -computeFluidInPlace(const std::vector& /*fipnum*/) const +std::vector::Scalar>> +BlackoilModel::computeFluidInPlace(const std::vector& /*fipnum*/) const { OPM_TIMEBLOCK(computeFluidInPlace); // assert(true) // return an empty vector - std::vector > regionValues(0, std::vector(0,0.0)); + std::vector> regionValues(0, std::vector(0, 0.0)); return regionValues; } template const SimulatorReport& -BlackoilModel:: -localAccumulatedReports() const +BlackoilModel::localAccumulatedReports() const { if (!hasNlddSolver()) { OPM_THROW(std::runtime_error, "Cannot get local reports from a model without NLDD solver"); @@ -1032,8 +959,7 @@ localAccumulatedReports() const template const std::vector& -BlackoilModel:: -domainAccumulatedReports() const +BlackoilModel::domainAccumulatedReports() const { if (!nlddSolver_) OPM_THROW(std::runtime_error, "Cannot get domain reports from a model without NLDD solver"); @@ -1042,8 +968,7 @@ domainAccumulatedReports() const template void -BlackoilModel:: -writeNonlinearIterationsPerCell(const std::filesystem::path& odir) const +BlackoilModel::writeNonlinearIterationsPerCell(const std::filesystem::path& odir) const { if (hasNlddSolver()) { nlddSolver_->writeNonlinearIterationsPerCell(odir); @@ -1052,8 +977,7 @@ writeNonlinearIterationsPerCell(const std::filesystem::path& odir) const template void -BlackoilModel:: -writePartitions(const std::filesystem::path& odir) const +BlackoilModel::writePartitions(const std::filesystem::path& odir) const { if (hasNlddSolver()) { nlddSolver_->writePartitions(odir); @@ -1070,28 +994,25 @@ writePartitions(const std::filesystem::path& odir) const std::ofstream pfile {odir / fmt::format("{1:0>{0}}", nDigit, comm.rank())}; for (const auto& cell : elements(grid.leafGridView(), Dune::Partitions::interior)) { - pfile << comm.rank() << ' ' - << cartMapper.cartesianIndex(elementMapper.index(cell)) << ' ' - << comm.rank() << '\n'; + pfile << comm.rank() << ' ' << cartMapper.cartesianIndex(elementMapper.index(cell)) << ' ' << comm.rank() + << '\n'; } } template -template +template void -BlackoilModel:: -getMaxCoeff(const unsigned cell_idx, - const IntensiveQuantities& intQuants, - const FluidState& fs, - const Residual& modelResid, - const Scalar pvValue, - std::vector& B_avg, - std::vector& R_sum, - std::vector& maxCoeff, - std::vector& maxCoeffCell) +BlackoilModel::getMaxCoeff(const unsigned cell_idx, + const IntensiveQuantities& intQuants, + const FluidState& fs, + const Residual& modelResid, + const Scalar pvValue, + std::vector& B_avg, + std::vector& R_sum, + std::vector& maxCoeff, + std::vector& maxCoeffCell) { - for (unsigned phaseIdx = 0; phaseIdx < FluidSystem::numPhases; ++phaseIdx) - { + for (unsigned phaseIdx = 0; phaseIdx < FluidSystem::numPhases; ++phaseIdx) { if (!FluidSystem::phaseIsActive(phaseIdx)) { continue; } @@ -1111,40 +1032,34 @@ getMaxCoeff(const unsigned cell_idx, } if constexpr (has_solvent_) { - B_avg[contiSolventEqIdx] += - 1.0 / intQuants.solventInverseFormationVolumeFactor().value(); + B_avg[contiSolventEqIdx] += 1.0 / intQuants.solventInverseFormationVolumeFactor().value(); const auto R2 = modelResid[cell_idx][contiSolventEqIdx]; R_sum[contiSolventEqIdx] += R2; - maxCoeff[contiSolventEqIdx] = std::max(maxCoeff[contiSolventEqIdx], - std::abs(R2) / pvValue); + maxCoeff[contiSolventEqIdx] = std::max(maxCoeff[contiSolventEqIdx], std::abs(R2) / pvValue); } if constexpr (has_extbo_) { B_avg[contiZfracEqIdx] += 1.0 / fs.invB(FluidSystem::gasPhaseIdx).value(); const auto R2 = modelResid[cell_idx][contiZfracEqIdx]; - R_sum[ contiZfracEqIdx ] += R2; - maxCoeff[contiZfracEqIdx] = std::max(maxCoeff[contiZfracEqIdx], - std::abs(R2) / pvValue); + R_sum[contiZfracEqIdx] += R2; + maxCoeff[contiZfracEqIdx] = std::max(maxCoeff[contiZfracEqIdx], std::abs(R2) / pvValue); } if constexpr (has_polymer_) { B_avg[contiPolymerEqIdx] += 1.0 / fs.invB(FluidSystem::waterPhaseIdx).value(); const auto R2 = modelResid[cell_idx][contiPolymerEqIdx]; R_sum[contiPolymerEqIdx] += R2; - maxCoeff[contiPolymerEqIdx] = std::max(maxCoeff[contiPolymerEqIdx], - std::abs(R2) / pvValue); + maxCoeff[contiPolymerEqIdx] = std::max(maxCoeff[contiPolymerEqIdx], std::abs(R2) / pvValue); } if constexpr (has_foam_) { - B_avg[ contiFoamEqIdx ] += 1.0 / fs.invB(FluidSystem::gasPhaseIdx).value(); + B_avg[contiFoamEqIdx] += 1.0 / fs.invB(FluidSystem::gasPhaseIdx).value(); const auto R2 = modelResid[cell_idx][contiFoamEqIdx]; R_sum[contiFoamEqIdx] += R2; - maxCoeff[contiFoamEqIdx] = std::max(maxCoeff[contiFoamEqIdx], - std::abs(R2) / pvValue); + maxCoeff[contiFoamEqIdx] = std::max(maxCoeff[contiFoamEqIdx], std::abs(R2) / pvValue); } if constexpr (has_brine_) { - B_avg[ contiBrineEqIdx ] += 1.0 / fs.invB(FluidSystem::waterPhaseIdx).value(); + B_avg[contiBrineEqIdx] += 1.0 / fs.invB(FluidSystem::waterPhaseIdx).value(); const auto R2 = modelResid[cell_idx][contiBrineEqIdx]; R_sum[contiBrineEqIdx] += R2; - maxCoeff[contiBrineEqIdx] = std::max(maxCoeff[contiBrineEqIdx], - std::abs(R2) / pvValue); + maxCoeff[contiBrineEqIdx] = std::max(maxCoeff[contiBrineEqIdx], std::abs(R2) / pvValue); } if constexpr (has_polymermw_) { @@ -1156,46 +1071,40 @@ getMaxCoeff(const unsigned cell_idx, // TODO: there should be a more general way to determine the scaling-down coefficient const auto R2 = modelResid[cell_idx][contiPolymerMWEqIdx] / 100.; R_sum[contiPolymerMWEqIdx] += R2; - maxCoeff[contiPolymerMWEqIdx] = std::max(maxCoeff[contiPolymerMWEqIdx], - std::abs(R2) / pvValue); + maxCoeff[contiPolymerMWEqIdx] = std::max(maxCoeff[contiPolymerMWEqIdx], std::abs(R2) / pvValue); } if constexpr (has_energy_) { - B_avg[contiEnergyEqIdx] += 1.0 / (4.182e1); // converting J -> RM3 (entalpy / (cp * deltaK * rho) assuming change of 1e-5K of water + B_avg[contiEnergyEqIdx] + += 1.0 / (4.182e1); // converting J -> RM3 (entalpy / (cp * deltaK * rho) assuming change of 1e-5K of water const auto R2 = modelResid[cell_idx][contiEnergyEqIdx]; R_sum[contiEnergyEqIdx] += R2; - maxCoeff[contiEnergyEqIdx] = std::max(maxCoeff[contiEnergyEqIdx], - std::abs(R2) / pvValue); + maxCoeff[contiEnergyEqIdx] = std::max(maxCoeff[contiEnergyEqIdx], std::abs(R2) / pvValue); } if constexpr (has_bioeffects_) { B_avg[contiMicrobialEqIdx] += 1.0 / fs.invB(FluidSystem::waterPhaseIdx).value(); const auto R1 = modelResid[cell_idx][contiMicrobialEqIdx]; R_sum[contiMicrobialEqIdx] += R1; - maxCoeff[contiMicrobialEqIdx] = std::max(maxCoeff[contiMicrobialEqIdx], - std::abs(R1) / pvValue); + maxCoeff[contiMicrobialEqIdx] = std::max(maxCoeff[contiMicrobialEqIdx], std::abs(R1) / pvValue); B_avg[contiBiofilmEqIdx] += 1.0 / fs.invB(FluidSystem::waterPhaseIdx).value(); const auto R2 = modelResid[cell_idx][contiBiofilmEqIdx]; R_sum[contiBiofilmEqIdx] += R2; - maxCoeff[contiBiofilmEqIdx] = std::max(maxCoeff[contiBiofilmEqIdx], - std::abs(R2) / pvValue); + maxCoeff[contiBiofilmEqIdx] = std::max(maxCoeff[contiBiofilmEqIdx], std::abs(R2) / pvValue); if constexpr (has_micp_) { B_avg[contiOxygenEqIdx] += 1.0 / fs.invB(FluidSystem::waterPhaseIdx).value(); const auto R3 = modelResid[cell_idx][contiOxygenEqIdx]; R_sum[contiOxygenEqIdx] += R3; - maxCoeff[contiOxygenEqIdx] = std::max(maxCoeff[contiOxygenEqIdx], - std::abs(R3) / pvValue); + maxCoeff[contiOxygenEqIdx] = std::max(maxCoeff[contiOxygenEqIdx], std::abs(R3) / pvValue); B_avg[contiUreaEqIdx] += 1.0 / fs.invB(FluidSystem::waterPhaseIdx).value(); const auto R4 = modelResid[cell_idx][contiUreaEqIdx]; R_sum[contiUreaEqIdx] += R4; - maxCoeff[contiUreaEqIdx] = std::max(maxCoeff[contiUreaEqIdx], - std::abs(R4) / pvValue); + maxCoeff[contiUreaEqIdx] = std::max(maxCoeff[contiUreaEqIdx], std::abs(R4) / pvValue); B_avg[contiCalciteEqIdx] += 1.0 / fs.invB(FluidSystem::waterPhaseIdx).value(); const auto R5 = modelResid[cell_idx][contiCalciteEqIdx]; R_sum[contiCalciteEqIdx] += R5; - maxCoeff[contiCalciteEqIdx] = std::max(maxCoeff[contiCalciteEqIdx], - std::abs(R5) / pvValue); - } + maxCoeff[contiCalciteEqIdx] = std::max(maxCoeff[contiCalciteEqIdx], std::abs(R5) / pvValue); + } } } diff --git a/opm/simulators/flow/CollectDataOnIORank.cpp b/opm/simulators/flow/CollectDataOnIORank.cpp index 7d5d75556cb..5be9ce3de80 100644 --- a/opm/simulators/flow/CollectDataOnIORank.cpp +++ b/opm/simulators/flow/CollectDataOnIORank.cpp @@ -32,19 +32,16 @@ #include #endif // HAVE_DUNE_FEM -namespace Opm { +namespace Opm +{ template class CollectDataOnIORank>>; #if HAVE_DUNE_FEM -using GV = Dune::Fem::AdaptiveLeafGridPart; -template class CollectDataOnIORank; +using GV = Dune::Fem::AdaptiveLeafGridPart; +template class CollectDataOnIORank; #endif // HAVE_DUNE_FEM } // end namespace Opm diff --git a/opm/simulators/flow/CollectDataOnIORank.hpp b/opm/simulators/flow/CollectDataOnIORank.hpp index c9801622592..5928ef051c2 100644 --- a/opm/simulators/flow/CollectDataOnIORank.hpp +++ b/opm/simulators/flow/CollectDataOnIORank.hpp @@ -45,11 +45,14 @@ #include #include -namespace Dune { -template class CartesianIndexMapper; +namespace Dune +{ +template +class CartesianIndexMapper; } -namespace Opm { +namespace Opm +{ template class CollectDataOnIORank @@ -64,8 +67,7 @@ class CollectDataOnIORank enum { ioRank = 0 }; - static const bool needsReordering = - !std::is_same::value; + static const bool needsReordering = !std::is_same::value; CollectDataOnIORank(const Grid& grid, const EquilGrid* equilGrid, @@ -75,59 +77,87 @@ class CollectDataOnIORank const std::set& fipRegionsInterregFlow = {}); // gather solution to rank 0 for EclipseWriter - void collect(const data::Solution& localCellData, + void collect(const data::Solution& localCellData, const std::map, double>& localBlockData, - std::map, double>& localExtraBlockData, - const data::Wells& localWellData, - const data::WellBlockAveragePressures& localWBPData, - const data::GroupAndNetworkValues& localGroupAndNetworkData, - const data::Aquifers& localAquiferData, - const WellTestState& localWellTestState, - const InterRegFlowMap& interRegFlows, - const std::array, 3>& localFlowsn, - const std::array, 3>& localFloresn); + std::map, double>& localExtraBlockData, + const data::Wells& localWellData, + const data::WellBlockAveragePressures& localWBPData, + const data::GroupAndNetworkValues& localGroupAndNetworkData, + const data::Aquifers& localAquiferData, + const WellTestState& localWellTestState, + const InterRegFlowMap& interRegFlows, + const std::array, 3>& localFlowsn, + const std::array, 3>& localFloresn); const std::map, double>& globalBlockData() const - { return globalBlockData_; } + { + return globalBlockData_; + } const data::Solution& globalCellData() const - { return globalCellData_; } + { + return globalCellData_; + } data::Solution& globalCellData() - { return globalCellData_; } + { + return globalCellData_; + } const data::Wells& globalWellData() const - { return globalWellData_; } + { + return globalWellData_; + } const data::WellBlockAveragePressures& globalWBPData() const - { return this->globalWBPData_; } + { + return this->globalWBPData_; + } const data::GroupAndNetworkValues& globalGroupAndNetworkData() const - { return globalGroupAndNetworkData_; } + { + return globalGroupAndNetworkData_; + } const data::Aquifers& globalAquiferData() const - { return globalAquiferData_; } + { + return globalAquiferData_; + } const WellTestState& globalWellTestState() const - { return this->globalWellTestState_; } + { + return this->globalWellTestState_; + } InterRegFlowMap& globalInterRegFlows() - { return this->globalInterRegFlows_; } + { + return this->globalInterRegFlows_; + } const InterRegFlowMap& globalInterRegFlows() const - { return this->globalInterRegFlows_; } + { + return this->globalInterRegFlows_; + } const std::array, 3>& globalFlowsn() const - { return globalFlowsn_; } + { + return globalFlowsn_; + } const std::array, 3>& globalFloresn() const - { return globalFloresn_; } + { + return globalFloresn_; + } bool isIORank() const - { return toIORankComm_.rank() == ioRank; } + { + return toIORankComm_.rank() == ioRank; + } bool isParallel() const - { return toIORankComm_.size() > 1; } + { + return toIORankComm_.size() > 1; + } int localIdxToGlobalIdx(unsigned localIdx) const; @@ -137,13 +167,19 @@ class CollectDataOnIORank } bool doesNeedReordering() const - { return needsReordering;} + { + return needsReordering; + } - std::size_t numCells () const - { return globalCartesianIndex_.size(); } + std::size_t numCells() const + { + return globalCartesianIndex_.size(); + } const std::vector& globalRanks() const - { return globalRanks_; } + { + return globalRanks_; + } bool isCartIdxOnThisRank(int cartIdx) const; diff --git a/opm/simulators/flow/CollectDataOnIORank_impl.hpp b/opm/simulators/flow/CollectDataOnIORank_impl.hpp index 91e0a25d862..60547a24856 100644 --- a/opm/simulators/flow/CollectDataOnIORank_impl.hpp +++ b/opm/simulators/flow/CollectDataOnIORank_impl.hpp @@ -39,14 +39,17 @@ #include #include -namespace { - std::vector toVector(const std::set& string_set) - { - return { string_set.begin(), string_set.end() }; - } +namespace +{ +std::vector +toVector(const std::set& string_set) +{ + return {string_set.begin(), string_set.end()}; } +} // namespace -namespace Opm { +namespace Opm +{ // global id class GlobalCellIndex @@ -60,21 +63,34 @@ class GlobalCellIndex : globalId_(-1) , localIndex_(-1) , isInterior_(true) - {} + { + } void setGhost() - { isInterior_ = false; } + { + isInterior_ = false; + } void setId(int globalId) - { globalId_ = globalId; } + { + globalId_ = globalId; + } void setIndex(int localIndex) - { localIndex_ = localIndex; } + { + localIndex_ = localIndex; + } - int localIndex () const - { return localIndex_; } - int id () const - { return globalId_; } + int localIndex() const + { + return localIndex_; + } + int id() const + { + return globalId_; + } bool isInterior() const - { return isInterior_; } + { + return isInterior_; + } }; using IndexMapType = std::vector; @@ -99,16 +115,16 @@ class DistributeIndexMapping : public P2PCommunicatorType::DataHandleInterface std::vector& ranks, std::set& recv, bool isIORank) - : distributedGlobalIndex_(distributedGlobalIndex) - , localIndexMap_(localIndexMap) - , indexMaps_(indexMaps) - , globalPosition_() - , recv_(recv) - , ranks_(ranks) + : distributedGlobalIndex_(distributedGlobalIndex) + , localIndexMap_(localIndexMap) + , indexMaps_(indexMaps) + , globalPosition_() + , recv_(recv) + , ranks_(ranks) { std::size_t size = globalIndex.size(); // create mapping globalIndex --> localIndex - if ( isIORank ) // ioRank + if (isIORank) // ioRank for (std::size_t index = 0; index < size; ++index) globalPosition_.insert(std::make_pair(globalIndex[index], index)); @@ -120,8 +136,7 @@ class DistributeIndexMapping : public P2PCommunicatorType::DataHandleInterface IndexMapType& indexMap = indexMaps_.back(); std::size_t localSize = localIndexMap_.size(); indexMap.resize(localSize); - for (std::size_t i = 0; i < localSize; ++i) - { + for (std::size_t i = 0; i < localSize; ++i) { int id = distributedGlobalIndex_[localIndexMap_[i]]; indexMap[i] = id; } @@ -133,18 +148,15 @@ class DistributeIndexMapping : public P2PCommunicatorType::DataHandleInterface if (!indexMaps_.size()) return; - if ( ranks_.size() ) - { + if (ranks_.size()) { auto rankIt = recv_.begin(); // translate index maps from global cartesian to index - for (auto& indexMap: indexMaps_) - { + for (auto& indexMap : indexMaps_) { int rank = 0; if (rankIt != recv_.end()) rank = *rankIt; - for (auto&& entry: indexMap) - { + for (auto&& entry : indexMap) { auto candidate = globalPosition_.find(entry); assert(candidate != globalPosition_.end()); entry = candidate->second; @@ -154,10 +166,10 @@ class DistributeIndexMapping : public P2PCommunicatorType::DataHandleInterface if (rankIt != recv_.end()) ++rankIt; } - #ifndef NDEBUG - for (const auto& rank: ranks_) - assert(rank>=0); - #endif +#ifndef NDEBUG + for (const auto& rank : ranks_) + assert(rank >= 0); +#endif } } @@ -195,30 +207,33 @@ class DistributeIndexMapping : public P2PCommunicatorType::DataHandleInterface /// \brief Communication handle to scatter the global index -template +template class ElementIndexScatterHandle { public: ElementIndexScatterHandle(const EquilMapper& sendMapper, const Mapper& recvMapper, std::vector& elementIndices) - : sendMapper_(sendMapper), recvMapper_(recvMapper), elementIndices_(elementIndices) - {} + : sendMapper_(sendMapper) + , recvMapper_(recvMapper) + , elementIndices_(elementIndices) + { + } using DataType = int; bool fixedSize(int /*dim*/, int /*codim*/) { return true; } - template + template std::size_t size(const T&) { return 1; } - template + template void gather(B& buffer, const T& t) { buffer.write(sendMapper_.index(t)); } - template + template void scatter(B& buffer, const T& t, std::size_t) { buffer.read(elementIndices_[recvMapper_.index(t)]); @@ -226,8 +241,9 @@ class ElementIndexScatterHandle bool contains(int dim, int codim) { - return dim==3 && codim==0; + return dim == 3 && codim == 0; } + private: const EquilMapper& sendMapper_; const Mapper& recvMapper_; @@ -235,30 +251,32 @@ class ElementIndexScatterHandle }; /// \brief Communication handle to scatter the global index -template +template class ElementIndexHandle { public: ElementIndexHandle(const Mapper& mapper, std::vector& elementIndices) - : mapper_(mapper), elementIndices_(elementIndices) - {} + : mapper_(mapper) + , elementIndices_(elementIndices) + { + } using DataType = int; bool fixedSize(int /*dim*/, int /*codim*/) { return true; } - template + template std::size_t size(const T&) { return 1; } - template + template void gather(B& buffer, const T& t) { buffer.write(elementIndices_[mapper_.index(t)]); } - template + template void scatter(B& buffer, const T& t, std::size_t) { buffer.read(elementIndices_[mapper_.index(t)]); @@ -266,8 +284,9 @@ class ElementIndexHandle bool contains(int dim, int codim) { - return dim==3 && codim==0; + return dim == 3 && codim == 0; } + private: const Mapper& mapper_; std::vector& elementIndices_; @@ -298,9 +317,8 @@ class PackUnPackCellData : public P2PCommunicatorType::DataHandleInterface for (const auto& pair : localCellData_) { const std::string& key = pair.first; std::size_t containerSize = globalSize; - [[maybe_unused]] auto ret = globalCellData_.insert(key, pair.second.dim, - std::vector(containerSize), - pair.second.target); + [[maybe_unused]] auto ret = globalCellData_.insert( + key, pair.second.dim, std::vector(containerSize), pair.second.target); assert(ret.second); } @@ -336,14 +354,16 @@ class PackUnPackCellData : public P2PCommunicatorType::DataHandleInterface const std::string& key = pair.first; auto& data = globalCellData_.data(key); - //write all data from local cell data to buffer + // write all data from local cell data to buffer read(buffer, indexMap, data); } } // unpack all data associated with link void unpack(int link, MessageBufferType& buffer) - { doUnpack(indexMaps_[link], buffer); } + { + doUnpack(indexMaps_[link], buffer); + } protected: template @@ -356,8 +376,7 @@ class PackUnPackCellData : public P2PCommunicatorType::DataHandleInterface unsigned int size = localIndexMap.size(); buffer.write(size); assert(vector.size() >= stride * size); - for (unsigned int i=0; ipack(0, buffer); @@ -447,9 +467,7 @@ class PackUnPackGroupAndNetworkValues : public P2PCommunicatorType::DataHandleIn { // we should only get one link if (link != 0) { - throw std::logic_error { - "link in method pack is not 0 as expected" - }; + throw std::logic_error {"link in method pack is not 0 as expected"}; } // write all group and network (node/branch) data @@ -458,7 +476,9 @@ class PackUnPackGroupAndNetworkValues : public P2PCommunicatorType::DataHandleIn // unpack all data associated with link void unpack(int /*link*/, MessageBufferType& buffer) - { this->globalGroupAndNetworkData_.read(buffer); } + { + this->globalGroupAndNetworkData_.read(buffer); + } }; class PackUnPackBlockData : public P2PCommunicatorType::DataHandleInterface @@ -525,12 +545,12 @@ class PackUnPackWBPData : public P2PCommunicatorType::DataHandleInterface public: PackUnPackWBPData(const data::WellBlockAveragePressures& localWBPData, - data::WellBlockAveragePressures& globalWBPValues, - const bool isIORank) - : localWBPData_ (localWBPData) + data::WellBlockAveragePressures& globalWBPValues, + const bool isIORank) + : localWBPData_(localWBPData) , globalWBPValues_(globalWBPValues) { - if (! isIORank) { + if (!isIORank) { return; } @@ -547,10 +567,7 @@ class PackUnPackWBPData : public P2PCommunicatorType::DataHandleInterface { // We should only get one link if (link != 0) { - throw std::logic_error { - "link (" + std::to_string(link) + - ") in method pack() is not 0 as expected" - }; + throw std::logic_error {"link (" + std::to_string(link) + ") in method pack() is not 0 as expected"}; } // Write all local, per-well, WBP data @@ -558,8 +575,7 @@ class PackUnPackWBPData : public P2PCommunicatorType::DataHandleInterface } // Unpack all data associated with link - void unpack([[maybe_unused]] const int link, - MessageBufferType& buffer) + void unpack([[maybe_unused]] const int link, MessageBufferType& buffer) { this->globalWBPValues_.read(buffer); } @@ -568,9 +584,7 @@ class PackUnPackWBPData : public P2PCommunicatorType::DataHandleInterface class PackUnPackWellTestState : public P2PCommunicatorType::DataHandleInterface { public: - PackUnPackWellTestState(const WellTestState& localWTestState, - WellTestState& globalWTestState, - bool isIORank) + PackUnPackWellTestState(const WellTestState& localWTestState, WellTestState& globalWTestState, bool isIORank) : local_(localWTestState) , global_(globalWTestState) { @@ -584,13 +598,15 @@ class PackUnPackWellTestState : public P2PCommunicatorType::DataHandleInterface } } - void pack(int link, MessageBufferType& buffer) { + void pack(int link, MessageBufferType& buffer) + { if (link != 0) throw std::logic_error("link in method pack is not 0 as expected"); this->local_.pack(buffer); } - void unpack(int, MessageBufferType& buffer) { + void unpack(int, MessageBufferType& buffer) + { this->global_.unpack(buffer); } @@ -605,9 +621,7 @@ class PackUnPackAquiferData : public P2PCommunicatorType::DataHandleInterface data::Aquifers& globalAquiferData_; public: - PackUnPackAquiferData(const data::Aquifers& localAquiferData, - data::Aquifers& globalAquiferData, - bool isIORank) + PackUnPackAquiferData(const data::Aquifers& localAquiferData, data::Aquifers& globalAquiferData, bool isIORank) : localAquiferData_(localAquiferData) , globalAquiferData_(globalAquiferData) { @@ -651,19 +665,11 @@ class PackUnPackAquiferData : public P2PCommunicatorType::DataHandleInterface this->unpackCommon(data, aq); - if (auto const* aquFet = data.typeData.get(); - aquFet != nullptr) - { + if (auto const* aquFet = data.typeData.get(); aquFet != nullptr) { this->unpackAquFet(*aquFet, aq); - } - else if (auto const* aquCT = data.typeData.get(); - aquCT != nullptr) - { + } else if (auto const* aquCT = data.typeData.get(); aquCT != nullptr) { this->unpackCarterTracy(*aquCT, aq); - } - else if (auto const* aquNum = data.typeData.get(); - aquNum != nullptr) - { + } else if (auto const* aquNum = data.typeData.get(); aquNum != nullptr) { this->unpackNumericAquifer(*aquNum, aq); } } @@ -682,58 +688,52 @@ class PackUnPackAquiferData : public P2PCommunicatorType::DataHandleInterface void unpackAquFet(const data::FetkovichData& aquFet, data::AquiferData& aq) { - if (! aq.typeData.is()) { + if (!aq.typeData.is()) { auto* tData = aq.typeData.create(); *tData = aquFet; - } - else { + } else { const auto& src = aquFet; - auto& dst = *aq.typeData.getMutable(); + auto& dst = *aq.typeData.getMutable(); - dst.initVolume = std::max(dst.initVolume , src.initVolume); - dst.prodIndex = std::max(dst.prodIndex , src.prodIndex); + dst.initVolume = std::max(dst.initVolume, src.initVolume); + dst.prodIndex = std::max(dst.prodIndex, src.prodIndex); dst.timeConstant = std::max(dst.timeConstant, src.timeConstant); } } void unpackCarterTracy(const data::CarterTracyData& aquCT, data::AquiferData& aq) { - if (! aq.typeData.is()) { + if (!aq.typeData.is()) { auto* tData = aq.typeData.create(); *tData = aquCT; - } - else { + } else { const auto& src = aquCT; - auto& dst = *aq.typeData.getMutable(); + auto& dst = *aq.typeData.getMutable(); - dst.timeConstant = std::max(dst.timeConstant , src.timeConstant); + dst.timeConstant = std::max(dst.timeConstant, src.timeConstant); dst.influxConstant = std::max(dst.influxConstant, src.influxConstant); - dst.waterDensity = std::max(dst.waterDensity , src.waterDensity); + dst.waterDensity = std::max(dst.waterDensity, src.waterDensity); dst.waterViscosity = std::max(dst.waterViscosity, src.waterViscosity); - dst.dimensionless_time = std::max(dst.dimensionless_time , src.dimensionless_time); + dst.dimensionless_time = std::max(dst.dimensionless_time, src.dimensionless_time); dst.dimensionless_pressure = std::max(dst.dimensionless_pressure, src.dimensionless_pressure); } } void unpackNumericAquifer(const data::NumericAquiferData& aquNum, data::AquiferData& aq) { - if (! aq.typeData.is()) { + if (!aq.typeData.is()) { auto* tData = aq.typeData.create(); *tData = aquNum; - } - else { + } else { const auto& src = aquNum; - auto& dst = *aq.typeData.getMutable(); + auto& dst = *aq.typeData.getMutable(); std::transform(src.initPressure.begin(), src.initPressure.end(), dst.initPressure.begin(), dst.initPressure.begin(), - [](const double p0_1, const double p0_2) - { - return std::max(p0_1, p0_2); - }); + [](const double p0_1, const double p0_2) { return std::max(p0_1, p0_2); }); } } }; @@ -741,16 +741,18 @@ class PackUnPackAquiferData : public P2PCommunicatorType::DataHandleInterface class PackUnpackInterRegFlows : public P2PCommunicatorType::DataHandleInterface { const InterRegFlowMap& localInterRegFlows_; - InterRegFlowMap& globalInterRegFlows_; + InterRegFlowMap& globalInterRegFlows_; public: PackUnpackInterRegFlows(const InterRegFlowMap& localInterRegFlows, - InterRegFlowMap& globalInterRegFlows, - const bool isIORank) + InterRegFlowMap& globalInterRegFlows, + const bool isIORank) : localInterRegFlows_(localInterRegFlows) , globalInterRegFlows_(globalInterRegFlows) { - if (! isIORank) { return; } + if (!isIORank) { + return; + } MessageBufferType buffer; this->pack(0, buffer); @@ -765,9 +767,7 @@ class PackUnpackInterRegFlows : public P2PCommunicatorType::DataHandleInterface { // we should only get one link if (link != 0) { - throw std::logic_error { - "link in method pack is not 0 as expected" - }; + throw std::logic_error {"link in method pack is not 0 as expected"}; } // write all inter-region flow data @@ -776,7 +776,9 @@ class PackUnpackInterRegFlows : public P2PCommunicatorType::DataHandleInterface // unpack all data associated with link void unpack(int /*link*/, MessageBufferType& buffer) - { this->globalInterRegFlows_.read(buffer); } + { + this->globalInterRegFlows_.read(buffer); + } }; class PackUnpackFlows : public P2PCommunicatorType::DataHandleInterface @@ -785,13 +787,15 @@ class PackUnpackFlows : public P2PCommunicatorType::DataHandleInterface std::array, 3>& globalFlows_; public: - PackUnpackFlows(const std::array, 3> & localFlows, + PackUnpackFlows(const std::array, 3>& localFlows, std::array, 3>& globalFlows, const bool isIORank) : localFlows_(localFlows) , globalFlows_(globalFlows) { - if (! isIORank) { return; } + if (!isIORank) { + return; + } MessageBufferType buffer; this->pack(0, buffer); @@ -842,17 +846,18 @@ class PackUnpackFlows : public P2PCommunicatorType::DataHandleInterface }; template -CollectDataOnIORank:: -CollectDataOnIORank(const Grid& grid, const EquilGrid* equilGrid, - const GridView& localGridView, - const Dune::CartesianIndexMapper& cartMapper, - const Dune::CartesianIndexMapper* equilCartMapper, - const std::set& fipRegionsInterregFlow) +CollectDataOnIORank::CollectDataOnIORank( + const Grid& grid, + const EquilGrid* equilGrid, + const GridView& localGridView, + const Dune::CartesianIndexMapper& cartMapper, + const Dune::CartesianIndexMapper* equilCartMapper, + const std::set& fipRegionsInterregFlow) : toIORankComm_(grid.comm()) , globalInterRegFlows_(InterRegFlowMap::createMapFromNames(toVector(fipRegionsInterregFlow))) { // Build index maps only when reordering is needed; skip in parallel runs for CpGrid with LGRs - if ((!needsReordering && !isParallel()) || (isParallel() && (grid.maxLevel()>0))) + if ((!needsReordering && !isParallel()) || (isParallel() && (grid.maxLevel() > 0))) return; const CollectiveCommunication& comm = grid.comm(); @@ -866,8 +871,7 @@ CollectDataOnIORank(const Grid& grid, const EquilGrid* equilGrid, ElementMapper elemMapper(localGridView, Dune::mcmgElementLayout()); sortedCartesianIdx_.reserve(localGridView.size(0)); - for (const auto& elem : elements(localGridView, Dune::Partitions::interior)) - { + for (const auto& elem : elements(localGridView, Dune::Partitions::interior)) { auto idx = elemMapper.index(elem); sortedCartesianIdx_.push_back(cartMapper.cartesianIndex(idx)); } @@ -887,11 +891,12 @@ CollectDataOnIORank(const Grid& grid, const EquilGrid* equilGrid, using EquilElementMapper = Dune::MultipleCodimMultipleGeomTypeMapper; EquilElementMapper equilElemMapper(equilGridView, Dune::mcmgElementLayout()); - // Scatter the global index to local index for lookup during restart - if constexpr (isSameGrid) { - ElementIndexScatterHandle handle(equilElemMapper, elemMapper, localIdxToGlobalIdx_); - grid.scatterData(handle); - } + // Scatter the global index to local index for lookup during restart + if constexpr (isSameGrid) { + ElementIndexScatterHandle handle( + equilElemMapper, elemMapper, localIdxToGlobalIdx_); + grid.scatterData(handle); + } // loop over all elements (global grid) and store Cartesian index for (const auto& elem : elements(equilGrid->leafGridView())) { @@ -904,9 +909,7 @@ CollectDataOnIORank(const Grid& grid, const EquilGrid* equilGrid, if (i != ioRank) recv.insert(i); } - } - else - { + } else { // all other simply send to the I/O rank send.insert(ioRank); @@ -914,16 +917,16 @@ CollectDataOnIORank(const Grid& grid, const EquilGrid* equilGrid, // This is a bit hacky since the type differs from the iorank. // But should work since we only receive, i.e. use the second parameter. if constexpr (isSameGrid) { - ElementIndexScatterHandle handle(elemMapper, elemMapper, localIdxToGlobalIdx_); - grid.scatterData(handle); + ElementIndexScatterHandle handle( + elemMapper, elemMapper, localIdxToGlobalIdx_); + grid.scatterData(handle); } } // Sync the global element indices if constexpr (isSameGrid) { - ElementIndexHandle handle(elemMapper, localIdxToGlobalIdx_); - grid.communicate(handle, Dune::InteriorBorder_All_Interface, - Dune::ForwardCommunication); + ElementIndexHandle handle(elemMapper, localIdxToGlobalIdx_); + grid.communicate(handle, Dune::InteriorBorder_All_Interface, Dune::ForwardCommunication); } localIndexMap_.clear(); @@ -965,22 +968,23 @@ CollectDataOnIORank(const Grid& grid, const EquilGrid* equilGrid, } template -void CollectDataOnIORank:: -collect(const data::Solution& localCellData, - const std::map, double>& localBlockData, - std::map, double>& extraBlockData, - const data::Wells& localWellData, - const data::WellBlockAveragePressures& localWBPData, - const data::GroupAndNetworkValues& localGroupAndNetworkData, - const data::Aquifers& localAquiferData, - const WellTestState& localWellTestState, - const InterRegFlowMap& localInterRegFlows, - const std::array, 3>& localFlowsn, - const std::array, 3>& localFloresn) +void +CollectDataOnIORank::collect( + const data::Solution& localCellData, + const std::map, double>& localBlockData, + std::map, double>& extraBlockData, + const data::Wells& localWellData, + const data::WellBlockAveragePressures& localWBPData, + const data::GroupAndNetworkValues& localGroupAndNetworkData, + const data::Aquifers& localAquiferData, + const WellTestState& localWellTestState, + const InterRegFlowMap& localInterRegFlows, + const std::array, 3>& localFlowsn, + const std::array, 3>& localFloresn) { globalCellData_ = {}; globalBlockData_.clear(); - std::map,double> globalExtraBlockData; + std::map, double> globalExtraBlockData; globalWellData_.clear(); globalWBPData_.values.clear(); globalGroupAndNetworkData_.clear(); @@ -991,20 +995,18 @@ collect(const data::Solution& localCellData, globalFloresn_ = {}; // index maps only have to be build when reordering is needed - if(!needsReordering && !isParallel()) + if (!needsReordering && !isParallel()) return; // this also linearises the local buffers on ioRank - PackUnPackCellData packUnpackCellData { - localCellData, - this->globalCellData_, - this->localIndexMap_, - this->indexMaps_, - this->numCells(), - this->isIORank() - }; - - if (! isParallel()) { + PackUnPackCellData packUnpackCellData {localCellData, + this->globalCellData_, + this->localIndexMap_, + this->indexMaps_, + this->numCells(), + this->isIORank()}; + + if (!isParallel()) { // no need to collect anything. return; } @@ -1017,65 +1019,26 @@ collect(const data::Solution& localCellData, globalFlowsn_[i].resize(sizeFlo); } - PackUnPackWellData packUnpackWellData { - localWellData, - this->globalWellData_, - this->isIORank() - }; + PackUnPackWellData packUnpackWellData {localWellData, this->globalWellData_, this->isIORank()}; PackUnPackGroupAndNetworkValues packUnpackGroupAndNetworkData { - localGroupAndNetworkData, - this->globalGroupAndNetworkData_, - this->isIORank() - }; - - PackUnPackBlockData packUnpackBlockData { - localBlockData, - this->globalBlockData_, - this->isIORank() - }; - - PackUnPackBlockData packUnpackExtraBlockData { - extraBlockData, - globalExtraBlockData, - this->isIORank() - }; - - PackUnPackWBPData packUnpackWBPData { - localWBPData, - this->globalWBPData_, - this->isIORank() - }; - - PackUnPackAquiferData packUnpackAquiferData { - localAquiferData, - this->globalAquiferData_, - this->isIORank() - }; - - PackUnPackWellTestState packUnpackWellTestState { - localWellTestState, - this->globalWellTestState_, - this->isIORank() - }; - - PackUnpackInterRegFlows packUnpackInterRegFlows { - localInterRegFlows, - this->globalInterRegFlows_, - this->isIORank() - }; - - PackUnpackFlows packUnpackFlowsn { - localFlowsn, - this->globalFlowsn_, - this->isIORank() - }; - - PackUnpackFlows packUnpackFloresn { - localFloresn, - this->globalFloresn_, - this->isIORank() - }; + localGroupAndNetworkData, this->globalGroupAndNetworkData_, this->isIORank()}; + + PackUnPackBlockData packUnpackBlockData {localBlockData, this->globalBlockData_, this->isIORank()}; + + PackUnPackBlockData packUnpackExtraBlockData {extraBlockData, globalExtraBlockData, this->isIORank()}; + + PackUnPackWBPData packUnpackWBPData {localWBPData, this->globalWBPData_, this->isIORank()}; + + PackUnPackAquiferData packUnpackAquiferData {localAquiferData, this->globalAquiferData_, this->isIORank()}; + + PackUnPackWellTestState packUnpackWellTestState {localWellTestState, this->globalWellTestState_, this->isIORank()}; + + PackUnpackInterRegFlows packUnpackInterRegFlows {localInterRegFlows, this->globalInterRegFlows_, this->isIORank()}; + + PackUnpackFlows packUnpackFlowsn {localFlowsn, this->globalFlowsn_, this->isIORank()}; + + PackUnpackFlows packUnpackFloresn {localFloresn, this->globalFloresn_, this->isIORank()}; toIORankComm_.exchange(packUnpackCellData); toIORankComm_.exchange(packUnpackWellData); @@ -1098,8 +1061,8 @@ collect(const data::Solution& localCellData, } template -int CollectDataOnIORank:: -localIdxToGlobalIdx(unsigned localIdx) const +int +CollectDataOnIORank::localIdxToGlobalIdx(unsigned localIdx) const { if (!isParallel()) { return localIdx; @@ -1117,21 +1080,18 @@ localIdxToGlobalIdx(unsigned localIdx) const } template -bool CollectDataOnIORank:: -isCartIdxOnThisRank(int cartIdx) const +bool +CollectDataOnIORank::isCartIdxOnThisRank(int cartIdx) const { - if (! this->isParallel()) { + if (!this->isParallel()) { return true; } - assert (! needsReordering); + assert(!needsReordering); - auto candidate = std::lower_bound(this->sortedCartesianIdx_.begin(), - this->sortedCartesianIdx_.end(), - cartIdx); + auto candidate = std::lower_bound(this->sortedCartesianIdx_.begin(), this->sortedCartesianIdx_.end(), cartIdx); - return (candidate != sortedCartesianIdx_.end()) - && (*candidate == cartIdx); + return (candidate != sortedCartesianIdx_.end()) && (*candidate == cartIdx); } } // end namespace Opm diff --git a/opm/simulators/flow/CompositionalContainer.cpp b/opm/simulators/flow/CompositionalContainer.cpp index 0a51ac903de..80639fd21e2 100644 --- a/opm/simulators/flow/CompositionalContainer.cpp +++ b/opm/simulators/flow/CompositionalContainer.cpp @@ -32,12 +32,12 @@ #include -namespace Opm { +namespace Opm +{ -template -void CompositionalContainer:: -allocate(const unsigned bufferSize, - std::map& rstKeywords) +template +void +CompositionalContainer::allocate(const unsigned bufferSize, std::map& rstKeywords) { if (auto& zmf = rstKeywords["ZMF"]; zmf > 0) { this->allocated_ = true; @@ -64,10 +64,9 @@ allocate(const unsigned bufferSize, } } -template -void CompositionalContainer:: -assignGasFractions(const unsigned globalDofIdx, - const AssignFunction& fractions) +template +void +CompositionalContainer::assignGasFractions(const unsigned globalDofIdx, const AssignFunction& fractions) { if (phaseMoleFractions_[gasPhaseIdx][0].empty()) { return; @@ -75,28 +74,25 @@ assignGasFractions(const unsigned globalDofIdx, std::for_each(phaseMoleFractions_[gasPhaseIdx].begin(), phaseMoleFractions_[gasPhaseIdx].end(), - [globalDofIdx, &fractions, c = 0](auto& comp) mutable - { comp[globalDofIdx] = fractions(c++); }); + [globalDofIdx, &fractions, c = 0](auto& comp) mutable { comp[globalDofIdx] = fractions(c++); }); } -template -void CompositionalContainer:: -assignMoleFractions(const unsigned globalDofIdx, - const AssignFunction& fractions) +template +void +CompositionalContainer::assignMoleFractions(const unsigned globalDofIdx, const AssignFunction& fractions) { if (moleFractions_.empty()) { return; } - std::for_each(moleFractions_.begin(), moleFractions_.end(), - [&fractions, globalDofIdx, c = 0](auto& comp) mutable - { comp[globalDofIdx] = fractions(c++); }); + std::for_each(moleFractions_.begin(), moleFractions_.end(), [&fractions, globalDofIdx, c = 0](auto& comp) mutable { + comp[globalDofIdx] = fractions(c++); + }); } -template -void CompositionalContainer:: -assignOilFractions(const unsigned globalDofIdx, - const AssignFunction& fractions) +template +void +CompositionalContainer::assignOilFractions(const unsigned globalDofIdx, const AssignFunction& fractions) { if (phaseMoleFractions_[oilPhaseIdx][0].empty()) { return; @@ -104,37 +100,30 @@ assignOilFractions(const unsigned globalDofIdx, std::for_each(phaseMoleFractions_[oilPhaseIdx].begin(), phaseMoleFractions_[oilPhaseIdx].end(), - [globalDofIdx, &fractions, c = 0](auto& comp) mutable - { comp[globalDofIdx] = fractions(c++); }); + [globalDofIdx, &fractions, c = 0](auto& comp) mutable { comp[globalDofIdx] = fractions(c++); }); } -template -void CompositionalContainer:: -outputRestart(data::Solution& sol, - ScalarBuffer& oil_saturation) +template +void +CompositionalContainer::outputRestart(data::Solution& sol, ScalarBuffer& oil_saturation) { - using DataEntry = - std::tuple&>; + using DataEntry = std::tuple&>; - auto doInsert = [&sol](DataEntry& entry, - const data::TargetType target) - { + auto doInsert = [&sol](DataEntry& entry, const data::TargetType target) { if (std::get<2>(entry).empty()) { return; } - sol.insert(std::get(entry), - std::get(entry), - std::move(std::get<2>(entry)), - target); + sol.insert( + std::get(entry), std::get(entry), std::move(std::get<2>(entry)), target); }; - auto entries = std::vector{}; + auto entries = std::vector {}; // ZMF if (!moleFractions_[0].empty()) { for (int i = 0; i < numComponents; ++i) { - const auto name = fmt::format("ZMF{}", i + 1); // Generate ZMF1, ZMF2, ... + const auto name = fmt::format("ZMF{}", i + 1); // Generate ZMF1, ZMF2, ... entries.emplace_back(name, UnitSystem::measure::identity, moleFractions_[i]); } } @@ -142,18 +131,16 @@ outputRestart(data::Solution& sol, // XMF if (!phaseMoleFractions_[oilPhaseIdx][0].empty()) { for (int i = 0; i < numComponents; ++i) { - const auto name = fmt::format("XMF{}", i + 1); // Generate XMF1, XMF2, ... - entries.emplace_back(name, UnitSystem::measure::identity, - phaseMoleFractions_[oilPhaseIdx][i]); + const auto name = fmt::format("XMF{}", i + 1); // Generate XMF1, XMF2, ... + entries.emplace_back(name, UnitSystem::measure::identity, phaseMoleFractions_[oilPhaseIdx][i]); } } // YMF if (!phaseMoleFractions_[gasPhaseIdx][0].empty()) { for (int i = 0; i < numComponents; ++i) { - const auto name = fmt::format("YMF{}", i + 1); // Generate YMF1, YMF2, ... - entries.emplace_back(name, UnitSystem::measure::identity, - phaseMoleFractions_[gasPhaseIdx][i]); + const auto name = fmt::format("YMF{}", i + 1); // Generate YMF1, YMF2, ... + entries.emplace_back(name, UnitSystem::measure::identity, phaseMoleFractions_[gasPhaseIdx][i]); } } @@ -161,26 +148,28 @@ outputRestart(data::Solution& sol, entries.emplace_back("SOIL", UnitSystem::measure::identity, oil_saturation); } - std::for_each(entries.begin(), entries.end(), - [&doInsert](auto& array) - { doInsert(array, data::TargetType::RESTART_SOLUTION); }); + std::for_each(entries.begin(), entries.end(), [&doInsert](auto& array) { + doInsert(array, data::TargetType::RESTART_SOLUTION); + }); this->allocated_ = false; } -#define INSTANTIATE_COMP_THREEPHASE(NUM) \ - template using FS##NUM = GenericOilGasWaterFluidSystem; \ +#define INSTANTIATE_COMP_THREEPHASE(NUM) \ + template \ + using FS##NUM = GenericOilGasWaterFluidSystem; \ template class CompositionalContainer>; -#define INSTANTIATE_COMP_TWOPHASE(NUM) \ - template using GFS##NUM = GenericOilGasWaterFluidSystem; \ +#define INSTANTIATE_COMP_TWOPHASE(NUM) \ + template \ + using GFS##NUM = GenericOilGasWaterFluidSystem; \ template class CompositionalContainer>; -#define INSTANTIATE_COMP(NUM) \ - INSTANTIATE_COMP_THREEPHASE(NUM) \ +#define INSTANTIATE_COMP(NUM) \ + INSTANTIATE_COMP_THREEPHASE(NUM) \ INSTANTIATE_COMP_TWOPHASE(NUM) -INSTANTIATE_COMP_THREEPHASE(0) // \Note: to register the parameter ForceDisableFluidInPlaceOutput +INSTANTIATE_COMP_THREEPHASE(0) // \Note: to register the parameter ForceDisableFluidInPlaceOutput INSTANTIATE_COMP(2) INSTANTIATE_COMP(3) INSTANTIATE_COMP(4) diff --git a/opm/simulators/flow/CompositionalContainer.hpp b/opm/simulators/flow/CompositionalContainer.hpp index 67a9ca4f98b..16be7daede1 100644 --- a/opm/simulators/flow/CompositionalContainer.hpp +++ b/opm/simulators/flow/CompositionalContainer.hpp @@ -32,11 +32,15 @@ #include #include -namespace Opm { +namespace Opm +{ -namespace data { class Solution; } +namespace data +{ + class Solution; +} -template +template class CompositionalContainer { using Scalar = typename FluidSystem::Scalar; @@ -50,25 +54,22 @@ class CompositionalContainer static constexpr int waterPhaseIdx = FluidSystem::waterPhaseIdx; public: - void allocate(const unsigned bufferSize, - std::map& rstKeywords); + void allocate(const unsigned bufferSize, std::map& rstKeywords); using AssignFunction = std::function; - void assignGasFractions(const unsigned globalDofIdx, - const AssignFunction& fractions); + void assignGasFractions(const unsigned globalDofIdx, const AssignFunction& fractions); - void assignMoleFractions(const unsigned globalDofIdx, - const AssignFunction& fractions); + void assignMoleFractions(const unsigned globalDofIdx, const AssignFunction& fractions); - void assignOilFractions(const unsigned globalDofIdx, - const AssignFunction& fractions); + void assignOilFractions(const unsigned globalDofIdx, const AssignFunction& fractions); - void outputRestart(data::Solution& sol, - ScalarBuffer& oil_saturation); + void outputRestart(data::Solution& sol, ScalarBuffer& oil_saturation); bool allocated() const - { return allocated_; } + { + return allocated_; + } private: bool allocated_ = false; diff --git a/opm/simulators/flow/ConvergenceOutputConfiguration.cpp b/opm/simulators/flow/ConvergenceOutputConfiguration.cpp index 245a96c3af2..6746cc039e8 100644 --- a/opm/simulators/flow/ConvergenceOutputConfiguration.cpp +++ b/opm/simulators/flow/ConvergenceOutputConfiguration.cpp @@ -23,8 +23,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -32,85 +32,78 @@ #include #include -namespace { - std::vector tokenizeOptionValues(std::string_view options) - { - const auto split = std::regex { R"(\s*,\s*)" }; - return { - std::cregex_token_iterator { - options.begin(), options.end(), split, -1 - }, - std::cregex_token_iterator {} - }; - } - - void reportUnsupportedOptionValuesAndThrow(std::vector unsupp, - std::string_view optionName) - { - std::sort(unsupp.begin(), unsupp.end()); - auto u = std::unique(unsupp.begin(), unsupp.end()); - - const auto pl = (std::distance(unsupp.begin(), u) != 1) ? "s" : ""; - - if (optionName.empty()) { - throw std::invalid_argument { - fmt::format("Unsupported convergence output " - "option value{}: {}\n" - "Supported values are \"none\", " - "\"steps\", and \"iterations\"", - pl, fmt::join(unsupp.begin(), u, ", ")) - }; - } +namespace +{ +std::vector +tokenizeOptionValues(std::string_view options) +{ + const auto split = std::regex {R"(\s*,\s*)"}; + return {std::cregex_token_iterator {options.begin(), options.end(), split, -1}, std::cregex_token_iterator {}}; +} - throw std::invalid_argument { - fmt::format("Option {}:\n - Unsupported value{}: {}\n" - " - Supported values are \"none\", " - "\"steps\", and \"iterations\"", - optionName, pl, - fmt::join(unsupp.begin(), u, ", ")) - }; +void +reportUnsupportedOptionValuesAndThrow(std::vector unsupp, std::string_view optionName) +{ + std::sort(unsupp.begin(), unsupp.end()); + auto u = std::unique(unsupp.begin(), unsupp.end()); + + const auto pl = (std::distance(unsupp.begin(), u) != 1) ? "s" : ""; + + if (optionName.empty()) { + throw std::invalid_argument {fmt::format("Unsupported convergence output " + "option value{}: {}\n" + "Supported values are \"none\", " + "\"steps\", and \"iterations\"", + pl, + fmt::join(unsupp.begin(), u, ", "))}; } - std::vector - getOptions(std::string_view options, std::string_view optionName) - { - using Option = Opm::ConvergenceOutputConfiguration::Option; - - auto opt = std::vector