MswRollUp: Started to clean up the MSW code.

This is an intermediate commit and does not compile
p4#: 22216
This commit is contained in:
Jacob Støren 2013-08-26 14:15:27 +02:00
parent 27cac28b74
commit e6dce28fa3
3 changed files with 157 additions and 189 deletions

View File

@ -864,41 +864,23 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid)
if (well_state_is_MSW(ert_well_state)) if (well_state_is_MSW(ert_well_state))
{ {
// Loop over all the grids in the model. If we have connections in one, we will discard wellResults->setMultiSegmentWell(true);
// the main grid connections as the well connections are duplicated in the main grid and LGR grids
bool hasWellConnectionsInLGR = false; for (size_t gridNr = 0; gridNr < grids.size(); ++gridNr)
#if 0
// To be discussed with Statoil
for (size_t gridNr = 1; gridNr < grids.size(); ++gridNr)
{ {
RigGridBase* lgrGrid = m_eclipseCase->grid(gridNr); // Set the wellhead
if (well_state_has_grid_connections(ert_well_state, lgrGrid->gridName().data()))
{ {
hasWellConnectionsInLGR = true; // If several grids have a wellhead definition for this well, we use the last one.
break; // (Possibly the innermost LGR)
}
}
#endif
size_t gridNr = hasWellConnectionsInLGR ? 1 : 0;
for (; gridNr < grids.size(); ++gridNr)
{
// Wellhead. If several grids have a wellhead definition for this well, we use the last one. (Possibly the innermost LGR)
const well_conn_type* ert_wellhead = well_state_iget_wellhead(ert_well_state, static_cast<int>(gridNr)); const well_conn_type* ert_wellhead = well_state_iget_wellhead(ert_well_state, static_cast<int>(gridNr));
if (ert_wellhead) if (ert_wellhead)
{ {
wellResFrame.m_wellHead = createWellResultPoint(grids[gridNr], ert_wellhead, -1, -1 ); wellResFrame.m_wellHead = createWellResultPoint(grids[gridNr], ert_wellhead, -1, -1 );
} }
else
{
// CVF_ASSERT(0); // This is just a test assert to see if this condition exists in some file.
// All the grids does not necessarily have a well head definition. (I think, JJS)
} }
// Find the grid name to be used later as key towards ert
std::string gridName; std::string gridName;
if (gridNr == 0) if (gridNr == 0)
@ -912,19 +894,16 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid)
} }
// Fill the SegmentData list with the segments from ert in branch sorted order:
// BrancN<TopSegment...BottomSegment>, ..., Branch0<TopSegment...BottomSegment>
std::list<SegmentData> segmentList; std::list<SegmentData> segmentList;
std::vector<const well_segment_type*> outletBranchSegmentList; // Keep a list of branch outlet segments to avoid traversal twice std::vector<const well_segment_type*> outletBranchSegmentList; // Keep a list of branch outlet segments to avoid traversal twice
std::vector<int> ertBranchIDs; std::vector<int> ertBranchIDs;
int branchCount = 0;
if (well_state_is_MSW(ert_well_state))
{
wellResults->setMultiSegmentWell(true);
well_branch_collection_type* branches = well_state_get_branches(ert_well_state); well_branch_collection_type* branches = well_state_get_branches(ert_well_state);
int branchCount = well_branch_collection_get_size(branches);
branchCount = well_branch_collection_get_size(branches);
for (int branchIdx = 0; branchIdx < well_branch_collection_get_size(branches); branchIdx++) for (int branchIdx = 0; branchIdx < well_branch_collection_get_size(branches); branchIdx++)
{ {
const well_segment_type* segment = well_branch_collection_iget_start_segment(branches, branchIdx); const well_segment_type* segment = well_branch_collection_iget_start_segment(branches, branchIdx);
@ -959,23 +938,12 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid)
outletBranchSegmentList.push_back(segment); outletBranchSegmentList.push_back(segment);
} }
}
else
{
branchCount = 1;
ertBranchIDs.push_back(0);
const well_conn_collection_type* connections = well_state_get_grid_connections(ert_well_state, gridName.data());
SegmentData segmentData(connections);
segmentData.m_gridIndex = gridNr;
segmentList.push_front(segmentData);
}
size_t currentGridBranchStartIndex = wellResFrame.m_wellResultBranches.size(); size_t currentGridBranchStartIndex = wellResFrame.m_wellResultBranches.size();
wellResFrame.m_wellResultBranches.resize(currentGridBranchStartIndex + branchCount); wellResFrame.m_wellResultBranches.resize(currentGridBranchStartIndex + branchCount);
// Import all well result cells for all connections, adding one ResultPoint to represent the bottom position
// for each segment having no connections
// Import all well result cells for all connections
for (int branchIdx = 0; branchIdx < branchCount; branchIdx++) for (int branchIdx = 0; branchIdx < branchCount; branchIdx++)
{ {
RigWellResultBranch& wellResultBranch = wellResFrame.m_wellResultBranches[currentGridBranchStartIndex + branchIdx]; RigWellResultBranch& wellResultBranch = wellResFrame.m_wellResultBranches[currentGridBranchStartIndex + branchIdx];
@ -993,13 +961,11 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid)
if (!connData.m_connections) if (!connData.m_connections)
{ {
size_t existingCellCount = wellResultBranch.m_branchResultPoints.size(); RigWellResultPoint data;
wellResultBranch.m_branchResultPoints.resize(existingCellCount + 1);
RigWellResultPoint& data = wellResultBranch.m_branchResultPoints[existingCellCount];
data.m_ertBranchId = connData.m_branchId; data.m_ertBranchId = connData.m_branchId;
data.m_ertSegmentId = connData.m_segmentId; data.m_ertSegmentId = connData.m_segmentId;
wellResultBranch.m_branchResultPoints.push_back(data);
} }
else else
{ {
@ -1018,10 +984,6 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid)
} }
} }
if (well_state_is_MSW(ert_well_state))
{
// Assign outlet well cells to leaf branch well heads // Assign outlet well cells to leaf branch well heads
for (int branchIdx = 0; branchIdx < branchCount; branchIdx++) for (int branchIdx = 0; branchIdx < branchCount; branchIdx++)
@ -1046,6 +1008,7 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid)
int outletErtSegmentId = well_segment_get_branch_id(outletBranchSegment); int outletErtSegmentId = well_segment_get_branch_id(outletBranchSegment);
size_t lastCellIndexForSegmentIdInOutletBranch = cvf::UNDEFINED_SIZE_T; size_t lastCellIndexForSegmentIdInOutletBranch = cvf::UNDEFINED_SIZE_T;
for (size_t outletCellIdx = 0; outletCellIdx < outletResultBranch.m_branchResultPoints.size(); outletCellIdx++) for (size_t outletCellIdx = 0; outletCellIdx < outletResultBranch.m_branchResultPoints.size(); outletCellIdx++)
{ {
if (outletResultBranch.m_branchResultPoints[outletCellIdx].m_ertSegmentId == outletErtSegmentId) if (outletResultBranch.m_branchResultPoints[outletCellIdx].m_ertSegmentId == outletErtSegmentId)
@ -1148,11 +1111,13 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid)
} }
} }
} }
}
} }
} }
else else
{ {
// Code handling None-MSW Wells ... Normal wells that is.
// Loop over all the grids in the model. If we have connections in one, we will discard // Loop over all the grids in the model. If we have connections in one, we will discard
// the main grid connections as the well connections are duplicated in the main grid and LGR grids // the main grid connections as the well connections are duplicated in the main grid and LGR grids
// Verified on 10 k case JJS. But smarter things could be done, like showing the "main grid well" if turning off the LGR's // Verified on 10 k case JJS. But smarter things could be done, like showing the "main grid well" if turning off the LGR's
@ -1178,13 +1143,13 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid)
if (ert_wellhead) if (ert_wellhead)
{ {
wellResFrame.m_wellHead = createWellResultPoint(grids[gridNr], ert_wellhead, -1, -1 ); wellResFrame.m_wellHead = createWellResultPoint(grids[gridNr], ert_wellhead, -1, -1 );
std::cout << "Wellhead YES at timeIdx: " << timeIdx << " wellIdx: " << wellIdx << " Grid: " << gridNr << std::endl; //std::cout << "Wellhead YES at timeIdx: " << timeIdx << " wellIdx: " << wellIdx << " Grid: " << gridNr << std::endl;
} }
else else
{ {
std::cout << "Wellhead NO at timeIdx: " << timeIdx << " wellIdx: " << wellIdx << " Grid: " << gridNr << std::endl; // std::cout << "Wellhead NO at timeIdx: " << timeIdx << " wellIdx: " << wellIdx << " Grid: " << gridNr << std::endl;
//CVF_ASSERT(0); // This is just a test assert to see if this condition exists in some file. //CVF_ASSERT(0); // This is just a test assert to see if this condition exists in some files and it does.
// All the grids does not necessarily have a well head definition. (I think, JJS) // All the grids does not necessarily have a well head definition.
} }

View File

@ -328,7 +328,7 @@ void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< std::vector
if (!currentWellResPoint.isValid()) if (!currentWellResPoint.isValid())
{ {
CVF_ASSERT(false); //CVF_ASSERT(false); // Some segments does not get anything yet.
continue; continue;
} }

View File

@ -168,6 +168,9 @@ void RigGridBase::cellCornerVertices(size_t cellIndex, cvf::Vec3d vertices[8]) c
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
size_t RigGridBase::cellIndexFromIJK(size_t i, size_t j, size_t k) const size_t RigGridBase::cellIndexFromIJK(size_t i, size_t j, size_t k) const
{ {
CVF_TIGHT_ASSERT(i != cvf::UNDEFINED_SIZE_T && j != cvf::UNDEFINED_SIZE_T && k != cvf::UNDEFINED_SIZE_T );
CVF_TIGHT_ASSERT(i < m_gridPointDimensions.x() && j < m_gridPointDimensions.y() && k < m_gridPointDimensions.z() );
size_t ci = i + j*(m_gridPointDimensions.x() - 1) + k*((m_gridPointDimensions.x() - 1)*(m_gridPointDimensions.y() - 1)); size_t ci = i + j*(m_gridPointDimensions.x() - 1) + k*((m_gridPointDimensions.x() - 1)*(m_gridPointDimensions.y() - 1));
return ci; return ci;
} }