opm-simulators
discretefracturelocalresidual.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 */
28 #ifndef EWOMS_DISCRETE_FRACTURE_LOCAL_RESIDUAL_BASE_HH
29 #define EWOMS_DISCRETE_FRACTURE_LOCAL_RESIDUAL_BASE_HH
30 
32 
33 namespace Opm {
34 
41 template <class TypeTag>
43 {
45 
51 
52  enum { conti0EqIdx = Indices::conti0EqIdx };
53  enum { numPhases = getPropValue<TypeTag, Properties::NumPhases>() };
54  enum { enableEnergy = getPropValue<TypeTag, Properties::EnableEnergy>() };
55 
57 
58 public:
67  void addPhaseStorage(EqVector& storage,
68  const ElementContext& elemCtx,
69  unsigned dofIdx,
70  unsigned timeIdx,
71  unsigned phaseIdx) const
72  {
73  EqVector phaseStorage(0.0);
74  ParentType::addPhaseStorage(phaseStorage, elemCtx, dofIdx, timeIdx, phaseIdx);
75 
76  const auto& problem = elemCtx.problem();
77  const auto& fractureMapper = problem.fractureMapper();
78  const unsigned globalIdx = elemCtx.globalSpaceIndex(dofIdx, timeIdx);
79 
80  if (!fractureMapper.isFractureVertex(globalIdx)) {
81  // don't do anything in addition to the immiscible model for degrees of
82  // freedom that do not feature fractures
83  storage += phaseStorage;
84  return;
85  }
86 
87  const auto& intQuants = elemCtx.intensiveQuantities(dofIdx, timeIdx);
88  const auto& scv = elemCtx.stencil(timeIdx).subControlVolume(dofIdx);
89 
90  // reduce the matrix storage by the fracture volume
91  phaseStorage *= 1 - intQuants.fractureVolume() / scv.volume();
92 
93  // add the storage term inside the fractures
94  const auto& fsFracture = intQuants.fractureFluidState();
95 
96  phaseStorage[conti0EqIdx + phaseIdx] +=
97  intQuants.fracturePorosity() *
98  fsFracture.saturation(phaseIdx) *
99  fsFracture.density(phaseIdx) *
100  intQuants.fractureVolume() / scv.volume();
101 
102  EnergyModule::addFracturePhaseStorage(phaseStorage, intQuants, scv,
103  phaseIdx);
104 
105  // add the result to the overall storage term
106  storage += phaseStorage;
107  }
108 
112  void computeFlux(RateVector& flux,
113  const ElementContext& elemCtx,
114  unsigned scvfIdx,
115  unsigned timeIdx) const
116  {
117  ParentType::computeFlux(flux, elemCtx, scvfIdx, timeIdx);
118 
119  const auto& extQuants = elemCtx.extensiveQuantities(scvfIdx, timeIdx);
120 
121  const unsigned i = extQuants.interiorIndex();
122  const unsigned j = extQuants.exteriorIndex();
123  const unsigned I = elemCtx.globalSpaceIndex(i, timeIdx);
124  const unsigned J = elemCtx.globalSpaceIndex(j, timeIdx);
125  const auto& fractureMapper = elemCtx.problem().fractureMapper();
126  if (!fractureMapper.isFractureEdge(I, J)) {
127  // do nothing if the edge from i to j is not part of a
128  // fracture
129  return;
130  }
131 
132  const auto& scvf = elemCtx.stencil(timeIdx).interiorFace(scvfIdx);
133  const Scalar scvfArea = scvf.area();
134 
135  // advective mass fluxes of all phases
136  for (unsigned phaseIdx = 0; phaseIdx < numPhases; ++phaseIdx) {
137  if (!elemCtx.model().phaseIsConsidered(phaseIdx)) {
138  continue;
139  }
140 
141  // reduce the matrix mass flux by the width of the scv
142  // face that is occupied by the fracture. As usual, the
143  // fracture is shared between two SCVs, so the its width
144  // needs to be divided by two.
145  flux[conti0EqIdx + phaseIdx] *=
146  1 - extQuants.fractureWidth() / (2 * scvfArea);
147 
148  // intensive quantities of the upstream and the downstream DOFs
149  const unsigned upIdx = static_cast<unsigned>(extQuants.upstreamIndex(phaseIdx));
150  const auto& up = elemCtx.intensiveQuantities(upIdx, timeIdx);
151  flux[conti0EqIdx + phaseIdx] +=
152  extQuants.fractureVolumeFlux(phaseIdx) * up.fractureFluidState().density(phaseIdx);
153  }
154 
155  EnergyModule::handleFractureFlux(flux, elemCtx, scvfIdx, timeIdx);
156  }
157 };
158 
159 } // namespace Opm
160 
161 #endif
void computeFlux(RateVector &flux, const ElementContext &elemCtx, unsigned scvfIdx, unsigned timeIdx) const
Evaluates the total mass flux of all conservation quantities over a face of a sub-control volume...
Definition: immisciblelocalresidual.hh:114
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
Calculates the local residual of the discrete fracture immiscible multi-phase model.
Definition: discretefracturelocalresidual.hh:42
void addPhaseStorage(EqVector &storage, const ElementContext &elemCtx, unsigned dofIdx, unsigned timeIdx, unsigned phaseIdx) const
Adds the amount all conservation quantities (e.g.
Definition: discretefracturelocalresidual.hh:67
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: blackoilbioeffectsmodules.hh:45
void addPhaseStorage(Dune::FieldVector< LhsEval, numEq > &storage, const ElementContext &elemCtx, unsigned dofIdx, unsigned timeIdx, unsigned phaseIdx) const
Adds the amount all conservation quantities (e.g.
Definition: immisciblelocalresidual.hh:76
Calculates the local residual of the immiscible multi-phase model.
Definition: immisciblelocalresidual.hh:45
void computeFlux(RateVector &flux, const ElementContext &elemCtx, unsigned scvfIdx, unsigned timeIdx) const
Evaluates the total mass flux of all conservation quantities over a face of a sub-control volume...
Definition: discretefracturelocalresidual.hh:112
Provides the auxiliary methods required for consideration of the energy equation. ...
Definition: energymodule.hh:54
Calculates the local residual of the immiscible multi-phase model.