Loading...
Searching...
No Matches
LookUpCellCentroid.hh
//===========================================================================
//
// File: LookUpCellCentroid.hh
//
// Created: Wed July 26 10:48:00 2023
//
// Author(s): Antonella Ritorto <antonella.ritorto@opm-op.com>
//
//
// $Date$
//
// $Revision$
//
//===========================================================================
/*
Copyright 2023 Equinor ASA.
This file is part of The Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <dune/grid/common/mcmgmapper.hh>
#include <opm/input/eclipse/EclipseState/Grid/EclipseGrid.hpp>
#include <type_traits>
namespace Dune
{
class CpGrid;
}
namespace Opm
{
class EclipseGrid;
template <typename Grid, typename GridView>
struct LookUpCellCentroid
{
explicit LookUpCellCentroid(const GridView& gridView,
const Dune::CartesianIndexMapper<Grid>& cartMapper,
const Opm::EclipseGrid* eclgrid) :
gridView_(gridView),
cartMapper_(&cartMapper),
eclGrid_(eclgrid)
{
}
template<typename GridType = Grid>
typename std::enable_if_t<!std::is_same_v<GridType,Dune::CpGrid>, std::array<double,3>>
operator()(std::size_t elemIdx) const;
// \param [in] elemIdx Element Index.
template<typename GridType = Grid>
typename std::enable_if_t<std::is_same_v<GridType,Dune::CpGrid>, std::array<double,3>>
operator()(std::size_t elemIdx) const;
const GridView& gridView_;
const Dune::CartesianIndexMapper<Grid>* cartMapper_;
const Opm::EclipseGrid* eclGrid_;
}; // end LookUpCellCentroid struct
}
// end namespace Opm
template<typename Grid, typename GridView>
template<typename GridType>
typename std::enable_if_t<!std::is_same_v<GridType,Dune::CpGrid>, std::array<double,3>>
Opm::LookUpCellCentroid<Grid,GridView>::operator()(std::size_t elemIdx) const
{
static_assert(std::is_same_v<Grid,GridType>);
return this -> eclGrid_ -> getCellCenter(this -> cartMapper_->cartesianIndex(elemIdx));
}
template<typename Grid, typename GridView>
template<typename GridType>
typename std::enable_if_t<std::is_same_v<GridType,Dune::CpGrid>,std::array<double,3>>
Opm::LookUpCellCentroid<Grid,GridView>::operator()(std::size_t elemIdx) const
{
static_assert(std::is_same_v<Grid,GridType>);
return this -> gridView_.grid().getEclCentroid(elemIdx); // Warning! might need to be changed, due to issue in simulators
}
Dune::CartesianIndexMapper
Interface class to access the logical Cartesian grid as used in industry standard simulator decks.
Definition CartesianIndexMapper.hpp:16
Dune::CpGrid
[ provides Dune::Grid ]
Definition CpGrid.hpp:203
Dune
The namespace Dune is the main namespace for all Dune code.
Definition CartesianIndexMapper.hpp:10
Opm
Holds the implementation of the CpGrid as a pimple.
Definition CellQuadrature.cpp:68
Opm::LookUpCellCentroid::operator()
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
Opm::LookUpCellCentroid::LookUpCellCentroid
LookUpCellCentroid(const GridView &gridView, const Dune::CartesianIndexMapper< Grid > &cartMapper, const Opm::EclipseGrid *eclgrid)
: Constructor taking a GridView, CartesianMapper
Definition LookUpCellCentroid.hh:65