Skip to content

Commit

Permalink
Guard against reading nnc data if none are available
Browse files Browse the repository at this point in the history
See Issue #278. (Not fixing the issue, just improving code)
  • Loading branch information
JacobStoren committed Feb 24, 2015
1 parent 27ce185 commit 02e47c6
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,26 +474,29 @@ void RifReaderEclipseOutput::transferNNCData( const ecl_grid_type * mainEclGrid
// Get the data from ERT

int numNNC = ecl_nnc_export_get_size( mainEclGrid );
ecl_nnc_type * eclNNCData= new ecl_nnc_type[numNNC];
if (numNNC > 0)
{
ecl_nnc_type * eclNNCData= new ecl_nnc_type[numNNC];

ecl_nnc_export( mainEclGrid , init_file , eclNNCData);
ecl_nnc_export(mainEclGrid, init_file, eclNNCData);

// Transform to our own datastructures
//cvf::Trace::show("Reading NNC. Count: " + cvf::String(numNNC));
// Transform to our own datastructures
//cvf::Trace::show("Reading NNC. Count: " + cvf::String(numNNC));

mainGrid->nncData()->connections().resize(numNNC);
std::vector<double>& transmissibilityValues = mainGrid->nncData()->makeConnectionScalarResult(cvf::UNDEFINED_SIZE_T);
for (int nIdx = 0; nIdx < numNNC; ++nIdx)
{
RigGridBase* grid1 = mainGrid->gridByIndex(eclNNCData[nIdx].grid_nr1);
mainGrid->nncData()->connections()[nIdx].m_c1GlobIdx = grid1->reservoirCellIndex(eclNNCData[nIdx].global_index1);
RigGridBase* grid2 = mainGrid->gridByIndex(eclNNCData[nIdx].grid_nr2);
mainGrid->nncData()->connections()[nIdx].m_c2GlobIdx = grid2->reservoirCellIndex(eclNNCData[nIdx].global_index2);
transmissibilityValues[nIdx] = eclNNCData[nIdx].trans;
}
mainGrid->nncData()->connections().resize(numNNC);
std::vector<double>& transmissibilityValues = mainGrid->nncData()->makeConnectionScalarResult(cvf::UNDEFINED_SIZE_T);
for (int nIdx = 0; nIdx < numNNC; ++nIdx)
{
RigGridBase* grid1 = mainGrid->gridByIndex(eclNNCData[nIdx].grid_nr1);
mainGrid->nncData()->connections()[nIdx].m_c1GlobIdx = grid1->reservoirCellIndex(eclNNCData[nIdx].global_index1);
RigGridBase* grid2 = mainGrid->gridByIndex(eclNNCData[nIdx].grid_nr2);
mainGrid->nncData()->connections()[nIdx].m_c2GlobIdx = grid2->reservoirCellIndex(eclNNCData[nIdx].global_index2);
transmissibilityValues[nIdx] = eclNNCData[nIdx].trans;
}


delete[] eclNNCData;
delete[] eclNNCData;
}
}


Expand Down

0 comments on commit 02e47c6

Please sign in to comment.