opm-common
Opm::NNCCollection Class Reference

Public Member Functions

 NNCCollection ()
 Default constructor: the global grid (grid 0) always exists, initially with an empty NNC container. More...
 
 NNCCollection (NNCDataContainer nnc_global)
 Constructs an NNCCollection pre-populated with nnc_global as the global (grid 0) same-grid NNC. More...
 
void addNNC (std::size_t grid1, std::size_t grid2, NNCDataContainerDiffGrid nnc)
 Add a cross-grid NNC between grid1 and grid2. More...
 
void addNNC (std::size_t grid, NNCDataContainer nnc)
 Add a same-grid NNC for the given grid index. More...
 
void addNNC (NNCDataContainer nnc)
 Add the global (main-grid) NNC. Equivalent to addNNC(0, nnc). More...
 
const NNCDataContainerDiffGridgetNNC (std::size_t grid1, std::size_t grid2) const
 Returns a const reference to the cross-grid NNC for the (grid1, grid2) pair. More...
 
NNCDataContainerDiffGridgetNNC (std::size_t grid1, std::size_t grid2)
 Returns a mutable reference to the cross-grid NNC for the (grid1, grid2) pair.
 
bool hasCrossGridNNC (std::size_t grid1, std::size_t grid2) const
 
bool empty () const
 Returns true if the collection holds no NNC data of any kind. More...
 
const NNCDataContainergetNNC (std::size_t grid) const
 Returns a const reference to the same-grid NNC for grid. More...
 
NNCDataContainergetNNC (std::size_t grid)
 Returns a mutable reference to the same-grid NNC for grid.
 
bool hasSameGridNNC (std::size_t grid) const
 
const NNCDataContainergetGlobalNNC () const
 Returns a const reference to the global (grid 0) same-grid NNC. More...
 
NNCDataContainergetGlobalNNC ()
 Returns a mutable reference to the global (grid 0) same-grid NNC. More...
 
bool hasGlobalNNC () const
 Returns true if the global grid has actual same-grid NNC data. More...
 
bool hasNNCForGrid (std::size_t grid_index) const
 Returns true if the given grid has any NNC involvement: same-grid NNCs with data, or cross-grid NNCs with any other grid. More...
 
const std::map< std::size_t, NNCDataContainer > & same_grid_nnc () const
 Returns a view of all same-grid NNCs as (grid_index, NNC) pairs.
 
const std::map< std::pair< std::size_t, std::size_t >, NNCDataContainerDiffGrid > & diff_grid_nnc () const
 Returns a view of all cross-grid NNCs keyed by normalised (g1,g2) pairs.
 
bool operator== (const NNCCollection &other) const
 

Static Public Member Functions

static NNCCollection fromLGROutputContainers (const std::vector< std::vector< NNCdata >> &outputNnc, const std::vector< std::vector< NNCdata >> &outputNncGlobalLocal, const std::vector< std::vector< std::vector< NNCdata >>> &outputAmalgamatedNnc)
 Build an NNCCollection from the three output containers produced by EclGenericWriter::exportNncStructure_(). More...
 

Constructor & Destructor Documentation

◆ NNCCollection() [1/2]

Opm::NNCCollection::NNCCollection ( )

Default constructor: the global grid (grid 0) always exists, initially with an empty NNC container.

◆ NNCCollection() [2/2]

Opm::NNCCollection::NNCCollection ( NNCDataContainer  nnc_global)
explicit

Constructs an NNCCollection pre-populated with nnc_global as the global (grid 0) same-grid NNC.

Member Function Documentation

◆ addNNC() [1/3]

void Opm::NNCCollection::addNNC ( std::size_t  grid1,
std::size_t  grid2,
NNCDataContainerDiffGrid  nnc 
)

Add a cross-grid NNC between grid1 and grid2.

Adds a cross-grid NNC between grid1 and grid2.

The key is normalised to (min, max) and cell indices are swapped accordingly. Throws std::runtime_error if an entry for this grid pair already exists.

◆ addNNC() [2/3]

