make the heat conduction laws usable with the local-AD framework
This commit is contained in:
parent
662531fee8
commit
520ce9ddf1
@ -49,7 +49,7 @@ public:
|
||||
*
|
||||
* If this method is called an exception is thrown at run time.
|
||||
*/
|
||||
template <class FluidState>
|
||||
template <class FluidState, class Evaluation = Scalar>
|
||||
static Scalar heatConductivity(const Params ¶ms,
|
||||
const FluidState &fluidState)
|
||||
{
|
||||
|
@ -29,8 +29,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace Opm
|
||||
{
|
||||
namespace Opm {
|
||||
/*!
|
||||
* \ingroup material
|
||||
*
|
||||
@ -50,13 +49,15 @@ public:
|
||||
* \brief Given a fluid state, return the effective heat conductivity [W/m^2 / (K/m)] of the porous
|
||||
* medium.
|
||||
*/
|
||||
template <class FluidState>
|
||||
static Scalar heatConductivity(const Params ¶ms,
|
||||
const FluidState &fluidState)
|
||||
template <class FluidState, class Evaluation = typename FluidState::Scalar>
|
||||
static Evaluation heatConductivity(const Params ¶ms,
|
||||
const FluidState &fluidState)
|
||||
{
|
||||
typename FluidSystem::ParameterCache paramCache;
|
||||
paramCache.updatePhase(fluidState, phaseIdx);
|
||||
return FluidSystem::thermalConductivity(fluidState, paramCache, phaseIdx);
|
||||
return FluidSystem::template thermalConductivity<FluidState, Evaluation>(fluidState,
|
||||
paramCache,
|
||||
phaseIdx);
|
||||
}
|
||||
};
|
||||
} // namespace Opm
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include <opm/material/common/Spline.hpp>
|
||||
|
||||
#include <opm/material/common/Valgrind.hpp>
|
||||
#include <opm/material/common/MathToolbox.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
@ -81,19 +82,22 @@ public:
|
||||
* phase \f$\alpha\f$ and \f$S_\alpha\f$ is the saturation of
|
||||
* phase \f$\alpha\f$.
|
||||
*/
|
||||
template <class FluidState>
|
||||
static Scalar heatConductivity(const Params ¶ms,
|
||||
const FluidState &fluidState)
|
||||
template <class FluidState, class Evaluation = Scalar>
|
||||
static Evaluation heatConductivity(const Params ¶ms,
|
||||
const FluidState &fluidState)
|
||||
{
|
||||
typedef Opm::MathToolbox<Evaluation> Toolbox;
|
||||
|
||||
Valgrind::CheckDefined(params.vacuumLambda());
|
||||
|
||||
Scalar lambda = 0;
|
||||
Evaluation lambda = 0;
|
||||
for (int phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
|
||||
Valgrind::CheckDefined(params.fullySaturatedLambda(phaseIdx));
|
||||
|
||||
if (FluidSystem::isLiquid(phaseIdx)) {
|
||||
const auto& sat = Toolbox::template toLhs<Evaluation>(fluidState.saturation(phaseIdx));
|
||||
lambda +=
|
||||
regularizedSqrt_(std::max(0.0, std::min(1.0, fluidState.saturation(phaseIdx))))
|
||||
regularizedSqrt_(Toolbox::max(0.0, Toolbox::min(1.0, sat)))
|
||||
* (params.fullySaturatedLambda(phaseIdx) - params.vacuumLambda());
|
||||
}
|
||||
else { // gas phase
|
||||
@ -107,8 +111,11 @@ public:
|
||||
}
|
||||
|
||||
protected:
|
||||
static Scalar regularizedSqrt_(Scalar x)
|
||||
template <class Evaluation>
|
||||
static Evaluation regularizedSqrt_(const Evaluation& x)
|
||||
{
|
||||
typedef Opm::MathToolbox<Evaluation> Toolbox;
|
||||
|
||||
static const Scalar xMin = 1e-2;
|
||||
static const Scalar sqrtXMin = std::sqrt(xMin);
|
||||
static const Scalar fPrimeXMin = 1.0/(2*std::sqrt(xMin));
|
||||
@ -119,7 +126,7 @@ protected:
|
||||
fPrime0, fPrimeXMin); // m0, m1
|
||||
|
||||
if (x > xMin)
|
||||
return std::sqrt(x);
|
||||
return Toolbox::sqrt(x);
|
||||
else if (x <= 0)
|
||||
return fPrime0 * x;
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user