opm-simulators
AquiferGridUtils.hpp
1 /*
2  Copyright 2013, 2015 SINTEF ICT, Applied Mathematics.
3  Copyright 2014, 2015 Dr. Blatt - HPC-Simulation-Software & Services
4  Copyright 2014, 2015 Statoil ASA.
5  Copyright 2015 NTNU
6  Copyright 2015, 2016, 2017 IRIS AS
7 
8  This file is part of the Open Porous Media project (OPM).
9 
10  OPM is free software: you can redistribute it and/or modify
11  it under the terms of the GNU General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  OPM is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with OPM. If not, see <http://www.gnu.org/licenses/>.
22 */
23 
24 #ifndef AQUIFER_GRID_UTILS_HEADER_INCLUDED
25 #define AQUIFER_GRID_UTILS_HEADER_INCLUDED
26 
27 #include <opm/grid/CpGrid.hpp>
28 
29 #include <algorithm>
30 #include <vector>
31 
32 namespace Opm {
33 
34 template<class Grid>
36  explicit IsNumericalAquiferCell(const Grid&)
37  {}
38 
39  template<class T>
40  bool operator()(const T&) const { return false; }
41 };
42 
43 template<>
44 struct IsNumericalAquiferCell<Dune::CpGrid> {
45  explicit IsNumericalAquiferCell(const Dune::CpGrid& grid)
46  : grid_(grid)
47  {}
48 
49  template<class T>
50  bool operator()(const T& elem) const
51  {
52  const auto& aquiferCells = grid_.sortedNumAquiferCells();
53  if (aquiferCells.empty())
54  {
55  return false;
56  }
57  auto candidate = std::lower_bound(aquiferCells.begin(),
58  aquiferCells.end(), elem.index());
59  return candidate != aquiferCells.end() && *candidate == elem.index();
60  }
61 
62 private:
63  const Dune::CpGrid& grid_;
64 };
65 
66 } // namespace Opm
67 
68 #endif
Definition: AquiferGridUtils.hpp:35
Definition: fvbaseprimaryvariables.hh:161
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: blackoilbioeffectsmodules.hh:45