LookUpCellCentroid.hh
Go to the documentation of this file.
1//===========================================================================
2//
3// File: LookUpCellCentroid.hh
4//
5// Created: Wed July 26 10:48:00 2023
6//
7// Author(s): Antonella Ritorto <antonella.ritorto@opm-op.com>
8//
9//
10// $Date$
11//
12// $Revision$
13//
14//===========================================================================
15
16/*
17 Copyright 2023 Equinor ASA.
18
19 This file is part of The Open Porous Media project (OPM).
20
21 OPM is free software: you can redistribute it and/or modify
22 it under the terms of the GNU General Public License as published by
23 the Free Software Foundation, either version 3 of the License, or
24 (at your option) any later version.
25
26 OPM is distributed in the hope that it will be useful,
27 but WITHOUT ANY WARRANTY; without even the implied warranty of
28 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29 GNU General Public License for more details.
30
31 You should have received a copy of the GNU General Public License
32 along with OPM. If not, see <http://www.gnu.org/licenses/>.
33*/
34
35#include <dune/grid/common/mcmgmapper.hh>
36#include <opm/input/eclipse/EclipseState/Grid/EclipseGrid.hpp>
37
38
39
40#include <type_traits>
41
42namespace Dune
43{
44class CpGrid;
45}
46
47namespace Opm
48{
49
50class EclipseGrid;
51
58template <typename Grid, typename GridView>
60{
65 explicit LookUpCellCentroid(const GridView& gridView,
66 const Dune::CartesianIndexMapper<Grid>& cartMapper,
67 const Opm::EclipseGrid* eclgrid) :
68 gridView_(gridView),
69 cartMapper_(&cartMapper),
70 eclGrid_(eclgrid)
71 {
72 }
73
84 template<typename GridType = Grid>
85 typename std::enable_if_t<!std::is_same_v<GridType,Dune::CpGrid>, std::array<double,3>>
86 operator()(std::size_t elemIdx) const;
87
96 // \param [in] elemIdx Element Index.
98 template<typename GridType = Grid>
99 typename std::enable_if_t<std::is_same_v<GridType,Dune::CpGrid>, std::array<double,3>>
100 operator()(std::size_t elemIdx) const;
101
102
103 const GridView& gridView_;
105 const Opm::EclipseGrid* eclGrid_;
106
107}; // end LookUpCellCentroid struct
108}
109// end namespace Opm
110
111
112template<typename Grid, typename GridView>
113template<typename GridType>
114typename std::enable_if_t<!std::is_same_v<GridType,Dune::CpGrid>, std::array<double,3>>
116{
117 static_assert(std::is_same_v<Grid,GridType>);
118 return this -> eclGrid_ -> getCellCenter(this -> cartMapper_->cartesianIndex(elemIdx));
119}
120
121template<typename Grid, typename GridView>
122template<typename GridType>
123typename std::enable_if_t<std::is_same_v<GridType,Dune::CpGrid>,std::array<double,3>>
125{
126 static_assert(std::is_same_v<Grid,GridType>);
127 return this -> gridView_.grid().getEclCentroid(elemIdx); // Warning! might need to be changed, due to issue in simulators
128}
Interface class to access the logical Cartesian grid as used in industry standard simulator decks.
Definition: common/CartesianIndexMapper.hpp:16
The namespace Dune is the main namespace for all Dune code.
Definition: common/CartesianIndexMapper.hpp:10
Holds the implementation of the CpGrid as a pimple.
Definition: CellQuadrature.hpp:26
Definition: LookUpCellCentroid.hh:60
const Opm::EclipseGrid * eclGrid_
Definition: LookUpCellCentroid.hh:105
const Dune::CartesianIndexMapper< Grid > * cartMapper_
Definition: LookUpCellCentroid.hh:104
std::enable_if_t<!std::is_same_v< GridType, Dune::CpGrid >, std::array< double, 3 > > operator()(std::size_t elemIdx) const
: Call operator
Definition: LookUpCellCentroid.hh:115
LookUpCellCentroid(const GridView &gridView, const Dune::CartesianIndexMapper< Grid > &cartMapper, const Opm::EclipseGrid *eclgrid)
: Constructor taking a GridView, CartesianMapper
Definition: LookUpCellCentroid.hh:65
const GridView & gridView_
Definition: LookUpCellCentroid.hh:103