Skip to content

Commit

Permalink
decorate fluidstate modules needed for spe11c
Browse files Browse the repository at this point in the history
  • Loading branch information
multitalentloes committed Sep 12, 2024
1 parent 8d53125 commit ab90d2b
Show file tree
Hide file tree
Showing 8 changed files with 108 additions and 51 deletions.
37 changes: 27 additions & 10 deletions opm/material/fluidstates/FluidStateCompositionModules.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include <opm/material/common/Valgrind.hpp>
#include <opm/material/common/MathToolbox.hpp>
#include <opm/common/utility/gpuDecorators.hpp>

#include <algorithm>
#include <array>
Expand Down Expand Up @@ -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]
Expand All @@ -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]
Expand All @@ -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.
Expand All @@ -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
{ }
};

Expand Down
31 changes: 22 additions & 9 deletions opm/material/fluidstates/FluidStateDensityModules.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include <opm/material/common/MathToolbox.hpp>
#include <opm/material/common/Valgrind.hpp>
#include <opm/common/utility/gpuDecorators.hpp>

#include <algorithm>

Expand Down Expand Up @@ -114,33 +115,45 @@ template <class Scalar,
class FluidStateNullDensityModule
{
public:
FluidStateNullDensityModule()
OPM_HOST_DEVICE FluidStateNullDensityModule()
{ }

/*!
* \brief The density of a fluid phase [kg/m^3]
*/
const Scalar& density(unsigned /* phaseIdx */) const
{ throw std::logic_error("Density is not provided by this fluid state"); }
OPM_HOST_DEVICE const Scalar& density(unsigned /* phaseIdx */) const
{
#if !OPM_IS_INSIDE_DEVICE_FUNCTION
throw std::logic_error("Density is not provided by this fluid state");
#endif
}

/*!
* \brief The molar density of a fluid phase [mol/m^3]
*/
const Scalar& molarDensity(unsigned /* phaseIdx */) const
{ throw std::logic_error("Molar density is not provided by this fluid state"); }
OPM_HOST_DEVICE const Scalar& molarDensity(unsigned /* phaseIdx */) const
{
#if !OPM_IS_INSIDE_DEVICE_FUNCTION
throw std::logic_error("Molar density is not provided by this fluid state");
#endif
}

/*!
* \brief The molar volume of a fluid phase [m^3/mol]
*/
const Scalar& molarVolume(unsigned /* phaseIdx */) const
{ throw std::logic_error("Molar volume is not provided by this fluid state"); }
OPM_HOST_DEVICE const Scalar& molarVolume(unsigned /* phaseIdx */) const
{
#if !OPM_IS_INSIDE_DEVICE_FUNCTION
throw std::logic_error("Molar volume is not provided by this fluid state");
#endif
}

/*!
* \brief Retrieve all parameters from an arbitrary fluid
* state.
*/
template <class FluidState>
void assign(const FluidState& /* fs */)
OPM_HOST_DEVICE void assign(const FluidState& /* fs */)
{ }

/*!
Expand All @@ -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
{ }
};

Expand Down
11 changes: 6 additions & 5 deletions opm/material/fluidstates/FluidStateEnthalpyModules.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include <opm/material/common/MathToolbox.hpp>
#include <opm/material/common/Valgrind.hpp>
#include <opm/common/utility/gpuDecorators.hpp>

#include <array>

Expand Down Expand Up @@ -108,13 +109,13 @@ template <class Scalar,
class FluidStateNullEnthalpyModule
{
public:
FluidStateNullEnthalpyModule()
OPM_HOST_DEVICE FluidStateNullEnthalpyModule()
{ }

/*!
* \brief The specific internal energy of a fluid phase [J/kg]
*/
const Scalar& internalEnergy(unsigned /* phaseIdx */) const
OPM_HOST_DEVICE const Scalar& internalEnergy(unsigned /* phaseIdx */) const
{
static Scalar tmp = 0;
Valgrind::SetUndefined(tmp);
Expand All @@ -124,7 +125,7 @@ class FluidStateNullEnthalpyModule
/*!
* \brief The specific enthalpy of a fluid phase [J/kg]
*/
const Scalar& enthalpy(unsigned /* phaseIdx */) const
OPM_HOST_DEVICE const Scalar& enthalpy(unsigned /* phaseIdx */) const
{
static Scalar tmp = 0;
Valgrind::SetUndefined(tmp);
Expand All @@ -136,7 +137,7 @@ class FluidStateNullEnthalpyModule
* state.
*/
template <class FluidState>
void assign(const FluidState& /* fs */)
OPM_HOST_DEVICE void assign(const FluidState& /* fs */)
{ }

/*!
Expand All @@ -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
{ }
};

Expand Down
21 changes: 15 additions & 6 deletions opm/material/fluidstates/FluidStateFugacityModules.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#define OPM_FLUID_STATE_FUGACITY_MODULES_HPP

#include <opm/material/common/Valgrind.hpp>
#include <opm/common/utility/gpuDecorators.hpp>

#include <algorithm>
#include <limits>
Expand Down Expand Up @@ -179,20 +180,28 @@ template <class Scalar>
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.
Expand All @@ -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
{ }
};

Expand Down
15 changes: 10 additions & 5 deletions opm/material/fluidstates/FluidStatePressureModules.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include <opm/material/common/MathToolbox.hpp>
#include <opm/material/common/Valgrind.hpp>
#include <opm/common/utility/gpuDecorators.hpp>

#include <algorithm>

Expand Down Expand Up @@ -98,22 +99,26 @@ template <class Scalar>
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
}


/*!
* \brief Retrieve all parameters from an arbitrary fluid
* state.
*/
template <class FluidState>
void assign(const FluidState& /* fs */)
OPM_HOST_DEVICE void assign(const FluidState& /* fs */)
{ }

/*!
Expand All @@ -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
{ }
};

Expand Down
13 changes: 8 additions & 5 deletions opm/material/fluidstates/FluidStateSaturationModules.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

#include <opm/material/common/MathToolbox.hpp>
#include <opm/material/common/Valgrind.hpp>
#include <opm/common/utility/gpuDecorators.hpp>

#include <algorithm>

Expand All @@ -45,27 +46,27 @@ template <class Scalar,
class FluidStateExplicitSaturationModule
{
public:
FluidStateExplicitSaturationModule()
OPM_HOST_DEVICE FluidStateExplicitSaturationModule()
{ Valgrind::SetUndefined(saturation_); }

/*!
* \brief The saturation of a fluid phase [-]
*/
const Scalar& saturation(unsigned phaseIdx) const
OPM_HOST_DEVICE const Scalar& saturation(unsigned phaseIdx) const
{ return saturation_[phaseIdx]; }

/*!
* \brief Set the saturation of a phase [-]
*/
void setSaturation(unsigned phaseIdx, const Scalar& value)
OPM_HOST_DEVICE void setSaturation(unsigned phaseIdx, const Scalar& value)
{ saturation_[phaseIdx] = value; }

/*!
* \brief Retrieve all parameters from an arbitrary fluid
* state.
*/
template <class FluidState>
void assign(const FluidState& fs)
OPM_HOST_DEVICE void assign(const FluidState& fs)
{
for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
saturation_[phaseIdx] = decay<Scalar>(fs.saturation(phaseIdx));
Expand All @@ -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:
Expand Down
Loading

0 comments on commit ab90d2b

Please sign in to comment.