stokesextensivequantities.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) 2011-2013 by Andreas Lauser
5  Copyright (C) 2012 by Klaus Mosthaf
6 
7  This file is part of the Open Porous Media project (OPM).
8 
9  OPM is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 2 of the License, or
12  (at your option) any later version.
13 
14  OPM is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with OPM. If not, see <http://www.gnu.org/licenses/>.
21 */
27 #ifndef EWOMS_STOKES_EXTENSIVE_QUANTITIES_HH
28 #define EWOMS_STOKES_EXTENSIVE_QUANTITIES_HH
29 
30 #include "stokesproperties.hh"
31 
34 
35 #include <opm/material/common/Valgrind.hpp>
36 
37 #include <dune/common/fvector.hh>
38 
39 namespace Ewoms {
40 
51 template <class TypeTag>
53  : public EnergyExtensiveQuantities<TypeTag, GET_PROP_VALUE(TypeTag, EnableEnergy)>
54 {
55  typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
56  typedef typename GET_PROP_TYPE(TypeTag, GridView) GridView;
57  typedef typename GET_PROP_TYPE(TypeTag, FluidSystem) FluidSystem;
58  typedef typename GET_PROP_TYPE(TypeTag, ElementContext) ElementContext;
59 
60  enum { dimWorld = GridView::dimensionworld };
61  enum { phaseIdx = GET_PROP_VALUE(TypeTag, StokesPhaseIndex) };
62  enum { enableEnergy = GET_PROP_VALUE(TypeTag, EnableEnergy) };
63 
64  typedef Dune::FieldVector<Scalar, dimWorld> DimVector;
66 
67 public:
71  static void registerParameters()
72  {}
73 
84  void update(const ElementContext &elemCtx, int scvfIdx, int timeIdx, bool isBoundaryFace=false)
85  {
86  const auto &stencil = elemCtx.stencil(timeIdx);
87  const auto &scvf =
88  isBoundaryFace?
89  stencil.boundaryFace(scvfIdx):
90  stencil.interiorFace(scvfIdx);
91 
92  insideIdx_ = scvf.interiorIndex();
93  outsideIdx_ = scvf.exteriorIndex();
94 
95  onBoundary_ = isBoundaryFace;
96  normal_ = scvf.normal();
97  Valgrind::CheckDefined(normal_);
98 
99  // calculate gradients and secondary variables at IPs
100  const auto& gradCalc = elemCtx.gradientCalculator();
101  PressureCallback<TypeTag> pressureCallback(elemCtx, phaseIdx);
102  DensityCallback<TypeTag> densityCallback(elemCtx, phaseIdx);
103  MolarDensityCallback<TypeTag> molarDensityCallback(elemCtx, phaseIdx);
104  ViscosityCallback<TypeTag> viscosityCallback(elemCtx, phaseIdx);
105  VelocityCallback<TypeTag> velocityCallback(elemCtx);
106  VelocityComponentCallback<TypeTag> velocityComponentCallback(elemCtx);
107 
108  pressure_ = gradCalc.calculateValue(elemCtx, scvfIdx, pressureCallback);
109  gradCalc.calculateGradient(pressureGrad_, elemCtx, scvfIdx, pressureCallback);
110  density_ = gradCalc.calculateValue(elemCtx, scvfIdx, densityCallback);
111  molarDensity_ = gradCalc.calculateValue(elemCtx, scvfIdx, molarDensityCallback);
112  viscosity_ = gradCalc.calculateValue(elemCtx, scvfIdx, viscosityCallback);
113  velocity_ = gradCalc.calculateValue(elemCtx, scvfIdx, velocityCallback);
114 
115  for (int dimIdx = 0; dimIdx < dimWorld; ++dimIdx) {
116  velocityComponentCallback.setDimIndex(dimIdx);
117  gradCalc.calculateGradient(velocityGrad_[dimIdx],
118  elemCtx,
119  scvfIdx,
120  velocityComponentCallback);
121  }
122 
123  volumeFlux_ = (velocity_ * normal_);
124  Valgrind::CheckDefined(volumeFlux_);
125 
126  // set the upstream and downstream DOFs
127  upstreamIdx_ = scvf.interiorIndex();
128  downstreamIdx_ = scvf.exteriorIndex();
129  if (volumeFlux_ < 0)
130  std::swap(upstreamIdx_, downstreamIdx_);
131 
132  EnergyExtensiveQuantities::update_(elemCtx, scvfIdx, timeIdx);
133 
134  Valgrind::CheckDefined(density_);
135  Valgrind::CheckDefined(viscosity_);
136  Valgrind::CheckDefined(velocity_);
137  Valgrind::CheckDefined(pressureGrad_);
138  Valgrind::CheckDefined(velocityGrad_);
139  }
140 
144  template <class Context, class FluidState>
145  void updateBoundary(const Context &context, int bfIdx, int timeIdx,
146  const FluidState &fluidState,
147  typename FluidSystem::ParameterCache &paramCache)
148  {
149  update(context, bfIdx, timeIdx, fluidState, paramCache,
150  /*isOnBoundary=*/true);
151  }
152 
157  Scalar pressure() const
158  { return pressure_; }
159 
165  Scalar density() const
166  { return density_; }
167 
172  Scalar molarDensity() const
173  { return molarDensity_; }
174 
179  Scalar viscosity() const
180  { return viscosity_; }
181 
185  const DimVector &pressureGrad() const
186  { return pressureGrad_; }
187 
191  const DimVector &velocity() const
192  { return velocity_; }
193 
198  const DimVector &velocityGrad(int axisIdx) const
199  { return velocityGrad_[axisIdx]; }
200 
204  Scalar eddyViscosity() const
205  { return 0; }
206 
210  Scalar eddyDiffusivity() const
211  { return 0; }
212 
216  Scalar volumeFlux(int phaseIdx) const
217  { return volumeFlux_; }
218 
222  Scalar upstreamWeight(int phaseIdx) const
223  { return 1.0; }
224 
228  Scalar downstreamWeight(int phaseIdx) const
229  { return 0.0; }
230 
234  int upstreamIndex(int phaseIdx) const
235  { return upstreamIdx_; }
236 
240  int downstreamIndex(int phaseIdx) const
241  { return downstreamIdx_; }
242 
247  int interiorIndex() const
248  { return insideIdx_; }
249 
254  int exteriorIndex() const
255  { return outsideIdx_; }
256 
261  bool onBoundary() const
262  { return onBoundary_; }
263 
267  Scalar extrusionFactor() const
268  { return 1.0; }
269 
273  const DimVector &normal() const
274  { return normal_; }
275 
276 private:
277  bool onBoundary_;
278 
279  // values at the integration point
280  Scalar density_;
281  Scalar molarDensity_;
282  Scalar viscosity_;
283  Scalar pressure_;
284  Scalar volumeFlux_;
285  DimVector velocity_;
286  DimVector normal_;
287 
288  // gradients at the IPs
289  DimVector pressureGrad_;
290  DimVector velocityGrad_[dimWorld];
291 
292  // local index of the upstream dof
293  int upstreamIdx_;
294  // local index of the downstream dof
295  int downstreamIdx_;
296 
297  int insideIdx_;
298  int outsideIdx_;
299 };
300 
301 } // namespace Ewoms
302 
303 #endif
Callback class for the molar density of a phase.
Definition: quantitycallbacks.hh:233
bool onBoundary() const
Indicates if a face is on a boundary. Used for in the face() method (e.g. for outflow boundary condit...
Definition: stokesextensivequantities.hh:261
Declares the properties required by the Stokes model.
Provides the quantities required to calculate energy fluxes.
Definition: energymodule.hh:695
Scalar eddyDiffusivity() const
Return the eddy diffusivity (if implemented).
Definition: stokesextensivequantities.hh:210
int interiorIndex() const
Return the local index of the sub-control volume which is located in negative normal direction...
Definition: stokesextensivequantities.hh:247
static void registerParameters()
Register all run-time parameters for the extensive quantities.
Definition: stokesextensivequantities.hh:71
#define GET_PROP_VALUE(TypeTag, PropTagName)
Access the value attribute of a property for a type tag.
Definition: propertysystem.hh:468
Scalar eddyViscosity() const
Return the eddy viscosity (if implemented).
Definition: stokesextensivequantities.hh:204
Scalar volumeFlux(int phaseIdx) const
Return the volume flux of mass.
Definition: stokesextensivequantities.hh:216
void update(const ElementContext &elemCtx, int scvfIdx, int timeIdx, bool isBoundaryFace=false)
Update all quantities which are required on an intersection between two finite volumes.
Definition: stokesextensivequantities.hh:84
Scalar upstreamWeight(int phaseIdx) const
Return the weight of the upstream index.
Definition: stokesextensivequantities.hh:222
int downstreamIndex(int phaseIdx) const
Return the local index of the downstream sub-control volume.
Definition: stokesextensivequantities.hh:240
void updateBoundary(const Context &context, int bfIdx, int timeIdx, const FluidState &fluidState, typename FluidSystem::ParameterCache &paramCache)
Update the extensive quantities for a given boundary face.
Definition: stokesextensivequantities.hh:145
void setDimIndex(short dimIdx)
Set the index of the component of the velocity which should be returned.
Definition: quantitycallbacks.hh:378
const DimVector & normal() const
Returns normal vector of the face of the extensive quantities.
Definition: stokesextensivequantities.hh:273
Callback class for the density of a phase.
Definition: quantitycallbacks.hh:186
Definition: baseauxiliarymodule.hh:35
Scalar viscosity() const
Return the viscosity at the integration point.
Definition: stokesextensivequantities.hh:179
Callback class for a phase pressure.
Definition: quantitycallbacks.hh:78
const DimVector & pressureGrad() const
Return the pressure gradient at the integration point.
Definition: stokesextensivequantities.hh:185
const DimVector & velocity() const
Return the velocity vector at the integration point.
Definition: stokesextensivequantities.hh:191
Contains the data which is required to calculate the mass and momentum fluxes over the face of a sub-...
Definition: stokesextensivequantities.hh:52
Callback class for the velocity of a phase at the center of a DOF.
Definition: quantitycallbacks.hh:327
This method contains all callback classes for quantities that are required by some extensive quantiti...
Scalar downstreamWeight(int phaseIdx) const
Return the weight of the downstream index.
Definition: stokesextensivequantities.hh:228
Callback class for the viscosity of a phase.
Definition: quantitycallbacks.hh:280
Scalar molarDensity() const
Return the molar density at the integration point.
Definition: stokesextensivequantities.hh:172
Scalar pressure() const
Return the pressure at the integration point.
Definition: stokesextensivequantities.hh:157
Scalar extrusionFactor() const
Returns the extrusionFactor of the face.
Definition: stokesextensivequantities.hh:267
Scalar density() const
Return the mass density at the integration point.
Definition: stokesextensivequantities.hh:165
int exteriorIndex() const
Return the local index of the sub-control volume which is located in negative normal direction...
Definition: stokesextensivequantities.hh:254
int upstreamIndex(int phaseIdx) const
Return the local index of the upstream sub-control volume.
Definition: stokesextensivequantities.hh:234
const DimVector & velocityGrad(int axisIdx) const
Return the velocity gradient at the integration point of a face.
Definition: stokesextensivequantities.hh:198
Callback class for the velocity of a phase at the center of a DOF.
Definition: quantitycallbacks.hh:357
Contains the classes required to consider energy as a conservation quantity in a multi-phase module...