move EnableIntensiveQuantityCache to TypeTag-free parameter system

This commit is contained in:
Arne Morten Kvarving 2024-07-05 17:49:51 +02:00
parent af30ebf0f7
commit 5b7fd50d1e
6 changed files with 27 additions and 53 deletions

View File

@ -143,11 +143,6 @@ template<class TypeTag>
struct EnableGravity<TypeTag, Properties::TTag::LensBaseProblem>
{ static constexpr bool value = true; };
// enable the cache for intensive quantities by default for this problem
template<class TypeTag>
struct EnableIntensiveQuantityCache<TypeTag, Properties::TTag::LensBaseProblem>
{ static constexpr bool value = true; };
// enable the storage cache by default for this problem
template<class TypeTag>
struct EnableStorageCache<TypeTag, Properties::TTag::LensBaseProblem>
@ -364,6 +359,7 @@ public:
}
Parameters::SetDefault<Parameters::EndTime<Scalar>>(30e3);
Parameters::SetDefault<Parameters::EnableIntensiveQuantityCache>(true);
Parameters::SetDefault<Parameters::InitialTimeStepSize<Scalar>>(250.0);
}

View File

@ -95,19 +95,6 @@ struct UseTwoPointGradients<TypeTag, TTag::DiscreteFractureModel> { static const
} // namespace Opm::Properties
namespace Opm::Parameters {
// The intensive quantity cache cannot be used by the discrete fracture model, because
// the intensive quantities of a control degree of freedom are not identical to the
// intensive quantities of the other intensive quantities of the same of the same degree
// of freedom. This is because the fracture properties (volume, permeability, etc) are
// specific for each...
template<class TypeTag>
struct EnableIntensiveQuantityCache<TypeTag, Properties::TTag::DiscreteFractureModel>
{ static constexpr bool value = false; };
} // namespace Opm::Parameters
namespace Opm {
/*!
@ -137,7 +124,7 @@ public:
DiscreteFractureModel(Simulator& simulator)
: ParentType(simulator)
{
if (Parameters::get<TypeTag, Parameters::EnableIntensiveQuantityCache>()) {
if (Parameters::Get<Parameters::EnableIntensiveQuantityCache>()) {
throw std::runtime_error("The discrete fracture model does not work in conjunction "
"with intensive quantities caching");
}
@ -152,6 +139,13 @@ public:
// register runtime parameters of the VTK output modules
Opm::VtkDiscreteFractureModule<TypeTag>::registerParameters();
// The intensive quantity cache cannot be used by the discrete fracture model, because
// the intensive quantities of a control degree of freedom are not identical to the
// intensive quantities of the other intensive quantities of the same of the same degree
// of freedom. This is because the fracture properties (volume, permeability, etc) are
// specific for each...
Parameters::SetDefault<Parameters::EnableIntensiveQuantityCache>(false);
}
/*!

View File

@ -284,14 +284,6 @@ struct DiscreteFunction<TypeTag, TTag::FvBaseDiscretization>
namespace Opm::Parameters {
//! by default, disable the intensive quantity cache. If the intensive quantities are
//! relatively cheap to calculate, the cache basically does not yield any performance
//! impact because of the intensive quantity cache will cause additional pressure on the
//! CPU caches...
template<class TypeTag>
struct EnableIntensiveQuantityCache<TypeTag, Properties::TTag::FvBaseDiscretization>
{ static constexpr bool value = false; };
// disable caching the storage term by default
template<class TypeTag>
struct EnableStorageCache<TypeTag, Properties::TTag::FvBaseDiscretization>
@ -441,7 +433,7 @@ public:
, localLinearizer_(ThreadManager::maxThreads())
, linearizer_(new Linearizer())
, enableGridAdaptation_(Parameters::Get<Parameters::EnableGridAdaptation>() )
, enableIntensiveQuantityCache_(Parameters::get<TypeTag, Parameters::EnableIntensiveQuantityCache>())
, enableIntensiveQuantityCache_(Parameters::Get<Parameters::EnableIntensiveQuantityCache>())
, enableStorageCache_(Parameters::get<TypeTag, Parameters::EnableStorageCache>())
, enableThermodynamicHints_(Parameters::get<TypeTag, Parameters::EnableThermodynamicHints>())
{
@ -503,7 +495,7 @@ public:
("Global switch for turning on writing VTK files");
Parameters::registerParam<TypeTag, Parameters::EnableThermodynamicHints>
("Enable thermodynamic hints");
Parameters::registerParam<TypeTag, Parameters::EnableIntensiveQuantityCache>
Parameters::Register<Parameters::EnableIntensiveQuantityCache>
("Turn on caching of intensive quantities");
Parameters::registerParam<TypeTag, Parameters::EnableStorageCache>
("Store previous storage terms and avoid re-calculating them.");

View File

@ -62,6 +62,17 @@ struct EnableAsyncVtkOutput { static constexpr bool value = true; };
*/
struct EnableGridAdaptation { static constexpr bool value = false; };
/*!
* \brief Specify whether all intensive quantities for the grid should be
* cached in the discretization.
*
* This potentially reduces the CPU time, but comes at the cost of
* higher memory consumption. In turn, the higher memory requirements
* may cause the simulation to exhibit worse cache coherence behavior
* which eats some of the computational benefits again.
*/
struct EnableIntensiveQuantityCache { static constexpr bool value = false; };
/*!
* \brief Global switch to enable or disable the writing of VTK output files
*
@ -100,18 +111,6 @@ struct OutputDir { static constexpr auto value = ""; };
//! \brief Number of threads per process.
struct ThreadsPerProcess { static constexpr int value = 1; };
/*!
* \brief Specify whether all intensive quantities for the grid should be
* cached in the discretization.
*
* This potentially reduces the CPU time, but comes at the cost of
* higher memory consumption. In turn, the higher memory requirements
* may cause the simulation to exhibit worse cache coherence behavior
* which eats some of the computational benefits again.
*/
template<class TypeTag, class MyTypeTag>
struct EnableIntensiveQuantityCache { using type = Properties::UndefinedProperty; };
/*!
* \brief Specify whether the storage terms for previous solutions should be cached.
*

View File

@ -120,12 +120,6 @@ struct EnableEnergy<TypeTag, TTag::FlashModel> { static constexpr bool value = f
namespace Opm::Parameters {
// The updates of intensive quantities tend to be _very_ expensive for this
// model, so let's try to minimize the number of required ones
template<class TypeTag>
struct EnableIntensiveQuantityCache<TypeTag, Properties::TTag::FlashModel>
{ static constexpr bool value = true; };
// since thermodynamic hints are basically free if the cache for intensive quantities is
// enabled, and this model usually shows quite a performance improvment if they are
// enabled, let's enable them by default.
@ -239,6 +233,10 @@ public:
Parameters::Register<Parameters::FlashTolerance<Scalar>>
("The maximum tolerance for the flash solver to "
"consider the solution converged");
// The updates of intensive quantities tend to be _very_ expensive for this
// model, so let's try to minimize the number of required ones
Parameters::SetDefault<Parameters::EnableIntensiveQuantityCache>(true);
}
/*!

View File

@ -143,12 +143,6 @@ struct EnableEnergy<TypeTag, TTag::FlashModel>
namespace Opm::Parameters {
// The updates of intensive quantities tend to be _very_ expensive for this
// model, so let's try to minimize the number of required ones
template<class TypeTag>
struct EnableIntensiveQuantityCache<TypeTag, Properties::TTag::FlashModel>
{ static constexpr bool value = true; };
// since thermodynamic hints are basically free if the cache for intensive quantities is
// enabled, and this model usually shows quite a performance improvment if they are
// enabled, let's enable them by default.
@ -253,6 +247,7 @@ public:
"ssi, newton, ssi+newton");
Parameters::SetDefault<Parameters::FlashTolerance<Scalar>>(1e-12);
Parameters::SetDefault<Parameters::EnableIntensiveQuantityCache>(true);
}
/*!