void Opm::NNCCollection::addNNC ( std::size_t  grid,
NNCDataContainer  nnc 
)

Add a same-grid NNC for the given grid index.

Adds a same-grid NNC for grid.

For grid 0 (global), replaces the existing empty entry inserted by the constructor. For all other grids, throws std::runtime_error if an entry already exists.

◆ addNNC() [3/3]

void Opm::NNCCollection::addNNC ( NNCDataContainer  nnc)

Add the global (main-grid) NNC. Equivalent to addNNC(0, nnc).

Replaces the global (grid 0) same-grid NNC.

◆ empty()

bool Opm::NNCCollection::empty ( ) const
inline

Returns true if the collection holds no NNC data of any kind.

Cannot use m_sameGridNNCs.empty() because grid 0 is always present (inserted by the constructor) even when no NNCs have been added. Instead, each same-grid container is checked for actual entries.

◆ fromLGROutputContainers()

NNCCollection Opm::NNCCollection::fromLGROutputContainers ( const std::vector< std::vector< NNCdata >> &  outputNnc,
const std::vector< std::vector< NNCdata >> &  outputNncGlobalLocal,
const std::vector< std::vector< std::vector< NNCdata >>> &  outputAmalgamatedNnc 
)
static

Build an NNCCollection from the three output containers produced by EclGenericWriter::exportNncStructure_().

Builds an NNCCollection from the three output containers produced by EclGenericWriter::exportNncStructure_().

Parameters
outputNncSame-grid NNCs, indexed by grid level. outputNnc[level] holds the NNCs internal to grid level (0 = main grid).
outputNncGlobalLocalGlobal-to-local NNCs, indexed by local level offset. outputNncGlobalLocal[i] holds connections between the main grid (level 0) and the refined level i+1.
outputAmalgamatedNncLGR-to-LGR NNCs, indexed by (smallerLevel-1, largerLevel-smallerLevel-1). outputAmalgamatedNnc[i][j] holds connections between level i+1 and level i+j+2.
Returns
An NNCCollection populated with all three NNC types.

Index convention (matches the layout written by exportNncStructure_):

outputNnc[level] → same-grid NNCs for grid level (0 = main grid).

outputNncGlobalLocal[i] → cross-grid NNCs between main grid (level 0) and level i+1.

outputAmalgamatedNnc[i][j] → cross-grid NNCs between level i+1 and level i+j+2.

◆ getGlobalNNC() [1/2]

const NNCDataContainer & Opm::NNCCollection::getGlobalNNC ( ) const

Returns a const reference to the global (grid 0) same-grid NNC.

Grid 0 is always present (inserted by the constructor); never throws.

◆ getGlobalNNC() [2/2]

NNCDataContainer & Opm::NNCCollection::getGlobalNNC ( )

Returns a mutable reference to the global (grid 0) same-grid NNC.

Grid 0 is always present (inserted by the constructor); never throws.

◆ getNNC() [1/2]

const NNCDataContainerDiffGrid & Opm::NNCCollection::getNNC ( std::size_t  grid1,
std::size_t  grid2 
) const

Returns a const reference to the cross-grid NNC for the (grid1, grid2) pair.

Grid order is normalised automatically. Throws std::runtime_error if no entry exists.

◆ getNNC() [2/2]

const NNCDataContainer & Opm::NNCCollection::getNNC ( std::size_t  grid) const

Returns a const reference to the same-grid NNC for grid.

Throws std::runtime_error if no entry exists.

◆ hasGlobalNNC()

bool Opm::NNCCollection::hasGlobalNNC ( ) const
inline

Returns true if the global grid has actual same-grid NNC data.

Grid 0 always exists in the collection; this checks whether it is non-empty (i.e. NNCs were explicitly added for the global grid).

◆ hasNNCForGrid()

bool Opm::NNCCollection::hasNNCForGrid ( std::size_t  grid_index) const
inline

Returns true if the given grid has any NNC involvement: same-grid NNCs with data, or cross-grid NNCs with any other grid.


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