mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
move NumericDifferenceMethod to TypeTag-free parameter system
This commit is contained in:
parent
7da433b6dd
commit
00121f10a4
@ -164,11 +164,6 @@ template<class TypeTag>
|
||||
struct NewtonWriteConvergence<TypeTag, Properties::TTag::FingerBaseProblem>
|
||||
{ static constexpr bool value = false; };
|
||||
|
||||
// Use forward differences instead of central differences
|
||||
template<class TypeTag>
|
||||
struct NumericDifferenceMethod<TypeTag, Properties::TTag::FingerBaseProblem>
|
||||
{ static constexpr int value = +1; };
|
||||
|
||||
} // namespace Opm::Parameters
|
||||
|
||||
namespace Opm {
|
||||
@ -298,6 +293,9 @@ public:
|
||||
Parameters::SetDefault<Parameters::CellsZ>(1);
|
||||
Parameters::SetDefault<Parameters::DomainSizeZ<Scalar>>(0.1);
|
||||
}
|
||||
|
||||
// Use forward differences
|
||||
Parameters::SetDefault<Parameters::NumericDifferenceMethod>(+1);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -118,11 +118,6 @@ template<class TypeTag>
|
||||
struct NewtonWriteConvergence<TypeTag, Properties::TTag::InfiltrationBaseProblem>
|
||||
{ static constexpr bool value = false; };
|
||||
|
||||
// -1 backward differences, 0: central differences, +1: forward differences
|
||||
template<class TypeTag>
|
||||
struct NumericDifferenceMethod<TypeTag, Properties::TTag::InfiltrationBaseProblem>
|
||||
{ static constexpr int value = 1; };
|
||||
|
||||
} // namespace Opm::Parameters
|
||||
|
||||
namespace Opm {
|
||||
@ -247,6 +242,7 @@ public:
|
||||
ParentType::registerParameters();
|
||||
|
||||
Parameters::SetDefault<Parameters::GridFile>("./data/infiltration_50x3.dgf");
|
||||
Parameters::SetDefault<Parameters::NumericDifferenceMethod>(1);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -371,6 +371,13 @@ public:
|
||||
Parameters::SetDefault<Parameters::CellsZ>(16);
|
||||
Parameters::SetDefault<Parameters::DomainSizeZ<Scalar>>(1.0);
|
||||
}
|
||||
|
||||
// Use forward differences
|
||||
using LLS = GetPropType<TypeTag, Properties::LocalLinearizerSplice>;
|
||||
constexpr bool useFD = std::is_same_v<LLS, Properties::TTag::FiniteDifferenceLocalLinearizer>;
|
||||
if constexpr (useFD) {
|
||||
Parameters::SetDefault<Parameters::NumericDifferenceMethod>(+1);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -379,20 +386,21 @@ public:
|
||||
static std::string briefDescription()
|
||||
{
|
||||
std::string thermal = "isothermal";
|
||||
bool enableEnergy = getPropValue<TypeTag, Properties::EnableEnergy>();
|
||||
if (enableEnergy)
|
||||
constexpr bool enableEnergy = getPropValue<TypeTag, Properties::EnableEnergy>();
|
||||
if constexpr (enableEnergy)
|
||||
thermal = "non-isothermal";
|
||||
|
||||
std::string deriv = "finite difference";
|
||||
using LLS = GetPropType<TypeTag, Properties::LocalLinearizerSplice>;
|
||||
bool useAutoDiff = std::is_same<LLS, Properties::TTag::AutoDiffLocalLinearizer>::value;
|
||||
if (useAutoDiff)
|
||||
constexpr bool useAutoDiff = std::is_same_v<LLS, Properties::TTag::AutoDiffLocalLinearizer>;
|
||||
if constexpr (useAutoDiff) {
|
||||
deriv = "automatic differentiation";
|
||||
}
|
||||
|
||||
std::string disc = "vertex centered finite volume";
|
||||
using D = GetPropType<TypeTag, Properties::Discretization>;
|
||||
bool useEcfv = std::is_same<D, Opm::EcfvDiscretization<TypeTag>>::value;
|
||||
if (useEcfv)
|
||||
constexpr bool useEcfv = std::is_same<D, Opm::EcfvDiscretization<TypeTag>>::value;
|
||||
if constexpr (useEcfv)
|
||||
disc = "element centered finite volume";
|
||||
|
||||
return std::string("")+
|
||||
@ -467,10 +475,10 @@ public:
|
||||
{
|
||||
using LLS = GetPropType<TypeTag, Properties::LocalLinearizerSplice>;
|
||||
|
||||
bool useAutoDiff = std::is_same<LLS, Properties::TTag::AutoDiffLocalLinearizer>::value;
|
||||
constexpr bool useAutoDiff = std::is_same_v<LLS, Properties::TTag::AutoDiffLocalLinearizer>;
|
||||
|
||||
using FM = GetPropType<TypeTag, Properties::FluxModule>;
|
||||
bool useTrans = std::is_same<FM, Opm::TransFluxModule<TypeTag>>::value;
|
||||
constexpr bool useTrans = std::is_same_v<FM, Opm::TransFluxModule<TypeTag>>;
|
||||
|
||||
std::ostringstream oss;
|
||||
oss << "lens_" << Model::name()
|
||||
|
@ -139,11 +139,6 @@ template<class TypeTag>
|
||||
struct NewtonMaxIterations<TypeTag, Properties::TTag::RichardsLensProblem>
|
||||
{ static constexpr int value = 28; };
|
||||
|
||||
// Use central differences to approximate the Jacobian matrix
|
||||
template<class TypeTag>
|
||||
struct NumericDifferenceMethod<TypeTag, Properties::TTag::RichardsLensProblem>
|
||||
{ static constexpr int value = 0; };
|
||||
|
||||
} // namespace Opm::Parameters
|
||||
|
||||
namespace Opm {
|
||||
@ -270,6 +265,13 @@ public:
|
||||
ParentType::registerParameters();
|
||||
|
||||
Parameters::SetDefault<Parameters::GridFile>("./data/richardslens_24x16.dgf");
|
||||
|
||||
// Use central differences to approximate the Jacobian matrix
|
||||
using LLS = GetPropType<TypeTag, Properties::LocalLinearizerSplice>;
|
||||
constexpr bool useFD = std::is_same_v<LLS, Properties::TTag::FiniteDifferenceLocalLinearizer>;
|
||||
if constexpr (useFD) {
|
||||
Parameters::SetDefault<Parameters::NumericDifferenceMethod>(0);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -28,25 +28,28 @@
|
||||
#ifndef EWOMS_WATER_AIR_PROBLEM_HH
|
||||
#define EWOMS_WATER_AIR_PROBLEM_HH
|
||||
|
||||
#include <opm/models/pvs/pvsproperties.hh>
|
||||
#include <opm/simulators/linalg/parallelistlbackend.hh>
|
||||
|
||||
#include <opm/material/fluidsystems/H2OAirFluidSystem.hpp>
|
||||
#include <opm/material/fluidstates/ImmiscibleFluidState.hpp>
|
||||
#include <opm/material/fluidstates/CompositionalFluidState.hpp>
|
||||
#include <opm/material/fluidmatrixinteractions/LinearMaterial.hpp>
|
||||
#include <opm/material/fluidmatrixinteractions/RegularizedBrooksCorey.hpp>
|
||||
#include <opm/material/fluidmatrixinteractions/EffToAbsLaw.hpp>
|
||||
#include <opm/material/fluidmatrixinteractions/MaterialTraits.hpp>
|
||||
#include <opm/material/thermal/ConstantSolidHeatCapLaw.hpp>
|
||||
#include <opm/material/thermal/SomertonThermalConductionLaw.hpp>
|
||||
#include <opm/material/constraintsolvers/ComputeFromReferencePhase.hpp>
|
||||
#include <dune/common/fmatrix.hh>
|
||||
#include <dune/common/fvector.hh>
|
||||
|
||||
#include <dune/grid/yaspgrid.hh>
|
||||
#include <dune/grid/io/file/dgfparser/dgfyasp.hh>
|
||||
|
||||
#include <dune/common/fvector.hh>
|
||||
#include <dune/common/fmatrix.hh>
|
||||
#include <opm/material/constraintsolvers/ComputeFromReferencePhase.hpp>
|
||||
#include <opm/material/fluidmatrixinteractions/LinearMaterial.hpp>
|
||||
#include <opm/material/fluidmatrixinteractions/RegularizedBrooksCorey.hpp>
|
||||
#include <opm/material/fluidmatrixinteractions/EffToAbsLaw.hpp>
|
||||
#include <opm/material/fluidmatrixinteractions/MaterialTraits.hpp>
|
||||
#include <opm/material/fluidstates/ImmiscibleFluidState.hpp>
|
||||
#include <opm/material/fluidstates/CompositionalFluidState.hpp>
|
||||
#include <opm/material/fluidsystems/H2OAirFluidSystem.hpp>
|
||||
#include <opm/material/thermal/ConstantSolidHeatCapLaw.hpp>
|
||||
#include <opm/material/thermal/SomertonThermalConductionLaw.hpp>
|
||||
|
||||
#include <opm/models/discretization/common/fvbasefdlocallinearizer.hh>
|
||||
|
||||
#include <opm/models/pvs/pvsproperties.hh>
|
||||
|
||||
#include <opm/simulators/linalg/parallelistlbackend.hh>
|
||||
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
@ -310,6 +313,9 @@ public:
|
||||
ParentType::registerParameters();
|
||||
|
||||
Parameters::SetDefault<Parameters::GridFile>("./data/waterair.dgf");
|
||||
|
||||
// Use forward differences
|
||||
Parameters::SetDefault<Parameters::NumericDifferenceMethod>(+1);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -82,9 +82,6 @@ struct BaseEpsilon<TypeTag, TTag::FiniteDifferenceLocalLinearizer>
|
||||
|
||||
namespace Opm::Parameters {
|
||||
|
||||
template<class TypeTag, class MyTypeTag>
|
||||
struct NumericDifferenceMethod { using type = Properties::UndefinedProperty; };
|
||||
|
||||
/*!
|
||||
* \brief Specify which kind of method should be used to numerically
|
||||
* calculate the partial derivatives of the residual.
|
||||
@ -92,9 +89,7 @@ struct NumericDifferenceMethod { using type = Properties::UndefinedProperty; };
|
||||
* -1 means backward differences, 0 means central differences, 1 means
|
||||
* forward differences. By default we use forward differences.
|
||||
*/
|
||||
template<class TypeTag>
|
||||
struct NumericDifferenceMethod<TypeTag, Properties::TTag::FiniteDifferenceLocalLinearizer>
|
||||
{ static constexpr int value = +1; };
|
||||
struct NumericDifferenceMethod { static constexpr int value = +1; };
|
||||
|
||||
} // namespace Opm::Parameters
|
||||
|
||||
@ -188,7 +183,7 @@ public:
|
||||
*/
|
||||
static void registerParameters()
|
||||
{
|
||||
Parameters::registerParam<TypeTag, Parameters::NumericDifferenceMethod>
|
||||
Parameters::Register<Parameters::NumericDifferenceMethod>
|
||||
("The method used for numeric differentiation (-1: backward "
|
||||
"differences, 0: central differences, 1: forward differences)");
|
||||
}
|
||||
@ -342,7 +337,7 @@ protected:
|
||||
*/
|
||||
static int numericDifferenceMethod_()
|
||||
{
|
||||
static int diff = Parameters::get<TypeTag, Parameters::NumericDifferenceMethod>();
|
||||
static int diff = Parameters::Get<Parameters::NumericDifferenceMethod>();
|
||||
return diff;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user