00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00028 #ifndef OPM_FLUID_STATE_SATURATION_MODULES_HPP
00029 #define OPM_FLUID_STATE_SATURATION_MODULES_HPP
00030
00031 #include <opm/common/ErrorMacros.hpp>
00032 #include <opm/common/Exceptions.hpp>
00033
00034 #include <opm/material/common/MathToolbox.hpp>
00035 #include <opm/common/Valgrind.hpp>
00036
00037 #include <algorithm>
00038
00039 namespace Opm {
00040
00045 template <class Scalar,
00046 unsigned numPhases,
00047 class Implementation>
00048 class FluidStateExplicitSaturationModule
00049 {
00050 public:
00051 FluidStateExplicitSaturationModule()
00052 { Valgrind::SetUndefined(saturation_); }
00053
00057 const Scalar& saturation(unsigned phaseIdx) const
00058 { return saturation_[phaseIdx]; }
00059
00063 bool phaseIsPresent(unsigned phaseIdx) const
00064 { return saturation_[phaseIdx] > 0.0; }
00065
00069 void setSaturation(unsigned phaseIdx, const Scalar& value)
00070 { saturation_[phaseIdx] = value; }
00071
00076 template <class FluidState>
00077 void assign(const FluidState& fs)
00078 {
00079 for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
00080 saturation_[phaseIdx] = Opm::decay<Scalar>(fs.saturation(phaseIdx));
00081 }
00082 }
00083
00092 void checkDefined() const
00093 {
00094 Valgrind::CheckDefined(saturation_);
00095 }
00096
00097 protected:
00098 Scalar saturation_[numPhases];
00099 };
00100
00105 template <class Scalar>
00106 class FluidStateNullSaturationModule
00107 {
00108 public:
00109 FluidStateNullSaturationModule()
00110 { }
00111
00115 const Scalar& saturation(unsigned ) const
00116 { OPM_THROW(std::runtime_error, "Saturation is not provided by this fluid state"); }
00117
00121 bool phaseIsPresent(unsigned ) const
00122 { OPM_THROW(std::runtime_error, "phaseIsPresent() is not provided by this fluid state"); }
00123
00128 template <class FluidState>
00129 void assign(const FluidState& )
00130 { }
00131
00140 void checkDefined() const
00141 { }
00142 };
00143
00144 }
00145
00146 #endif