29#ifndef EWOMS_QUANTITY_CALLBACKS_HH
30#define EWOMS_QUANTITY_CALLBACKS_HH
34#include <opm/material/common/MathToolbox.hpp>
35#include <opm/material/common/Valgrind.hpp>
47template <
class TypeTag>
48class TemperatureCallback
53 using IQFluidState =
decltype(std::declval<IntensiveQuantities>().fluidState());
54 using ResultRawType =
decltype(std::declval<IQFluidState>().temperature(0));
57 using ResultType = std::remove_const_t<std::remove_reference_t<ResultRawType>>;
58 using ResultValueType =
typename MathToolbox<ResultType>::ValueType;
60 explicit TemperatureCallback(
const ElementContext& elemCtx)
72 {
return elemCtx_.intensiveQuantities(dofIdx, 0).fluidState().temperature(0); }
75 const ElementContext& elemCtx_;
83template <
class TypeTag>
89 using IQFluidState =
decltype(std::declval<IntensiveQuantities>().fluidState());
90 using ResultRawType =
decltype(std::declval<IQFluidState>().pressure(0));
93 using ResultType = std::remove_const_t<std::remove_reference_t<ResultRawType>>;
94 using ResultValueType =
typename MathToolbox<ResultType>::ValueType;
96 explicit PressureCallback(
const ElementContext& elemCtx)
98 { Valgrind::SetUndefined(phaseIdx_); }
100 PressureCallback(
const ElementContext& elemCtx,
unsigned phaseIdx)
102 , phaseIdx_(
static_cast<unsigned short>(phaseIdx))
110 { phaseIdx_ =
static_cast<unsigned short>(phaseIdx); }
118 Valgrind::CheckDefined(phaseIdx_);
119 return elemCtx_.intensiveQuantities(dofIdx, 0).fluidState().pressure(phaseIdx_);
123 const ElementContext& elemCtx_;
124 unsigned short phaseIdx_;
132template <
class TypeTag,
class Flu
idState>
133class BoundaryPressureCallback
139 using IQRawFluidState =
decltype(std::declval<IntensiveQuantities>().fluidState());
140 using IQFluidState = std::remove_const_t<std::remove_reference_t<IQRawFluidState>>;
141 using IQValueType = std::decay_t<decltype(std::declval<IQFluidState>().pressure(0))>;
144 using ResultType = IQValueType;
146 BoundaryPressureCallback(
const ElementContext& elemCtx,
const FluidState& boundaryFs)
148 , boundaryFs_(boundaryFs)
149 { Valgrind::SetUndefined(phaseIdx_); }
151 BoundaryPressureCallback(
const ElementContext& elemCtx,
152 const FluidState& boundaryFs,
155 , boundaryFs_(boundaryFs)
156 , phaseIdx_(
static_cast<unsigned short>(phaseIdx))
164 { phaseIdx_ =
static_cast<unsigned short>(phaseIdx); }
172 Valgrind::CheckDefined(phaseIdx_);
173 return elemCtx_.intensiveQuantities(dofIdx, 0).fluidState().pressure(phaseIdx_);
176 IQValueType boundaryValue()
const
178 Valgrind::CheckDefined(phaseIdx_);
179 return boundaryFs_.pressure(phaseIdx_);
183 const ElementContext& elemCtx_;
184 const FluidState& boundaryFs_;
185 unsigned short phaseIdx_;
193template <
class TypeTag>
199 using IQFluidState =
decltype(std::declval<IntensiveQuantities>().fluidState());
200 using ResultRawType =
decltype(std::declval<IQFluidState>().density(0));
203 using ResultType = std::remove_const_t<std::remove_reference_t<ResultRawType>>;
204 using ResultValueType =
typename MathToolbox<ResultType>::ValueType;
206 explicit DensityCallback(
const ElementContext& elemCtx)
208 { Valgrind::SetUndefined(phaseIdx_); }
210 DensityCallback(
const ElementContext& elemCtx,
unsigned phaseIdx)
212 , phaseIdx_(
static_cast<unsigned short>(phaseIdx))
220 { phaseIdx_ =
static_cast<unsigned short>(phaseIdx); }
228 Valgrind::CheckDefined(phaseIdx_);
229 return elemCtx_.intensiveQuantities(dofIdx, 0).fluidState().density(phaseIdx_);
233 const ElementContext& elemCtx_;
234 unsigned short phaseIdx_;
242template <
class TypeTag>
243class MolarDensityCallback
248 using IQFluidState =
decltype(std::declval<IntensiveQuantities>().fluidState());
251 using ResultType =
decltype(std::declval<IQFluidState>().molarDensity(0));
252 using ResultValueType =
typename MathToolbox<ResultType>::ValueType;
254 explicit MolarDensityCallback(
const ElementContext& elemCtx)
256 { Valgrind::SetUndefined(phaseIdx_); }
258 MolarDensityCallback(
const ElementContext& elemCtx,
unsigned phaseIdx)
260 , phaseIdx_(
static_cast<unsigned short>(phaseIdx))
268 { phaseIdx_ =
static_cast<unsigned short>(phaseIdx); }
276 Valgrind::CheckDefined(phaseIdx_);
277 return elemCtx_.intensiveQuantities(dofIdx, 0).fluidState().molarDensity(phaseIdx_);
281 const ElementContext& elemCtx_;
282 unsigned short phaseIdx_;
290template <
class TypeTag>
291class ViscosityCallback
296 using IQFluidState =
decltype(std::declval<IntensiveQuantities>().fluidState());
297 using ResultRawType =
decltype(std::declval<IQFluidState>().viscosity(0));
300 using ResultType = std::remove_const_t<std::remove_reference_t<ResultRawType>>;
301 using ResultValueType =
typename MathToolbox<ResultType>::ValueType;
303 explicit ViscosityCallback(
const ElementContext& elemCtx)
305 { Valgrind::SetUndefined(phaseIdx_); }
307 ViscosityCallback(
const ElementContext& elemCtx,
unsigned phaseIdx)
309 , phaseIdx_(
static_cast<unsigned short>(phaseIdx))
317 { phaseIdx_ =
static_cast<unsigned short>(phaseIdx); }
325 Valgrind::CheckDefined(phaseIdx_);
326 return elemCtx_.intensiveQuantities(dofIdx, 0).fluidState().viscosity(phaseIdx_);
330 const ElementContext& elemCtx_;
331 unsigned short phaseIdx_;
339template <
class TypeTag>
340class VelocityCallback
345 using ResultRawType =
decltype(IntensiveQuantities().velocityCenter());
348 using ResultType = std::remove_const_t<std::remove_reference_t<ResultRawType>>;
349 using ResultFieldType =
typename ResultType::field_type;
350 using ResultFieldValueType =
typename MathToolbox<ResultFieldType>::ValueType;
352 explicit VelocityCallback(
const ElementContext& elemCtx)
361 {
return elemCtx_.intensiveQuantities(dofIdx, 0).velocityCenter(); }
364 const ElementContext& elemCtx_;
372template <
class TypeTag>
373class VelocityComponentCallback
378 using ResultRawType =
decltype(IntensiveQuantities().velocityCenter()[0]);
381 using ResultType = std::remove_const_t<std::remove_reference_t<ResultRawType>>;
382 using ResultValueType =
typename MathToolbox<ResultType>::ValueType;
384 explicit VelocityComponentCallback(
const ElementContext& elemCtx)
386 { Valgrind::SetUndefined(dimIdx_); }
388 VelocityComponentCallback(
const ElementContext& elemCtx,
unsigned dimIdx)
398 { dimIdx_ = dimIdx; }
406 Valgrind::CheckDefined(dimIdx_);
407 return elemCtx_.intensiveQuantities(dofIdx, 0).velocityCenter()[dimIdx_];
411 const ElementContext& elemCtx_;
420template <
class TypeTag>
421class MoleFractionCallback
426 using IQFluidState =
decltype(std::declval<IntensiveQuantities>().fluidState());
427 using ResultRawType =
decltype(std::declval<IQFluidState>().moleFraction(0, 0));
430 using ResultType = std::remove_const_t<std::remove_reference_t<ResultRawType>>;
431 using ResultValueType =
typename MathToolbox<ResultType>::ValueType;
433 explicit MoleFractionCallback(
const ElementContext& elemCtx)
436 Valgrind::SetUndefined(phaseIdx_);
437 Valgrind::SetUndefined(compIdx_);
440 MoleFractionCallback(
const ElementContext& elemCtx,
unsigned phaseIdx,
unsigned compIdx)
442 , phaseIdx_(
static_cast<unsigned short>(phaseIdx))
443 , compIdx_(
static_cast<unsigned short>(compIdx))
451 { phaseIdx_ =
static_cast<unsigned short>(phaseIdx); }
458 { compIdx_ =
static_cast<unsigned short>(compIdx); }
466 Valgrind::CheckDefined(phaseIdx_);
467 Valgrind::CheckDefined(compIdx_);
468 return elemCtx_.intensiveQuantities(dofIdx, 0).fluidState().moleFraction(phaseIdx_, compIdx_);
472 const ElementContext& elemCtx_;
473 unsigned short phaseIdx_;
474 unsigned short compIdx_;
void setPhaseIndex(unsigned phaseIdx)
Set the index of the fluid phase for which the pressure should be returned.
Definition quantitycallbacks.hh:163
ResultType operator()(unsigned dofIdx) const
Return the pressure of a phase given the index of a degree of freedom within an element context.
Definition quantitycallbacks.hh:170
void setPhaseIndex(unsigned phaseIdx)
Set the index of the fluid phase for which the density should be returned.
Definition quantitycallbacks.hh:219
ResultType operator()(unsigned dofIdx) const
Return the density of a phase given the index of a degree of freedom within an element context.
Definition quantitycallbacks.hh:226
void setPhaseIndex(unsigned phaseIdx)
Set the index of the fluid phase for which the molar density should be returned.
Definition quantitycallbacks.hh:267
ResultType operator()(unsigned dofIdx) const
Return the molar density of a phase given the index of a degree of freedom within an element context.
Definition quantitycallbacks.hh:274
void setComponentIndex(unsigned compIdx)
Set the index of the component for which the mole fraction should be returned.
Definition quantitycallbacks.hh:457
void setPhaseIndex(unsigned phaseIdx)
Set the index of the fluid phase for which a mole fraction should be returned.
Definition quantitycallbacks.hh:450
ResultType operator()(unsigned dofIdx) const
Return the mole fraction of a component in a phase given the index of a degree of freedom within an e...
Definition quantitycallbacks.hh:464
ResultType operator()(unsigned dofIdx) const
Return the pressure of the specified phase given the index of a degree of freedom within an element c...
Definition quantitycallbacks.hh:116
void setPhaseIndex(unsigned phaseIdx)
Set the index of the fluid phase for which the pressure should be returned.
Definition quantitycallbacks.hh:109
ResultType operator()(unsigned dofIdx) const
Return the temperature given the index of a degree of freedom within an element context.
Definition quantitycallbacks.hh:71
ResultType operator()(unsigned dofIdx) const
Return the velocity of a phase given the index of a degree of freedom within an element context.
Definition quantitycallbacks.hh:360
void setDimIndex(unsigned dimIdx)
Set the index of the component of the velocity which should be returned.
Definition quantitycallbacks.hh:397
ResultType operator()(unsigned dofIdx) const
Return the velocity of a phase given the index of a degree of freedom within an element context.
Definition quantitycallbacks.hh:404
ResultType operator()(unsigned dofIdx) const
Return the viscosity of a phase given the index of a degree of freedom within an element context.
Definition quantitycallbacks.hh:323
void setPhaseIndex(unsigned phaseIdx)
Set the index of the fluid phase for which the viscosity should be returned.
Definition quantitycallbacks.hh:316
Declare the properties used by the infrastructure code of the finite volume discretizations.
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilbioeffectsmodules.hh:45
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition propertysystem.hh:233