opm-grid
Loading...
Searching...
No Matches
Opm::LookUpCartesianData< Grid, GridView > Class Template Reference

LookUpCartesianData - To search field properties of leaf grid view elements via CartesianIndex (cartesianMapper). More...

#include <LookUpData.hh>

Public Member Functions

 LookUpCartesianData (const GridView &gridView, const Dune::CartesianIndexMapper< Grid > &mapper, bool isFieldPropInLgr=false)
 : Constructor taking a GridView, a CartesianIndexMapper, and a bool
template<class ElementOrIndex, class FieldProperties>
auto operator() (const ElementOrIndex &elemIdx, const FieldProperties &fieldProp) const
 : Get field property for an element in the leaf grid view, from a vector, via Cartesian Index.
std::vector< double > assignFieldPropsDoubleOnLeaf (const FieldPropsManager &fieldPropsManager, const std::string &propString) const
 : Get field property of type double from field properties manager by name.
template<typename IntType>
std::vector< IntType > assignFieldPropsIntOnLeaf (const FieldPropsManager &fieldPropsManager, const std::string &propString, const bool &needsTranslation, std::function< void(IntType, int)> valueCheck=[](IntType, int){}) const
 : Get field property of type int from field properties manager by name.
template<typename ElemOrIndex>
double fieldPropDouble (const FieldPropsManager &fieldPropsManager, const std::string &propString, const ElemOrIndex &elemOrIndex) const
 : Get property of type double from field properties manager by name, via element or its index.
template<typename ElemOrIndex>
int fieldPropInt (const FieldPropsManager &fieldPropsManager, const std::string &propString, const ElemOrIndex &elemOrIndex) const
 : Get property of type int from field properties manager by name, via element or its index.
template<class ElementType>
auto getFieldPropCartesianIdx (const ElementType &elemIdx) const
 Calls getFieldPropCartesianIdx<Grid, ElementType>(elemIdx).
template<class GridType, class ElementType>
auto getFieldPropCartesianIdx (const ElementType &elemIdx) const
 Return the cartesian index used to retrieve field properties, depending on whether the grid is a CpGrid or another type of grid (with no LGR).
template<typename IndexType, typename FieldPropType>
auto operator() (const IndexType &elementOrIndex, const FieldPropType &fieldProp) const
 LookUpCartesianData.

Protected Attributes

const GridView & gridView_
Dune::MultipleCodimMultipleGeomTypeMapper< GridView > elemMapper_
const Dune::CartesianIndexMapper< Grid > * cartMapper_
bool isFieldPropInLgr_

Detailed Description

template<typename Grid, typename GridView>
class Opm::LookUpCartesianData< Grid, GridView >

LookUpCartesianData - To search field properties of leaf grid view elements via CartesianIndex (cartesianMapper).

Instead of using a specialitation for Dune::CpGrid, we implement std::enable_if to overload methods with different definitions: for Dune:CpGrid and for other Grid types. An auxiliary defualt template parameter (GridType = Grid) is added to deal with the dependent names at template instantiation.

Constructor & Destructor Documentation

◆ LookUpCartesianData()

template<typename Grid, typename GridView>
Opm::LookUpCartesianData< Grid, GridView >::LookUpCartesianData ( const GridView & gridView,
const Dune::CartesianIndexMapper< Grid > & mapper,
bool isFieldPropInLgr = false )
inlineexplicit

: Constructor taking a GridView, a CartesianIndexMapper, and a bool

Parameters
[in]gridView
[in]mapperDune::CartesianIndexMapper<Grid>.
[in]isFieldPropInLgrbool: default false (search field property in unrefined grid) true (search field property in refined grid; LGR-id/level required) Currently, isFieldPropInLgr_ == false means that all the field properties are given in the unrefined grid (level 0).

Member Function Documentation

◆ getFieldPropCartesianIdx()

template<typename Grid, typename GridView>
template<typename GridType, typename ElementType>
auto Opm::LookUpCartesianData< Grid, GridView >::getFieldPropCartesianIdx ( const ElementType & elemIdx) const

Return the cartesian index used to retrieve field properties, depending on whether the grid is a CpGrid or another type of grid (with no LGR).

This method determines the correct cartesian index under two main conditions:

  • Non-CpGrid: If GridType is not Dune::CpGrid, the cartesian index is obtained via cartMapper_->cartesianIndex(...). The function asserts that maxLevel() == 0, i.e., no local grid refinements (LGR).
  • CpGrid: For CpGrid, if isFieldPropInLgr_ is true and the element resides on a refined level (> 0), then its cartesian index is taken from the LGR-level entity. Otherwise, the index is derived from the origin (level 0) entity through cartMapper_ after mapping the underlying entity index.
Template Parameters
GridTypeAuxiliary type used to specialize the method for CpGrid vs. other grids. If GridType = Dune::CpGrid, local grid refinements (LGR) are considered; otherwise, LGR is not supported.
ElementTypethe type of the element or index passed in.
Parameters
elemIdxAn integral cell index or a grid entity (EntityType) used to compute the cartesian index. For CpGrid, if an integral index is passed, the method creates a Dune::cpgrid::Entity on the fly. Otherwise, it uses the provided entity.
Returns
The integer cartesian index to be used for looking up the relevant field properties. For non-CpGrid, it is simply the mapped index via cartMapper_->cartesianIndex(...). For CpGrid, it can be the LGR-based cartesian index if isFieldPropInLgr_ and the element is refined, or the origin-based cartesian index otherwise.
Note
For non-CpGrid use-cases, the method asserts that maxLevel() == 0, since local grid refinements are only supported for CpGrid.

◆ operator()()

template<typename Grid, typename GridView>
template<class ElementOrIndex, class FieldProperties>
auto Opm::LookUpCartesianData< Grid, GridView >::operator() ( const ElementOrIndex & elemIdx,
const FieldProperties & fieldProp ) const

: Get field property for an element in the leaf grid view, from a vector, via Cartesian Index.

   For general grids, the field property vector is assumed to be given for the gridView_.
   For CpGrid, the field property vector is assumed to be given for level 0 when isFieldPropLgr_ == false,
   and for certain LGR/level > 0 when isFieldPropLgr_ == true.
Template Parameters
ElementOrIndexthe type of the element or index passed in.
FieldPropertiesthe type of the field properties vector. Should be an std::vector like type.

The documentation for this class was generated from the following file: