thresholdPressures.hpp
Go to the documentation of this file.
1 /*
2  Copyright 2014 SINTEF ICT, Applied Mathematics.
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 3 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 
20 #ifndef OPM_THRESHOLDPRESSURES_HEADER_INCLUDED
21 #define OPM_THRESHOLDPRESSURES_HEADER_INCLUDED
22 
23 #include <vector>
24 #include <opm/parser/eclipse/EclipseState/SimulationConfig/SimulationConfig.hpp>
25 #include <opm/parser/eclipse/EclipseState/SimulationConfig/ThresholdPressure.hpp>
26 #include <opm/parser/eclipse/Parser/ParseMode.hpp>
27 
28 
29 namespace Opm
30 {
31 
47 
48 
49 
50  template <class Grid>
51  std::vector<double> thresholdPressures(const ParseMode& parseMode ,EclipseStateConstPtr eclipseState, const Grid& grid)
52  {
53  SimulationConfigConstPtr simulationConfig = eclipseState->getSimulationConfig();
54  std::vector<double> thpres_vals;
55  if (simulationConfig->hasThresholdPressure()) {
56  std::shared_ptr<const ThresholdPressure> thresholdPressure = simulationConfig->getThresholdPressure();
57  std::shared_ptr<GridProperty<int>> eqlnum = eclipseState->getIntGridProperty("EQLNUM");
58  auto eqlnumData = eqlnum->getData();
59 
60  // Set values for each face.
61  const int num_faces = UgGridHelpers::numFaces(grid);
62  thpres_vals.resize(num_faces, 0.0);
63  const int* gc = UgGridHelpers::globalCell(grid);
64  auto fc = UgGridHelpers::faceCells(grid);
65  for (int face = 0; face < num_faces; ++face) {
66  const int c1 = fc(face, 0);
67  const int c2 = fc(face, 1);
68  if (c1 < 0 || c2 < 0) {
69  // Boundary face, skip this.
70  continue;
71  }
72  const int gc1 = (gc == 0) ? c1 : gc[c1];
73  const int gc2 = (gc == 0) ? c2 : gc[c2];
74  const int eq1 = eqlnumData[gc1];
75  const int eq2 = eqlnumData[gc2];
76 
77  if (thresholdPressure->hasRegionBarrier(eq1,eq2)) {
78  if (thresholdPressure->hasThresholdPressure(eq1,eq2)) {
79  thpres_vals[face] = thresholdPressure->getThresholdPressure(eq1,eq2);
80  } else {
81  std::string msg = "Initializing the THPRES pressure values from the initial state is not supported - using 0.0";
82  parseMode.handleError( ParseMode::UNSUPPORTED_INITIAL_THPRES , msg );
83  }
84  }
85  }
86  }
87  return thpres_vals;
88  }
89 }
90 
91 #endif // OPM_THRESHOLDPRESSURES_HEADER_INCLUDED
FaceCellTraits< UnstructuredGrid >::Type faceCells(const UnstructuredGrid &grid)
Get the face to cell mapping of a grid.
Definition: AnisotropicEikonal.hpp:43
int numFaces(const UnstructuredGrid &grid)
Get the number of faces of a grid.
std::vector< double > thresholdPressures(const ParseMode &parseMode, EclipseStateConstPtr eclipseState, const Grid &grid)
Get a vector of pressure thresholds from EclipseState. This function looks at EQLOPTS, THPRES and EQLNUM to determine pressure thresholds. It does not consider the case where the threshold values are defaulted, in which case they should be determined from the initial, equilibrated simulation state.
Definition: thresholdPressures.hpp:51
const int * globalCell(const UnstructuredGrid &grid)
Get the local to global index mapping.
const UnstructuredGrid & grid
Definition: ColumnExtract.hpp:31