quantitycallbacks.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3/*
4 This file is part of the Open Porous Media project (OPM).
5
6 OPM is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 2 of the License, or
9 (at your option) any later version.
10
11 OPM is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with OPM. If not, see <http://www.gnu.org/licenses/>.
18
19 Consult the COPYING file in the top-level source directory of this
20 module for the precise wording of the license and the list of
21 copyright holders.
22*/
29#ifndef EWOMS_QUANTITY_CALLBACKS_HH
30#define EWOMS_QUANTITY_CALLBACKS_HH
31
33
34#include <opm/material/common/MathToolbox.hpp>
35#include <opm/material/common/Valgrind.hpp>
36
37#include <type_traits>
38#include <utility>
39
40namespace Opm {
41
47template <class TypeTag>
49{
52
53 using IQFluidState = decltype(std::declval<IntensiveQuantities>().fluidState());
54 using ResultRawType = decltype(std::declval<IQFluidState>().temperature(0));
55
56public:
57 using ResultType = std::remove_const_t<std::remove_reference_t<ResultRawType>>;
58 using ResultValueType = typename MathToolbox<ResultType>::ValueType;
59
60 explicit TemperatureCallback(const ElementContext& elemCtx)
61 : elemCtx_(elemCtx)
62 {}
63
71 ResultType operator()(unsigned dofIdx) const
72 { return elemCtx_.intensiveQuantities(dofIdx, /*timeIdx=*/0).fluidState().temperature(/*phaseIdx=*/0); }
73
74private:
75 const ElementContext& elemCtx_;
76};
77
83template <class TypeTag>
85{
88
89 using IQFluidState = decltype(std::declval<IntensiveQuantities>().fluidState());
90 using ResultRawType = decltype(std::declval<IQFluidState>().pressure(0));
91
92public:
93 using ResultType = std::remove_const_t<std::remove_reference_t<ResultRawType>>;
94 using ResultValueType = typename MathToolbox<ResultType>::ValueType;
95
96 explicit PressureCallback(const ElementContext& elemCtx)
97 : elemCtx_(elemCtx)
98 { Valgrind::SetUndefined(phaseIdx_); }
99
100 PressureCallback(const ElementContext& elemCtx, unsigned phaseIdx)
101 : elemCtx_(elemCtx)
102 , phaseIdx_(static_cast<unsigned short>(phaseIdx))
103 {}
104
109 void setPhaseIndex(unsigned phaseIdx)
110 { phaseIdx_ = static_cast<unsigned short>(phaseIdx); }
111
116 ResultType operator()(unsigned dofIdx) const
117 {
118 Valgrind::CheckDefined(phaseIdx_);
119 return elemCtx_.intensiveQuantities(dofIdx, /*timeIdx=*/0).fluidState().pressure(phaseIdx_);
120 }
121
122private:
123 const ElementContext& elemCtx_;
124 unsigned short phaseIdx_;
125};
126
132template <class TypeTag, class FluidState>
134{
138
139 using IQRawFluidState = decltype(std::declval<IntensiveQuantities>().fluidState());
140 using IQFluidState = std::remove_const_t<std::remove_reference_t<IQRawFluidState>>;
141 using IQScalar = typename IQFluidState::Scalar;
142
143public:
144 using ResultType = IQScalar;
145
146 BoundaryPressureCallback(const ElementContext& elemCtx, const FluidState& boundaryFs)
147 : elemCtx_(elemCtx)
148 , boundaryFs_(boundaryFs)
149 { Valgrind::SetUndefined(phaseIdx_); }
150
151 BoundaryPressureCallback(const ElementContext& elemCtx,
152 const FluidState& boundaryFs,
153 unsigned phaseIdx)
154 : elemCtx_(elemCtx)
155 , boundaryFs_(boundaryFs)
156 , phaseIdx_(static_cast<unsigned short>(phaseIdx))
157 {}
158
163 void setPhaseIndex(unsigned phaseIdx)
164 { phaseIdx_ = static_cast<unsigned short>(phaseIdx); }
165
170 ResultType operator()(unsigned dofIdx) const
171 {
172 Valgrind::CheckDefined(phaseIdx_);
173 return elemCtx_.intensiveQuantities(dofIdx, /*timeIdx=*/0).fluidState().pressure(phaseIdx_);
174 }
175
176 IQScalar boundaryValue() const
177 {
178 Valgrind::CheckDefined(phaseIdx_);
179 return boundaryFs_.pressure(phaseIdx_);
180 }
181
182private:
183 const ElementContext& elemCtx_;
184 const FluidState& boundaryFs_;
185 unsigned short phaseIdx_;
186};
187
193template <class TypeTag>
195{
198
199 using IQFluidState = decltype(std::declval<IntensiveQuantities>().fluidState());
200 using ResultRawType = decltype(std::declval<IQFluidState>().density(0));
201
202public:
203 using ResultType = std::remove_const_t<std::remove_reference_t<ResultRawType>>;
204 using ResultValueType = typename MathToolbox<ResultType>::ValueType;
205
206 explicit DensityCallback(const ElementContext& elemCtx)
207 : elemCtx_(elemCtx)
208 { Valgrind::SetUndefined(phaseIdx_); }
209
210 DensityCallback(const ElementContext& elemCtx, unsigned phaseIdx)
211 : elemCtx_(elemCtx)
212 , phaseIdx_(static_cast<unsigned short>(phaseIdx))
213 {}
214
219 void setPhaseIndex(unsigned phaseIdx)
220 { phaseIdx_ = static_cast<unsigned short>(phaseIdx); }
221
226 ResultType operator()(unsigned dofIdx) const
227 {
228 Valgrind::CheckDefined(phaseIdx_);
229 return elemCtx_.intensiveQuantities(dofIdx, /*timeIdx=*/0).fluidState().density(phaseIdx_);
230 }
231
232private:
233 const ElementContext& elemCtx_;
234 unsigned short phaseIdx_;
235};
236
242template <class TypeTag>
244{
247
248 using IQFluidState = decltype(std::declval<IntensiveQuantities>().fluidState());
249
250public:
251 using ResultType = decltype(std::declval<IQFluidState>().molarDensity(0));
252 using ResultValueType = typename MathToolbox<ResultType>::ValueType;
253
254 explicit MolarDensityCallback(const ElementContext& elemCtx)
255 : elemCtx_(elemCtx)
256 { Valgrind::SetUndefined(phaseIdx_); }
257
258 MolarDensityCallback(const ElementContext& elemCtx, unsigned phaseIdx)
259 : elemCtx_(elemCtx)
260 , phaseIdx_(static_cast<unsigned short>(phaseIdx))
261 {}
262
267 void setPhaseIndex(unsigned phaseIdx)
268 { phaseIdx_ = static_cast<unsigned short>(phaseIdx); }
269
274 ResultType operator()(unsigned dofIdx) const
275 {
276 Valgrind::CheckDefined(phaseIdx_);
277 return elemCtx_.intensiveQuantities(dofIdx, /*timeIdx=*/0).fluidState().molarDensity(phaseIdx_);
278 }
279
280private:
281 const ElementContext& elemCtx_;
282 unsigned short phaseIdx_;
283};
284
290template <class TypeTag>
292{
295
296 using IQFluidState = decltype(std::declval<IntensiveQuantities>().fluidState());
297 using ResultRawType = decltype(std::declval<IQFluidState>().viscosity(0));
298
299public:
300 using ResultType = std::remove_const_t<std::remove_reference_t<ResultRawType>>;
301 using ResultValueType = typename MathToolbox<ResultType>::ValueType;
302
303 explicit ViscosityCallback(const ElementContext& elemCtx)
304 : elemCtx_(elemCtx)
305 { Valgrind::SetUndefined(phaseIdx_); }
306
307 ViscosityCallback(const ElementContext& elemCtx, unsigned phaseIdx)
308 : elemCtx_(elemCtx)
309 , phaseIdx_(static_cast<unsigned short>(phaseIdx))
310 {}
311
316 void setPhaseIndex(unsigned phaseIdx)
317 { phaseIdx_ = static_cast<unsigned short>(phaseIdx); }
318
323 ResultType operator()(unsigned dofIdx) const
324 {
325 Valgrind::CheckDefined(phaseIdx_);
326 return elemCtx_.intensiveQuantities(dofIdx, /*timeIdx=*/0).fluidState().viscosity(phaseIdx_);
327 }
328
329private:
330 const ElementContext& elemCtx_;
331 unsigned short phaseIdx_;
332};
333
339template <class TypeTag>
341{
344
345 using ResultRawType = decltype(IntensiveQuantities().velocityCenter());
346
347public:
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;
351
352 explicit VelocityCallback(const ElementContext& elemCtx)
353 : elemCtx_(elemCtx)
354 {}
355
360 ResultType operator()(unsigned dofIdx) const
361 { return elemCtx_.intensiveQuantities(dofIdx, /*timeIdx=*/0).velocityCenter(); }
362
363private:
364 const ElementContext& elemCtx_;
365};
366
372template <class TypeTag>
374{
377
378 using ResultRawType = decltype(IntensiveQuantities().velocityCenter()[0]);
379
380public:
381 using ResultType = std::remove_const_t<std::remove_reference_t<ResultRawType>>;
382 using ResultValueType = typename MathToolbox<ResultType>::ValueType;
383
384 explicit VelocityComponentCallback(const ElementContext& elemCtx)
385 : elemCtx_(elemCtx)
386 { Valgrind::SetUndefined(dimIdx_); }
387
388 VelocityComponentCallback(const ElementContext& elemCtx, unsigned dimIdx)
389 : elemCtx_(elemCtx)
390 , dimIdx_(dimIdx)
391 {}
392
397 void setDimIndex(unsigned dimIdx)
398 { dimIdx_ = dimIdx; }
399
404 ResultType operator()(unsigned dofIdx) const
405 {
406 Valgrind::CheckDefined(dimIdx_);
407 return elemCtx_.intensiveQuantities(dofIdx, /*timeIdx=*/0).velocityCenter()[dimIdx_];
408 }
409
410private:
411 const ElementContext& elemCtx_;
412 unsigned dimIdx_;
413};
414
420template <class TypeTag>
422{
425
426 using IQFluidState = decltype(std::declval<IntensiveQuantities>().fluidState());
427 using ResultRawType = decltype(std::declval<IQFluidState>().moleFraction(0, 0));
428
429public:
430 using ResultType = std::remove_const_t<std::remove_reference_t<ResultRawType>>;
431 using ResultValueType = typename MathToolbox<ResultType>::ValueType;
432
433 explicit MoleFractionCallback(const ElementContext& elemCtx)
434 : elemCtx_(elemCtx)
435 {
436 Valgrind::SetUndefined(phaseIdx_);
437 Valgrind::SetUndefined(compIdx_);
438 }
439
440 MoleFractionCallback(const ElementContext& elemCtx, unsigned phaseIdx, unsigned compIdx)
441 : elemCtx_(elemCtx)
442 , phaseIdx_(static_cast<unsigned short>(phaseIdx))
443 , compIdx_(static_cast<unsigned short>(compIdx))
444 {}
445
450 void setPhaseIndex(unsigned phaseIdx)
451 { phaseIdx_ = static_cast<unsigned short>(phaseIdx); }
452
457 void setComponentIndex(unsigned compIdx)
458 { compIdx_ = static_cast<unsigned short>(compIdx); }
459
464 ResultType operator()(unsigned dofIdx) const
465 {
466 Valgrind::CheckDefined(phaseIdx_);
467 Valgrind::CheckDefined(compIdx_);
468 return elemCtx_.intensiveQuantities(dofIdx, /*timeIdx=*/0).fluidState().moleFraction(phaseIdx_, compIdx_);
469 }
470
471private:
472 const ElementContext& elemCtx_;
473 unsigned short phaseIdx_;
474 unsigned short compIdx_;
475};
476
477} // namespace Opm
478
479#endif
Callback class for a phase pressure.
Definition: quantitycallbacks.hh:134
IQScalar ResultType
Definition: quantitycallbacks.hh:144
BoundaryPressureCallback(const ElementContext &elemCtx, const FluidState &boundaryFs, unsigned phaseIdx)
Definition: quantitycallbacks.hh:151
BoundaryPressureCallback(const ElementContext &elemCtx, const FluidState &boundaryFs)
Definition: quantitycallbacks.hh:146
IQScalar boundaryValue() const
Definition: quantitycallbacks.hh:176
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
Callback class for the density of a phase.
Definition: quantitycallbacks.hh:195
void setPhaseIndex(unsigned phaseIdx)
Set the index of the fluid phase for which the density should be returned.
Definition: quantitycallbacks.hh:219
DensityCallback(const ElementContext &elemCtx, unsigned phaseIdx)
Definition: quantitycallbacks.hh:210
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
typename MathToolbox< ResultType >::ValueType ResultValueType
Definition: quantitycallbacks.hh:204
std::remove_const_t< std::remove_reference_t< ResultRawType > > ResultType
Definition: quantitycallbacks.hh:203
DensityCallback(const ElementContext &elemCtx)
Definition: quantitycallbacks.hh:206
Callback class for the molar density of a phase.
Definition: quantitycallbacks.hh:244
typename MathToolbox< ResultType >::ValueType ResultValueType
Definition: quantitycallbacks.hh:252
decltype(std::declval< IQFluidState >().molarDensity(0)) ResultType
Definition: quantitycallbacks.hh:251
void setPhaseIndex(unsigned phaseIdx)
Set the index of the fluid phase for which the molar density should be returned.
Definition: quantitycallbacks.hh:267
MolarDensityCallback(const ElementContext &elemCtx, unsigned phaseIdx)
Definition: quantitycallbacks.hh:258
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
MolarDensityCallback(const ElementContext &elemCtx)
Definition: quantitycallbacks.hh:254
Callback class for a mole fraction of a component in a phase.
Definition: quantitycallbacks.hh:422
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
MoleFractionCallback(const ElementContext &elemCtx, unsigned phaseIdx, unsigned compIdx)
Definition: quantitycallbacks.hh:440
typename MathToolbox< ResultType >::ValueType ResultValueType
Definition: quantitycallbacks.hh:431
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
std::remove_const_t< std::remove_reference_t< ResultRawType > > ResultType
Definition: quantitycallbacks.hh:430
MoleFractionCallback(const ElementContext &elemCtx)
Definition: quantitycallbacks.hh:433
Callback class for a phase pressure.
Definition: quantitycallbacks.hh:85
PressureCallback(const ElementContext &elemCtx, unsigned phaseIdx)
Definition: quantitycallbacks.hh:100
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
PressureCallback(const ElementContext &elemCtx)
Definition: quantitycallbacks.hh:96
typename MathToolbox< ResultType >::ValueType ResultValueType
Definition: quantitycallbacks.hh:94
std::remove_const_t< std::remove_reference_t< ResultRawType > > ResultType
Definition: quantitycallbacks.hh:93
void setPhaseIndex(unsigned phaseIdx)
Set the index of the fluid phase for which the pressure should be returned.
Definition: quantitycallbacks.hh:109
Callback class for temperature.
Definition: quantitycallbacks.hh:49
ResultType operator()(unsigned dofIdx) const
Return the temperature given the index of a degree of freedom within an element context.
Definition: quantitycallbacks.hh:71
TemperatureCallback(const ElementContext &elemCtx)
Definition: quantitycallbacks.hh:60
std::remove_const_t< std::remove_reference_t< ResultRawType > > ResultType
Definition: quantitycallbacks.hh:57
typename MathToolbox< ResultType >::ValueType ResultValueType
Definition: quantitycallbacks.hh:58
Callback class for the velocity of a phase at the center of a DOF.
Definition: quantitycallbacks.hh:341
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
std::remove_const_t< std::remove_reference_t< ResultRawType > > ResultType
Definition: quantitycallbacks.hh:348
typename ResultType::field_type ResultFieldType
Definition: quantitycallbacks.hh:349
typename MathToolbox< ResultFieldType >::ValueType ResultFieldValueType
Definition: quantitycallbacks.hh:350
VelocityCallback(const ElementContext &elemCtx)
Definition: quantitycallbacks.hh:352
Callback class for the velocity of a phase at the center of a DOF.
Definition: quantitycallbacks.hh:374
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
std::remove_const_t< std::remove_reference_t< ResultRawType > > ResultType
Definition: quantitycallbacks.hh:381
typename MathToolbox< ResultType >::ValueType ResultValueType
Definition: quantitycallbacks.hh:382
VelocityComponentCallback(const ElementContext &elemCtx)
Definition: quantitycallbacks.hh:384
VelocityComponentCallback(const ElementContext &elemCtx, unsigned dimIdx)
Definition: quantitycallbacks.hh:388
Callback class for the viscosity of a phase.
Definition: quantitycallbacks.hh:292
typename MathToolbox< ResultType >::ValueType ResultValueType
Definition: quantitycallbacks.hh:301
ViscosityCallback(const ElementContext &elemCtx, unsigned phaseIdx)
Definition: quantitycallbacks.hh:307
std::remove_const_t< std::remove_reference_t< ResultRawType > > ResultType
Definition: quantitycallbacks.hh:300
ViscosityCallback(const ElementContext &elemCtx)
Definition: quantitycallbacks.hh:303
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.
Definition: blackoilbioeffectsmodules.hh:43
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