From bde10e60c8b2ceb091370948243490b5eaa20411 Mon Sep 17 00:00:00 2001 From: Tobias Meyer Andersen Date: Thu, 12 Sep 2024 14:49:16 +0200 Subject: [PATCH] decorate fluidstate modules needed for spe11c --- .../FluidStateCompositionModules.hpp | 37 ++++++++++++++----- .../fluidstates/FluidStateDensityModules.hpp | 31 +++++++++++----- .../fluidstates/FluidStateEnthalpyModules.hpp | 11 +++--- .../fluidstates/FluidStateFugacityModules.hpp | 21 ++++++++--- .../fluidstates/FluidStatePressureModules.hpp | 15 +++++--- .../FluidStateSaturationModules.hpp | 13 ++++--- .../FluidStateTemperatureModules.hpp | 16 +++++--- .../FluidStateViscosityModules.hpp | 15 +++++--- 8 files changed, 108 insertions(+), 51 deletions(-) diff --git a/opm/material/fluidstates/FluidStateCompositionModules.hpp b/opm/material/fluidstates/FluidStateCompositionModules.hpp index 1970e465c0e..9a9f3460b64 100644 --- a/opm/material/fluidstates/FluidStateCompositionModules.hpp +++ b/opm/material/fluidstates/FluidStateCompositionModules.hpp @@ -30,6 +30,7 @@ #include #include +#include #include #include @@ -317,19 +318,27 @@ class FluidStateNullCompositionModule public: enum { numComponents = 0 }; - FluidStateNullCompositionModule() = default; + OPM_HOST_DEVICE FluidStateNullCompositionModule() = default; /*! * \brief The mole fraction of a component in a phase [] */ - Scalar moleFraction(unsigned /* phaseIdx */, unsigned /* compIdx */) const - { throw std::logic_error("Mole fractions are not provided by this fluid state"); } + OPM_HOST_DEVICE Scalar moleFraction(unsigned /* phaseIdx */, unsigned /* compIdx */) const + { +#if !OPM_IS_INSIDE_DEVICE_FUNCTION + throw std::logic_error("Mole fractions are not provided by this fluid state"); +#endif + } /*! * \brief The mass fraction of a component in a phase [] */ - Scalar massFraction(unsigned /* phaseIdx */, unsigned /* compIdx */) const - { throw std::logic_error("Mass fractions are not provided by this fluid state"); } + OPM_HOST_DEVICE Scalar massFraction(unsigned /* phaseIdx */, unsigned /* compIdx */) const + { +#if !OPM_IS_INSIDE_DEVICE_FUNCTION + throw std::logic_error("Mass fractions are not provided by this fluid state"); +#endif + } /*! * \brief The mean molar mass of a fluid phase [kg/mol] @@ -339,8 +348,12 @@ class FluidStateNullCompositionModule * component's molar masses weighted by the current mole fraction: * \f[ \bar M_\alpha = \sum_\kappa M^\kappa x_\alpha^\kappa \f] */ - Scalar averageMolarMass(unsigned /* phaseIdx */) const - { throw std::logic_error("Mean molar masses are not provided by this fluid state"); } + OPM_HOST_DEVICE Scalar averageMolarMass(unsigned /* phaseIdx */) const + { +#if !OPM_IS_INSIDE_DEVICE_FUNCTION + throw std::logic_error("Mean molar masses are not provided by this fluid state"); +#endif + } /*! * \brief The concentration of a component in a phase [mol/m^3] @@ -351,8 +364,12 @@ class FluidStateNullCompositionModule * * http://en.wikipedia.org/wiki/Concentration */ - Scalar molarity(unsigned /* phaseIdx */, unsigned /* compIdx */) const - { throw std::logic_error("Molarities are not provided by this fluid state"); } + OPM_HOST_DEVICE Scalar molarity(unsigned /* phaseIdx */, unsigned /* compIdx */) const + { +#if !OPM_IS_INSIDE_DEVICE_FUNCTION + throw std::logic_error("Molarities are not provided by this fluid state"); +#endif + } /*! * \brief Make sure that all attributes are defined. @@ -362,7 +379,7 @@ class FluidStateNullCompositionModule * message if some attributes of the object have not been properly * defined. */ - void checkDefined() const + OPM_HOST_DEVICE void checkDefined() const { } }; diff --git a/opm/material/fluidstates/FluidStateDensityModules.hpp b/opm/material/fluidstates/FluidStateDensityModules.hpp index 179e2613ffa..624129d0823 100644 --- a/opm/material/fluidstates/FluidStateDensityModules.hpp +++ b/opm/material/fluidstates/FluidStateDensityModules.hpp @@ -30,6 +30,7 @@ #include #include +#include #include @@ -114,33 +115,45 @@ template - void assign(const FluidState& /* fs */) + OPM_HOST_DEVICE void assign(const FluidState& /* fs */) { } /*! @@ -151,7 +164,7 @@ class FluidStateNullDensityModule * message if some attributes of the object have not been properly * defined. */ - void checkDefined() const + OPM_HOST_DEVICE void checkDefined() const { } }; diff --git a/opm/material/fluidstates/FluidStateEnthalpyModules.hpp b/opm/material/fluidstates/FluidStateEnthalpyModules.hpp index db7ad4a85a2..1de9ac547c0 100644 --- a/opm/material/fluidstates/FluidStateEnthalpyModules.hpp +++ b/opm/material/fluidstates/FluidStateEnthalpyModules.hpp @@ -30,6 +30,7 @@ #include #include +#include #include @@ -108,13 +109,13 @@ template - void assign(const FluidState& /* fs */) + OPM_HOST_DEVICE void assign(const FluidState& /* fs */) { } /*! @@ -147,7 +148,7 @@ class FluidStateNullEnthalpyModule * message if some attributes of the object have not been properly * defined. */ - void checkDefined() const + OPM_HOST_DEVICE void checkDefined() const { } }; diff --git a/opm/material/fluidstates/FluidStateFugacityModules.hpp b/opm/material/fluidstates/FluidStateFugacityModules.hpp index f52aefb2199..b37b20d9fdb 100644 --- a/opm/material/fluidstates/FluidStateFugacityModules.hpp +++ b/opm/material/fluidstates/FluidStateFugacityModules.hpp @@ -29,6 +29,7 @@ #define OPM_FLUID_STATE_FUGACITY_MODULES_HPP #include +#include #include #include @@ -179,20 +180,28 @@ template class FluidStateNullFugacityModule { public: - FluidStateNullFugacityModule() + OPM_HOST_DEVICE FluidStateNullFugacityModule() { } /*! * \brief The fugacity coefficient of a component in a phase [] */ - const Scalar& fugacityCoefficient(unsigned /* phaseIdx */, unsigned /* compIdx */) const - { throw std::logic_error("Fugacity coefficients are not provided by this fluid state"); } + OPM_HOST_DEVICE const Scalar& fugacityCoefficient(unsigned /* phaseIdx */, unsigned /* compIdx */) const + { +#if !OPM_IS_INSIDE_DEVICE_FUNCTION + throw std::logic_error("Fugacity coefficients are not provided by this fluid state"); +#endif + } /*! * \brief The fugacity of a component in a phase [Pa] */ - const Scalar& fugacity(unsigned /* phaseIdx */, unsigned /* compIdx */) const - { throw std::logic_error("Fugacities coefficients are not provided by this fluid state"); } + OPM_HOST_DEVICE const Scalar& fugacity(unsigned /* phaseIdx */, unsigned /* compIdx */) const + { +#if !OPM_IS_INSIDE_DEVICE_FUNCTION + throw std::logic_error("Fugacities coefficients are not provided by this fluid state"); +#endif + } /*! * \brief Make sure that all attributes are defined. @@ -202,7 +211,7 @@ class FluidStateNullFugacityModule * message if some attributes of the object have not been properly * defined. */ - void checkDefined() const + OPM_HOST_DEVICE void checkDefined() const { } }; diff --git a/opm/material/fluidstates/FluidStatePressureModules.hpp b/opm/material/fluidstates/FluidStatePressureModules.hpp index 4b962bd2056..60c800a37ab 100644 --- a/opm/material/fluidstates/FluidStatePressureModules.hpp +++ b/opm/material/fluidstates/FluidStatePressureModules.hpp @@ -30,6 +30,7 @@ #include #include +#include #include @@ -98,14 +99,18 @@ template class FluidStateNullPressureModule { public: - FluidStateNullPressureModule() + OPM_HOST_DEVICE FluidStateNullPressureModule() { } /*! * \brief The pressure of a fluid phase [Pa] */ - const Scalar& pressure(unsigned /* phaseIdx */) const - { throw std::logic_error("Pressure is not provided by this fluid state"); } + OPM_HOST_DEVICE const Scalar& pressure(unsigned /* phaseIdx */) const + { +#if !OPM_IS_INSIDE_DEVICE_FUNCTION + throw std::logic_error("Pressure is not provided by this fluid state"); +#endif + } /*! @@ -113,7 +118,7 @@ class FluidStateNullPressureModule * state. */ template - void assign(const FluidState& /* fs */) + OPM_HOST_DEVICE void assign(const FluidState& /* fs */) { } /*! @@ -124,7 +129,7 @@ class FluidStateNullPressureModule * message if some attributes of the object have not been properly * defined. */ - void checkDefined() const + OPM_HOST_DEVICE void checkDefined() const { } }; diff --git a/opm/material/fluidstates/FluidStateSaturationModules.hpp b/opm/material/fluidstates/FluidStateSaturationModules.hpp index 589eb2d1ecf..697e0779a9b 100644 --- a/opm/material/fluidstates/FluidStateSaturationModules.hpp +++ b/opm/material/fluidstates/FluidStateSaturationModules.hpp @@ -30,6 +30,7 @@ #include #include +#include #include @@ -45,19 +46,19 @@ template - void assign(const FluidState& fs) + OPM_HOST_DEVICE void assign(const FluidState& fs) { for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) { saturation_[phaseIdx] = decay(fs.saturation(phaseIdx)); @@ -80,9 +81,11 @@ class FluidStateExplicitSaturationModule * message if some attributes of the object have not been properly * defined. */ - void checkDefined() const + OPM_HOST_DEVICE void checkDefined() const { +#if !OPM_IS_INSIDE_DEVICE_FUNCTION Valgrind::CheckDefined(saturation_); +#endif } protected: diff --git a/opm/material/fluidstates/FluidStateTemperatureModules.hpp b/opm/material/fluidstates/FluidStateTemperatureModules.hpp index 27d670636a0..3a39a0c1e26 100644 --- a/opm/material/fluidstates/FluidStateTemperatureModules.hpp +++ b/opm/material/fluidstates/FluidStateTemperatureModules.hpp @@ -29,8 +29,8 @@ #define OPM_FLUID_STATE_TEMPERATURE_MODULES_HPP #include - #include +#include #include #include @@ -158,21 +158,25 @@ template class FluidStateNullTemperatureModule { public: - FluidStateNullTemperatureModule() + OPM_HOST_DEVICE FluidStateNullTemperatureModule() { } /*! * \brief The temperature of a fluid phase [-] */ - const Scalar& temperature(unsigned /* phaseIdx */) const - { throw std::runtime_error("Temperature is not provided by this fluid state"); } + OPM_HOST_DEVICE const Scalar& temperature(unsigned /* phaseIdx */) const + { +#if !OPM_IS_INSIDE_DEVICE_FUNCTION + throw std::runtime_error("Temperature is not provided by this fluid state"); +#endif + } /*! * \brief Retrieve all parameters from an arbitrary fluid * state. */ template - void assign(const FluidState& /* fs */) + OPM_HOST_DEVICE void assign(const FluidState& /* fs */) { } /*! @@ -183,7 +187,7 @@ class FluidStateNullTemperatureModule * message if some attributes of the object have not been properly * defined. */ - void checkDefined() const + OPM_HOST_DEVICE void checkDefined() const { } }; diff --git a/opm/material/fluidstates/FluidStateViscosityModules.hpp b/opm/material/fluidstates/FluidStateViscosityModules.hpp index 256576de0b9..20600298ee3 100644 --- a/opm/material/fluidstates/FluidStateViscosityModules.hpp +++ b/opm/material/fluidstates/FluidStateViscosityModules.hpp @@ -30,6 +30,7 @@ #include #include +#include #include @@ -98,21 +99,25 @@ template - void assign(const FluidState& /* fs */) + OPM_HOST_DEVICE void assign(const FluidState& /* fs */) { } /*! @@ -123,7 +128,7 @@ class FluidStateNullViscosityModule * message if some attributes of the object have not been properly * defined. */ - void checkDefined() const + OPM_HOST_DEVICE void checkDefined() const { } };