fvbaseintensivequantities.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  Copyright (C) 2008-2013 by Andreas Lauser
5 
6  This file is part of the Open Porous Media project (OPM).
7 
8  OPM is free software: you can redistribute it and/or modify
9  it under the terms of the GNU General Public License as published by
10  the Free Software Foundation, either version 2 of the License, or
11  (at your option) any later version.
12 
13  OPM is distributed in the hope that it will be useful,
14  but WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with OPM. If not, see <http://www.gnu.org/licenses/>.
20 */
26 #ifndef EWOMS_FV_BASE_INTENSIVE_QUANTITIES_HH
27 #define EWOMS_FV_BASE_INTENSIVE_QUANTITIES_HH
28 
29 #include "fvbaseproperties.hh"
30 
31 #include <opm/material/common/Valgrind.hpp>
32 
33 namespace Ewoms {
34 
41 template <class TypeTag>
43 {
44  typedef typename GET_PROP_TYPE(TypeTag, IntensiveQuantities) Implementation;
45  typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
46  typedef typename GET_PROP_TYPE(TypeTag, ElementContext) ElementContext;
47 
48 public:
49  // default constructor
51  { evalPoint_ = 0; }
52 
53  // copy constructor
55  {
56  evalPoint_ = 0;
57  extrusionFactor_ = v.extrusionFactor_;
58  }
59 
64  {
65  evalPoint_ = 0;
66  extrusionFactor_ = v.extrusionFactor_;
67 
68  return *this;
69  }
70 
74  static void registerParameters()
75  { }
76 
84  void setEvalPoint(const Implementation *ep)
85  {
86  evalPoint_ = ep;
87  Valgrind::CheckDefined(evalPoint_);
88  }
89 
95  const Implementation &evalPoint() const
96  { return (evalPoint_ == 0)?asImp_():*evalPoint_; }
97 
101  void update(const ElementContext &elemCtx,
102  int dofIdx,
103  int timeIdx)
104  { extrusionFactor_ = elemCtx.problem().extrusionFactor(elemCtx, dofIdx, timeIdx); }
105 
115  void updateScvGradients(const ElementContext &elemCtx,
116  int dofIdx,
117  int timeIdx)
118  { }
119 
129  Scalar extrusionFactor() const
130  { return extrusionFactor_; }
131 
136  void checkDefined() const
137  {
138 #if !defined NDEBUG && HAVE_VALGRIND
139  Valgrind::CheckDefined(evalPoint_);
140  if (evalPoint_ && evalPoint_ != this)
141  evalPoint_->checkDefined();
142 #endif
143  }
144 
145 private:
146  const Implementation &asImp_() const
147  { return *static_cast<const Implementation*>(this); }
148  Implementation &asImp_()
149  { return *static_cast<Implementation*>(this); }
150 
151  // the evaluation point of the local jacobian
152  const Implementation *evalPoint_;
153 
154  Scalar extrusionFactor_;
155 };
156 
157 } // namespace Ewoms
158 
159 #endif
Scalar extrusionFactor() const
Return how much a given sub-control volume is extruded.
Definition: fvbaseintensivequantities.hh:129
FvBaseIntensiveQuantities(const FvBaseIntensiveQuantities &v)
Definition: fvbaseintensivequantities.hh:54
const Implementation & evalPoint() const
Returns the evaluation point used by the local jacobian.
Definition: fvbaseintensivequantities.hh:95
Declare the properties used by the infrastructure code of the finite volume discretizations.
void updateScvGradients(const ElementContext &elemCtx, int dofIdx, int timeIdx)
Update all gradients for a given control volume.
Definition: fvbaseintensivequantities.hh:115
FvBaseIntensiveQuantities & operator=(const FvBaseIntensiveQuantities &v)
Assignment operator.
Definition: fvbaseintensivequantities.hh:63
Definition: baseauxiliarymodule.hh:35
Base class for the model specific class which provides access to all intensive (i.e., volume averaged) quantities.
Definition: fvbaseintensivequantities.hh:42
FvBaseIntensiveQuantities()
Definition: fvbaseintensivequantities.hh:50
void update(const ElementContext &elemCtx, int dofIdx, int timeIdx)
Update all quantities for a given control volume.
Definition: fvbaseintensivequantities.hh:101
void checkDefined() const
If running in valgrind this makes sure that all quantities in the intensive quantities are defined...
Definition: fvbaseintensivequantities.hh:136
static void registerParameters()
Register all run-time parameters for the intensive quantities.
Definition: fvbaseintensivequantities.hh:74
void setEvalPoint(const Implementation *ep)
Sets the evaluation point used by the local jacobian.
Definition: fvbaseintensivequantities.hh:84