mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
MswRollUp: Principal fixes to the MSW algorithms
Add point contributions even when it is undefined to store the segment below id, which is needed for the traversal. The undefined positions comes from bottom end segments without connections. Also cleaned up the the static well calculation This is an intermediate commit and does not compile p4#: 22226
This commit is contained in:
parent
6ecfbdb8ee
commit
d5aa8e4f30
@ -854,8 +854,6 @@ void propagatePosContribDownwards(std::map<int, std::vector<SegmentPositionContr
|
|||||||
std::map<int, std::vector<SegmentPositionContribution> >::iterator posContribIt;
|
std::map<int, std::vector<SegmentPositionContribution> >::iterator posContribIt;
|
||||||
posContribIt = segmentIdToPositionContrib.find(ertSegmentId);
|
posContribIt = segmentIdToPositionContrib.find(ertSegmentId);
|
||||||
|
|
||||||
well_segment_type *segment = well_segment_collection_get( allErtSegments , posContribIt->first);
|
|
||||||
double sementLength = well_segment_get_length(segment);
|
|
||||||
|
|
||||||
if ( posContribIt != segmentIdToPositionContrib.end())
|
if ( posContribIt != segmentIdToPositionContrib.end())
|
||||||
{
|
{
|
||||||
@ -867,7 +865,12 @@ void propagatePosContribDownwards(std::map<int, std::vector<SegmentPositionContr
|
|||||||
segmentIdsBelow.insert(posContribIt->second[i].m_segmentIdUnder);
|
segmentIdsBelow.insert(posContribIt->second[i].m_segmentIdUnder);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we do naot have the contribution represented, add it, and accumulate the length
|
// Get the segment length to add to the contributions
|
||||||
|
|
||||||
|
well_segment_type *segment = well_segment_collection_get( allErtSegments , posContribIt->first);
|
||||||
|
double sementLength = well_segment_get_length(segment);
|
||||||
|
|
||||||
|
// If we do not have the contribution represented, add it, and accumulate the length
|
||||||
// If it is already present, do not touch
|
// If it is already present, do not touch
|
||||||
for (size_t i = 0; i < posContrib.size(); ++i)
|
for (size_t i = 0; i < posContrib.size(); ++i)
|
||||||
{
|
{
|
||||||
@ -883,8 +886,8 @@ void propagatePosContribDownwards(std::map<int, std::vector<SegmentPositionContr
|
|||||||
|
|
||||||
if (! foundContribution)
|
if (! foundContribution)
|
||||||
{
|
{
|
||||||
posContribIt->second.push_back(posContrib[i]);
|
|
||||||
posContrib[i].m_lengthFromConnection += sementLength;
|
posContrib[i].m_lengthFromConnection += sementLength;
|
||||||
|
posContribIt->second.push_back(posContrib[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1072,12 +1075,11 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid)
|
|||||||
wellResultBranch.m_branchResultPoints.push_back(data);
|
wellResultBranch.m_branchResultPoints.push_back(data);
|
||||||
|
|
||||||
// Store data for segment position calculation
|
// Store data for segment position calculation
|
||||||
if (lastConnectionPos != cvf::Vec3d::UNDEFINED)
|
|
||||||
{
|
segmentIdToPositionContrib[well_segment_get_id(segment)].push_back(
|
||||||
segmentIdToPositionContrib[well_segment_get_id(segment)].push_back(
|
SegmentPositionContribution(lastConnectionSegmentId, lastConnectionPos, accLengthFromLastConnection, segmentIdBelow));
|
||||||
SegmentPositionContribution(lastConnectionSegmentId, lastConnectionPos, accLengthFromLastConnection, segmentIdBelow));
|
accLengthFromLastConnection += well_segment_get_length(segment);
|
||||||
accLengthFromLastConnection += well_segment_get_length(segment);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
segmentIdBelow = well_segment_get_id(segment);
|
segmentIdBelow = well_segment_get_id(segment);
|
||||||
@ -1133,9 +1135,7 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid)
|
|||||||
|
|
||||||
// Store data for segment position calculation, and propagate it upwards until we meet a segment with connections
|
// Store data for segment position calculation, and propagate it upwards until we meet a segment with connections
|
||||||
|
|
||||||
if (lastConnectionPos != cvf::Vec3d::UNDEFINED)
|
segmentIdToPositionContrib[well_segment_get_id(outletSegment)].push_back(
|
||||||
{
|
|
||||||
segmentIdToPositionContrib[well_segment_get_id(outletSegment)].push_back(
|
|
||||||
SegmentPositionContribution(lastConnectionSegmentId, lastConnectionPos, accLengthFromLastConnection, segmentIdBelow));
|
SegmentPositionContribution(lastConnectionSegmentId, lastConnectionPos, accLengthFromLastConnection, segmentIdBelow));
|
||||||
|
|
||||||
/// Loop further to add this position contribution until a segment with connections is found
|
/// Loop further to add this position contribution until a segment with connections is found
|
||||||
@ -1193,12 +1193,14 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid)
|
|||||||
aboveOutletSegment = well_segment_get_outlet(aboveOutletSegment);
|
aboveOutletSegment = well_segment_get_outlet(aboveOutletSegment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Add wellhead as result point ?
|
// Add wellhead as result point Nope. Not Yet, but it is a good idea.
|
||||||
|
// The centerline calculations would be a bit simpler, I think.
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reverse the order of the resultpoints in this branch, making the deepest come last
|
// Reverse the order of the resultpoints in this branch, making the deepest come last
|
||||||
@ -1214,35 +1216,46 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid)
|
|||||||
{
|
{
|
||||||
RigWellResultBranch& wellResultBranch = wellResFrame.m_wellResultBranches[ bIdx];
|
RigWellResultBranch& wellResultBranch = wellResFrame.m_wellResultBranches[ bIdx];
|
||||||
bool previousResultPointWasCell = false;
|
bool previousResultPointWasCell = false;
|
||||||
|
if (bIdx == 0) previousResultPointWasCell = true; // Wellhead
|
||||||
|
|
||||||
for (size_t rpIdx = 0; rpIdx < wellResultBranch.m_branchResultPoints.size(); ++rpIdx)
|
for (size_t rpIdx = 0; rpIdx < wellResultBranch.m_branchResultPoints.size(); ++rpIdx)
|
||||||
{
|
{
|
||||||
if ( wellResultBranch.m_branchResultPoints[rpIdx].isCell() )
|
RigWellResultPoint resPoint = wellResultBranch.m_branchResultPoints[rpIdx];
|
||||||
|
if ( resPoint.isCell() )
|
||||||
{
|
{
|
||||||
previousResultPointWasCell = true;
|
previousResultPointWasCell = true;
|
||||||
}
|
}
|
||||||
else if (previousResultPointWasCell)
|
else
|
||||||
{
|
{
|
||||||
CVF_ASSERT(rpIdx > 0);
|
if (previousResultPointWasCell)
|
||||||
RigWellResultPoint prevResPoint = wellResultBranch.m_branchResultPoints[rpIdx - 1 ];
|
{
|
||||||
cvf::Vec3d lastConnectionPos = grids[prevResPoint.m_gridIndex]->cell(prevResPoint.m_gridCellIndex).center();
|
RigWellResultPoint prevResPoint;
|
||||||
well_segment_type *segment = well_segment_collection_get( allErtSegments , prevResPoint.m_ertSegmentId);
|
if (bIdx == 0 && rpIdx == 0)
|
||||||
const well_conn_collection_type* connections = well_segment_get_connections(segment, this->ertGridName(prevResPoint.m_gridIndex).data());
|
{
|
||||||
int connectionCount = well_conn_collection_get_size(connections);
|
prevResPoint = wellResFrame.m_wellHead;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
prevResPoint = wellResultBranch.m_branchResultPoints[rpIdx - 1 ];
|
||||||
|
}
|
||||||
|
|
||||||
double accLengthFromLastConnection = well_segment_get_length(segment)/(connectionCount+1);
|
cvf::Vec3d lastConnectionPos = grids[prevResPoint.m_gridIndex]->cell(prevResPoint.m_gridCellIndex).center();
|
||||||
|
|
||||||
SegmentPositionContribution posContrib(prevResPoint.m_ertSegmentId, lastConnectionPos, accLengthFromLastConnection, -1);
|
SegmentPositionContribution posContrib(prevResPoint.m_ertSegmentId, lastConnectionPos, 0.0, -1);
|
||||||
|
|
||||||
int ertSegmentId = wellResultBranch.m_branchResultPoints[rpIdx].m_ertSegmentId;
|
int ertSegmentId = resPoint.m_ertSegmentId;
|
||||||
|
|
||||||
std::map<int, std::vector<SegmentPositionContribution> >::iterator posContribIt;
|
std::map<int, std::vector<SegmentPositionContribution> >::iterator posContribIt;
|
||||||
posContribIt = segmentIdToPositionContrib.find(ertSegmentId);
|
posContribIt = segmentIdToPositionContrib.find(ertSegmentId);
|
||||||
CVF_ASSERT(posContribIt != segmentIdToPositionContrib.end());
|
CVF_ASSERT(posContribIt != segmentIdToPositionContrib.end());
|
||||||
|
|
||||||
std::vector<SegmentPositionContribution> posContributions = posContribIt->second;
|
std::vector<SegmentPositionContribution> posContributions = posContribIt->second;
|
||||||
posContributions.push_back(posContrib);
|
posContributions.push_back(posContrib);
|
||||||
|
|
||||||
propagatePosContribDownwards(segmentIdToPositionContrib, allErtSegments, ertSegmentId, posContributions);
|
propagatePosContribDownwards(segmentIdToPositionContrib, allErtSegments, ertSegmentId, posContributions);
|
||||||
|
}
|
||||||
|
|
||||||
|
previousResultPointWasCell = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1579,19 +1592,7 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid)
|
|||||||
// All the grids does not necessarily have a well head definition.
|
// All the grids does not necessarily have a well head definition.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const well_conn_collection_type* connections = well_state_get_grid_connections(ert_well_state, this->ertGridName(gridNr).data());
|
||||||
std::string gridName;
|
|
||||||
if (gridNr == 0)
|
|
||||||
{
|
|
||||||
gridName = ECL_GRID_GLOBAL_GRID;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
RigGridBase* rigGrid = m_eclipseCase->grid(gridNr);
|
|
||||||
gridName = rigGrid->gridName();
|
|
||||||
}
|
|
||||||
|
|
||||||
const well_conn_collection_type* connections = well_state_get_grid_connections(ert_well_state, gridName.data());
|
|
||||||
|
|
||||||
// Import all well result cells for all connections
|
// Import all well result cells for all connections
|
||||||
if (connections)
|
if (connections)
|
||||||
@ -1603,7 +1604,7 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid)
|
|||||||
RigWellResultBranch& wellResultBranch = wellResFrame.m_wellResultBranches.back();
|
RigWellResultBranch& wellResultBranch = wellResFrame.m_wellResultBranches.back();
|
||||||
|
|
||||||
wellResultBranch.m_branchIndex = 0;
|
wellResultBranch.m_branchIndex = 0;
|
||||||
wellResultBranch.m_ertBranchId = -1;
|
wellResultBranch.m_ertBranchId = 0; // Normal wells have only one branch
|
||||||
|
|
||||||
size_t existingCellCount = wellResultBranch.m_branchResultPoints.size();
|
size_t existingCellCount = wellResultBranch.m_branchResultPoints.size();
|
||||||
wellResultBranch.m_branchResultPoints.resize(existingCellCount + connectionCount);
|
wellResultBranch.m_branchResultPoints.resize(existingCellCount + connectionCount);
|
||||||
|
@ -206,6 +206,7 @@ void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< std::vector
|
|||||||
if (resBranches[i].m_branchResultPoints.size() != 0)
|
if (resBranches[i].m_branchResultPoints.size() != 0)
|
||||||
{
|
{
|
||||||
hasResultCells = true;
|
hasResultCells = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ void RigSingleWellResultsData::computeStaticWellCellPath()
|
|||||||
|
|
||||||
for (size_t bIdx = 0; bIdx < m_wellCellsTimeSteps[0].m_wellResultBranches.size(); ++bIdx)
|
for (size_t bIdx = 0; bIdx < m_wellCellsTimeSteps[0].m_wellResultBranches.size(); ++bIdx)
|
||||||
{
|
{
|
||||||
size_t branchNumber = m_wellCellsTimeSteps[0].m_wellResultBranches[bIdx].m_branchIndex;
|
size_t branchNumber = m_wellCellsTimeSteps[0].m_wellResultBranches[bIdx].m_ertBranchId;
|
||||||
std::vector<RigWellResultPoint>& frameCells = m_wellCellsTimeSteps[0].m_wellResultBranches[bIdx].m_branchResultPoints;
|
std::vector<RigWellResultPoint>& frameCells = m_wellCellsTimeSteps[0].m_wellResultBranches[bIdx].m_branchResultPoints;
|
||||||
|
|
||||||
std::list< RigWellResultPoint >& branch = staticWellBranches[branchNumber];
|
std::list< RigWellResultPoint >& branch = staticWellBranches[branchNumber];
|
||||||
@ -145,7 +145,7 @@ void RigSingleWellResultsData::computeStaticWellCellPath()
|
|||||||
|
|
||||||
for (size_t bIdx = 0; bIdx < m_wellCellsTimeSteps[tIdx].m_wellResultBranches.size(); ++bIdx)
|
for (size_t bIdx = 0; bIdx < m_wellCellsTimeSteps[tIdx].m_wellResultBranches.size(); ++bIdx)
|
||||||
{
|
{
|
||||||
size_t branchNumber = m_wellCellsTimeSteps[tIdx].m_wellResultBranches[bIdx].m_branchIndex;
|
size_t branchNumber = m_wellCellsTimeSteps[tIdx].m_wellResultBranches[bIdx].m_ertBranchId;
|
||||||
std::vector<RigWellResultPoint>& resBranch = m_wellCellsTimeSteps[tIdx].m_wellResultBranches[bIdx].m_branchResultPoints;
|
std::vector<RigWellResultPoint>& resBranch = m_wellCellsTimeSteps[tIdx].m_wellResultBranches[bIdx].m_branchResultPoints;
|
||||||
|
|
||||||
std::list< RigWellResultPoint >& stBranch = staticWellBranches[branchNumber];
|
std::list< RigWellResultPoint >& stBranch = staticWellBranches[branchNumber];
|
||||||
@ -161,17 +161,9 @@ void RigSingleWellResultsData::computeStaticWellCellPath()
|
|||||||
bool found = false;
|
bool found = false;
|
||||||
if (stBranch.size())
|
if (stBranch.size())
|
||||||
{
|
{
|
||||||
size_t sGridIdx = sEndIt->m_gridIndex;
|
|
||||||
size_t sCellIdx = sEndIt->m_gridCellIndex;
|
|
||||||
|
|
||||||
for (rEndIdx = 0; !found && rEndIdx < resBranch.size(); ++rEndIdx)
|
for (rEndIdx = 0; !found && rEndIdx < resBranch.size(); ++rEndIdx)
|
||||||
{
|
{
|
||||||
size_t rGridIdx = resBranch[rEndIdx].m_gridIndex;
|
|
||||||
size_t rCellIdx = resBranch[rEndIdx].m_gridCellIndex;
|
|
||||||
|
|
||||||
//if (sGridIdx == rGridIdx && sCellIdx == rCellIdx) { found = true; break; }
|
|
||||||
if ((*sEndIt) == (resBranch[rEndIdx])) { found = true; break; }
|
if ((*sEndIt) == (resBranch[rEndIdx])) { found = true; break; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,16 +198,9 @@ void RigSingleWellResultsData::computeStaticWellCellPath()
|
|||||||
if (sEndIt != stBranch.end()) ++sEndIt;
|
if (sEndIt != stBranch.end()) ++sEndIt;
|
||||||
for ( ; sEndIt != stBranch.end() ; ++sEndIt)
|
for ( ; sEndIt != stBranch.end() ; ++sEndIt)
|
||||||
{
|
{
|
||||||
size_t sGridIdx = sEndIt->m_gridIndex;
|
|
||||||
size_t sCellIdx = sEndIt->m_gridCellIndex;
|
|
||||||
|
|
||||||
bool found = false;
|
bool found = false;
|
||||||
for (rEndIdx += 1; !found && rEndIdx < resBranch.size(); ++rEndIdx)
|
for (rEndIdx += 1; !found && rEndIdx < resBranch.size(); ++rEndIdx)
|
||||||
{
|
{
|
||||||
size_t rGridIdx = resBranch[rEndIdx].m_gridIndex;
|
|
||||||
size_t rCellIdx = resBranch[rEndIdx].m_gridCellIndex;
|
|
||||||
|
|
||||||
//if (sGridIdx == rGridIdx && sCellIdx == rCellIdx) { found = true; break; }
|
|
||||||
if ((*sEndIt) == (resBranch[rEndIdx])) { found = true; break; }
|
if ((*sEndIt) == (resBranch[rEndIdx])) { found = true; break; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -264,7 +249,7 @@ void RigSingleWellResultsData::computeStaticWellCellPath()
|
|||||||
|
|
||||||
// Copy from first time step
|
// Copy from first time step
|
||||||
RigWellResultBranch rigBranch = m_wellCellsTimeSteps[0].m_wellResultBranches[bIt->first];
|
RigWellResultBranch rigBranch = m_wellCellsTimeSteps[0].m_wellResultBranches[bIt->first];
|
||||||
rigBranch.m_branchIndex = bIt->first;
|
rigBranch.m_ertBranchId = bIt->first;
|
||||||
|
|
||||||
// Clear well cells, and insert the collection of well cells for the static situation
|
// Clear well cells, and insert the collection of well cells for the static situation
|
||||||
rigBranch.m_branchResultPoints.clear();
|
rigBranch.m_branchResultPoints.clear();
|
||||||
|
Loading…
Reference in New Issue
Block a user