Two- and three-phase compositional simulators.

Choice of simulator is based on if WATER is present in RUNSPEC.
This commit is contained in:
Svenn Tveit 2025-01-20 12:51:23 +01:00
parent fb403d05ae
commit 2f0443947d
15 changed files with 306 additions and 70 deletions

View File

@ -625,6 +625,7 @@ opm_add_test(flowexp_blackoil
set(FLOWEXP_COMPONENTS_SOURCES)
foreach(component IN LISTS OPM_COMPILE_COMPONENTS)
list(APPEND FLOWEXP_COMPONENTS_SOURCES flowexperimental/comp/flowexp_comp${component}.cpp)
list(APPEND FLOWEXP_COMPONENTS_SOURCES flowexperimental/comp/flowexp_comp${component}_2p.cpp)
endforeach()
opm_add_test(flowexp_comp

View File

@ -36,10 +36,13 @@
template <int compileTimeComponent>
std::tuple<bool, int>
runComponent(int runtimeComponent, int argc, char** argv)
runComponent(int runtimeComponent, bool water, int argc, char** argv)
{
if (runtimeComponent == compileTimeComponent) {
return std::make_tuple(true, Opm::dispatchFlowExpComp<compileTimeComponent>(argc, argv));
if (water)
return std::make_tuple(true, Opm::dispatchFlowExpComp<compileTimeComponent, true>(argc, argv));
else
return std::make_tuple(true, Opm::dispatchFlowExpComp<compileTimeComponent, false>(argc, argv));
}
return std::make_tuple(false, EXIT_FAILURE);
}
@ -63,18 +66,21 @@ runComponent(int runtimeComponent, int argc, char** argv)
*/
template <int currentCompileTimeComponent, int nextComponent, int... components>
std::tuple<bool, int>
runComponent(int runtimecomponent, int argc, char** argv)
runComponent(int runtimecomponent, bool water, int argc, char** argv)
{
if (currentCompileTimeComponent == runtimecomponent) {
return std::make_tuple(true, Opm::dispatchFlowExpComp<currentCompileTimeComponent>(argc, argv));
if (water)
return std::make_tuple(true, Opm::dispatchFlowExpComp<currentCompileTimeComponent, true>(argc, argv));
else
return std::make_tuple(true, Opm::dispatchFlowExpComp<currentCompileTimeComponent, false>(argc, argv));
}
return runComponent<nextComponent, components...>(runtimecomponent, argc, argv);
return runComponent<nextComponent, components...>(runtimecomponent, water, argc, argv);
}
int
main(int argc, char** argv)
{
using TypeTag = Opm::Properties::TTag::FlowExpCompProblem<0>;
using TypeTag = Opm::Properties::TTag::FlowExpCompProblem<0, true>;
Opm::registerEclTimeSteppingParameters<double>();
// At the moment, this is probably as optimal as can be.
@ -90,9 +96,11 @@ main(int argc, char** argv)
= Opm::Parser {}.parseFile(inputFilename, Opm::ParseContext {}, std::vector {Opm::Ecl::SectionType::RUNSPEC});
const auto runspec = Opm::Runspec(deck);
const auto numComps = runspec.numComps();
const auto& phases = runspec.phases();
const auto wat = phases.active(Opm::Phase::WATER);
auto [componentSupported, executionStatus]
= runComponent<OPM_COMPILE_COMPONENTS_TEMPLATE_LIST>(numComps, argc, argv);
= runComponent<OPM_COMPILE_COMPONENTS_TEMPLATE_LIST>(numComps, wat, argc, argv);
if (!componentSupported) {
fmt::print("Deck has {} components, not supported. In this build of the simulator, we support the "

View File

@ -39,7 +39,7 @@
// suggestTimeStep is taken from newton solver in problem.limitTimestep
namespace Opm {
template<int numComp>
template<int numComp, bool EnableWater>
int dispatchFlowExpComp(int argc, char** argv);
}
@ -47,15 +47,15 @@ int dispatchFlowExpComp(int argc, char** argv);
namespace Opm::Properties {
namespace TTag {
template<int NumComp>
template<int NumComp, bool EnableWater>
struct FlowExpCompProblem {
using InheritsFrom = std::tuple<FlowBaseProblemComp, FlashModel>;
};
}
template<class TypeTag, int NumComp>
struct SparseMatrixAdapter<TypeTag, TTag::FlowExpCompProblem<NumComp>>
template<class TypeTag, int NumComp, bool EnableWater>
struct SparseMatrixAdapter<TypeTag, TTag::FlowExpCompProblem<NumComp, EnableWater>>
{
private:
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
@ -109,30 +109,30 @@ struct LocalLinearizerSplice<TypeTag, TTag::FlowExpCompProblem>
#endif
// Set the problem property
template <class TypeTag, int NumComp>
struct Problem<TypeTag, TTag::FlowExpCompProblem<NumComp>>
template <class TypeTag, int NumComp, bool EnableWater>
struct Problem<TypeTag, TTag::FlowExpCompProblem<NumComp, EnableWater>>
{
using type = FlowProblemComp<TypeTag>;
};
template<class TypeTag, int NumComp>
struct AquiferModel<TypeTag, TTag::FlowExpCompProblem<NumComp>> {
template<class TypeTag, int NumComp, bool EnableWater>
struct AquiferModel<TypeTag, TTag::FlowExpCompProblem<NumComp, EnableWater>> {
using type = EmptyModel<TypeTag>;
};
template<class TypeTag, int NumComp>
struct WellModel<TypeTag, TTag::FlowExpCompProblem<NumComp>> {
template<class TypeTag, int NumComp, bool EnableWater>
struct WellModel<TypeTag, TTag::FlowExpCompProblem<NumComp, EnableWater>> {
using type = EmptyModel<TypeTag>;
};
template<class TypeTag, int NumComp>
struct TracerModel<TypeTag, TTag::FlowExpCompProblem<NumComp>> {
template<class TypeTag, int NumComp, bool EnableWater>
struct TracerModel<TypeTag, TTag::FlowExpCompProblem<NumComp, EnableWater>> {
using type = EmptyModel<TypeTag>;
};
template <class TypeTag, int NumComp>
struct FlashSolver<TypeTag, TTag::FlowExpCompProblem<NumComp>> {
template <class TypeTag, int NumComp, bool EnableWater>
struct FlashSolver<TypeTag, TTag::FlowExpCompProblem<NumComp, EnableWater>> {
private:
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
using FluidSystem = GetPropType<TypeTag, Properties::FluidSystem>;
@ -147,10 +147,18 @@ template <class TypeTag, class MyTypeTag>
struct NumComp { using type = UndefinedProperty; };
// TODO: this is unfortunate, have to check why we need to hard-code it
template <class TypeTag, int NumComp_>
struct NumComp<TypeTag, TTag::FlowExpCompProblem<NumComp_>> {
template <class TypeTag, int NumComp_, bool EnableWater_>
struct NumComp<TypeTag, TTag::FlowExpCompProblem<NumComp_, EnableWater_>> {
static constexpr int value = NumComp_;
};
template <class TypeTag, class MyTypeTag>
struct EnableDummyWater { using type = UndefinedProperty; };
template <class TypeTag, int NumComp_, bool EnableWater_>
struct EnableDummyWater<TypeTag, TTag::FlowExpCompProblem<NumComp_, EnableWater_>> {
static constexpr bool value = EnableWater_;
};
#if 0
struct Temperature { using type = UndefinedProperty; };
@ -161,26 +169,29 @@ struct Temperature { using type = UndefinedProperty; };
};
#endif
template <class TypeTag, int NumComp_>
struct FluidSystem<TypeTag, TTag::FlowExpCompProblem<NumComp_>>
template <class TypeTag, int NumComp_, bool EnableWater_>
struct FluidSystem<TypeTag, TTag::FlowExpCompProblem<NumComp_, EnableWater_>>
{
private:
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
static constexpr int num_comp = getPropValue<TypeTag, Properties::NumComp>();
static constexpr bool enable_water = getPropValue<TypeTag, Properties::EnableDummyWater>();
public:
using type = Opm::GenericOilGasWaterFluidSystem<Scalar, num_comp>;
using type = Opm::GenericOilGasWaterFluidSystem<Scalar, num_comp, enable_water>;
};
template<class TypeTag, int NumComp>
struct EnableMech<TypeTag, TTag::FlowExpCompProblem<NumComp>> {
template<class TypeTag, int NumComp, bool EnableWater>
struct EnableMech<TypeTag, TTag::FlowExpCompProblem<NumComp, EnableWater>> {
static constexpr bool value = false;
};
template<class TypeTag, int NumComp>
struct EnableDisgasInWater<TypeTag, TTag::FlowExpCompProblem<NumComp>> { static constexpr bool value = false; };
template<class TypeTag, int NumComp, bool EnableWater>
struct EnableDisgasInWater<TypeTag, TTag::FlowExpCompProblem<NumComp, EnableWater>> {
static constexpr bool value = false;
};
template<class TypeTag, int NumComp>
struct Stencil<TypeTag, TTag::FlowExpCompProblem<NumComp>>
template<class TypeTag, int NumComp, bool EnableWater>
struct Stencil<TypeTag, TTag::FlowExpCompProblem<NumComp, EnableWater>>
{
private:
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
@ -190,62 +201,62 @@ public:
using type = EcfvStencil<Scalar, GridView>;
};
template<class TypeTag, int NumComp>
struct EnableApiTracking<TypeTag, TTag::FlowExpCompProblem<NumComp>> {
template<class TypeTag, int NumComp, bool EnableWater>
struct EnableApiTracking<TypeTag, TTag::FlowExpCompProblem<NumComp, EnableWater>> {
static constexpr bool value = false;
};
template<class TypeTag, int NumComp>
struct EnableTemperature<TypeTag, TTag::FlowExpCompProblem<NumComp>> {
template<class TypeTag, int NumComp, bool EnableWater>
struct EnableTemperature<TypeTag, TTag::FlowExpCompProblem<NumComp, EnableWater>> {
static constexpr bool value = false;
};
template<class TypeTag, int NumComp>
struct EnableSaltPrecipitation<TypeTag, TTag::FlowExpCompProblem<NumComp>> {
template<class TypeTag, int NumComp, bool EnableWater>
struct EnableSaltPrecipitation<TypeTag, TTag::FlowExpCompProblem<NumComp, EnableWater>> {
static constexpr bool value = false;
};
template<class TypeTag, int NumComp>
struct EnablePolymerMW<TypeTag, TTag::FlowExpCompProblem<NumComp>> {
template<class TypeTag, int NumComp, bool EnableWater>
struct EnablePolymerMW<TypeTag, TTag::FlowExpCompProblem<NumComp, EnableWater>> {
static constexpr bool value = false;
};
template<class TypeTag, int NumComp>
struct EnablePolymer<TypeTag, TTag::FlowExpCompProblem<NumComp>> {
template<class TypeTag, int NumComp, bool EnableWater>
struct EnablePolymer<TypeTag, TTag::FlowExpCompProblem<NumComp, EnableWater>> {
static constexpr bool value = false;
};
template<class TypeTag, int NumComp>
struct EnableDispersion<TypeTag, TTag::FlowExpCompProblem<NumComp>> {
template<class TypeTag, int NumComp, bool EnableWater>
struct EnableDispersion<TypeTag, TTag::FlowExpCompProblem<NumComp, EnableWater>> {
static constexpr bool value = false;
};
template<class TypeTag, int NumComp>
struct EnableBrine<TypeTag, TTag::FlowExpCompProblem<NumComp>> {
template<class TypeTag, int NumComp, bool EnableWater>
struct EnableBrine<TypeTag, TTag::FlowExpCompProblem<NumComp, EnableWater>> {
static constexpr bool value = false;
};
template<class TypeTag, int NumComp>
struct EnableVapwat<TypeTag, TTag::FlowExpCompProblem<NumComp>> {
template<class TypeTag, int NumComp, bool EnableWater>
struct EnableVapwat<TypeTag, TTag::FlowExpCompProblem<NumComp, EnableWater>> {
static constexpr bool value = false;
};
template<class TypeTag, int NumComp>
struct EnableSolvent<TypeTag, TTag::FlowExpCompProblem<NumComp>> {
template<class TypeTag, int NumComp, bool EnableWater>
struct EnableSolvent<TypeTag, TTag::FlowExpCompProblem<NumComp, EnableWater>> {
static constexpr bool value = false;
};
template<class TypeTag, int NumComp>
struct EnableEnergy<TypeTag, TTag::FlowExpCompProblem<NumComp>> {
template<class TypeTag, int NumComp, bool EnableWater>
struct EnableEnergy<TypeTag, TTag::FlowExpCompProblem<NumComp, EnableWater>> {
static constexpr bool value = false;
};
template<class TypeTag, int NumComp>
struct EnableFoam<TypeTag, TTag::FlowExpCompProblem<NumComp>> {
template<class TypeTag, int NumComp, bool EnableWater>
struct EnableFoam<TypeTag, TTag::FlowExpCompProblem<NumComp, EnableWater>> {
static constexpr bool value = false;
};
template<class TypeTag, int NumComp>
struct EnableExtbo<TypeTag, TTag::FlowExpCompProblem<NumComp>> {
template<class TypeTag, int NumComp, bool EnableWater>
struct EnableExtbo<TypeTag, TTag::FlowExpCompProblem<NumComp, EnableWater>> {
static constexpr bool value = false;
};
template<class TypeTag, int NumComp>
struct EnableMICP<TypeTag, TTag::FlowExpCompProblem<NumComp>> {
template<class TypeTag, int NumComp, bool EnableWater>
struct EnableMICP<TypeTag, TTag::FlowExpCompProblem<NumComp, EnableWater>> {
static constexpr bool value = false;
};

View File

@ -28,9 +28,9 @@
namespace Opm {
template<>
int dispatchFlowExpComp<2>(int argc, char** argv)
int dispatchFlowExpComp<2, true>(int argc, char** argv)
{
return start<Properties::TTag::FlowExpCompProblem<2>>(argc, argv, false);
return start<Properties::TTag::FlowExpCompProblem<2, true>>(argc, argv, false);
}
}

View File

@ -0,0 +1,36 @@
/*
Copyright 2024, SINTEF Digital
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <opm/models/utils/start.hh>
#include <opm/simulators/flow/FlowGenericProblem_impl.hpp>
#include "flowexp_comp.hpp"
namespace Opm {
template<>
int dispatchFlowExpComp<2, false>(int argc, char** argv)
{
return start<Properties::TTag::FlowExpCompProblem<2, false>>(argc, argv, false);
}
}

View File

@ -28,9 +28,9 @@
namespace Opm {
template<>
int dispatchFlowExpComp<3>(int argc, char** argv)
int dispatchFlowExpComp<3, true>(int argc, char** argv)
{
return start<Properties::TTag::FlowExpCompProblem<3>>(argc, argv, false);
return start<Properties::TTag::FlowExpCompProblem<3, true>>(argc, argv, false);
}
}

View File

@ -0,0 +1,36 @@
/*
Copyright 2024, SINTEF Digital
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <opm/models/utils/start.hh>
#include <opm/simulators/flow/FlowGenericProblem_impl.hpp>
#include "flowexp_comp.hpp"
namespace Opm {
template<>
int dispatchFlowExpComp<3, false>(int argc, char** argv)
{
return start<Properties::TTag::FlowExpCompProblem<3, false>>(argc, argv, false);
}
}

View File

@ -28,9 +28,9 @@
namespace Opm {
template<>
int dispatchFlowExpComp<4>(int argc, char** argv)
int dispatchFlowExpComp<4, true>(int argc, char** argv)
{
return start<Properties::TTag::FlowExpCompProblem<4>>(argc, argv, false);
return start<Properties::TTag::FlowExpCompProblem<4, true>>(argc, argv, false);
}
}

View File

@ -0,0 +1,36 @@
/*
Copyright 2024, SINTEF Digital
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <opm/models/utils/start.hh>
#include <opm/simulators/flow/FlowGenericProblem_impl.hpp>
#include "flowexp_comp.hpp"
namespace Opm {
template<>
int dispatchFlowExpComp<4, false>(int argc, char** argv)
{
return start<Properties::TTag::FlowExpCompProblem<4, false>>(argc, argv, false);
}
}

View File

@ -28,9 +28,9 @@
namespace Opm {
template<>
int dispatchFlowExpComp<5>(int argc, char** argv)
int dispatchFlowExpComp<5, true>(int argc, char** argv)
{
return start<Properties::TTag::FlowExpCompProblem<5>>(argc, argv, false);
return start<Properties::TTag::FlowExpCompProblem<5, true>>(argc, argv, false);
}
}

View File

@ -0,0 +1,36 @@
/*
Copyright 2024, SINTEF Digital
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <opm/models/utils/start.hh>
#include <opm/simulators/flow/FlowGenericProblem_impl.hpp>
#include "flowexp_comp.hpp"
namespace Opm {
template<>
int dispatchFlowExpComp<5, false>(int argc, char** argv)
{
return start<Properties::TTag::FlowExpCompProblem<5, false>>(argc, argv, false);
}
}

View File

@ -28,9 +28,9 @@
namespace Opm {
template<>
int dispatchFlowExpComp<6>(int argc, char** argv)
int dispatchFlowExpComp<6, true>(int argc, char** argv)
{
return start<Properties::TTag::FlowExpCompProblem<6>>(argc, argv, false);
return start<Properties::TTag::FlowExpCompProblem<6, true>>(argc, argv, false);
}
}

View File

@ -0,0 +1,36 @@
/*
Copyright 2024, SINTEF Digital
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <opm/models/utils/start.hh>
#include <opm/simulators/flow/FlowGenericProblem_impl.hpp>
#include "flowexp_comp.hpp"
namespace Opm {
template<>
int dispatchFlowExpComp<6, false>(int argc, char** argv)
{
return start<Properties::TTag::FlowExpCompProblem<6, false>>(argc, argv, false);
}
}

View File

@ -28,9 +28,9 @@
namespace Opm {
template<>
int dispatchFlowExpComp<7>(int argc, char** argv)
int dispatchFlowExpComp<7, true>(int argc, char** argv)
{
return start<Properties::TTag::FlowExpCompProblem<7>>(argc, argv, false);
return start<Properties::TTag::FlowExpCompProblem<7, true>>(argc, argv, false);
}
}

View File

@ -0,0 +1,36 @@
/*
Copyright 2024, SINTEF Digital
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <opm/models/utils/start.hh>
#include <opm/simulators/flow/FlowGenericProblem_impl.hpp>
#include "flowexp_comp.hpp"
namespace Opm {
template<>
int dispatchFlowExpComp<7, false>(int argc, char** argv)
{
return start<Properties::TTag::FlowExpCompProblem<7, false>>(argc, argv, false);
}
}