MswRollUp: Splitted normal well and MSW handling. Got the Normal path to work fairly well. Some strangeties at the end of the pipes though

This is an intermediate commit and does not compile
p4#: 22214
This commit is contained in:
Jacob Støren 2013-08-26 14:03:01 +02:00
parent b63f51921d
commit f392f4457d
12 changed files with 485 additions and 392 deletions

View File

@ -725,6 +725,54 @@ struct SegmentData
const well_conn_collection_type* m_connections;
};
struct SegmentTreeNode
{
SegmentTreeNode() : outletSegment(NULL), mainChildSegment(NULL) {}
std::vector<RigWellResultPoint> connections;
SegmentTreeNode* outletSegment;
SegmentTreeNode* mainChildSegment;
std::vector<SegmentTreeNode*> additionalChildSegments;
};
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigWellResultPoint RifReaderEclipseOutput::createWellResultPoint(const RigGridBase* grid, const well_conn_type* ert_connection, int ertBranchId, int ertSegmentId)
{
CVF_ASSERT(ert_connection);
CVF_ASSERT(grid);
RigWellResultPoint resultPoint;
int cellI = well_conn_get_i( ert_connection );
int cellJ = well_conn_get_j( ert_connection );
int cellK = well_conn_get_k( ert_connection );
bool isCellOpen = well_conn_open( ert_connection );
// If a well is defined in fracture region, the K-value is from (cellCountK - 1) -> cellCountK*2 - 1
// Adjust K so index is always in valid grid region
if (cellK >= static_cast<int>(grid->cellCountK()))
{
cellK -= static_cast<int>(grid->cellCountK());
}
// The K value might also be -1. It is not yet known why, or what it is supposed to mean,
// but for now we will interpret as 0.
// TODO: Ask Joakim Haave regarding this.
if (cellK < 0) cellK = 0;
resultPoint.m_gridIndex = grid->gridIndex();
resultPoint.m_gridCellIndex = grid->cellIndexFromIJK(cellI, cellJ, cellK);
resultPoint.m_isOpen = isCellOpen;
resultPoint.m_ertBranchId = ertBranchId;
resultPoint.m_ertSegmentId = ertSegmentId;
return resultPoint;
}
void getSegmentDataByBranchId(const std::list<SegmentData>& segments, std::vector<SegmentData>& branchSegments, int branchId)
{
std::list<SegmentData>::const_iterator it;
@ -814,317 +862,365 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid)
wellResFrame.m_isOpen = well_state_is_open( 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
// the main grid connections as the well connections are duplicated in the main grid and LGR grids
// 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
bool hasWellConnectionsInLGR = false;
bool hasWellConnectionsInLGR = false;
#if 0
// To be discussed with Statoil
for (size_t gridNr = 1; gridNr < grids.size(); ++gridNr)
{
RigGridBase* lgrGrid = m_eclipseCase->grid(gridNr);
if (well_state_has_grid_connections(ert_well_state, lgrGrid->gridName().data()))
// To be discussed with Statoil
for (size_t gridNr = 1; gridNr < grids.size(); ++gridNr)
{
hasWellConnectionsInLGR = true;
break;
RigGridBase* lgrGrid = m_eclipseCase->grid(gridNr);
if (well_state_has_grid_connections(ert_well_state, lgrGrid->gridName().data()))
{
hasWellConnectionsInLGR = true;
break;
}
}
}
#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));
if (ert_wellhead)
size_t gridNr = hasWellConnectionsInLGR ? 1 : 0;
for (; gridNr < grids.size(); ++gridNr)
{
int cellI = well_conn_get_i( ert_wellhead );
int cellJ = well_conn_get_j( ert_wellhead );
int cellK = CVF_MAX(0, well_conn_get_k(ert_wellhead)); // Why this ?
// If a well is defined in fracture region, the K-value is from (cellCountK - 1) -> cellCountK*2 - 1
// Adjust K so index is always in valid grid region
if (cellK >= static_cast<int>(grids[gridNr]->cellCountK()))
// 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));
if (ert_wellhead)
{
cellK -= static_cast<int>(grids[gridNr]->cellCountK());
wellResFrame.m_wellHead = createWellResultPoint(grids[gridNr], ert_wellhead, -1, -1 );
}
wellResFrame.m_wellHead.m_gridCellIndex = grids[gridNr]->cellIndexFromIJK(cellI, cellJ, cellK);
wellResFrame.m_wellHead.m_gridIndex = gridNr;
}
else
{
CVF_ASSERT(0);
}
std::string gridName;
if (gridNr == 0)
{
gridName = ECL_GRID_GLOBAL_GRID;
}
else
{
RigGridBase* rigGrid = m_eclipseCase->grid(gridNr);
gridName = rigGrid->gridName();
}
std::list<SegmentData> segmentList;
std::vector<const well_segment_type*> outletBranchSegmentList; // Keep a list of branch outlet segments to avoid traversal twice
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);
branchCount = well_branch_collection_get_size(branches);
for (int branchIdx = 0; branchIdx < well_branch_collection_get_size(branches); branchIdx++)
else
{
const well_segment_type* segment = well_branch_collection_iget_start_segment(branches, branchIdx);
int branchId = well_segment_get_branch_id(segment);
ertBranchIDs.push_back(branchId);
while (segment && branchId == well_segment_get_branch_id(segment))
{
SegmentData segmentData(NULL);
segmentData.m_branchId = branchId;
segmentData.m_segmentId = well_segment_get_id(segment);
segmentData.m_gridIndex = gridNr;
if (well_segment_has_grid_connections(segment, gridName.data()))
{
const well_conn_collection_type* connections = well_segment_get_connections(segment, gridName.data());
segmentData.m_connections = connections;
}
// Insert in front, as the segments are accessed starting from grid cell closes to well head
segmentList.push_front(segmentData);
if (well_segment_get_outlet_id(segment) == -1)
{
break;
}
segment = well_segment_get_outlet(segment);
}
outletBranchSegmentList.push_back(segment);
// 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)
}
}
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();
wellResFrame.m_wellResultBranches.resize(currentGridBranchStartIndex + branchCount);
// Import all well result cells for all connections
for (int branchIdx = 0; branchIdx < branchCount; branchIdx++)
{
RigWellResultBranch& wellResultBranch = wellResFrame.m_wellResultBranches[currentGridBranchStartIndex + branchIdx];
wellResultBranch.m_branchIndex = branchIdx;
int ertBranchId = ertBranchIDs[branchIdx];
wellResultBranch.m_ertBranchId = ertBranchId;
std::vector<SegmentData> branchSegments;
getSegmentDataByBranchId(segmentList, branchSegments, ertBranchId);
for (size_t segmentIdx = 0; segmentIdx < branchSegments.size(); segmentIdx++)
std::string gridName;
if (gridNr == 0)
{
SegmentData& connData = branchSegments[segmentIdx];
gridName = ECL_GRID_GLOBAL_GRID;
}
else
{
RigGridBase* rigGrid = m_eclipseCase->grid(gridNr);
gridName = rigGrid->gridName();
}
if (!connData.m_connections)
std::list<SegmentData> segmentList;
std::vector<const well_segment_type*> outletBranchSegmentList; // Keep a list of branch outlet segments to avoid traversal twice
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);
branchCount = well_branch_collection_get_size(branches);
for (int branchIdx = 0; branchIdx < well_branch_collection_get_size(branches); branchIdx++)
{
size_t existingCellCount = wellResultBranch.m_wellCells.size();
wellResultBranch.m_wellCells.resize(existingCellCount + 1);
RigWellResultCell& data = wellResultBranch.m_wellCells[existingCellCount];
const well_segment_type* segment = well_branch_collection_iget_start_segment(branches, branchIdx);
int branchId = well_segment_get_branch_id(segment);
data.m_ertBranchId = connData.m_branchId;
data.m_ertSegmentId = connData.m_segmentId;
}
else
{
int connectionCount = well_conn_collection_get_size(connData.m_connections);
ertBranchIDs.push_back(branchId);
size_t existingCellCount = wellResultBranch.m_wellCells.size();
wellResultBranch.m_wellCells.resize(existingCellCount + connectionCount);
for (int connIdx = 0; connIdx < connectionCount; connIdx++)
while (segment && branchId == well_segment_get_branch_id(segment))
{
well_conn_type* ert_connection = well_conn_collection_iget(connData.m_connections, connIdx);
CVF_ASSERT(ert_connection);
SegmentData segmentData(NULL);
segmentData.m_branchId = branchId;
segmentData.m_segmentId = well_segment_get_id(segment);
segmentData.m_gridIndex = gridNr;
RigWellResultCell& data = wellResultBranch.m_wellCells[existingCellCount + connIdx];
int cellI = well_conn_get_i( ert_connection );
int cellJ = well_conn_get_j( ert_connection );
int cellK = well_conn_get_k( ert_connection );
bool isCellOpen = well_conn_open( ert_connection );
// If a well is defined in fracture region, the K-value is from (cellCountK - 1) -> cellCountK*2 - 1
// Adjust K so index is always in valid grid region
if (cellK >= static_cast<int>(grids[gridNr]->cellCountK()))
if (well_segment_has_grid_connections(segment, gridName.data()))
{
cellK -= static_cast<int>(grids[gridNr]->cellCountK());
const well_conn_collection_type* connections = well_segment_get_connections(segment, gridName.data());
segmentData.m_connections = connections;
}
data.m_gridIndex = gridNr;
data.m_gridCellIndex = grids[gridNr]->cellIndexFromIJK(cellI, cellJ, cellK);
// Insert in front, as the segments are accessed starting from grid cell closes to well head
segmentList.push_front(segmentData);
data.m_isOpen = isCellOpen;
if (well_segment_get_outlet_id(segment) == -1)
{
break;
}
segment = well_segment_get_outlet(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();
wellResFrame.m_wellResultBranches.resize(currentGridBranchStartIndex + branchCount);
// Import all well result cells for all connections
for (int branchIdx = 0; branchIdx < branchCount; branchIdx++)
{
RigWellResultBranch& wellResultBranch = wellResFrame.m_wellResultBranches[currentGridBranchStartIndex + branchIdx];
wellResultBranch.m_branchIndex = branchIdx;
int ertBranchId = ertBranchIDs[branchIdx];
wellResultBranch.m_ertBranchId = ertBranchId;
std::vector<SegmentData> branchSegments;
getSegmentDataByBranchId(segmentList, branchSegments, ertBranchId);
for (size_t segmentIdx = 0; segmentIdx < branchSegments.size(); segmentIdx++)
{
SegmentData& connData = branchSegments[segmentIdx];
if (!connData.m_connections)
{
size_t existingCellCount = wellResultBranch.m_branchResultPoints.size();
wellResultBranch.m_branchResultPoints.resize(existingCellCount + 1);
RigWellResultPoint& data = wellResultBranch.m_branchResultPoints[existingCellCount];
data.m_ertBranchId = connData.m_branchId;
data.m_ertSegmentId = connData.m_segmentId;
}
else
{
int connectionCount = well_conn_collection_get_size(connData.m_connections);
size_t existingCellCount = wellResultBranch.m_branchResultPoints.size();
wellResultBranch.m_branchResultPoints.resize(existingCellCount + connectionCount);
for (int connIdx = 0; connIdx < connectionCount; connIdx++)
{
well_conn_type* ert_connection = well_conn_collection_iget(connData.m_connections, connIdx);
wellResultBranch.m_branchResultPoints[existingCellCount + connIdx] =
createWellResultPoint(grids[gridNr], ert_connection, connData.m_branchId, connData.m_segmentId);
}
}
}
}
if (well_state_is_MSW(ert_well_state))
{
// Assign outlet well cells to leaf branch well heads
for (int branchIdx = 0; branchIdx < branchCount; branchIdx++)
{
RigWellResultBranch& wellResultLeafBranch = wellResFrame.m_wellResultBranches[currentGridBranchStartIndex + branchIdx];
const well_segment_type* outletBranchSegment = outletBranchSegmentList[branchIdx];
CVF_ASSERT(outletBranchSegment);
int outletErtBranchId = well_segment_get_branch_id(outletBranchSegment);
size_t outletErtBranchIndex = cvf::UNDEFINED_SIZE_T;
for (size_t i = 0; i < ertBranchIDs.size(); i++)
{
if (ertBranchIDs[i] == outletErtBranchId)
{
outletErtBranchIndex = i;
}
}
RigWellResultBranch& outletResultBranch = wellResFrame.m_wellResultBranches[currentGridBranchStartIndex + outletErtBranchIndex];
int outletErtSegmentId = well_segment_get_branch_id(outletBranchSegment);
size_t lastCellIndexForSegmentIdInOutletBranch = cvf::UNDEFINED_SIZE_T;
for (size_t outletCellIdx = 0; outletCellIdx < outletResultBranch.m_branchResultPoints.size(); outletCellIdx++)
{
if (outletResultBranch.m_branchResultPoints[outletCellIdx].m_ertSegmentId == outletErtSegmentId)
{
lastCellIndexForSegmentIdInOutletBranch = outletCellIdx;
}
}
if (lastCellIndexForSegmentIdInOutletBranch == cvf::UNDEFINED_SIZE_T)
{
// Did not find the cell in the outlet branch based on branch id and segment id from outlet cell in leaf branch
CVF_ASSERT(0);
}
else
{
RigWellResultPoint& outletCell = outletResultBranch.m_branchResultPoints[lastCellIndexForSegmentIdInOutletBranch];
wellResultLeafBranch.m_outletBranchIndex_OBSOLETE = currentGridBranchStartIndex + outletErtBranchIndex;
wellResultLeafBranch.m_outletBranchHeadCellIndex_OBSOLETE = lastCellIndexForSegmentIdInOutletBranch;
}
}
// Update outlet well cells with no grid cell connections
for (int branchIdx = 0; branchIdx < branchCount; branchIdx++)
{
RigWellResultBranch& wellResultLeafBranch = wellResFrame.m_wellResultBranches[currentGridBranchStartIndex + branchIdx];
const RigWellResultPoint* leafBranchHead = wellResFrame.findResultCellFromOutletSpecification(wellResultLeafBranch.m_outletBranchIndex_OBSOLETE, wellResultLeafBranch.m_outletBranchHeadCellIndex_OBSOLETE);
if (!leafBranchHead || leafBranchHead->isCell())
{
continue;
}
RigWellResultBranch& outletResultBranch = wellResFrame.m_wellResultBranches[wellResultLeafBranch.m_outletBranchIndex_OBSOLETE];
size_t firstCellIndexWithGridConnectionInLeafBranch = cvf::UNDEFINED_SIZE_T;
for (size_t j = 0; j < wellResultLeafBranch.m_branchResultPoints.size(); j++)
{
if (wellResultLeafBranch.m_branchResultPoints[j].isCell())
{
firstCellIndexWithGridConnectionInLeafBranch = j;
break;
}
}
if (firstCellIndexWithGridConnectionInLeafBranch != cvf::UNDEFINED_SIZE_T)
{
const RigCell& firstCellWithGridConnectionInLeafBranch = m_eclipseCase->cellFromWellResultCell(wellResultLeafBranch.m_branchResultPoints[firstCellIndexWithGridConnectionInLeafBranch]);
cvf::Vec3d firstGridConnectionCenterInLeafBranch = firstCellWithGridConnectionInLeafBranch.center();
size_t cellIndexInOutletBranch = wellResultLeafBranch.m_outletBranchHeadCellIndex_OBSOLETE;
CVF_ASSERT(cellIndexInOutletBranch != cvf::UNDEFINED_SIZE_T);
RigWellResultPoint& currCell = outletResultBranch.m_branchResultPoints[cellIndexInOutletBranch];
while (cellIndexInOutletBranch != cvf::UNDEFINED_SIZE_T && !currCell.isCell())
{
size_t branchConnectionCount = currCell.m_branchConnectionCount;
if (branchConnectionCount == 0)
{
currCell.m_bottomPosition = firstGridConnectionCenterInLeafBranch;
}
else
{
cvf::Vec3d currentWeightedCoord = currCell.m_bottomPosition * branchConnectionCount / static_cast<double>(branchConnectionCount + 1);
cvf::Vec3d additionalWeightedCoord = firstGridConnectionCenterInLeafBranch / static_cast<double>(branchConnectionCount + 1);
currCell.m_bottomPosition = currentWeightedCoord + additionalWeightedCoord;
}
currCell.m_branchConnectionCount++;
if (cellIndexInOutletBranch == 0)
{
cellIndexInOutletBranch = cvf::UNDEFINED_SIZE_T;
// Find the branch the outlet is connected to, and continue update of
// segments until a segment with a grid connection is found
const RigWellResultPoint* leafBranchHead = wellResFrame.findResultCellFromOutletSpecification(outletResultBranch.m_outletBranchIndex_OBSOLETE, outletResultBranch.m_outletBranchHeadCellIndex_OBSOLETE);
if (leafBranchHead &&
!leafBranchHead->isCell() &&
leafBranchHead->m_ertBranchId != outletResultBranch.m_ertBranchId)
{
outletResultBranch = wellResFrame.m_wellResultBranches[outletResultBranch.m_outletBranchIndex_OBSOLETE];
cellIndexInOutletBranch = outletResultBranch.m_outletBranchHeadCellIndex_OBSOLETE;
}
}
else
{
cellIndexInOutletBranch--;
}
if(cellIndexInOutletBranch >= 0 && cellIndexInOutletBranch < outletResultBranch.m_branchResultPoints.size())
{
currCell = outletResultBranch.m_branchResultPoints[cellIndexInOutletBranch];
}
}
}
}
}
}
}
else
{
// 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
if (well_state_is_MSW(ert_well_state))
bool hasWellConnectionsInLGR = false;
#if 0
// To be discussed with Statoil
for (size_t gridIdx = 1; gridIdx < grids.size(); ++gridIdx)
{
// Assign outlet well cells to leaf branch well heads
for (int branchIdx = 0; branchIdx < branchCount; branchIdx++)
RigGridBase* lgrGrid = m_eclipseCase->grid(gridIdx);
if (well_state_has_grid_connections(ert_well_state, lgrGrid->gridName().data()))
{
RigWellResultBranch& wellResultLeafBranch = wellResFrame.m_wellResultBranches[currentGridBranchStartIndex + branchIdx];
hasWellConnectionsInLGR = true;
break;
}
}
#endif
size_t gridNr = hasWellConnectionsInLGR ? 1 : 0;
for (; gridNr < grids.size(); ++gridNr)
{
const well_segment_type* outletBranchSegment = outletBranchSegmentList[branchIdx];
CVF_ASSERT(outletBranchSegment);
int outletErtBranchId = well_segment_get_branch_id(outletBranchSegment);
size_t outletErtBranchIndex = cvf::UNDEFINED_SIZE_T;
for (size_t i = 0; i < ertBranchIDs.size(); i++)
{
if (ertBranchIDs[i] == outletErtBranchId)
{
outletErtBranchIndex = i;
}
}
RigWellResultBranch& outletResultBranch = wellResFrame.m_wellResultBranches[currentGridBranchStartIndex + outletErtBranchIndex];
int outletErtSegmentId = well_segment_get_branch_id(outletBranchSegment);
size_t lastCellIndexForSegmentIdInOutletBranch = cvf::UNDEFINED_SIZE_T;
for (size_t outletCellIdx = 0; outletCellIdx < outletResultBranch.m_wellCells.size(); outletCellIdx++)
{
if (outletResultBranch.m_wellCells[outletCellIdx].m_ertSegmentId == outletErtSegmentId)
{
lastCellIndexForSegmentIdInOutletBranch = outletCellIdx;
}
}
if (lastCellIndexForSegmentIdInOutletBranch == cvf::UNDEFINED_SIZE_T)
{
// Did not find the cell in the outlet branch based on branch id and segment id from outlet cell in leaf branch
CVF_ASSERT(0);
}
else
{
RigWellResultCell& outletCell = outletResultBranch.m_wellCells[lastCellIndexForSegmentIdInOutletBranch];
wellResultLeafBranch.m_outletBranchIndex = currentGridBranchStartIndex + outletErtBranchIndex;
wellResultLeafBranch.m_outletBranchHeadCellIndex = lastCellIndexForSegmentIdInOutletBranch;
}
// 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));
if (ert_wellhead)
{
wellResFrame.m_wellHead = createWellResultPoint(grids[gridNr], ert_wellhead, -1, -1 );
std::cout << "Wellhead YES at timeIdx: " << timeIdx << " wellIdx: " << wellIdx << " Grid: " << gridNr << std::endl;
}
else
{
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.
// All the grids does not necessarily have a well head definition. (I think, JJS)
}
// Update outlet well cells with no grid cell connections
for (int branchIdx = 0; branchIdx < branchCount; branchIdx++)
std::string gridName;
if (gridNr == 0)
{
RigWellResultBranch& wellResultLeafBranch = wellResFrame.m_wellResultBranches[currentGridBranchStartIndex + branchIdx];
const RigWellResultCell* leafBranchHead = wellResFrame.findResultCellFromOutletSpecification(wellResultLeafBranch.m_outletBranchIndex, wellResultLeafBranch.m_outletBranchHeadCellIndex);
if (!leafBranchHead || leafBranchHead->hasGridConnections())
{
continue;
}
RigWellResultBranch& outletResultBranch = wellResFrame.m_wellResultBranches[wellResultLeafBranch.m_outletBranchIndex];
gridName = ECL_GRID_GLOBAL_GRID;
}
else
{
RigGridBase* rigGrid = m_eclipseCase->grid(gridNr);
gridName = rigGrid->gridName();
}
size_t firstCellIndexWithGridConnectionInLeafBranch = cvf::UNDEFINED_SIZE_T;
for (size_t j = 0; j < wellResultLeafBranch.m_wellCells.size(); j++)
const well_conn_collection_type* connections = well_state_get_grid_connections(ert_well_state, gridName.data());
// Import all well result cells for all connections
if (connections)
{
int connectionCount = well_conn_collection_get_size(connections);
if (connectionCount)
{
if (wellResultLeafBranch.m_wellCells[j].hasGridConnections())
wellResFrame.m_wellResultBranches.push_back(RigWellResultBranch());
RigWellResultBranch& wellResultBranch = wellResFrame.m_wellResultBranches.back();
wellResultBranch.m_branchIndex = 0;
wellResultBranch.m_ertBranchId = -1;
size_t existingCellCount = wellResultBranch.m_branchResultPoints.size();
wellResultBranch.m_branchResultPoints.resize(existingCellCount + connectionCount);
for (int connIdx = 0; connIdx < connectionCount; connIdx++)
{
firstCellIndexWithGridConnectionInLeafBranch = j;
break;
}
}
if (firstCellIndexWithGridConnectionInLeafBranch != cvf::UNDEFINED_SIZE_T)
{
const RigCell& firstCellWithGridConnectionInLeafBranch = m_eclipseCase->cellFromWellResultCell(wellResultLeafBranch.m_wellCells[firstCellIndexWithGridConnectionInLeafBranch]);
cvf::Vec3d firstGridConnectionCenterInLeafBranch = firstCellWithGridConnectionInLeafBranch.center();
size_t cellIndexInOutletBranch = wellResultLeafBranch.m_outletBranchHeadCellIndex;
CVF_ASSERT(cellIndexInOutletBranch != cvf::UNDEFINED_SIZE_T);
RigWellResultCell& currCell = outletResultBranch.m_wellCells[cellIndexInOutletBranch];
while (cellIndexInOutletBranch != cvf::UNDEFINED_SIZE_T && !currCell.hasGridConnections())
{
size_t branchConnectionCount = currCell.m_branchConnectionCount;
if (branchConnectionCount == 0)
{
currCell.m_averageCenter = firstGridConnectionCenterInLeafBranch;
}
else
{
cvf::Vec3d currentWeightedCoord = currCell.m_averageCenter * branchConnectionCount / static_cast<double>(branchConnectionCount + 1);
cvf::Vec3d additionalWeightedCoord = firstGridConnectionCenterInLeafBranch / static_cast<double>(branchConnectionCount + 1);
currCell.m_averageCenter = currentWeightedCoord + additionalWeightedCoord;
}
currCell.m_branchConnectionCount++;
if (cellIndexInOutletBranch == 0)
{
cellIndexInOutletBranch = cvf::UNDEFINED_SIZE_T;
// Find the branch the outlet is connected to, and continue update of
// segments until a segment with a grid connection is found
const RigWellResultCell* leafBranchHead = wellResFrame.findResultCellFromOutletSpecification(outletResultBranch.m_outletBranchIndex, outletResultBranch.m_outletBranchHeadCellIndex);
if (leafBranchHead &&
!leafBranchHead->hasGridConnections() &&
leafBranchHead->m_ertBranchId != outletResultBranch.m_ertBranchId)
{
outletResultBranch = wellResFrame.m_wellResultBranches[outletResultBranch.m_outletBranchIndex];
cellIndexInOutletBranch = outletResultBranch.m_outletBranchHeadCellIndex;
}
}
else
{
cellIndexInOutletBranch--;
}
if(cellIndexInOutletBranch >= 0 && cellIndexInOutletBranch < outletResultBranch.m_wellCells.size())
{
currCell = outletResultBranch.m_wellCells[cellIndexInOutletBranch];
}
well_conn_type* ert_connection = well_conn_collection_iget(connections, connIdx);
wellResultBranch.m_branchResultPoints[existingCellCount + connIdx] =
createWellResultPoint(grids[gridNr], ert_connection, -1, -1);
}
}
}

View File

@ -22,6 +22,8 @@
#include <QList>
#include <QDateTime>
#include "RigSingleWellResultsData.h"
class RifEclipseOutputFileTools;
class RifEclipseRestartDataAccess;
class RigGridBase;
@ -30,7 +32,7 @@ class RigActiveCellInfo;
typedef struct ecl_grid_struct ecl_grid_type;
typedef struct ecl_file_struct ecl_file_type;
typedef struct well_conn_struct well_conn_type;
//==================================================================================================
//
@ -57,7 +59,10 @@ private:
bool readActiveCellInfo();
void buildMetaData();
void readWellCells(const ecl_grid_type* mainEclGrid);
static RigWellResultPoint createWellResultPoint(const RigGridBase* grid, const well_conn_type* ert_connection, int ertBranchId, int ertSegmentId);
void openInitFile();
bool openDynamicAccess();

View File

@ -97,7 +97,7 @@ void RivWellPipesPartMgr::buildWellPipeParts()
std::vector< size_t > pipeBranchIds;
std::vector< std::vector <cvf::Vec3d> > pipeBranchesCLCoords;
std::vector< std::vector <RigWellResultCell> > pipeBranchesCellIds;
std::vector< std::vector <RigWellResultPoint> > pipeBranchesCellIds;
calculateWellPipeCenterline(pipeBranchesCLCoords, pipeBranchesCellIds);
@ -163,10 +163,10 @@ void RivWellPipesPartMgr::buildWellPipeParts()
//--------------------------------------------------------------------------------------------------
///
/// Based on the points and cells, calculate a pipe centerline
//--------------------------------------------------------------------------------------------------
void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< std::vector <cvf::Vec3d> >& pipeBranchesCLCoords,
std::vector< std::vector <RigWellResultCell> >& pipeBranchesCellIds) const
std::vector< std::vector <RigWellResultPoint> >& pipeBranchesCellIds) const
{
CVF_ASSERT(m_rimWell.notNull());
CVF_ASSERT(m_rimReservoirView.notNull());
@ -193,7 +193,7 @@ void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< std::vector
// Match this position with well head position in RivWellHeadPartMgr::buildWellHeadParts()
const RigCell& whCell = rigReservoir->cellFromWellResultCell(staticWellFrame.m_wellHead);
cvf::Vec3d whStartPos = whCell.faceCenter(cvf::StructGridInterface::NEG_K);
const RigWellResultCell* whResCell = &(staticWellFrame.m_wellHead);
const RigWellResultPoint* whResCell = &(staticWellFrame.m_wellHead);
// Loop over all the well branches
const std::vector<RigWellResultBranch>& resBranches = staticWellFrame.m_wellResultBranches;
@ -202,7 +202,7 @@ void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< std::vector
{
for (size_t i = 0 ; i < resBranches.size(); ++i)
{
if (resBranches[i].m_wellCells.size() != 0)
if (resBranches[i].m_branchResultPoints.size() != 0)
{
hasResultCells = true;
}
@ -218,15 +218,15 @@ void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< std::vector
whIntermediate.z() = (whStartPos.z() + whCell.center().z()) / 2.0;
const RigWellResultCell* prevResCell = NULL;
const RigWellResultPoint* prevResCell = NULL;
// Use well head if branch head is not specified
if (!wellResults->isMultiSegmentWell())
if (false && !wellResults->isMultiSegmentWell())
{
// Create a new branch from wellhead
pipeBranchesCLCoords.push_back(std::vector<cvf::Vec3d>());
pipeBranchesCellIds.push_back(std::vector <RigWellResultCell>());
pipeBranchesCellIds.push_back(std::vector <RigWellResultPoint>());
prevResCell = whResCell;
@ -237,9 +237,11 @@ void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< std::vector
pipeBranchesCellIds.back().push_back(*prevResCell);
}
CVF_ASSERT(wellResults->isMultiSegmentWell() || resBranches.size() <= 1);
for (size_t brIdx = 0; brIdx < resBranches.size(); brIdx++)
{
if (resBranches[brIdx].m_wellCells.size() == 0)
if (resBranches[brIdx].m_branchResultPoints.size() == 0)
continue; // Skip empty branches. Do not know why they exist, but they make problems.
prevResCell = NULL;
@ -247,10 +249,10 @@ void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< std::vector
// Find the start the MSW well-branch centerline. Normal wells are started "once" at wellhead in the code above
if (wellResults->isMultiSegmentWell())
{
// if (wellResults->isMultiSegmentWell())
// {
pipeBranchesCLCoords.push_back(std::vector<cvf::Vec3d>());
pipeBranchesCellIds.push_back(std::vector <RigWellResultCell>());
pipeBranchesCellIds.push_back(std::vector <RigWellResultPoint>());
if (brIdx == 0)
{
@ -264,9 +266,12 @@ void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< std::vector
pipeBranchesCLCoords.back().push_back(whIntermediate);
pipeBranchesCellIds.back().push_back(*prevResCell);
}
#if 0 // Branch is supposed to contain its start point except the
else
{
const RigWellResultCell* leafBranchHead = staticWellFrame.findResultCellFromOutletSpecification(resBranches[brIdx].m_outletBranchIndex, resBranches[brIdx].m_outletBranchHeadCellIndex);
const RigWellResultPoint* leafBranchHead = staticWellFrame.findResultCellFromOutletSpecification(resBranches[brIdx].m_outletBranchIndex_OBSOLETE, resBranches[brIdx].m_outletBranchHeadCellIndex_OBSOLETE);
if (leafBranchHead && leafBranchHead->hasGridConnections())
{
// Create a new branch and use branch head as previous result cell
@ -281,13 +286,13 @@ void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< std::vector
}
else if (leafBranchHead)
{
cvf::Vec3d interpolatedCoord = leafBranchHead->m_averageCenter;
cvf::Vec3d interpolatedCoord = leafBranchHead->m_bottomPosition;
CVF_ASSERT(interpolatedCoord != cvf::Vec3d::UNDEFINED);
if (interpolatedCoord != cvf::Vec3d::UNDEFINED)
{
pipeBranchesCLCoords.back().push_back(interpolatedCoord);
pipeBranchesCellIds.back().push_back(RigWellResultCell());
pipeBranchesCellIds.back().push_back(RigWellResultPoint());
}
}
else
@ -295,34 +300,36 @@ void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< std::vector
// No branch head found: Possibly main branch
CVF_ASSERT(false);
}
}
}
#endif
// }
// Loop over all the resultCells in the branch
const std::vector<RigWellResultCell>& resBranchCells = resBranches[brIdx].m_wellCells;
const std::vector<RigWellResultPoint>& resBranchCells = resBranches[brIdx].m_branchResultPoints;
for (int cIdx = 0; cIdx < static_cast<int>(resBranchCells.size()); cIdx++) // Need int because cIdx can temporarily end on -1
{
std::vector<cvf::Vec3d>& branchCLCoords = pipeBranchesCLCoords.back();
std::vector<RigWellResultCell>& branchCellIds = pipeBranchesCellIds.back();
std::vector<RigWellResultPoint>& branchCellIds = pipeBranchesCellIds.back();
const RigWellResultCell& resCell = resBranchCells[cIdx];
const RigWellResultPoint& resPoint = resBranchCells[cIdx];
if (!resCell.hasConnections())
if (!resPoint.isValid())
{
continue;
}
if (resCell.hasBranchConnections())
if (!resPoint.isCell())
{
// Use the interpolated value of branch head
cvf::Vec3d interpolatedCoord = resCell.m_averageCenter;
cvf::Vec3d interpolatedCoord = resPoint.m_bottomPosition;
CVF_ASSERT(interpolatedCoord != cvf::Vec3d::UNDEFINED);
if (interpolatedCoord != cvf::Vec3d::UNDEFINED)
{
pipeBranchesCLCoords.back().push_back(interpolatedCoord);
pipeBranchesCellIds.back().push_back(RigWellResultCell());
pipeBranchesCellIds.back().push_back(RigWellResultPoint());
}
// Set previous result cell to NULL
@ -331,23 +338,25 @@ void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< std::vector
continue;
}
const RigCell& cell = rigReservoir->cellFromWellResultCell(resCell);
const RigCell& cell = rigReservoir->cellFromWellResultCell(resPoint);
// Check if this and the previous cells has shared faces
cvf::StructGridInterface::FaceType sharedFace;
if (prevResCell && rigReservoir->findSharedSourceFace(sharedFace, resCell, *prevResCell))
if (prevResCell && rigReservoir->findSharedSourceFace(sharedFace, resPoint, *prevResCell))
{
branchCLCoords.push_back(cell.faceCenter(sharedFace));
branchCellIds.push_back(resCell);
branchCellIds.push_back(resPoint);
}
else
{
// This and the previous cell does not share a face.
cvf::Vec3d previousCoord;
// If we have a previous cell, we need to go out of it, before entering this.
if (prevResCell)
{
// This and the previous cell does not share a face. We need to go out of the previous cell, before entering this.
const RigCell& prevCell = rigReservoir->cellFromWellResultCell(*prevResCell);
previousCoord = prevCell.center();
}
@ -362,7 +371,7 @@ void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< std::vector
if ( wellResults->isMultiSegmentWell()
|| !isAutoDetectBranches
|| (prevResCell == whResCell)
|| (centerThisCell-previousCoord).lengthSquared() <= (centerThisCell - whStartPos).lengthSquared()
|| (centerThisCell - previousCoord).lengthSquared() <= (centerThisCell - whStartPos).lengthSquared()
)
{
// Not starting a "display" branch
@ -391,7 +400,7 @@ void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< std::vector
}
branchCLCoords.push_back(intoThisCell);
branchCellIds.push_back(resCell);
branchCellIds.push_back(resPoint);
}
else
{
@ -405,7 +414,7 @@ void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< std::vector
// Create new display branch
pipeBranchesCLCoords.push_back(std::vector<cvf::Vec3d>());
pipeBranchesCellIds.push_back(std::vector <RigWellResultCell>());
pipeBranchesCellIds.push_back(std::vector <RigWellResultPoint>());
// Start the new branch by entering the first cell (the wellhead) and intermediate
prevResCell = whResCell;
@ -422,7 +431,7 @@ void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< std::vector
}
}
prevResCell = &resCell;
prevResCell = &resPoint;
}
if ( wellResults->isMultiSegmentWell())
@ -509,14 +518,14 @@ void RivWellPipesPartMgr::updatePipeResultColor(size_t frameIndex)
wellCellStates.clear();
wellCellStates.resize(brIt->m_cellIds.size(), closed);
const std::vector <RigWellResultCell>& cellIds = brIt->m_cellIds;
const std::vector <RigWellResultPoint>& cellIds = brIt->m_cellIds;
for (size_t wcIdx = 0; wcIdx < cellIds.size(); ++wcIdx)
{
// we need a faster lookup, I guess
const RigWellResultCell* wResCell = NULL;
const RigWellResultPoint* wResCell = NULL;
if (cellIds[wcIdx].hasGridConnections())
if (cellIds[wcIdx].isCell())
{
wResCell = wResFrame.findResultCell(cellIds[wcIdx].m_gridIndex, cellIds[wcIdx].m_gridCellIndex);
}

View File

@ -67,11 +67,11 @@ private:
//void calculateWellPipeCenterline(std::vector<cvf::Vec3d>& coords) const;
void calculateWellPipeCenterline(std::vector< std::vector <cvf::Vec3d> >& pipeBranchesCLCoords,
std::vector< std::vector <RigWellResultCell> >& pipeBranchesCellIds ) const;
std::vector< std::vector <RigWellResultPoint> >& pipeBranchesCellIds ) const;
struct RivPipeBranchData
{
std::vector <RigWellResultCell> m_cellIds;
std::vector <RigWellResultPoint> m_cellIds;
//std::vector< std::vector<WellCellStatus> > m_cellStatusPrFrame;
cvf::ref<RivPipeGeometryGenerator> m_pipeGeomGenerator;

View File

@ -1037,14 +1037,14 @@ void RimReservoirView::appendCellResultInfo(size_t gridIndex, size_t cellIndex,
}
const RigWellResultFrame& wellResultFrame = singleWellResultData->wellResultFrame(m_currentTimeStep);
const RigWellResultCell* wellResultCell = wellResultFrame.findResultCell(gridIndex, cellIndex);
const RigWellResultPoint* wellResultCell = wellResultFrame.findResultCell(gridIndex, cellIndex);
if (wellResultCell)
{
resultInfoText->append(QString("(0-based) Branch Id : %1 Segment Id %2\n").arg(wellResultCell->m_ertBranchId).arg(wellResultCell->m_ertSegmentId));
if (wellResultCell->hasBranchConnections())
if (wellResultCell->m_branchConnectionCount)
{
resultInfoText->append(QString("Branch Connection Count : %1\n").arg(wellResultCell->m_branchConnectionCount));
resultInfoText->append(QString("Center coord : %1 %2 %3\n").arg(wellResultCell->m_averageCenter.x()).arg(wellResultCell->m_averageCenter.y()).arg(wellResultCell->m_averageCenter.z()));
resultInfoText->append(QString("Center coord : %1 %2 %3\n").arg(wellResultCell->m_bottomPosition.x()).arg(wellResultCell->m_bottomPosition.y()).arg(wellResultCell->m_bottomPosition.z()));
}
}
}
@ -1399,12 +1399,12 @@ void RimReservoirView::calculateVisibleWellCellsIncFence(cvf::UByteArray* visibl
const std::vector<RigWellResultBranch>& wellResSegments = wellResFrames[wfIdx].m_wellResultBranches;
for (size_t wsIdx = 0; wsIdx < wellResSegments.size(); ++wsIdx)
{
const std::vector<RigWellResultCell>& wsResCells = wellResSegments[wsIdx].m_wellCells;
const std::vector<RigWellResultPoint>& wsResCells = wellResSegments[wsIdx].m_branchResultPoints;
for (size_t cIdx = 0; cIdx < wsResCells.size(); ++ cIdx)
{
if (wsResCells[cIdx].m_gridIndex == grid->gridIndex())
{
if (!wsResCells[cIdx].hasGridConnections())
if (!wsResCells[cIdx].isCell())
{
continue;
}

View File

@ -193,10 +193,10 @@ bool RimWell::calculateWellPipeVisibility(size_t frameIndex)
const std::vector<RigWellResultBranch>& wellResSegments = wrsf.m_wellResultBranches;
for (size_t wsIdx = 0; wsIdx < wellResSegments.size(); ++wsIdx)
{
const std::vector<RigWellResultCell>& wsResCells = wellResSegments[wsIdx].m_wellCells;
const std::vector<RigWellResultPoint>& wsResCells = wellResSegments[wsIdx].m_branchResultPoints;
for (size_t cIdx = 0; cIdx < wsResCells.size(); ++ cIdx)
{
if (wsResCells[cIdx].hasGridConnections())
if (wsResCells[cIdx].isCell())
{
gridIndex = wsResCells[cIdx].m_gridIndex;
gridCellIndex = wsResCells[cIdx].m_gridCellIndex;

View File

@ -66,16 +66,6 @@ namespace caf
}
}
namespace caf
{
template<>
void RimWellCollection::WellHeadPositionEnum::setUp()
{
addItem(RimWellCollection::WELLHEAD_POS_ACTIVE_CELLS_BB, "WELLHEAD_POS_ACTIVE_CELLS_BB", "Top of active cells BB");
addItem(RimWellCollection::WELLHEAD_POS_TOP_COLUMN, "WELLHEAD_POS_TOP_COLUMN", "Top of active cells IJ-column");
setDefault(RimWellCollection::WELLHEAD_POS_TOP_COLUMN);
}
}
CAF_PDM_SOURCE_INIT(RimWellCollection, "Wells");
@ -86,13 +76,12 @@ RimWellCollection::RimWellCollection()
{
CAF_PDM_InitObject("Wells", ":/WellCollection.png", "", "");
CAF_PDM_InitField(&isActive, "Active", true, "Active", "", "", "");
isActive.setUiHidden(true);
CAF_PDM_InitField(&active, "Active", true, "Active", "", "", "");
active.setUiHidden(true);
CAF_PDM_InitField(&showWellHead, "ShowWellHead", true, "Show well heads", "", "", "");
CAF_PDM_InitField(&showWellLabel, "ShowWellLabel", true, "Show well labels", "", "", "");
CAF_PDM_InitField(&wellHeadScaleFactor, "WellHeadScale", 1.0, "Well head scale", "", "", "");
CAF_PDM_InitField(&wellHeadPosition, "WellHeadPosition", WellHeadPositionEnum(WELLHEAD_POS_TOP_COLUMN), "Well head position", "", "", "");
CAF_PDM_InitField(&wellPipeVisibility, "GlobalWellPipeVisibility", WellVisibilityEnum(PIPES_OPEN_IN_VISIBLE_CELLS), "Global well pipe visibility", "", "", "");
@ -141,7 +130,6 @@ RimWell* RimWellCollection::findWell(QString name)
//--------------------------------------------------------------------------------------------------
bool RimWellCollection::hasVisibleWellCells()
{
if (!this->isActive()) return false;
if (this->wellCellsToRangeFilterMode() == RANGE_ADD_NONE) return false;
if (this->wells().size() == 0 ) return false;
@ -156,7 +144,7 @@ bool RimWellCollection::hasVisibleWellCells()
const RigWellResultFrame& wellResultFrame = well->wellResults()->m_wellCellsTimeSteps[tIdx];
for (size_t wsIdx = 0; !hasCells && wsIdx < wellResultFrame.m_wellResultBranches.size(); ++wsIdx)
{
if (wellResultFrame.m_wellResultBranches[wsIdx].m_wellCells.size() > 0 ) hasCells = true;
if (wellResultFrame.m_wellResultBranches[wsIdx].m_branchResultPoints.size() > 0 ) hasCells = true;
}
}
}
@ -176,7 +164,7 @@ bool RimWellCollection::hasVisibleWellCells()
//--------------------------------------------------------------------------------------------------
bool RimWellCollection::hasVisibleWellPipes()
{
if (!this->isActive()) return false;
if (!this->active()) return false;
if (this->wellPipeVisibility() == PIPES_FORCE_ALL_OFF) return false;
if (this->wells().size() == 0 ) return false;
if (this->wellPipeVisibility() == PIPES_FORCE_ALL_ON) return true;
@ -190,13 +178,12 @@ bool RimWellCollection::hasVisibleWellPipes()
//--------------------------------------------------------------------------------------------------
void RimWellCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue)
{
if (&showWellLabel == changedField || &isActive == changedField)
if (&showWellLabel == changedField || &active == changedField)
{
this->updateUiIconFromState(isActive);
this->updateUiIconFromState(active);
if (m_reservoirView)
{
m_reservoirView->scheduleGeometryRegen(RivReservoirViewPartMgr::VISIBLE_WELL_CELLS);
m_reservoirView->createDisplayModelAndRedraw();
}
}
@ -242,8 +229,7 @@ void RimWellCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField
|| &pipeRadiusScaleFactor == changedField
|| &wellHeadScaleFactor == changedField
|| &showWellHead == changedField
|| &isAutoDetectingBranches == changedField
|| &wellHeadPosition == changedField)
|| &isAutoDetectingBranches == changedField)
{
if (m_reservoirView)
{
@ -290,7 +276,7 @@ void RimWellCollection::defineUiOrdering(QString uiConfigName, caf::PdmUiOrderin
//--------------------------------------------------------------------------------------------------
caf::PdmFieldHandle* RimWellCollection::objectToggleField()
{
return &isActive;
return &active;
}

View File

@ -173,10 +173,10 @@ void RigCaseData::computeWellCellsPrGrid()
{
RigWellResultBranch& wellSegment = wellCells.m_wellResultBranches[sIdx];
size_t cdIdx;
for (cdIdx = 0; cdIdx < wellSegment.m_wellCells.size(); ++cdIdx)
for (cdIdx = 0; cdIdx < wellSegment.m_branchResultPoints.size(); ++cdIdx)
{
gridIndex = wellSegment.m_wellCells[cdIdx].m_gridIndex;
gridCellIndex = wellSegment.m_wellCells[cdIdx].m_gridCellIndex;
gridIndex = wellSegment.m_branchResultPoints[cdIdx].m_gridIndex;
gridCellIndex = wellSegment.m_branchResultPoints[cdIdx].m_gridCellIndex;
if(gridIndex < m_wellCellsInGrid.size() && gridCellIndex < m_wellCellsInGrid[gridIndex]->size())
{
@ -227,7 +227,7 @@ cvf::UIntArray* RigCaseData::gridCellToWellIndex(size_t gridIndex)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigCell& RigCaseData::cellFromWellResultCell(const RigWellResultCell& wellResultCell)
RigCell& RigCaseData::cellFromWellResultCell(const RigWellResultPoint& wellResultCell)
{
size_t gridIndex = wellResultCell.m_gridIndex;
size_t gridCellIndex = wellResultCell.m_gridCellIndex;
@ -241,7 +241,7 @@ RigCell& RigCaseData::cellFromWellResultCell(const RigWellResultCell& wellResult
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigCaseData::findSharedSourceFace(cvf::StructGridInterface::FaceType& sharedSourceFace,const RigWellResultCell& sourceWellCellResult, const RigWellResultCell& otherWellCellResult) const
bool RigCaseData::findSharedSourceFace(cvf::StructGridInterface::FaceType& sharedSourceFace,const RigWellResultPoint& sourceWellCellResult, const RigWellResultPoint& otherWellCellResult) const
{
size_t gridIndex = sourceWellCellResult.m_gridIndex;
size_t gridCellIndex = sourceWellCellResult.m_gridCellIndex;

View File

@ -65,8 +65,8 @@ public:
cvf::UByteArray* wellCellsInGrid(size_t gridIndex);
cvf::UIntArray* gridCellToWellIndex(size_t gridIndex);
RigCell& cellFromWellResultCell(const RigWellResultCell& wellResultCell);
bool findSharedSourceFace(cvf::StructGridInterface::FaceType& sharedSourceFace, const RigWellResultCell& sourceWellCellResult, const RigWellResultCell& otherWellCellResult) const;
RigCell& cellFromWellResultCell(const RigWellResultPoint& wellResultCell);
bool findSharedSourceFace(cvf::StructGridInterface::FaceType& sharedSourceFace, const RigWellResultPoint& sourceWellCellResult, const RigWellResultPoint& otherWellCellResult) const;
void computeActiveCellBoundingBoxes();

View File

@ -407,7 +407,7 @@ void RigReservoirBuilderMock::addWellData(RigCaseData* eclipseCase, RigGridBase*
{
if (connIdx == (size_t)(connectionCount/4)) continue;
RigWellResultCell data;
RigWellResultPoint data;
data.m_gridIndex = 0;
if (connIdx < dim.y()-2)
@ -425,28 +425,28 @@ void RigReservoirBuilderMock::addWellData(RigCaseData* eclipseCase, RigGridBase*
data.m_isOpen = false;
}
if (wellSegment.m_wellCells.size() == 0 || wellSegment.m_wellCells.back().m_gridCellIndex != data.m_gridCellIndex)
if (wellSegment.m_branchResultPoints.size() == 0 || wellSegment.m_branchResultPoints.back().m_gridCellIndex != data.m_gridCellIndex)
{
wellSegment.m_wellCells.push_back(data);
wellSegment.m_branchResultPoints.push_back(data);
if (connIdx == connectionCount / 2 )
{
RigWellResultCell deadEndData = data;
RigWellResultPoint deadEndData = data;
deadEndData.m_gridCellIndex = data.m_gridCellIndex + 1;
deadEndData.m_isOpen = true;
RigWellResultCell deadEndData1 = data;
RigWellResultPoint deadEndData1 = data;
deadEndData1.m_gridCellIndex = data.m_gridCellIndex + 2;
deadEndData.m_isOpen = false;
wellSegment.m_wellCells.push_back(deadEndData);
wellSegment.m_wellCells.push_back(deadEndData1);
wellSegment.m_branchResultPoints.push_back(deadEndData);
wellSegment.m_branchResultPoints.push_back(deadEndData1);
deadEndData.m_isOpen = true;
wellSegment.m_wellCells.push_back(deadEndData);
wellSegment.m_branchResultPoints.push_back(deadEndData);
data.m_isOpen = true;
wellSegment.m_wellCells.push_back(data);
wellSegment.m_branchResultPoints.push_back(data);
}
}
@ -454,9 +454,9 @@ void RigReservoirBuilderMock::addWellData(RigCaseData* eclipseCase, RigGridBase*
{
data.m_gridCellIndex = grid->cellIndexFromIJK(1 , 1 + connIdx , 2 + connIdx);
if (wellSegment.m_wellCells.size() == 0 || wellSegment.m_wellCells.back().m_gridCellIndex != data.m_gridCellIndex)
if (wellSegment.m_branchResultPoints.size() == 0 || wellSegment.m_branchResultPoints.back().m_gridCellIndex != data.m_gridCellIndex)
{
wellSegment.m_wellCells.push_back(data);
wellSegment.m_branchResultPoints.push_back(data);
}
}
}

View File

@ -112,16 +112,16 @@ void RigSingleWellResultsData::computeStaticWellCellPath()
{
if (m_wellCellsTimeSteps.size() == 0) return;
std::map < size_t, std::list< RigWellResultCell > > staticWellBranches;
std::map < size_t, std::list< RigWellResultPoint > > staticWellBranches;
// Add ResultCell data from the first timestep to the final result.
for (size_t bIdx = 0; bIdx < m_wellCellsTimeSteps[0].m_wellResultBranches.size(); ++bIdx)
{
size_t branchNumber = m_wellCellsTimeSteps[0].m_wellResultBranches[bIdx].m_branchIndex;
std::vector<RigWellResultCell>& frameCells = m_wellCellsTimeSteps[0].m_wellResultBranches[bIdx].m_wellCells;
std::vector<RigWellResultPoint>& frameCells = m_wellCellsTimeSteps[0].m_wellResultBranches[bIdx].m_branchResultPoints;
std::list< RigWellResultCell >& branch = staticWellBranches[branchNumber];
std::list< RigWellResultPoint >& branch = staticWellBranches[branchNumber];
for(size_t cIdx = 0; cIdx < frameCells.size(); ++cIdx)
{
@ -138,12 +138,12 @@ void RigSingleWellResultsData::computeStaticWellCellPath()
for (size_t bIdx = 0; bIdx < m_wellCellsTimeSteps[tIdx].m_wellResultBranches.size(); ++bIdx)
{
size_t branchNumber = m_wellCellsTimeSteps[tIdx].m_wellResultBranches[bIdx].m_branchIndex;
std::vector<RigWellResultCell>& resBranch = m_wellCellsTimeSteps[tIdx].m_wellResultBranches[bIdx].m_wellCells;
std::vector<RigWellResultPoint>& resBranch = m_wellCellsTimeSteps[tIdx].m_wellResultBranches[bIdx].m_branchResultPoints;
std::list< RigWellResultCell >& stBranch = staticWellBranches[branchNumber];
std::list< RigWellResultCell >::iterator it;
std::list< RigWellResultCell >::iterator sStartIt;
std::list< RigWellResultCell >::iterator sEndIt;
std::list< RigWellResultPoint >& stBranch = staticWellBranches[branchNumber];
std::list< RigWellResultPoint >::iterator it;
std::list< RigWellResultPoint >::iterator sStartIt;
std::list< RigWellResultPoint >::iterator sEndIt;
size_t rStartIdx;
size_t rEndIdx;
@ -245,7 +245,7 @@ void RigSingleWellResultsData::computeStaticWellCellPath()
// Populate the static well info
std::map < size_t, std::list< RigWellResultCell > >::iterator bIt;
std::map < size_t, std::list< RigWellResultPoint > >::iterator bIt;
m_staticWellCells.m_wellResultBranches.clear();
m_staticWellCells.m_wellHead = m_wellCellsTimeSteps[0].m_wellHead;
@ -262,15 +262,15 @@ void RigSingleWellResultsData::computeStaticWellCellPath()
rigBranch.m_branchIndex = bIt->first;
// Clear well cells, and insert the collection of well cells for the static situation
rigBranch.m_wellCells.clear();
rigBranch.m_branchResultPoints.clear();
std::list< RigWellResultCell >& branch = bIt->second;
std::list< RigWellResultCell >::iterator cIt;
std::list< RigWellResultPoint >& branch = bIt->second;
std::list< RigWellResultPoint >::iterator cIt;
for (cIt = branch.begin(); cIt != branch.end(); ++cIt)
{
RigWellResultCell rwc = *cIt;
RigWellResultPoint rwc = *cIt;
rwc.m_isOpen = false; // Reset the dynamic property
rigBranch.m_wellCells.push_back(*cIt);
rigBranch.m_branchResultPoints.push_back(*cIt);
}
m_staticWellCells.m_wellResultBranches.push_back(rigBranch);

View File

@ -27,31 +27,31 @@
#include <vector>
#include "cvfVector3.h"
struct RigWellResultCell
struct RigWellResultPoint
{
RigWellResultCell() :
RigWellResultPoint() :
m_gridIndex(cvf::UNDEFINED_SIZE_T),
m_gridCellIndex(cvf::UNDEFINED_SIZE_T),
m_isOpen(false),
m_ertBranchId(-1),
m_ertSegmentId(-1),
m_averageCenter(cvf::Vec3d::UNDEFINED),
m_bottomPosition(cvf::Vec3d::UNDEFINED),
m_branchConnectionCount(0)
{ }
bool hasBranchConnections() const
bool isPointValid() const
{
return m_branchConnectionCount != 0;
return m_bottomPosition != cvf::Vec3d::UNDEFINED;
}
bool hasGridConnections() const
bool isCell() const
{
return m_gridCellIndex != cvf::UNDEFINED_SIZE_T;
}
bool hasConnections() const
bool isValid() const
{
return hasGridConnections() || hasBranchConnections();
return isCell() || isPointValid();
}
@ -63,33 +63,30 @@ struct RigWellResultCell
int m_ertBranchId;
int m_ertSegmentId;
cvf::Vec3d m_averageCenter;
cvf::Vec3d m_bottomPosition;
size_t m_branchConnectionCount;
};
struct RigWellResultBranch
{
RigWellResultBranch() :
m_branchIndex(cvf::UNDEFINED_SIZE_T),
m_ertBranchId(-1),
m_outletBranchIndex(cvf::UNDEFINED_SIZE_T),
m_outletBranchHeadCellIndex(cvf::UNDEFINED_SIZE_T)
m_outletBranchIndex_OBSOLETE(cvf::UNDEFINED_SIZE_T),
m_outletBranchHeadCellIndex_OBSOLETE(cvf::UNDEFINED_SIZE_T)
{}
size_t m_branchIndex;
int m_ertBranchId;
std::vector<RigWellResultCell> m_wellCells;
std::vector<RigWellResultPoint> m_branchResultPoints;
// Grid cell from last connection in outlet segment. For MSW wells, this is either well head or a well result cell in another branch
// For standard wells, this is always well head.
RigWellResultCell m_branchHead;
// Grid cell from last connection in outlet segment. For MSW wells, this is either well head or a well result cell in another branch
// For standard wells, this is always well head.
size_t m_outletBranchIndex;
size_t m_outletBranchHeadCellIndex;
size_t m_outletBranchIndex_OBSOLETE;
size_t m_outletBranchHeadCellIndex_OBSOLETE;
};
@ -104,7 +101,7 @@ public:
m_productionType(UNDEFINED_PRODUCTION_TYPE)
{ }
const RigWellResultCell* findResultCell(size_t gridIndex, size_t gridCellIndex) const
const RigWellResultPoint* findResultCell(size_t gridIndex, size_t gridCellIndex) const
{
CVF_ASSERT(gridIndex != cvf::UNDEFINED_SIZE_T && gridCellIndex != cvf::UNDEFINED_SIZE_T);
@ -115,12 +112,12 @@ public:
for (size_t wb = 0; wb < m_wellResultBranches.size(); ++wb)
{
for (size_t wc = 0; wc < m_wellResultBranches[wb].m_wellCells.size(); ++wc)
for (size_t wc = 0; wc < m_wellResultBranches[wb].m_branchResultPoints.size(); ++wc)
{
if ( m_wellResultBranches[wb].m_wellCells[wc].m_gridCellIndex == gridCellIndex
&& m_wellResultBranches[wb].m_wellCells[wc].m_gridIndex == gridIndex )
if ( m_wellResultBranches[wb].m_branchResultPoints[wc].m_gridCellIndex == gridCellIndex
&& m_wellResultBranches[wb].m_branchResultPoints[wc].m_gridIndex == gridIndex )
{
return &(m_wellResultBranches[wb].m_wellCells[wc]);
return &(m_wellResultBranches[wb].m_branchResultPoints[wc]);
}
}
}
@ -128,14 +125,14 @@ public:
return NULL;
}
const RigWellResultCell* findResultCellFromOutletSpecification(size_t branchIndex, size_t wellResultCellIndex) const
const RigWellResultPoint* findResultCellFromOutletSpecification(size_t branchIndex, size_t wellResultCellIndex) const
{
if (branchIndex != cvf::UNDEFINED_SIZE_T && branchIndex < m_wellResultBranches.size())
{
const RigWellResultBranch& resBranch = m_wellResultBranches[branchIndex];
if (wellResultCellIndex != cvf::UNDEFINED_SIZE_T && wellResultCellIndex < resBranch.m_wellCells.size())
if (wellResultCellIndex != cvf::UNDEFINED_SIZE_T && wellResultCellIndex < resBranch.m_branchResultPoints.size())
{
return (&resBranch.m_wellCells[wellResultCellIndex]);
return (&resBranch.m_branchResultPoints[wellResultCellIndex]);
}
}
@ -145,7 +142,7 @@ public:
WellProductionType m_productionType;
bool m_isOpen;
RigWellResultCell m_wellHead;
RigWellResultPoint m_wellHead;
QDateTime m_timestamp;
std::vector<RigWellResultBranch> m_wellResultBranches;