mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
MSW code reverted. Regrettfully the work has to be reconsidered.
Both ERT and the resinsight code is rolled back to before MSW was introduced as refined. p4#: 21999
This commit is contained in:
parent
172c2d8b21
commit
4be58edf78
@ -370,10 +370,14 @@ bool RifReaderEclipseOutput::open(const QString& fileName, RigCaseData* eclipseC
|
||||
if (!transferGeometry(mainEclGrid, eclipseCase)) return false;
|
||||
progInfo.incrementProgress();
|
||||
|
||||
m_eclipseCase = eclipseCase;
|
||||
progInfo.setProgressDescription("Releasing reader memory");
|
||||
ecl_grid_free( mainEclGrid );
|
||||
progInfo.incrementProgress();
|
||||
|
||||
progInfo.setProgressDescription("Reading Result index");
|
||||
progInfo.setNextProgressIncrement(60);
|
||||
|
||||
m_eclipseCase = eclipseCase;
|
||||
|
||||
// Build results meta data
|
||||
buildMetaData();
|
||||
@ -381,11 +385,9 @@ bool RifReaderEclipseOutput::open(const QString& fileName, RigCaseData* eclipseC
|
||||
|
||||
progInfo.setNextProgressIncrement(8);
|
||||
progInfo.setProgressDescription("Reading Well information");
|
||||
readWellCells(mainEclGrid);
|
||||
|
||||
readWellCells();
|
||||
|
||||
progInfo.setProgressDescription("Releasing reader memory");
|
||||
ecl_grid_free( mainEclGrid );
|
||||
progInfo.incrementProgress();
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -707,48 +709,16 @@ bool RifReaderEclipseOutput::dynamicResult(const QString& result, PorosityModelR
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Helper structure to handle the metadata for connections in segments
|
||||
struct SegmentData
|
||||
{
|
||||
SegmentData(const well_conn_collection_type* connections) :
|
||||
m_branchId(-1),
|
||||
m_segmentId(-1),
|
||||
m_gridIndex(cvf::UNDEFINED_SIZE_T),
|
||||
m_connections(connections)
|
||||
{}
|
||||
|
||||
int m_branchId;
|
||||
int m_segmentId;
|
||||
size_t m_gridIndex;
|
||||
const well_conn_collection_type* m_connections;
|
||||
};
|
||||
|
||||
void getSegmentDataByBranchId(const std::list<SegmentData>& segments, std::vector<SegmentData>& branchSegments, int branchId)
|
||||
{
|
||||
std::list<SegmentData>::const_iterator it;
|
||||
|
||||
for (it = segments.begin(); it != segments.end(); it++)
|
||||
{
|
||||
if (it->m_branchId == branchId)
|
||||
{
|
||||
branchSegments.push_back(*it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid)
|
||||
void RifReaderEclipseOutput::readWellCells()
|
||||
{
|
||||
CVF_ASSERT(m_eclipseCase);
|
||||
|
||||
if (m_dynamicResultsAccess.isNull()) return;
|
||||
|
||||
well_info_type* ert_well_info = well_info_alloc(mainEclGrid);
|
||||
well_info_type* ert_well_info = well_info_alloc(NULL);
|
||||
if (!ert_well_info) return;
|
||||
|
||||
m_dynamicResultsAccess->readWellData(ert_well_info);
|
||||
@ -815,29 +785,25 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid)
|
||||
|
||||
|
||||
|
||||
|
||||
// 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 maingrid connections as they are "duplicates"
|
||||
|
||||
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()))
|
||||
int branchCount = well_state_iget_lgr_num_branches(ert_well_state, static_cast<int>(gridNr));
|
||||
if (branchCount > 0)
|
||||
{
|
||||
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)
|
||||
// Wellhead. If several grids have a wellhead definition for this well, we use tha 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)
|
||||
{
|
||||
@ -855,275 +821,53 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid)
|
||||
wellResFrame.m_wellHead.m_gridCellIndex = grids[gridNr]->cellIndexFromIJK(cellI, cellJ, cellK);
|
||||
wellResFrame.m_wellHead.m_gridIndex = gridNr;
|
||||
}
|
||||
else
|
||||
|
||||
|
||||
int branchCount = well_state_iget_lgr_num_branches(ert_well_state, static_cast<int>(gridNr));
|
||||
if (branchCount > 0)
|
||||
{
|
||||
CVF_ASSERT(0);
|
||||
}
|
||||
if (static_cast<int>(wellResFrame.m_wellResultBranches.size()) < branchCount) wellResFrame.m_wellResultBranches.resize(branchCount);
|
||||
|
||||
|
||||
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++)
|
||||
for (int branchIdx = 0; branchIdx < branchCount; ++branchIdx )
|
||||
{
|
||||
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))
|
||||
// Connections
|
||||
int connectionCount = well_state_iget_num_lgr_connections(ert_well_state, static_cast<int>(gridNr), branchIdx);
|
||||
if (connectionCount > 0)
|
||||
{
|
||||
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()))
|
||||
|
||||
RigWellResultBranch& wellSegment = wellResFrame.m_wellResultBranches[branchIdx]; // Is this completely right? Is the branch index actually the same between lgrs ?
|
||||
wellSegment.m_branchNumber = branchIdx;
|
||||
size_t existingConnCount = wellSegment.m_wellCells.size();
|
||||
wellSegment.m_wellCells.resize(existingConnCount + connectionCount);
|
||||
|
||||
int connIdx;
|
||||
for (connIdx = 0; connIdx < connectionCount; connIdx++)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
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_wellCells.size();
|
||||
wellResultBranch.m_wellCells.resize(existingCellCount + 1);
|
||||
|
||||
RigWellResultCell& data = wellResultBranch.m_wellCells[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_wellCells.size();
|
||||
wellResultBranch.m_wellCells.resize(existingCellCount + connectionCount);
|
||||
|
||||
for (int connIdx = 0; connIdx < connectionCount; connIdx++)
|
||||
{
|
||||
well_conn_type* ert_connection = well_conn_collection_iget(connData.m_connections, connIdx);
|
||||
const well_conn_type* ert_connection = well_state_iget_lgr_connections( ert_well_state, static_cast<int>(gridNr), branchIdx)[connIdx];
|
||||
CVF_ASSERT(ert_connection);
|
||||
|
||||
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()))
|
||||
{
|
||||
cellK -= static_cast<int>(grids[gridNr]->cellCountK());
|
||||
}
|
||||
|
||||
RigWellResultCell& data = wellSegment.m_wellCells[existingConnCount + connIdx];
|
||||
data.m_gridIndex = gridNr;
|
||||
data.m_gridCellIndex = grids[gridNr]->cellIndexFromIJK(cellI, cellJ, cellK);
|
||||
|
||||
data.m_isOpen = isCellOpen;
|
||||
|
||||
data.m_ertBranchId = connData.m_branchId;
|
||||
data.m_ertSegmentId = 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_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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Update outlet well cells with no grid cell connections
|
||||
|
||||
for (int branchIdx = 0; branchIdx < branchCount; branchIdx++)
|
||||
{
|
||||
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];
|
||||
|
||||
size_t firstCellIndexWithGridConnectionInLeafBranch = cvf::UNDEFINED_SIZE_T;
|
||||
for (size_t j = 0; j < wellResultLeafBranch.m_wellCells.size(); j++)
|
||||
{
|
||||
if (wellResultLeafBranch.m_wellCells[j].hasGridConnections())
|
||||
{
|
||||
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)
|
||||
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 open = well_conn_open( ert_connection );
|
||||
int branch = well_conn_get_branch( ert_connection );
|
||||
int segment = well_conn_get_segment( 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()))
|
||||
{
|
||||
outletResultBranch = wellResFrame.m_wellResultBranches[outletResultBranch.m_outletBranchIndex];
|
||||
cellIndexInOutletBranch = outletResultBranch.m_outletBranchHeadCellIndex;
|
||||
cellK -= static_cast<int>(grids[gridNr]->cellCountK());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cellIndexInOutletBranch--;
|
||||
}
|
||||
|
||||
if(cellIndexInOutletBranch >= 0 && cellIndexInOutletBranch < outletResultBranch.m_wellCells.size())
|
||||
{
|
||||
currCell = outletResultBranch.m_wellCells[cellIndexInOutletBranch];
|
||||
data.m_gridCellIndex = grids[gridNr]->cellIndexFromIJK(cellI , cellJ , cellK);
|
||||
|
||||
data.m_isOpen = open;
|
||||
data.m_branchId = branch;
|
||||
data.m_segmentId = segment;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1132,7 +876,6 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
wellResults->computeMappingFromResultTimeIndicesToWellTimeIndices(m_timeSteps);
|
||||
|
||||
wells.push_back(wellResults.p());
|
||||
|
@ -56,7 +56,7 @@ public:
|
||||
private:
|
||||
bool readActiveCellInfo();
|
||||
void buildMetaData();
|
||||
void readWellCells(const ecl_grid_type* mainEclGrid);
|
||||
void readWellCells();
|
||||
|
||||
void openInitFile();
|
||||
bool openDynamicAccess();
|
||||
|
@ -547,8 +547,20 @@ void RivPipeGeometryGenerator::updateFilteredPipeCenterCoords()
|
||||
}
|
||||
}
|
||||
|
||||
// Always append last coord as it is not added by above algorithm
|
||||
m_filteredPipeCenterCoords.push_back(m_originalPipeCenterCoords->get(m_originalPipeCenterCoords->size() - 1));
|
||||
// Add last cross section if not duplicate coordinate
|
||||
cvf::Vec3d coordA = m_originalPipeCenterCoords->get(m_originalPipeCenterCoords->size() - 2);
|
||||
cvf::Vec3d coordB = m_originalPipeCenterCoords->get(m_originalPipeCenterCoords->size() - 1);
|
||||
|
||||
cvf::Vec3d directionAB = coordB - coordA;
|
||||
if (directionAB.lengthSquared() > squareDistanceTolerance)
|
||||
{
|
||||
m_filteredPipeCenterCoords.push_back(m_originalPipeCenterCoords->get(m_originalPipeCenterCoords->size() - 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
// Remove last segment as the length is below tolerance
|
||||
m_filteredPipeSegmentToResult.pop_back();
|
||||
}
|
||||
|
||||
CVF_ASSERT(m_filteredPipeCenterCoords.size() - 1 == m_filteredPipeSegmentToResult.size());
|
||||
}
|
||||
|
@ -176,15 +176,15 @@ void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< std::vector
|
||||
RigCaseData* rigReservoir = m_rimReservoirView->eclipseCase()->reservoirData();
|
||||
RigSingleWellResultsData* wellResults = m_rimWell->wellResults();
|
||||
|
||||
const RigWellResultFrame& staticWellFrame = m_rimWell->wellResults()->m_staticWellCells;
|
||||
|
||||
// Make sure we have computed the static representation of the well
|
||||
if (wellResults->m_staticWellCells.m_wellResultBranches.size() == 0)
|
||||
if (staticWellFrame.m_wellResultBranches.size() == 0)
|
||||
{
|
||||
wellResults->computeStaticWellCellPath();
|
||||
}
|
||||
|
||||
const RigWellResultFrame& staticWellFrame = wellResults->m_staticWellCells;
|
||||
if (staticWellFrame.m_wellResultBranches.size() == 0) return;
|
||||
|
||||
|
||||
// Initialize the return arrays
|
||||
pipeBranchesCLCoords.clear();
|
||||
pipeBranchesCellIds.clear();
|
||||
@ -211,93 +211,31 @@ void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< std::vector
|
||||
|
||||
if (hasResultCells)
|
||||
{
|
||||
// Create a new branch from wellhead
|
||||
|
||||
pipeBranchesCLCoords.push_back(std::vector<cvf::Vec3d>());
|
||||
pipeBranchesCellIds.push_back(std::vector <RigWellResultCell>());
|
||||
|
||||
// We start by entering the first cell (the wellhead)
|
||||
const RigWellResultCell* prevResCell = whResCell;
|
||||
|
||||
pipeBranchesCLCoords.back().push_back(whStartPos);
|
||||
pipeBranchesCellIds.back().push_back(*prevResCell );
|
||||
|
||||
// Add extra coordinate between cell face and cell center
|
||||
// to make sure the well pipe terminated in a segment parallel to z-axis
|
||||
cvf::Vec3d whIntermediate = whStartPos;
|
||||
whIntermediate.z() = (whStartPos.z() + whCell.center().z()) / 2.0;
|
||||
|
||||
pipeBranchesCLCoords.back().push_back(whIntermediate);
|
||||
pipeBranchesCellIds.back().push_back(*prevResCell );
|
||||
|
||||
const RigWellResultCell* prevResCell = NULL;
|
||||
|
||||
// Use well head if branch head is not specified
|
||||
if (!wellResults->isMultiSegmentWell())
|
||||
{
|
||||
// Create a new branch from wellhead
|
||||
|
||||
pipeBranchesCLCoords.push_back(std::vector<cvf::Vec3d>());
|
||||
pipeBranchesCellIds.push_back(std::vector <RigWellResultCell>());
|
||||
|
||||
prevResCell = whResCell;
|
||||
|
||||
pipeBranchesCLCoords.back().push_back(whStartPos);
|
||||
pipeBranchesCellIds.back().push_back(*prevResCell);
|
||||
|
||||
pipeBranchesCLCoords.back().push_back(whIntermediate);
|
||||
pipeBranchesCellIds.back().push_back(*prevResCell);
|
||||
}
|
||||
|
||||
for (size_t brIdx = 0; brIdx < resBranches.size(); brIdx++)
|
||||
{
|
||||
if (resBranches[brIdx].m_wellCells.size() == 0)
|
||||
continue; // Skip empty branches. Do not know why they exist, but they make problems.
|
||||
|
||||
prevResCell = NULL;
|
||||
|
||||
|
||||
// Find the start the MSW well-branch centerline. Normal wells are started "once" at wellhead in the code above
|
||||
|
||||
if (wellResults->isMultiSegmentWell())
|
||||
{
|
||||
pipeBranchesCLCoords.push_back(std::vector<cvf::Vec3d>());
|
||||
pipeBranchesCellIds.push_back(std::vector <RigWellResultCell>());
|
||||
|
||||
if (brIdx == 0)
|
||||
{
|
||||
// The first branch contains segment number 1, and this is the only segment connected to well head
|
||||
// See Eclipse documentation for the keyword WELSEGS
|
||||
prevResCell = whResCell;
|
||||
|
||||
pipeBranchesCLCoords.back().push_back(whStartPos);
|
||||
pipeBranchesCellIds.back().push_back(*prevResCell);
|
||||
|
||||
pipeBranchesCLCoords.back().push_back(whIntermediate);
|
||||
pipeBranchesCellIds.back().push_back(*prevResCell);
|
||||
}
|
||||
else
|
||||
{
|
||||
const RigWellResultCell* leafBranchHead = staticWellFrame.findResultCellFromOutletSpecification(resBranches[brIdx].m_outletBranchIndex, resBranches[brIdx].m_outletBranchHeadCellIndex);
|
||||
if (leafBranchHead && leafBranchHead->hasGridConnections())
|
||||
{
|
||||
// Create a new branch and use branch head as previous result cell
|
||||
|
||||
prevResCell = leafBranchHead;
|
||||
|
||||
const RigCell& cell = rigReservoir->cellFromWellResultCell(*leafBranchHead);
|
||||
cvf::Vec3d branchHeadStartPos = cell.faceCenter(cvf::StructGridInterface::NEG_K);
|
||||
|
||||
pipeBranchesCLCoords.back().push_back(branchHeadStartPos);
|
||||
pipeBranchesCellIds.back().push_back(*prevResCell);
|
||||
}
|
||||
else if (leafBranchHead)
|
||||
{
|
||||
cvf::Vec3d interpolatedCoord = leafBranchHead->m_averageCenter;
|
||||
|
||||
CVF_ASSERT(interpolatedCoord != cvf::Vec3d::UNDEFINED);
|
||||
if (interpolatedCoord != cvf::Vec3d::UNDEFINED)
|
||||
{
|
||||
pipeBranchesCLCoords.back().push_back(interpolatedCoord);
|
||||
pipeBranchesCellIds.back().push_back(RigWellResultCell());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// No branch head found: Possibly main branch
|
||||
CVF_ASSERT(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Loop over all the resultCells in the branch
|
||||
const std::vector<RigWellResultCell>& resBranchCells = resBranches[brIdx].m_wellCells;
|
||||
|
||||
@ -307,101 +245,56 @@ void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< std::vector
|
||||
std::vector<RigWellResultCell>& branchCellIds = pipeBranchesCellIds.back();
|
||||
|
||||
const RigWellResultCell& resCell = resBranchCells[cIdx];
|
||||
|
||||
if (!resCell.hasConnections())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (resCell.hasBranchConnections())
|
||||
{
|
||||
// Use the interpolated value of branch head
|
||||
cvf::Vec3d interpolatedCoord = resCell.m_averageCenter;
|
||||
|
||||
CVF_ASSERT(interpolatedCoord != cvf::Vec3d::UNDEFINED);
|
||||
if (interpolatedCoord != cvf::Vec3d::UNDEFINED)
|
||||
{
|
||||
pipeBranchesCLCoords.back().push_back(interpolatedCoord);
|
||||
pipeBranchesCellIds.back().push_back(RigWellResultCell());
|
||||
}
|
||||
|
||||
// Set previous result cell to NULL
|
||||
prevResCell = NULL;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
const RigCell& cell = rigReservoir->cellFromWellResultCell(resCell);
|
||||
|
||||
// Check if this and the previous cells has shared faces
|
||||
|
||||
cvf::StructGridInterface::FaceType sharedFace;
|
||||
if (prevResCell && rigReservoir->findSharedSourceFace(sharedFace, resCell, *prevResCell))
|
||||
if (rigReservoir->findSharedSourceFace(sharedFace, resCell, *prevResCell))
|
||||
{
|
||||
branchCLCoords.push_back(cell.faceCenter(sharedFace));
|
||||
branchCellIds.push_back(resCell);
|
||||
}
|
||||
else
|
||||
{
|
||||
cvf::Vec3d previousCoord;
|
||||
|
||||
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();
|
||||
}
|
||||
else
|
||||
{
|
||||
previousCoord = pipeBranchesCLCoords.back().back();
|
||||
}
|
||||
|
||||
// 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);
|
||||
cvf::Vec3d centerPrevCell = prevCell.center();
|
||||
cvf::Vec3d centerThisCell = cell.center();
|
||||
|
||||
// First make sure this cell is not starting a new "display" branch
|
||||
if ( wellResults->isMultiSegmentWell()
|
||||
|| !isAutoDetectBranches
|
||||
|| (prevResCell == whResCell)
|
||||
|| (centerThisCell-previousCoord).lengthSquared() <= (centerThisCell - whStartPos).lengthSquared()
|
||||
)
|
||||
if ( !isAutoDetectBranches || (prevResCell == whResCell)
|
||||
|| (centerThisCell-centerPrevCell).lengthSquared() <= (centerThisCell - whStartPos).lengthSquared())
|
||||
{
|
||||
// Not starting a "display" branch
|
||||
// Create ray and intersect with cells
|
||||
|
||||
cvf::Ray rayToThisCell;
|
||||
rayToThisCell.setOrigin(previousCoord);
|
||||
rayToThisCell.setDirection((centerThisCell - previousCoord).getNormalized());
|
||||
rayToThisCell.setOrigin(centerPrevCell);
|
||||
rayToThisCell.setDirection((centerThisCell - centerPrevCell).getNormalized());
|
||||
|
||||
cvf::Vec3d outOfPrevCell(centerPrevCell);
|
||||
cvf::Vec3d intoThisCell(centerThisCell);
|
||||
cell.firstIntersectionPoint(rayToThisCell, &intoThisCell);
|
||||
|
||||
if (prevResCell)
|
||||
bool intersectionOk = prevCell.firstIntersectionPoint(rayToThisCell, &outOfPrevCell);
|
||||
//CVF_ASSERT(intersectionOk);
|
||||
intersectionOk = cell.firstIntersectionPoint(rayToThisCell, &intoThisCell);
|
||||
//CVF_ASSERT(intersectionOk);
|
||||
if ((intoThisCell - outOfPrevCell).lengthSquared() > 1e-3)
|
||||
{
|
||||
cvf::Vec3d outOfPrevCell(previousCoord);
|
||||
|
||||
const RigCell& prevCell = rigReservoir->cellFromWellResultCell(*prevResCell);
|
||||
bool intersectionOk = prevCell.firstIntersectionPoint(rayToThisCell, &outOfPrevCell);
|
||||
//CVF_ASSERT(intersectionOk);
|
||||
//CVF_ASSERT(intersectionOk);
|
||||
if ((intoThisCell - outOfPrevCell).lengthSquared() > 1e-3)
|
||||
{
|
||||
branchCLCoords.push_back(outOfPrevCell);
|
||||
branchCellIds.push_back(*prevResCell);
|
||||
}
|
||||
branchCLCoords.push_back(outOfPrevCell);
|
||||
branchCellIds.push_back(RigWellResultCell());
|
||||
}
|
||||
|
||||
branchCLCoords.push_back(intoThisCell);
|
||||
branchCellIds.push_back(resCell);
|
||||
}
|
||||
else
|
||||
{
|
||||
CVF_ASSERT(!wellResults->isMultiSegmentWell());
|
||||
|
||||
// This cell is further from the previous cell than from the well head,
|
||||
// thus we interpret it as a new branch.
|
||||
|
||||
// First finish the current branch
|
||||
branchCLCoords.push_back(branchCLCoords.back() + 1.5*(previousCoord - branchCLCoords.back()) );
|
||||
branchCLCoords.push_back(branchCLCoords.back() + 1.5*(centerPrevCell - branchCLCoords.back()) );
|
||||
|
||||
// Create new display branch
|
||||
pipeBranchesCLCoords.push_back(std::vector<cvf::Vec3d>());
|
||||
@ -423,32 +316,14 @@ void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< std::vector
|
||||
}
|
||||
|
||||
prevResCell = &resCell;
|
||||
|
||||
}
|
||||
|
||||
if ( wellResults->isMultiSegmentWell())
|
||||
{
|
||||
// All MSW branches are completed using the point 0.5 past the center of last cell
|
||||
size_t clCoordCount = pipeBranchesCLCoords.back().size();
|
||||
CVF_ASSERT(clCoordCount >= 2);
|
||||
cvf::Vec3d centerPrevCell = pipeBranchesCLCoords.back()[clCoordCount - 2];
|
||||
cvf::Vec3d centerThisCell = pipeBranchesCLCoords.back()[clCoordCount - 1];
|
||||
|
||||
pipeBranchesCLCoords.back().push_back(centerThisCell + 1.5*(centerPrevCell - centerThisCell) );
|
||||
}
|
||||
}
|
||||
|
||||
if (!wellResults->isMultiSegmentWell())
|
||||
{
|
||||
// None MSW wells
|
||||
// For the last cell, add the point 0.5 past the center of that cell
|
||||
|
||||
size_t clCoordCount = pipeBranchesCLCoords.back().size();
|
||||
CVF_ASSERT(clCoordCount >= 2);
|
||||
cvf::Vec3d centerPrevCell = pipeBranchesCLCoords.back()[clCoordCount - 2];
|
||||
cvf::Vec3d centerThisCell = pipeBranchesCLCoords.back()[clCoordCount - 1];
|
||||
|
||||
pipeBranchesCLCoords.back().push_back(centerThisCell + 1.5*(centerPrevCell - centerThisCell) );
|
||||
}
|
||||
// For the last cell, add the point 0.5 past the center of that cell
|
||||
const RigCell& prevCell = rigReservoir->cellFromWellResultCell(*prevResCell);
|
||||
cvf::Vec3d centerPrevCell = prevCell.center();
|
||||
pipeBranchesCLCoords.back().push_back(pipeBranchesCLCoords.back().back() + 1.5*(centerPrevCell - pipeBranchesCLCoords.back().back()) );
|
||||
|
||||
}
|
||||
|
||||
@ -514,12 +389,7 @@ void RivWellPipesPartMgr::updatePipeResultColor(size_t frameIndex)
|
||||
for (size_t wcIdx = 0; wcIdx < cellIds.size(); ++wcIdx)
|
||||
{
|
||||
// we need a faster lookup, I guess
|
||||
const RigWellResultCell* wResCell = NULL;
|
||||
|
||||
if (cellIds[wcIdx].hasGridConnections())
|
||||
{
|
||||
wResCell = wResFrame.findResultCell(cellIds[wcIdx].m_gridIndex, cellIds[wcIdx].m_gridCellIndex);
|
||||
}
|
||||
const RigWellResultCell* wResCell = wResFrame.findResultCell(cellIds[wcIdx].m_gridIndex, cellIds[wcIdx].m_gridCellIndex);
|
||||
|
||||
if (wResCell == NULL)
|
||||
{
|
||||
|
@ -1025,29 +1025,6 @@ void RimReservoirView::appendCellResultInfo(size_t gridIndex, size_t cellIndex,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cvf::Collection<RigSingleWellResultsData> wellResults = m_reservoir->reservoirData()->wellResults();
|
||||
for (size_t i = 0; i < wellResults.size(); i++)
|
||||
{
|
||||
RigSingleWellResultsData* singleWellResultData = wellResults.at(i);
|
||||
|
||||
if (m_currentTimeStep < singleWellResultData->firstResultTimeStep())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
const RigWellResultFrame& wellResultFrame = singleWellResultData->wellResultFrame(m_currentTimeStep);
|
||||
const RigWellResultCell* 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())
|
||||
{
|
||||
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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1404,11 +1381,6 @@ void RimReservoirView::calculateVisibleWellCellsIncFence(cvf::UByteArray* visibl
|
||||
{
|
||||
if (wsResCells[cIdx].m_gridIndex == grid->gridIndex())
|
||||
{
|
||||
if (!wsResCells[cIdx].hasGridConnections())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
size_t gridCellIndex = wsResCells[cIdx].m_gridCellIndex;
|
||||
(*visibleCells)[gridCellIndex] = true;
|
||||
|
||||
|
@ -196,16 +196,13 @@ bool RimWell::calculateWellPipeVisibility(size_t frameIndex)
|
||||
const std::vector<RigWellResultCell>& wsResCells = wellResSegments[wsIdx].m_wellCells;
|
||||
for (size_t cIdx = 0; cIdx < wsResCells.size(); ++ cIdx)
|
||||
{
|
||||
if (wsResCells[cIdx].hasGridConnections())
|
||||
{
|
||||
gridIndex = wsResCells[cIdx].m_gridIndex;
|
||||
gridCellIndex = wsResCells[cIdx].m_gridCellIndex;
|
||||
gridIndex = wsResCells[cIdx].m_gridIndex;
|
||||
gridCellIndex = wsResCells[cIdx].m_gridCellIndex;
|
||||
|
||||
cvf::cref<cvf::UByteArray> cellVisibility = rvMan->cellVisibility(visGridParts[gpIdx], gridIndex, frameIndex);
|
||||
if ((*cellVisibility)[gridCellIndex])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
cvf::cref<cvf::UByteArray> cellVisibility = rvMan->cellVisibility(visGridParts[gpIdx], gridIndex, frameIndex);
|
||||
if ((*cellVisibility)[gridCellIndex])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -118,7 +118,7 @@ void RigSingleWellResultsData::computeStaticWellCellPath()
|
||||
|
||||
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_branchNumber;
|
||||
std::vector<RigWellResultCell>& frameCells = m_wellCellsTimeSteps[0].m_wellResultBranches[bIdx].m_wellCells;
|
||||
|
||||
std::list< RigWellResultCell >& branch = staticWellBranches[branchNumber];
|
||||
@ -137,7 +137,7 @@ 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;
|
||||
size_t branchNumber = m_wellCellsTimeSteps[tIdx].m_wellResultBranches[bIdx].m_branchNumber;
|
||||
std::vector<RigWellResultCell>& resBranch = m_wellCellsTimeSteps[tIdx].m_wellResultBranches[bIdx].m_wellCells;
|
||||
|
||||
std::list< RigWellResultCell >& stBranch = staticWellBranches[branchNumber];
|
||||
@ -252,20 +252,12 @@ void RigSingleWellResultsData::computeStaticWellCellPath()
|
||||
|
||||
for (bIt = staticWellBranches.begin(); bIt != staticWellBranches.end(); ++bIt)
|
||||
{
|
||||
if (bIt->first >= m_wellCellsTimeSteps[0].m_wellResultBranches.size())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// Copy from first time step
|
||||
RigWellResultBranch rigBranch = m_wellCellsTimeSteps[0].m_wellResultBranches[bIt->first];
|
||||
rigBranch.m_branchIndex = bIt->first;
|
||||
|
||||
// Clear well cells, and insert the collection of well cells for the static situation
|
||||
rigBranch.m_wellCells.clear();
|
||||
RigWellResultBranch rigBranch;
|
||||
rigBranch.m_branchNumber = bIt->first;
|
||||
|
||||
std::list< RigWellResultCell >& branch = bIt->second;
|
||||
std::list< RigWellResultCell >::iterator cIt;
|
||||
|
||||
for (cIt = branch.begin(); cIt != branch.end(); ++cIt)
|
||||
{
|
||||
RigWellResultCell rwc = *cIt;
|
||||
@ -277,19 +269,3 @@ void RigSingleWellResultsData::computeStaticWellCellPath()
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigSingleWellResultsData::setMultiSegmentWell(bool isMultiSegmentWell)
|
||||
{
|
||||
m_isMultiSegmentWell = isMultiSegmentWell;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RigSingleWellResultsData::isMultiSegmentWell() const
|
||||
{
|
||||
return m_isMultiSegmentWell;
|
||||
}
|
||||
|
||||
|
@ -25,72 +25,33 @@
|
||||
#include "RimDefines.h"
|
||||
#include <QDateTime>
|
||||
#include <vector>
|
||||
#include "cvfVector3.h"
|
||||
|
||||
struct RigWellResultCell
|
||||
{
|
||||
RigWellResultCell() :
|
||||
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_branchConnectionCount(0)
|
||||
m_branchId(-1),
|
||||
m_segmentId(-1),
|
||||
m_isOpen(false)
|
||||
{ }
|
||||
|
||||
bool hasBranchConnections() const
|
||||
{
|
||||
return m_branchConnectionCount != 0;
|
||||
}
|
||||
|
||||
bool hasGridConnections() const
|
||||
{
|
||||
return m_gridCellIndex != cvf::UNDEFINED_SIZE_T;
|
||||
}
|
||||
|
||||
bool hasConnections() const
|
||||
{
|
||||
return hasGridConnections() || hasBranchConnections();
|
||||
}
|
||||
|
||||
|
||||
size_t m_gridIndex;
|
||||
size_t m_gridCellIndex; //< Index to cell which is included in the well
|
||||
int m_branchId;
|
||||
int m_segmentId;
|
||||
|
||||
bool m_isOpen; //< Marks the well as open or closed as of Eclipse simulation
|
||||
|
||||
int m_ertBranchId;
|
||||
int m_ertSegmentId;
|
||||
|
||||
cvf::Vec3d m_averageCenter;
|
||||
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_branchNumber(cvf::UNDEFINED_SIZE_T)
|
||||
{}
|
||||
|
||||
|
||||
size_t m_branchIndex;
|
||||
int m_ertBranchId;
|
||||
|
||||
size_t m_branchNumber;
|
||||
std::vector<RigWellResultCell> m_wellCells;
|
||||
|
||||
// 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;
|
||||
|
||||
};
|
||||
|
||||
class RigWellResultFrame
|
||||
@ -106,8 +67,6 @@ public:
|
||||
|
||||
const RigWellResultCell* findResultCell(size_t gridIndex, size_t gridCellIndex) const
|
||||
{
|
||||
CVF_ASSERT(gridIndex != cvf::UNDEFINED_SIZE_T && gridCellIndex != cvf::UNDEFINED_SIZE_T);
|
||||
|
||||
if (m_wellHead.m_gridCellIndex == gridCellIndex && m_wellHead.m_gridIndex == gridIndex )
|
||||
{
|
||||
return &m_wellHead;
|
||||
@ -128,21 +87,6 @@ public:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
const RigWellResultCell* 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())
|
||||
{
|
||||
return (&resBranch.m_wellCells[wellResultCellIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
WellProductionType m_productionType;
|
||||
bool m_isOpen;
|
||||
RigWellResultCell m_wellHead;
|
||||
@ -158,11 +102,6 @@ public:
|
||||
class RigSingleWellResultsData : public cvf::Object
|
||||
{
|
||||
public:
|
||||
RigSingleWellResultsData() { m_isMultiSegmentWell = false; }
|
||||
|
||||
void setMultiSegmentWell(bool isMultiSegmentWell);
|
||||
bool isMultiSegmentWell() const;
|
||||
|
||||
bool hasWellResult(size_t resultTimeStepIndex) const;
|
||||
size_t firstResultTimeStep() const;
|
||||
|
||||
@ -174,7 +113,6 @@ public:
|
||||
|
||||
public:
|
||||
QString m_wellName;
|
||||
bool m_isMultiSegmentWell;
|
||||
|
||||
std::vector<size_t> m_resultTimeStepIndexToWellTimeStepIndex; // Well result timesteps may differ from result timesteps
|
||||
std::vector< RigWellResultFrame > m_wellCellsTimeSteps;
|
||||
|
6
ThirdParty/Ert/devel/cmake/cmake_pyc2
vendored
6
ThirdParty/Ert/devel/cmake/cmake_pyc2
vendored
@ -11,11 +11,7 @@ target_file = sys.argv[2]
|
||||
|
||||
(target_path , tail) = os.path.split( target_file )
|
||||
if not os.path.exists( target_path ):
|
||||
try:
|
||||
os.makedirs( target_path )
|
||||
except:
|
||||
# When running with make -j 4 there might be a race to create this directory.
|
||||
pass
|
||||
os.makedirs( target_path )
|
||||
|
||||
shutil.copyfile( src_file , target_file )
|
||||
try:
|
||||
|
4
ThirdParty/Ert/devel/cmake/cmake_pyc_tree
vendored
4
ThirdParty/Ert/devel/cmake/cmake_pyc_tree
vendored
@ -17,10 +17,6 @@ for (root , dir_list , file_list) in os.walk( root_path ):
|
||||
(tmp , ext) = os.path.splitext( full_path )
|
||||
if ext == ".py":
|
||||
py_file = full_path
|
||||
pyc_file = full_path + "c"
|
||||
if os.path.exists( pyc_file ):
|
||||
os.unlink( pyc_file )
|
||||
|
||||
try:
|
||||
print "Compiling: %s" % py_file
|
||||
py_compile.compile( py_file , doraise = True )
|
||||
|
@ -3,7 +3,6 @@ if (BUILD_APPLICATIONS)
|
||||
add_executable( make_grid make_grid.c )
|
||||
add_executable( grdecl_grid grdecl_grid.c )
|
||||
add_executable( summary2csv summary2csv.c )
|
||||
add_executable( summary2csv2 summary2csv2.c )
|
||||
if (ERT_LINUX)
|
||||
add_executable( esummary.x esummary.c )
|
||||
add_executable( convert.x convert.c )
|
||||
@ -16,7 +15,7 @@ if (BUILD_APPLICATIONS)
|
||||
add_executable( summary.x view_summary.c )
|
||||
add_executable( select_test.x select_test.c )
|
||||
add_executable( load_test.x load_test.c )
|
||||
set(program_list summary2csv2 summary2csv esummary.x kw_extract.x grdecl_grid make_grid sum_write load_test.x grdecl_test.x grid_dump_ascii.x select_test.x grid_dump.x convert.x kw_list.x grid_info.x summary.x)
|
||||
set(program_list summary2csv esummary.x kw_extract.x grdecl_grid make_grid sum_write load_test.x grdecl_test.x grid_dump_ascii.x select_test.x grid_dump.x convert.x kw_list.x grid_info.x summary.x)
|
||||
else()
|
||||
# The stupid .x extension creates problems on windows
|
||||
add_executable( convert convert.c )
|
||||
@ -29,7 +28,7 @@ if (BUILD_APPLICATIONS)
|
||||
add_executable( summary view_summary.c )
|
||||
add_executable( select_test select_test.c )
|
||||
add_executable( load_test load_test.c )
|
||||
set(program_list summary2csv2 summary2csv kw_extract grdecl_grid make_grid sum_write load_test grdecl_test grid_dump_ascii select_test grid_dump convert kw_list grid_info summary)
|
||||
set(program_list summary2csv kw_extract grdecl_grid make_grid sum_write load_test grdecl_test grid_dump_ascii select_test grid_dump convert kw_list grid_info summary)
|
||||
endif()
|
||||
|
||||
|
||||
|
163
ThirdParty/Ert/devel/libecl/applications/makefile
vendored
Normal file
163
ThirdParty/Ert/devel/libecl/applications/makefile
vendored
Normal file
@ -0,0 +1,163 @@
|
||||
# CMAKE generated file: DO NOT EDIT!
|
||||
# Generated by "MinGW Makefiles" Generator, CMake Version 2.8
|
||||
|
||||
# Default target executed when no arguments are given to make.
|
||||
default_target: all
|
||||
.PHONY : default_target
|
||||
|
||||
#=============================================================================
|
||||
# Special targets provided by cmake.
|
||||
|
||||
# Disable implicit rules so canoncical targets will work.
|
||||
.SUFFIXES:
|
||||
|
||||
# Remove some rules from gmake that .SUFFIXES does not remove.
|
||||
SUFFIXES =
|
||||
|
||||
.SUFFIXES: .hpux_make_needs_suffix_list
|
||||
|
||||
# Suppress display of executed commands.
|
||||
$(VERBOSE).SILENT:
|
||||
|
||||
# A target that is always out of date.
|
||||
cmake_force:
|
||||
.PHONY : cmake_force
|
||||
|
||||
#=============================================================================
|
||||
# Set environment variables for the build.
|
||||
|
||||
SHELL = cmd.exe
|
||||
|
||||
# The CMake executable.
|
||||
CMAKE_COMMAND = "C:\Program Files\CMake 2.8\bin\cmake.exe"
|
||||
|
||||
# The command to remove a file.
|
||||
RM = "C:\Program Files\CMake 2.8\bin\cmake.exe" -E remove -f
|
||||
|
||||
# The program to use to edit the cache.
|
||||
CMAKE_EDIT_COMMAND = "C:\Program Files\CMake 2.8\bin\cmake-gui.exe"
|
||||
|
||||
# The top-level source directory on which CMake was run.
|
||||
CMAKE_SOURCE_DIR = C:\code\ERT
|
||||
|
||||
# The top-level build directory on which CMake was run.
|
||||
CMAKE_BINARY_DIR = C:\code\ERT
|
||||
|
||||
#=============================================================================
|
||||
# Targets provided globally by CMake.
|
||||
|
||||
# Special rule for the target edit_cache
|
||||
edit_cache:
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake cache editor..."
|
||||
"C:\Program Files\CMake 2.8\bin\cmake-gui.exe" -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
|
||||
.PHONY : edit_cache
|
||||
|
||||
# Special rule for the target edit_cache
|
||||
edit_cache/fast: edit_cache
|
||||
.PHONY : edit_cache/fast
|
||||
|
||||
# Special rule for the target rebuild_cache
|
||||
rebuild_cache:
|
||||
@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..."
|
||||
"C:\Program Files\CMake 2.8\bin\cmake.exe" -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
|
||||
.PHONY : rebuild_cache
|
||||
|
||||
# Special rule for the target rebuild_cache
|
||||
rebuild_cache/fast: rebuild_cache
|
||||
.PHONY : rebuild_cache/fast
|
||||
|
||||
# The main all target
|
||||
all: cmake_check_build_system
|
||||
cd /d C:\code\ERT && $(CMAKE_COMMAND) -E cmake_progress_start C:\code\ERT\CMakeFiles C:\code\ERT\libecl\applications\CMakeFiles\progress.marks
|
||||
cd /d C:\code\ERT && $(MAKE) -f CMakeFiles\Makefile2 libecl/applications/all
|
||||
$(CMAKE_COMMAND) -E cmake_progress_start C:\code\ERT\CMakeFiles 0
|
||||
.PHONY : all
|
||||
|
||||
# The main clean target
|
||||
clean:
|
||||
cd /d C:\code\ERT && $(MAKE) -f CMakeFiles\Makefile2 libecl/applications/clean
|
||||
.PHONY : clean
|
||||
|
||||
# The main clean target
|
||||
clean/fast: clean
|
||||
.PHONY : clean/fast
|
||||
|
||||
# Prepare targets for installation.
|
||||
preinstall: all
|
||||
cd /d C:\code\ERT && $(MAKE) -f CMakeFiles\Makefile2 libecl/applications/preinstall
|
||||
.PHONY : preinstall
|
||||
|
||||
# Prepare targets for installation.
|
||||
preinstall/fast:
|
||||
cd /d C:\code\ERT && $(MAKE) -f CMakeFiles\Makefile2 libecl/applications/preinstall
|
||||
.PHONY : preinstall/fast
|
||||
|
||||
# clear depends
|
||||
depend:
|
||||
cd /d C:\code\ERT && $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles\Makefile.cmake 1
|
||||
.PHONY : depend
|
||||
|
||||
# Convenience name for target.
|
||||
libecl/applications/CMakeFiles/grid_info.x.dir/rule:
|
||||
cd /d C:\code\ERT && $(MAKE) -f CMakeFiles\Makefile2 libecl/applications/CMakeFiles/grid_info.x.dir/rule
|
||||
.PHONY : libecl/applications/CMakeFiles/grid_info.x.dir/rule
|
||||
|
||||
# Convenience name for target.
|
||||
grid_info.x: libecl/applications/CMakeFiles/grid_info.x.dir/rule
|
||||
.PHONY : grid_info.x
|
||||
|
||||
# fast build rule for target.
|
||||
grid_info.x/fast:
|
||||
cd /d C:\code\ERT && $(MAKE) -f libecl\applications\CMakeFiles\grid_info.x.dir\build.make libecl/applications/CMakeFiles/grid_info.x.dir/build
|
||||
.PHONY : grid_info.x/fast
|
||||
|
||||
grid_info.obj: grid_info.c.obj
|
||||
.PHONY : grid_info.obj
|
||||
|
||||
# target to build an object file
|
||||
grid_info.c.obj:
|
||||
cd /d C:\code\ERT && $(MAKE) -f libecl\applications\CMakeFiles\grid_info.x.dir\build.make libecl/applications/CMakeFiles/grid_info.x.dir/grid_info.c.obj
|
||||
.PHONY : grid_info.c.obj
|
||||
|
||||
grid_info.i: grid_info.c.i
|
||||
.PHONY : grid_info.i
|
||||
|
||||
# target to preprocess a source file
|
||||
grid_info.c.i:
|
||||
cd /d C:\code\ERT && $(MAKE) -f libecl\applications\CMakeFiles\grid_info.x.dir\build.make libecl/applications/CMakeFiles/grid_info.x.dir/grid_info.c.i
|
||||
.PHONY : grid_info.c.i
|
||||
|
||||
grid_info.s: grid_info.c.s
|
||||
.PHONY : grid_info.s
|
||||
|
||||
# target to generate assembly for a file
|
||||
grid_info.c.s:
|
||||
cd /d C:\code\ERT && $(MAKE) -f libecl\applications\CMakeFiles\grid_info.x.dir\build.make libecl/applications/CMakeFiles/grid_info.x.dir/grid_info.c.s
|
||||
.PHONY : grid_info.c.s
|
||||
|
||||
# Help Target
|
||||
help:
|
||||
@$(CMAKE_COMMAND) -E echo "The following are some of the valid targets for this Makefile:"
|
||||
@$(CMAKE_COMMAND) -E echo "... all (the default if no target is provided)"
|
||||
@$(CMAKE_COMMAND) -E echo "... clean"
|
||||
@$(CMAKE_COMMAND) -E echo "... depend"
|
||||
@$(CMAKE_COMMAND) -E echo "... edit_cache"
|
||||
@$(CMAKE_COMMAND) -E echo "... grid_info.x"
|
||||
@$(CMAKE_COMMAND) -E echo "... rebuild_cache"
|
||||
@$(CMAKE_COMMAND) -E echo "... grid_info.obj"
|
||||
@$(CMAKE_COMMAND) -E echo "... grid_info.i"
|
||||
@$(CMAKE_COMMAND) -E echo "... grid_info.s"
|
||||
.PHONY : help
|
||||
|
||||
|
||||
|
||||
#=============================================================================
|
||||
# Special targets to cleanup operation of make.
|
||||
|
||||
# Special rule to run CMake to check the build system integrity.
|
||||
# No rule that depends on this can have commands that come from listfiles
|
||||
# because they might be regenerated.
|
||||
cmake_check_build_system:
|
||||
cd /d C:\code\ERT && $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles\Makefile.cmake 0
|
||||
.PHONY : cmake_check_build_system
|
||||
|
@ -27,32 +27,39 @@
|
||||
|
||||
|
||||
|
||||
static bool extend_key_list( const ecl_sum_type * ecl_sum , const stringlist_type * var_list , const char * well , stringlist_type * key_list ) {
|
||||
bool oil_producer = false;
|
||||
|
||||
static void build_key_list( const ecl_sum_type * ecl_sum , stringlist_type * key_list ) {
|
||||
int iw;
|
||||
int last_step = ecl_sum_get_data_length( ecl_sum ) - 1;
|
||||
char * wopt_key = ecl_sum_alloc_well_key( ecl_sum , "WOPT", well);
|
||||
if (ecl_sum_has_key( ecl_sum , wopt_key) && (ecl_sum_get_well_var( ecl_sum , last_step , well , "WOPT") > 0 )) {
|
||||
/*
|
||||
We add all the keys unconditionally here; and then let the
|
||||
ecl_sum_fprintf() function print a message on stderr if it is
|
||||
missing.
|
||||
*/
|
||||
int ivar;
|
||||
for (ivar = 0; ivar < stringlist_get_size( var_list ); ivar++) {
|
||||
const char * var = stringlist_iget( var_list , ivar );
|
||||
stringlist_append_owned_ref( key_list , ecl_sum_alloc_well_key( ecl_sum , var, well) );
|
||||
}
|
||||
oil_producer = true;
|
||||
}
|
||||
free( wopt_key );
|
||||
return oil_producer;
|
||||
stringlist_type * well_list = ecl_sum_alloc_well_list( ecl_sum , NULL );
|
||||
for (iw = 0; iw < stringlist_get_size( well_list ); iw++) {
|
||||
const char * well = stringlist_iget( well_list , iw );
|
||||
char * wopt_key = ecl_sum_alloc_well_key( ecl_sum , "WOPR", well);
|
||||
if (ecl_sum_has_key( ecl_sum , wopt_key) && (ecl_sum_get_well_var( ecl_sum , last_step , well , "WOPT") > 0 )) {
|
||||
/*
|
||||
We add all the keys unconditionally here; and then let the
|
||||
ecl_sum_fprintf() function print a message on stderr if it is
|
||||
missing.
|
||||
*/
|
||||
stringlist_append_owned_ref( key_list , ecl_sum_alloc_well_key( ecl_sum , "WOPR", well) );
|
||||
stringlist_append_owned_ref( key_list , ecl_sum_alloc_well_key( ecl_sum , "WOPT", well) );
|
||||
|
||||
stringlist_append_owned_ref( key_list , ecl_sum_alloc_well_key( ecl_sum , "WGPR", well) );
|
||||
stringlist_append_owned_ref( key_list , ecl_sum_alloc_well_key( ecl_sum , "WGPT", well) );
|
||||
|
||||
stringlist_append_owned_ref( key_list , ecl_sum_alloc_well_key( ecl_sum , "WWPR", well) );
|
||||
stringlist_append_owned_ref( key_list , ecl_sum_alloc_well_key( ecl_sum , "WWPT", well) );
|
||||
} else
|
||||
printf("Ignoring well: %s \n",well);
|
||||
free( wopt_key );
|
||||
}
|
||||
stringlist_free( well_list );
|
||||
}
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
{
|
||||
ecl_sum_fmt_type fmt;
|
||||
bool well_rows = false;
|
||||
bool include_restart = true;
|
||||
int arg_offset = 1;
|
||||
|
||||
@ -64,49 +71,23 @@ int main(int argc , char ** argv) {
|
||||
{
|
||||
char * data_file = argv[arg_offset];
|
||||
ecl_sum_type * ecl_sum;
|
||||
stringlist_type * var_list = stringlist_alloc_new();
|
||||
|
||||
stringlist_append_ref( var_list , "WOPR" );
|
||||
stringlist_append_ref( var_list , "WOPT" );
|
||||
stringlist_append_ref( var_list , "WGPR" );
|
||||
stringlist_append_ref( var_list , "WGPT" );
|
||||
stringlist_append_ref( var_list , "WWPR" );
|
||||
stringlist_append_ref( var_list , "WWPT" );
|
||||
|
||||
ecl_sum_fmt_init_csv( &fmt );
|
||||
ecl_sum = ecl_sum_fread_alloc_case__( data_file , ":" , include_restart);
|
||||
if (ecl_sum != NULL) {
|
||||
char * csv_file = util_alloc_filename( NULL , ecl_sum_get_base(ecl_sum) , "txt"); // Will save to current path; can use ecl_sum_get_path() to save to target path instead.
|
||||
FILE * stream = util_fopen( csv_file , "w");
|
||||
|
||||
stringlist_type * well_list = ecl_sum_alloc_well_list( ecl_sum , NULL );
|
||||
stringlist_type * key_list = stringlist_alloc_new( );
|
||||
int iw;
|
||||
|
||||
for (iw = 0; iw < stringlist_get_size( well_list ); iw++) {
|
||||
const char * well = stringlist_iget( well_list , iw );
|
||||
if (!extend_key_list( ecl_sum , var_list , well , key_list))
|
||||
fprintf(stderr , "Ignoring well: %s \n",well);
|
||||
|
||||
if (well_rows) {
|
||||
if (stringlist_get_size(key_list)) {
|
||||
ecl_sum_fprintf(ecl_sum , stream , key_list , false , &fmt);
|
||||
stringlist_clear( key_list );
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!well_rows)
|
||||
build_key_list( ecl_sum , key_list );
|
||||
{
|
||||
char * csv_file = util_alloc_filename( NULL , ecl_sum_get_base(ecl_sum) , "txt"); // Weill save to current path; can use ecl_sum_get_path() to save to target path instead.
|
||||
FILE * stream = util_fopen( csv_file , "w");
|
||||
ecl_sum_fprintf(ecl_sum , stream , key_list , false , &fmt);
|
||||
|
||||
stringlist_free( well_list );
|
||||
fclose( stream );
|
||||
free( csv_file );
|
||||
}
|
||||
stringlist_free( key_list );
|
||||
ecl_sum_free(ecl_sum);
|
||||
fclose( stream );
|
||||
free( csv_file );
|
||||
} else
|
||||
fprintf(stderr,"summary2csv: No summary data found for case:%s\n", data_file );
|
||||
|
||||
stringlist_free( var_list );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,146 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
The file 'summary2csv2.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <signal.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/util.h>
|
||||
#include <ert/util/stringlist.h>
|
||||
|
||||
#include <ert/ecl/ecl_sum.h>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static void fprintf_line( const ecl_sum_type * ecl_sum , const ecl_sum_fmt_type * fmt , const char * well , int time_index , const stringlist_type * var_list , FILE * stream) {
|
||||
/* WELL */
|
||||
fprintf(stream , fmt->header_fmt , well);
|
||||
fprintf(stream , fmt->sep );
|
||||
|
||||
/* DAYS */
|
||||
fprintf(stream , fmt->days_fmt , ecl_sum_iget_sim_days(ecl_sum , time_index));
|
||||
fprintf(stream , fmt->sep );
|
||||
|
||||
/* DATE */
|
||||
{
|
||||
struct tm ts;
|
||||
const int DATE_STRING_LENGTH = 128;
|
||||
char * date_string = util_malloc( DATE_STRING_LENGTH * sizeof * date_string);
|
||||
time_t sim_time = ecl_sum_iget_sim_time(ecl_sum , time_index );
|
||||
util_localtime( &sim_time , &ts);
|
||||
strftime( date_string , DATE_STRING_LENGTH - 1 , fmt->date_fmt , &ts);
|
||||
fprintf(stream , date_string );
|
||||
free( date_string );
|
||||
}
|
||||
|
||||
{
|
||||
int ivar;
|
||||
for (ivar = 0; ivar < stringlist_get_size( var_list ); ivar++) {
|
||||
const char * var = stringlist_iget( var_list , ivar );
|
||||
double value = 0;
|
||||
if (ecl_sum_has_well_var( ecl_sum , well , var ))
|
||||
value = ecl_sum_get_well_var( ecl_sum , time_index , well , var );
|
||||
else
|
||||
fprintf(stderr,"Missing variable:%s for well:%s - substituting 0.0 \n",var , well);
|
||||
|
||||
fprintf(stream , fmt->sep );
|
||||
fprintf(stream , fmt->value_fmt , value );
|
||||
}
|
||||
fprintf( stream , fmt->newline );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
{
|
||||
ecl_sum_fmt_type fmt;
|
||||
bool include_restart = true;
|
||||
int arg_offset = 1;
|
||||
|
||||
if (argc != 2) {
|
||||
printf("You must supply the name of a case as:\n\n summary2csv.exe ECLIPSE_CASE\n\nThe case can optionally contain a leading path component.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
{
|
||||
char * data_file = argv[arg_offset];
|
||||
ecl_sum_type * ecl_sum;
|
||||
stringlist_type * var_list = stringlist_alloc_new();
|
||||
|
||||
stringlist_append_ref( var_list , "WOPR" );
|
||||
stringlist_append_ref( var_list , "WOPT" );
|
||||
stringlist_append_ref( var_list , "WGPR" );
|
||||
stringlist_append_ref( var_list , "WGPT" );
|
||||
stringlist_append_ref( var_list , "WWPR" );
|
||||
stringlist_append_ref( var_list , "WWPT" );
|
||||
|
||||
|
||||
ecl_sum_fmt_init_csv( &fmt );
|
||||
ecl_sum = ecl_sum_fread_alloc_case__( data_file , ":" , include_restart);
|
||||
if (ecl_sum != NULL) {
|
||||
char * csv_file = util_alloc_filename( NULL , ecl_sum_get_base(ecl_sum) , "txt"); // Will save to current path; can use ecl_sum_get_path() to save to target path instead.
|
||||
FILE * stream = util_fopen( csv_file , "w");
|
||||
|
||||
stringlist_type * well_list = ecl_sum_alloc_well_list( ecl_sum , NULL );
|
||||
stringlist_type * key_list = stringlist_alloc_new( );
|
||||
|
||||
fprintf(stream , fmt.header_fmt , "WELLNAME");
|
||||
|
||||
fprintf(stream , fmt.sep );
|
||||
fprintf(stream , fmt.header_fmt , "DAYS");
|
||||
|
||||
fprintf(stream , fmt.sep );
|
||||
fprintf(stream , fmt.header_fmt , "DATES");
|
||||
|
||||
{
|
||||
int ivar;
|
||||
for (ivar = 0; ivar < stringlist_get_size( var_list ); ivar++) {
|
||||
const char * var = stringlist_iget( var_list , ivar );
|
||||
fprintf(stream , fmt.sep );
|
||||
fprintf(stream , fmt.header_fmt , var );
|
||||
}
|
||||
fprintf(stream , "\n");
|
||||
}
|
||||
|
||||
{
|
||||
int iw;
|
||||
for (iw = 0; iw < stringlist_get_size( well_list ); iw++) {
|
||||
const char * well = stringlist_iget( well_list , iw );
|
||||
if (ecl_sum_is_oil_producer( ecl_sum , well )) {
|
||||
int time_index;
|
||||
for (time_index = 0; time_index < ecl_sum_get_data_length( ecl_sum ); time_index++)
|
||||
fprintf_line( ecl_sum , &fmt , well , time_index , var_list , stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
stringlist_free( well_list );
|
||||
stringlist_free( key_list );
|
||||
ecl_sum_free(ecl_sum);
|
||||
fclose( stream );
|
||||
free( csv_file );
|
||||
} else
|
||||
fprintf(stderr,"summary2csv2: No summary data found for case:%s\n", data_file );
|
||||
|
||||
stringlist_free( var_list );
|
||||
}
|
||||
}
|
||||
}
|
@ -31,8 +31,6 @@ extern "C" {
|
||||
#include <ert/ecl/ecl_kw.h>
|
||||
#include <ert/ecl/grid_dims.h>
|
||||
|
||||
#define ECL_GRID_GLOBAL_GRID "Global" // used as key in hash tables over grids.
|
||||
|
||||
|
||||
typedef double (block_function_ftype) ( const double_vector_type *);
|
||||
typedef struct ecl_grid_struct ecl_grid_type;
|
||||
@ -142,7 +140,6 @@ extern "C" {
|
||||
ecl_grid_type * ecl_grid_iget_lgr(const ecl_grid_type * main_grid , int lgr_nr);
|
||||
ecl_grid_type * ecl_grid_get_lgr(const ecl_grid_type * main_grid, const char * __lgr_name);
|
||||
bool ecl_grid_has_lgr(const ecl_grid_type * main_grid, const char * __lgr_name);
|
||||
const char * ecl_grid_iget_lgr_name( const ecl_grid_type * ecl_grid , int lgr_nr);
|
||||
stringlist_type * ecl_grid_alloc_lgr_name_list(const ecl_grid_type * ecl_grid);
|
||||
int ecl_grid_get_parent_cell1( const ecl_grid_type * grid , int global_index);
|
||||
int ecl_grid_get_parent_cell3( const ecl_grid_type * grid , int i , int j , int k);
|
||||
@ -174,8 +171,6 @@ extern "C" {
|
||||
void ecl_grid_cell_ri_export( const ecl_grid_type * ecl_grid , int global_index , double * ri_points);
|
||||
|
||||
bool ecl_grid_dual_grid( const ecl_grid_type * ecl_grid );
|
||||
|
||||
UTIL_IS_INSTANCE_HEADER( ecl_grid );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -104,7 +104,6 @@ extern "C" {
|
||||
#define ZWEL_KW "ZWEL"
|
||||
#define ICON_KW "ICON"
|
||||
#define ISEG_KW "ISEG"
|
||||
#define RSEG_KW "RSEG"
|
||||
|
||||
#define ECLIPSE100_OIL_DEN_KW "OIL_DEN"
|
||||
#define ECLIPSE100_GAS_DEN_KW "GAS_DEN"
|
||||
@ -136,9 +135,9 @@ extern "C" {
|
||||
#define INTEHEAD_NSEGMX_INDEX 176
|
||||
#define INTEHEAD_NLBRMX_INDEX 177
|
||||
#define INTEHEAD_NISEGZ_INDEX 178
|
||||
#define INTEHEAD_NRSEGZ_INDEX 179
|
||||
#define INTEHEAD_NILBRZ_INDEX 180
|
||||
|
||||
|
||||
#define DOUBHEAD_DAYS_INDEX 0
|
||||
|
||||
/*****************************************************************/
|
||||
@ -231,11 +230,7 @@ extern "C" {
|
||||
#define CONGRAT_KW "CONGRAT" /* Gas ... */
|
||||
#define CONORAT_KW "CONORAT" /* Oil ... */
|
||||
#define CONPRES_KW "CONPRES" /* Pressure ... */
|
||||
#define CONLENST_KW "CONLENST" /* Length along MSW well */
|
||||
#define CONVTUB_KW "CONVTUB" /* Volumetric flow at tubing head conditions. */
|
||||
#define CONOTUB_KW "CONOTUB" /* Volumetric oil flow at tubing head conditions. */
|
||||
#define CONGTUB_KW "CONGTUB" /* Volumetric gas flow at tubing head conditions. */
|
||||
#define CONWTUB_KW "CONWTUB" /* Volumetric water flow at tubing head conditions. */
|
||||
|
||||
|
||||
|
||||
#define WELLETC_TYPE_INDEX 5 /* At this keyword the WELLETC keyword contains a string
|
||||
|
@ -1,83 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2011 Statoil ASA, Norway.
|
||||
|
||||
The file 'ecl_rft_cell.h' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#ifndef __ECL_RFT_CELL_H__
|
||||
#define __ECL_RFT_CELL_H__
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <ert/util/type_macros.h>
|
||||
|
||||
#define ECL_RFT_CELL_INVALID_VALUE -1
|
||||
|
||||
typedef struct ecl_rft_cell_struct ecl_rft_cell_type;
|
||||
|
||||
|
||||
|
||||
|
||||
UTIL_IS_INSTANCE_HEADER( ecl_rft_cell );
|
||||
|
||||
ecl_rft_cell_type * ecl_rft_cell_alloc_PLT( int i ,
|
||||
int j ,
|
||||
int k ,
|
||||
double depth ,
|
||||
double pressure ,
|
||||
double orat ,
|
||||
double grat ,
|
||||
double wrat ,
|
||||
double connection_start,
|
||||
double flowrate,
|
||||
double oil_flowrate,
|
||||
double gas_flowrate,
|
||||
double water_flowrate);
|
||||
|
||||
ecl_rft_cell_type * ecl_rft_cell_alloc_RFT( int i , int j , int k , double depth , double pressure , double swat , double sgas);
|
||||
void ecl_rft_cell_free( ecl_rft_cell_type * cell );
|
||||
void ecl_rft_cell_free__( void * arg);
|
||||
|
||||
bool ecl_rft_cell_ijk_equal( const ecl_rft_cell_type * cell , int i , int j , int k);
|
||||
void ecl_rft_cell_get_ijk( const ecl_rft_cell_type * cell , int * i , int * j , int * k);
|
||||
int ecl_rft_cell_get_i( const ecl_rft_cell_type * cell );
|
||||
int ecl_rft_cell_get_j( const ecl_rft_cell_type * cell );
|
||||
int ecl_rft_cell_get_k( const ecl_rft_cell_type * cell );
|
||||
double ecl_rft_cell_get_depth( const ecl_rft_cell_type * cell );
|
||||
double ecl_rft_cell_get_pressure( const ecl_rft_cell_type * cell );
|
||||
|
||||
double ecl_rft_cell_get_swat( const ecl_rft_cell_type * cell );
|
||||
double ecl_rft_cell_get_sgas( const ecl_rft_cell_type * cell );
|
||||
double ecl_rft_cell_get_soil( const ecl_rft_cell_type * cell );
|
||||
|
||||
double ecl_rft_cell_get_wrat( const ecl_rft_cell_type * cell );
|
||||
double ecl_rft_cell_get_grat( const ecl_rft_cell_type * cell );
|
||||
double ecl_rft_cell_get_orat( const ecl_rft_cell_type * cell );
|
||||
double ecl_rft_cell_get_connection_start( const ecl_rft_cell_type * cell );
|
||||
double ecl_rft_cell_get_flowrate( const ecl_rft_cell_type * cell );
|
||||
double ecl_rft_cell_get_oil_flowrate( const ecl_rft_cell_type * cell );
|
||||
double ecl_rft_cell_get_gas_flowrate( const ecl_rft_cell_type * cell );
|
||||
double ecl_rft_cell_get_water_flowrate( const ecl_rft_cell_type * cell );
|
||||
|
||||
int ecl_rft_cell_cmp__( const void * arg1 , const void * arg2);
|
||||
int ecl_rft_cell_cmp( const ecl_rft_cell_type * cell1 , const ecl_rft_cell_type * cell2);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -39,13 +39,15 @@ void ecl_rft_file_free(ecl_rft_file_type * );
|
||||
void ecl_rft_file_block(const ecl_rft_file_type * , double , const char * , int , const double * , int * , int * , int *);
|
||||
void ecl_rft_file_fprintf_rft_obs(const ecl_rft_file_type * , double , const char * , const char *, const char * , double);
|
||||
ecl_rft_node_type * ecl_rft_file_get_node(const ecl_rft_file_type * , const char * );
|
||||
void ecl_rft_file_summarize(const ecl_rft_file_type * , bool );
|
||||
void ecl_rft_file_xml_summary( const ecl_rft_file_type * rft_file );
|
||||
|
||||
const ecl_rft_node_type * ecl_rft_file_get_well_time_rft( const ecl_rft_file_type * rft_file , const char * well , time_t recording_time);
|
||||
|
||||
int ecl_rft_file_get_size__( const ecl_rft_file_type * rft_file, const char * well_pattern , time_t recording_time);
|
||||
int ecl_rft_file_get_size( const ecl_rft_file_type * rft_file);
|
||||
ecl_rft_node_type * ecl_rft_file_get_well_time_rft( const ecl_rft_file_type * rft_file , const char * well , time_t recording_time);
|
||||
ecl_rft_node_type * ecl_rft_file_iget_node( const ecl_rft_file_type * rft_file , int index);
|
||||
ecl_rft_node_type * ecl_rft_file_iget_well_rft( const ecl_rft_file_type * rft_file , const char * well, int index);
|
||||
const ecl_rft_node_type * ecl_rft_file_iget_node( const ecl_rft_file_type * rft_file , int index);
|
||||
const ecl_rft_node_type * ecl_rft_file_iget_well_rft( const ecl_rft_file_type * rft_file , const char * well, int index);
|
||||
bool ecl_rft_file_has_well( const ecl_rft_file_type * rft_file , const char * well);
|
||||
int ecl_rft_file_get_well_occurences( const ecl_rft_file_type * rft_file , const char * well);
|
||||
stringlist_type * ecl_rft_file_alloc_well_list(const ecl_rft_file_type * rft_file );
|
||||
|
@ -24,7 +24,6 @@ extern "C" {
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/ecl/ecl_file.h>
|
||||
#include <ert/ecl/ecl_rft_cell.h>
|
||||
|
||||
typedef enum { RFT = 1 ,
|
||||
PLT = 2 ,
|
||||
@ -32,34 +31,28 @@ typedef enum { RFT = 1 ,
|
||||
|
||||
typedef struct ecl_rft_node_struct ecl_rft_node_type;
|
||||
|
||||
void ecl_rft_node_inplace_sort_cells( ecl_rft_node_type * rft_node );
|
||||
const ecl_rft_cell_type * ecl_rft_node_iget_cell_sorted( ecl_rft_node_type * rft_node , int index);
|
||||
const ecl_rft_cell_type * ecl_rft_node_iget_cell( const ecl_rft_node_type * rft_node , int index);
|
||||
const ecl_rft_cell_type * ecl_rft_node_lookup_ijk( const ecl_rft_node_type * rft_node , int i, int j , int k);
|
||||
int ecl_rft_node_lookup_ijk( const ecl_rft_node_type * rft_node , int i, int j , int k);
|
||||
void ecl_rft_node_fprintf_rft_obs(const ecl_rft_node_type * , double , const char * , const char * , double );
|
||||
ecl_rft_node_type * ecl_rft_node_alloc(const ecl_file_type * file_map );
|
||||
const char * ecl_rft_node_get_well_name(const ecl_rft_node_type * );
|
||||
void ecl_rft_node_free(ecl_rft_node_type * );
|
||||
void ecl_rft_node_free__(void * );
|
||||
void ecl_rft_node_block2(const ecl_rft_node_type * , int , const double * , const double * , int * , int * , int *);
|
||||
void ecl_rft_node_block(const ecl_rft_node_type * , double , int , const double * , int * , int * , int *);
|
||||
time_t ecl_rft_node_get_date(const ecl_rft_node_type * );
|
||||
int ecl_rft_node_get_size(const ecl_rft_node_type * );
|
||||
void ecl_rft_node_summarize(const ecl_rft_node_type * , bool );
|
||||
const char * ecl_rft_node_get_well_name( const ecl_rft_node_type * rft_node );
|
||||
void ecl_rft_node_iget_ijk( const ecl_rft_node_type * rft_node , int index , int *i , int *j , int *k);
|
||||
|
||||
bool ecl_rft_node_is_RFT( const ecl_rft_node_type * rft_node );
|
||||
bool ecl_rft_node_is_PLT( const ecl_rft_node_type * rft_node );
|
||||
bool ecl_rft_node_is_SEGMENT( const ecl_rft_node_type * rft_node );
|
||||
bool ecl_rft_node_is_MSW( const ecl_rft_node_type * rft_node );
|
||||
|
||||
void ecl_rft_node_export_DEPTH(const ecl_rft_node_type * , const char * );
|
||||
double ecl_rft_node_iget_pressure( const ecl_rft_node_type * rft_node , int index);
|
||||
double ecl_rft_node_iget_depth( const ecl_rft_node_type * rft_node , int index);
|
||||
double ecl_rft_node_iget_wrat( const ecl_rft_node_type * rft_node , int index);
|
||||
double ecl_rft_node_iget_grat( const ecl_rft_node_type * rft_node , int index);
|
||||
double ecl_rft_node_iget_orat( const ecl_rft_node_type * rft_node , int index);
|
||||
|
||||
double ecl_rft_node_iget_swat( const ecl_rft_node_type * rft_node , int index);
|
||||
double ecl_rft_node_iget_sgas( const ecl_rft_node_type * rft_node , int index);
|
||||
double ecl_rft_node_iget_soil( const ecl_rft_node_type * rft_node , int index);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -63,7 +63,6 @@ extern "C" {
|
||||
int nswlmx; // The maximum number of segmented wells
|
||||
int nlbrmx; // The maximum number of lateral branches pr well
|
||||
int nilbrz; // The number of entries pr segment in ILBR array
|
||||
int nrsegz; // The number of entries pr segment in RSEG array
|
||||
|
||||
// Properteies from the LOGIHEAD keyword:
|
||||
bool dualp;
|
||||
|
@ -200,7 +200,6 @@ typedef struct ecl_sum_struct ecl_sum_type;
|
||||
ecl_sum_tstep_type * ecl_sum_add_tstep( ecl_sum_type * ecl_sum , int report_step , double sim_days);
|
||||
void ecl_sum_update_wgname( ecl_sum_type * ecl_sum , smspec_node_type * node , const char * wgname );
|
||||
|
||||
bool ecl_sum_is_oil_producer( const ecl_sum_type * ecl_sum , const char * well);
|
||||
char * ecl_sum_alloc_well_key( const ecl_sum_type * ecl_sum , const char * keyword , const char * wgname);
|
||||
UTIL_IS_INSTANCE_HEADER( ecl_sum );
|
||||
|
||||
|
@ -2,9 +2,9 @@ include_directories( ext )
|
||||
file(GLOB ext_source "ext/*.c" )
|
||||
file(GLOB ext_header "ext/*.h" )
|
||||
|
||||
set( source_files ecl_rsthead.c ecl_sum_tstep.c ecl_rst_file.c ecl_init_file.c ecl_grid_cache.c smspec_node.c ecl_kw_grdecl.c ecl_file_kw.c ecl_grav.c ecl_grav_calc.c ecl_smspec.c ecl_sum_data.c ecl_util.c ecl_kw.c ecl_sum.c fortio.c ecl_rft_file.c ecl_rft_node.c ecl_rft_cell.c ecl_grid.c ecl_coarse_cell.c ecl_box.c ecl_io_config.c ecl_file.c ecl_region.c point.c tetrahedron.c ecl_subsidence.c ecl_grid_dims.c grid_dims.c ecl_grav_common.c ${ext_source})
|
||||
set( source_files ecl_rsthead.c ecl_sum_tstep.c ecl_rst_file.c ecl_init_file.c ecl_grid_cache.c smspec_node.c ecl_kw_grdecl.c ecl_file_kw.c ecl_grav.c ecl_grav_calc.c ecl_smspec.c ecl_sum_data.c ecl_util.c ecl_kw.c ecl_sum.c fortio.c ecl_rft_file.c ecl_rft_node.c ecl_grid.c ecl_coarse_cell.c ecl_box.c ecl_io_config.c ecl_file.c ecl_region.c point.c tetrahedron.c ecl_subsidence.c ecl_grid_dims.c grid_dims.c ecl_grav_common.c ${ext_source})
|
||||
|
||||
set( header_files ecl_rsthead.h ecl_sum_tstep.h ecl_rst_file.h ecl_init_file.h smspec_node.h ecl_grid_cache.h ecl_kw_grdecl.h ecl_file_kw.h ecl_grav.h ecl_grav_calc.h ecl_endian_flip.h ecl_smspec.h ecl_sum_data.h ecl_util.h ecl_kw.h ecl_sum.h fortio.h ecl_rft_file.h ecl_rft_node.h ecl_rft_cell.h ecl_box.h ecl_coarse_cell.h ecl_grid.h ecl_io_config.h ecl_file.h ecl_region.h ecl_kw_magic.h ecl_subsidence.h ecl_grid_dims.h grid_dims.h ${ext_header} ecl_grav_common.h)
|
||||
set( header_files ecl_rsthead.h ecl_sum_tstep.h ecl_rst_file.h ecl_init_file.h smspec_node.h ecl_grid_cache.h ecl_kw_grdecl.h ecl_file_kw.h ecl_grav.h ecl_grav_calc.h ecl_endian_flip.h ecl_smspec.h ecl_sum_data.h ecl_util.h ecl_kw.h ecl_sum.h fortio.h ecl_rft_file.h ecl_rft_node.h ecl_box.h ecl_coarse_cell.h ecl_grid.h ecl_io_config.h ecl_file.h ecl_region.h ecl_kw_magic.h ecl_subsidence.h ecl_grid_dims.h grid_dims.h ${ext_header} ecl_grav_common.h)
|
||||
|
||||
|
||||
|
||||
|
27
ThirdParty/Ert/devel/libecl/src/ecl_grid.c
vendored
27
ThirdParty/Ert/devel/libecl/src/ecl_grid.c
vendored
@ -513,12 +513,12 @@ struct ecl_grid_struct {
|
||||
int parent_box[6]; /* integers i1,i2, j1,j2, k1,k2 of the parent grid region containing this lgr. the indices are inclusive - zero offset */
|
||||
/* not used yet .. */
|
||||
|
||||
int dualp_flag;
|
||||
bool use_mapaxes;
|
||||
double unit_x[2];
|
||||
double unit_y[2];
|
||||
double origo[2];
|
||||
float mapaxes[6];
|
||||
int dualp_flag;
|
||||
bool use_mapaxes;
|
||||
double unit_x[2];
|
||||
double unit_y[2];
|
||||
double origo[2];
|
||||
float mapaxes[6];
|
||||
/*------------------------------: the fields below this line are used for blocking algorithms - and not allocated by default.*/
|
||||
int block_dim; /* == 2 for maps and 3 for fields. 0 when not in use. */
|
||||
int block_size;
|
||||
@ -1089,7 +1089,6 @@ static void ecl_cell_init_regular( ecl_cell_type * cell , const double * offset
|
||||
/* starting on the ecl_grid proper implementation */
|
||||
|
||||
UTIL_SAFE_CAST_FUNCTION(ecl_grid , ECL_GRID_ID);
|
||||
UTIL_IS_INSTANCE_FUNCTION( ecl_grid , ECL_GRID_ID);
|
||||
|
||||
/**
|
||||
this function allocates the internal index_map and inv_index_map fields.
|
||||
@ -2602,10 +2601,7 @@ ecl_grid_type * ecl_grid_load_case( const char * case_input ) {
|
||||
ecl_grid_type * ecl_grid = NULL;
|
||||
char * grid_file = ecl_grid_alloc_case_filename( case_input );
|
||||
if (grid_file != NULL) {
|
||||
|
||||
if (util_file_exists( grid_file ))
|
||||
ecl_grid = ecl_grid_alloc( grid_file );
|
||||
|
||||
ecl_grid = ecl_grid_alloc( grid_file );
|
||||
free( grid_file );
|
||||
}
|
||||
return ecl_grid;
|
||||
@ -3545,15 +3541,6 @@ stringlist_type * ecl_grid_alloc_lgr_name_list(const ecl_grid_type * ecl_grid) {
|
||||
}
|
||||
}
|
||||
|
||||
const char * ecl_grid_iget_lgr_name( const ecl_grid_type * ecl_grid , int lgr_nr) {
|
||||
__assert_main_grid( ecl_grid );
|
||||
if (lgr_nr < (vector_get_size( ecl_grid->LGR_list ) - 1)) {
|
||||
const ecl_grid_type * lgr = vector_iget( ecl_grid->LGR_list , lgr_nr + 1);
|
||||
return lgr->name;
|
||||
} else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*****************************************************************/
|
||||
|
5
ThirdParty/Ert/devel/libecl/src/ecl_region.c
vendored
5
ThirdParty/Ert/devel/libecl/src/ecl_region.c
vendored
@ -689,9 +689,8 @@ void ecl_region_deselect_i1i2( ecl_region_type * region , int i1 , int i2) {
|
||||
static void ecl_region_select_j1j2__( ecl_region_type * region , int j1 , int j2 , bool select) {
|
||||
if (j1 > j2)
|
||||
util_abort("%s: i1 > i2 - this is illogical ... \n",__func__);
|
||||
|
||||
j1 = util_int_max(0 , j1);
|
||||
j2 = util_int_min(region->grid_ny - 1 , j2);
|
||||
j2 = util_int_min(region->grid_nx - 1 , j2);
|
||||
{
|
||||
int i,j,k;
|
||||
for (k = 0; k < region->grid_nz; k++)
|
||||
@ -730,7 +729,7 @@ static void ecl_region_select_k1k2__( ecl_region_type * region , int k1 , int k2
|
||||
if (k1 > k2)
|
||||
util_abort("%s: i1 > i2 - this is illogical ... \n",__func__);
|
||||
k1 = util_int_max(0 , k1);
|
||||
k2 = util_int_min(region->grid_nz - 1 , k2);
|
||||
k2 = util_int_min(region->grid_nx - 1 , k2);
|
||||
{
|
||||
int i,j,k;
|
||||
for (k = k1; k <= k2; k++)
|
||||
|
357
ThirdParty/Ert/devel/libecl/src/ecl_rft_cell.c
vendored
357
ThirdParty/Ert/devel/libecl/src/ecl_rft_cell.c
vendored
@ -1,357 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2011 Statoil ASA, Norway.
|
||||
|
||||
The file 'ecl_rft_cell.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <time.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include <ert/util/util.h>
|
||||
#include <ert/util/type_macros.h>
|
||||
|
||||
#include <ert/ecl/ecl_kw.h>
|
||||
#include <ert/ecl/ecl_kw_magic.h>
|
||||
#include <ert/ecl/ecl_file.h>
|
||||
#include <ert/ecl/ecl_rft_cell.h>
|
||||
|
||||
|
||||
#define ECL_RFT_CELL_TYPE_ID 99164012
|
||||
#define RFT_DATA_TYPE_ID 66787166
|
||||
#define PLT_DATA_TYPE_ID 87166667
|
||||
|
||||
|
||||
struct ecl_rft_cell_struct {
|
||||
UTIL_TYPE_ID_DECLARATION;
|
||||
int i,j,k;
|
||||
double pressure;
|
||||
double depth;
|
||||
|
||||
void * data;
|
||||
};
|
||||
|
||||
|
||||
typedef struct plt_data_struct plt_data_type;
|
||||
typedef struct rft_data_struct rft_data_type;
|
||||
|
||||
|
||||
struct rft_data_struct {
|
||||
UTIL_TYPE_ID_DECLARATION;
|
||||
double swat;
|
||||
double sgas;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
struct plt_data_struct {
|
||||
UTIL_TYPE_ID_DECLARATION;
|
||||
double orat;
|
||||
double wrat;
|
||||
double grat;
|
||||
double connection_start;
|
||||
double flowrate;
|
||||
double oil_flowrate;
|
||||
double gas_flowrate;
|
||||
double water_flowrate;
|
||||
};
|
||||
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
static rft_data_type * rft_data_alloc( double swat , double sgas) {
|
||||
rft_data_type * data = util_malloc( sizeof * data );
|
||||
UTIL_TYPE_ID_INIT( data , RFT_DATA_TYPE_ID );
|
||||
|
||||
data->swat = swat;
|
||||
data->sgas = sgas;
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
static void rft_data_free( rft_data_type * data ) {
|
||||
free( data );
|
||||
}
|
||||
|
||||
static UTIL_TRY_CAST_FUNCTION_CONST( rft_data , RFT_DATA_TYPE_ID)
|
||||
static UTIL_IS_INSTANCE_FUNCTION( rft_data , RFT_DATA_TYPE_ID)
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
static plt_data_type * plt_data_alloc( double orat , double grat , double wrat,double connection_start, double flowrate , double oil_flowrate , double gas_flowrate , double water_flowrate) {
|
||||
plt_data_type * data = util_malloc( sizeof * data );
|
||||
UTIL_TYPE_ID_INIT( data , PLT_DATA_TYPE_ID );
|
||||
|
||||
data->orat = orat;
|
||||
data->grat = grat;
|
||||
data->wrat = wrat;
|
||||
data->connection_start = connection_start;
|
||||
data->flowrate = flowrate;
|
||||
data->oil_flowrate = oil_flowrate;
|
||||
data->gas_flowrate = gas_flowrate;
|
||||
data->water_flowrate = water_flowrate;
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
static void plt_data_free( plt_data_type * data ) {
|
||||
free( data );
|
||||
}
|
||||
|
||||
static UTIL_TRY_CAST_FUNCTION_CONST( plt_data , PLT_DATA_TYPE_ID)
|
||||
static UTIL_IS_INSTANCE_FUNCTION( plt_data , PLT_DATA_TYPE_ID)
|
||||
|
||||
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
static UTIL_SAFE_CAST_FUNCTION( ecl_rft_cell , ECL_RFT_CELL_TYPE_ID)
|
||||
static UTIL_SAFE_CAST_FUNCTION_CONST( ecl_rft_cell , ECL_RFT_CELL_TYPE_ID)
|
||||
UTIL_IS_INSTANCE_FUNCTION( ecl_rft_cell , ECL_RFT_CELL_TYPE_ID)
|
||||
|
||||
|
||||
|
||||
static ecl_rft_cell_type * ecl_rft_cell_alloc_common(int i , int j , int k , double depth , double pressure) {
|
||||
ecl_rft_cell_type * cell = util_malloc( sizeof * cell );
|
||||
UTIL_TYPE_ID_INIT( cell , ECL_RFT_CELL_TYPE_ID );
|
||||
|
||||
cell->i = i;
|
||||
cell->j = j;
|
||||
cell->k = k;
|
||||
cell->depth = depth;
|
||||
cell->pressure = pressure;
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
|
||||
|
||||
ecl_rft_cell_type * ecl_rft_cell_alloc_RFT( int i , int j , int k , double depth , double pressure , double swat , double sgas) {
|
||||
ecl_rft_cell_type * cell = ecl_rft_cell_alloc_common( i , j , k , depth , pressure );
|
||||
|
||||
cell->data = rft_data_alloc( swat , sgas );
|
||||
return cell;
|
||||
}
|
||||
|
||||
|
||||
ecl_rft_cell_type * ecl_rft_cell_alloc_PLT( int i ,
|
||||
int j ,
|
||||
int k ,
|
||||
double depth ,
|
||||
double pressure ,
|
||||
double orat ,
|
||||
double grat ,
|
||||
double wrat,
|
||||
double connection_start,
|
||||
double flowrate ,
|
||||
double oil_flowrate ,
|
||||
double gas_flowrate ,
|
||||
double water_flowrate) {
|
||||
|
||||
ecl_rft_cell_type * cell = ecl_rft_cell_alloc_common( i , j , k , depth , pressure );
|
||||
|
||||
cell->data = plt_data_alloc( orat , grat , wrat , connection_start , flowrate , oil_flowrate , gas_flowrate , water_flowrate);
|
||||
return cell;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ecl_rft_cell_free( ecl_rft_cell_type * cell ) {
|
||||
if (rft_data_is_instance( cell->data ))
|
||||
rft_data_free( cell->data );
|
||||
else if (plt_data_is_instance( cell->data ))
|
||||
plt_data_free( cell->data );
|
||||
|
||||
free( cell );
|
||||
}
|
||||
|
||||
void ecl_rft_cell_free__( void * arg) {
|
||||
ecl_rft_cell_type * cell = ecl_rft_cell_safe_cast( arg );
|
||||
ecl_rft_cell_free( cell );
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
int ecl_rft_cell_get_i( const ecl_rft_cell_type * cell ) {
|
||||
return cell->i;
|
||||
}
|
||||
|
||||
int ecl_rft_cell_get_j( const ecl_rft_cell_type * cell ) {
|
||||
return cell->j;
|
||||
}
|
||||
|
||||
int ecl_rft_cell_get_k( const ecl_rft_cell_type * cell ) {
|
||||
return cell->k;
|
||||
}
|
||||
|
||||
void ecl_rft_cell_get_ijk( const ecl_rft_cell_type * cell , int * i , int * j , int * k) {
|
||||
*i = cell->i;
|
||||
*j = cell->j;
|
||||
*k = cell->k;
|
||||
}
|
||||
|
||||
double ecl_rft_cell_get_depth( const ecl_rft_cell_type * cell ) {
|
||||
return cell->depth;
|
||||
}
|
||||
|
||||
double ecl_rft_cell_get_pressure( const ecl_rft_cell_type * cell ) {
|
||||
return cell->pressure;
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
double ecl_rft_cell_get_swat( const ecl_rft_cell_type * cell ) {
|
||||
const rft_data_type * data = rft_data_try_cast_const( cell->data );
|
||||
if (data)
|
||||
return data->swat;
|
||||
else
|
||||
return ECL_RFT_CELL_INVALID_VALUE;
|
||||
}
|
||||
|
||||
|
||||
double ecl_rft_cell_get_sgas( const ecl_rft_cell_type * cell ) {
|
||||
const rft_data_type * data = rft_data_try_cast_const( cell->data );
|
||||
if (data)
|
||||
return data->sgas;
|
||||
else
|
||||
return ECL_RFT_CELL_INVALID_VALUE;
|
||||
}
|
||||
|
||||
|
||||
double ecl_rft_cell_get_soil( const ecl_rft_cell_type * cell ) {
|
||||
const rft_data_type * data = rft_data_try_cast_const( cell->data );
|
||||
if (data)
|
||||
return 1 - (data->swat + data->sgas);
|
||||
else
|
||||
return ECL_RFT_CELL_INVALID_VALUE;
|
||||
}
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
double ecl_rft_cell_get_orat( const ecl_rft_cell_type * cell ) {
|
||||
const plt_data_type * data = plt_data_try_cast_const( cell->data );
|
||||
if (data)
|
||||
return data->orat;
|
||||
else
|
||||
return ECL_RFT_CELL_INVALID_VALUE;
|
||||
}
|
||||
|
||||
|
||||
double ecl_rft_cell_get_grat( const ecl_rft_cell_type * cell ) {
|
||||
const plt_data_type * data = plt_data_try_cast_const( cell->data );
|
||||
if (data)
|
||||
return data->grat;
|
||||
else
|
||||
return ECL_RFT_CELL_INVALID_VALUE;
|
||||
}
|
||||
|
||||
|
||||
double ecl_rft_cell_get_wrat( const ecl_rft_cell_type * cell ) {
|
||||
const plt_data_type * data = plt_data_try_cast_const( cell->data );
|
||||
if (data)
|
||||
return data->wrat;
|
||||
else
|
||||
return ECL_RFT_CELL_INVALID_VALUE;
|
||||
}
|
||||
|
||||
double ecl_rft_cell_get_connection_start( const ecl_rft_cell_type * cell ) {
|
||||
const plt_data_type * data = plt_data_try_cast_const( cell->data );
|
||||
if (data)
|
||||
return data->connection_start;
|
||||
else
|
||||
return ECL_RFT_CELL_INVALID_VALUE;
|
||||
}
|
||||
|
||||
|
||||
double ecl_rft_cell_get_flowrate( const ecl_rft_cell_type * cell ) {
|
||||
const plt_data_type * data = plt_data_try_cast_const( cell->data );
|
||||
if (data)
|
||||
return data->flowrate;
|
||||
else
|
||||
return ECL_RFT_CELL_INVALID_VALUE;
|
||||
}
|
||||
|
||||
|
||||
double ecl_rft_cell_get_oil_flowrate( const ecl_rft_cell_type * cell ) {
|
||||
const plt_data_type * data = plt_data_try_cast_const( cell->data );
|
||||
if (data)
|
||||
return data->oil_flowrate;
|
||||
else
|
||||
return ECL_RFT_CELL_INVALID_VALUE;
|
||||
}
|
||||
|
||||
|
||||
double ecl_rft_cell_get_gas_flowrate( const ecl_rft_cell_type * cell ) {
|
||||
const plt_data_type * data = plt_data_try_cast_const( cell->data );
|
||||
if (data)
|
||||
return data->gas_flowrate;
|
||||
else
|
||||
return ECL_RFT_CELL_INVALID_VALUE;
|
||||
}
|
||||
|
||||
|
||||
double ecl_rft_cell_get_water_flowrate( const ecl_rft_cell_type * cell ) {
|
||||
const plt_data_type * data = plt_data_try_cast_const( cell->data );
|
||||
if (data)
|
||||
return data->water_flowrate;
|
||||
else
|
||||
return ECL_RFT_CELL_INVALID_VALUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
|
||||
|
||||
bool ecl_rft_cell_ijk_equal( const ecl_rft_cell_type * cell , int i , int j , int k) {
|
||||
return ( (i == cell->i) &&
|
||||
(j == cell->j) &&
|
||||
(k == cell->k) );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Currently only comparison based on connection length along PLT is supported.
|
||||
*/
|
||||
int ecl_rft_cell_cmp( const ecl_rft_cell_type * cell1 , const ecl_rft_cell_type * cell2) {
|
||||
double val1 = ecl_rft_cell_get_connection_start( cell1 );
|
||||
double val2 = ecl_rft_cell_get_connection_start( cell2 );
|
||||
|
||||
if (val1 < val2)
|
||||
return -1;
|
||||
else if (val1 == val2)
|
||||
return 0;
|
||||
else
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
int ecl_rft_cell_cmp__( const void * arg1 , const void * arg2) {
|
||||
const ecl_rft_cell_type * cell1 = ecl_rft_cell_safe_cast_const( arg1 );
|
||||
const ecl_rft_cell_type * cell2 = ecl_rft_cell_safe_cast_const( arg2 );
|
||||
return ecl_rft_cell_cmp( cell1 , cell2 );
|
||||
}
|
64
ThirdParty/Ert/devel/libecl/src/ecl_rft_file.c
vendored
64
ThirdParty/Ert/devel/libecl/src/ecl_rft_file.c
vendored
@ -226,8 +226,8 @@ int ecl_rft_file_get_size__( const ecl_rft_file_type * rft_file, const char * we
|
||||
for ( i=0; i < vector_get_size( rft_file->data ); i++) {
|
||||
const ecl_rft_node_type * rft = vector_iget_const( rft_file->data , i);
|
||||
|
||||
if (well_pattern) {
|
||||
if (util_fnmatch( well_pattern , ecl_rft_node_get_well_name( rft )) != 0)
|
||||
if (well_pattern != NULL) {
|
||||
if (!util_fnmatch( well_pattern , ecl_rft_node_get_well_name( rft )))
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -269,8 +269,8 @@ const char * ecl_rft_file_get_filename( const ecl_rft_file_type * rft_file ) {
|
||||
handle that.
|
||||
*/
|
||||
|
||||
ecl_rft_node_type * ecl_rft_file_iget_node( const ecl_rft_file_type * rft_file , int index) {
|
||||
return vector_iget( rft_file->data , index );
|
||||
const ecl_rft_node_type * ecl_rft_file_iget_node( const ecl_rft_file_type * rft_file , int index) {
|
||||
return vector_iget_const( rft_file->data , index );
|
||||
}
|
||||
|
||||
|
||||
@ -301,7 +301,7 @@ ecl_rft_node_type * ecl_rft_file_iget_node( const ecl_rft_file_type * rft_file ,
|
||||
|
||||
|
||||
|
||||
ecl_rft_node_type * ecl_rft_file_iget_well_rft( const ecl_rft_file_type * rft_file , const char * well, int index) {
|
||||
const ecl_rft_node_type * ecl_rft_file_iget_well_rft( const ecl_rft_file_type * rft_file , const char * well, int index) {
|
||||
const int_vector_type * index_vector = hash_get(rft_file->well_index , well);
|
||||
return ecl_rft_file_iget_node( rft_file , int_vector_iget(index_vector , index));
|
||||
}
|
||||
@ -315,8 +315,8 @@ ecl_rft_node_type * ecl_rft_file_iget_well_rft( const ecl_rft_file_type * rft_fi
|
||||
*/
|
||||
|
||||
|
||||
ecl_rft_node_type * ecl_rft_file_get_well_time_rft( const ecl_rft_file_type * rft_file , const char * well , time_t recording_time) {
|
||||
ecl_rft_node_type * node = NULL;
|
||||
const ecl_rft_node_type * ecl_rft_file_get_well_time_rft( const ecl_rft_file_type * rft_file , const char * well , time_t recording_time) {
|
||||
const ecl_rft_node_type * node = NULL;
|
||||
if (hash_has_key( rft_file->well_index , well)) {
|
||||
const int_vector_type * index_vector = hash_get(rft_file->well_index , well);
|
||||
int index = 0;
|
||||
@ -367,6 +367,56 @@ stringlist_type * ecl_rft_file_alloc_well_list(const ecl_rft_file_type * rft_fil
|
||||
}
|
||||
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
|
||||
void ecl_rft_file_summarize(const ecl_rft_file_type * rft_vector , bool show_completions) {
|
||||
int iw;
|
||||
for (iw = 0; iw < vector_get_size( rft_vector->data ); iw++) {
|
||||
ecl_rft_node_summarize(vector_iget( rft_vector->data , iw) , show_completions);
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ecl_rft_file_xml_summary( const ecl_rft_file_type * rft_file ) {
|
||||
stringlist_type * wells = ecl_rft_file_alloc_well_list( rft_file );
|
||||
printf("<ECLIPSE RFT FILE>\n");
|
||||
{
|
||||
int iw;
|
||||
for (iw = 0; iw < stringlist_get_size( wells ); iw++) {
|
||||
const char * well = stringlist_iget(wells , iw);
|
||||
printf(" <WELL>\n");
|
||||
{
|
||||
int it;
|
||||
for (it = 0; it < ecl_rft_file_get_well_occurences( rft_file , well ); it++) {
|
||||
const ecl_rft_node_type * node = ecl_rft_file_iget_well_rft( rft_file , well , it);
|
||||
time_t date = ecl_rft_node_get_date( node );
|
||||
{
|
||||
int mday, year,month;
|
||||
util_set_date_values( date , &mday , &month , &year);
|
||||
printf(" <RFT>\n");
|
||||
printf(" <DATE>%02d/%02d/%4d</DATE> \n",mday,month,year);
|
||||
{
|
||||
int num_cells = ecl_rft_node_get_size( node );
|
||||
int icell;
|
||||
for (icell = 0; icell < num_cells; icell++) {
|
||||
int i,j,k;
|
||||
ecl_rft_node_iget_ijk( node , icell , &i , &j , &k);
|
||||
printf(" <cell>\n");
|
||||
printf(" <PRESSURE> %g </PRESSURE> \n", ecl_rft_node_iget_pressure( node, icell));
|
||||
printf(" <DPETH> %g </DEPTH> \n" , ecl_rft_node_iget_depth( node , icell));
|
||||
printf(" <ijk> %3d,%3d,%3d </ijk> \n",i,j,k);
|
||||
printf(" </cell>\n");
|
||||
}
|
||||
}
|
||||
printf(" </RFT>\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
printf(" </WELL>\n");
|
||||
}
|
||||
}
|
||||
printf("</ECLIPSE RFT FILE>\n");
|
||||
stringlist_free( wells );
|
||||
}
|
||||
|
646
ThirdParty/Ert/devel/libecl/src/ecl_rft_node.c
vendored
646
ThirdParty/Ert/devel/libecl/src/ecl_rft_node.c
vendored
@ -25,14 +25,12 @@
|
||||
|
||||
#include <ert/util/util.h>
|
||||
#include <ert/util/hash.h>
|
||||
#include <ert/util/vector.h>
|
||||
#include <ert/util/int_vector.h>
|
||||
|
||||
#include <ert/ecl/ecl_kw.h>
|
||||
#include <ert/ecl/ecl_kw_magic.h>
|
||||
#include <ert/ecl/ecl_file.h>
|
||||
#include <ert/ecl/ecl_rft_node.h>
|
||||
#include <ert/ecl/ecl_rft_cell.h>
|
||||
|
||||
|
||||
/**
|
||||
The RFT's from several wells, and possibly also several timesteps
|
||||
@ -50,20 +48,80 @@
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
Here comes some small structs containing various pieces of
|
||||
information. Observe the following which is common to all these
|
||||
structs:
|
||||
|
||||
* In the implementation only 'full instance' are employed, and
|
||||
not pointers. This implies that the code does not provide
|
||||
xxx_alloc() and xx_free() functions.
|
||||
|
||||
* They should NOT be exported out of this file.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
This type is used to hold the coordinates of a perforated
|
||||
cell. This type is used irrespective of whether this is a simple
|
||||
RFT or a PLT.
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
int i;
|
||||
int j;
|
||||
int k;
|
||||
double depth;
|
||||
double pressure; /* both CONPRES from PLT and PRESSURE from RFT are internalized as pressure in the cell_type. */
|
||||
} cell_type;
|
||||
|
||||
/*-----------------------------------------------------------------*/
|
||||
/**
|
||||
Type which contains the information for one cell in an RFT.
|
||||
*/
|
||||
typedef struct {
|
||||
double swat;
|
||||
double sgas;
|
||||
} rft_data_type;
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------*/
|
||||
/**
|
||||
Type which contains the information for one cell in an PLT.
|
||||
*/
|
||||
typedef struct {
|
||||
double orat;
|
||||
double grat;
|
||||
double wrat;
|
||||
/* There is quite a lot of more information in the PLT - not yet internalized. */
|
||||
} plt_data_type;
|
||||
|
||||
|
||||
|
||||
|
||||
/* This is not implemented at all ..... */
|
||||
typedef struct {
|
||||
double data;
|
||||
} segment_data_type;
|
||||
|
||||
|
||||
#define ECL_RFT_NODE_ID 887195
|
||||
struct ecl_rft_node_struct {
|
||||
UTIL_TYPE_ID_DECLARATION;
|
||||
char * well_name; /* Name of the well. */
|
||||
int size; /* The number of entries in this RFT vector (i.e. the number of cells) .*/
|
||||
|
||||
ecl_rft_enum data_type; /* What type of data: RFT|PLT|SEGMENT */
|
||||
time_t recording_date; /* When was the RFT recorded - date.*/
|
||||
double days; /* When was the RFT recorded - days after simulaton start. */
|
||||
bool MSW;
|
||||
|
||||
bool sort_perm_in_sync ;
|
||||
int_vector_type * sort_perm;
|
||||
vector_type *cells;
|
||||
cell_type *cells; /* Coordinates and depth of the well cells. */
|
||||
|
||||
/* Only one of segment_data, rft_data or plt_data can be != NULL */
|
||||
segment_data_type * segment_data;
|
||||
rft_data_type * rft_data;
|
||||
plt_data_type * plt_data;
|
||||
|
||||
bool __vertical_well; /* Internal variable - when this is true we can try to block - otherwise it is NO FUXXXX WAY. */
|
||||
};
|
||||
|
||||
|
||||
@ -73,7 +131,7 @@ struct ecl_rft_node_struct {
|
||||
that is not (yet) supported.
|
||||
*/
|
||||
|
||||
static ecl_rft_node_type * ecl_rft_node_alloc_empty(const char * data_type_string) {
|
||||
static ecl_rft_node_type * ecl_rft_node_alloc_empty(int size , const char * data_type_string) {
|
||||
ecl_rft_enum data_type = SEGMENT;
|
||||
|
||||
/* According to the ECLIPSE documentaton. */
|
||||
@ -82,7 +140,7 @@ static ecl_rft_node_type * ecl_rft_node_alloc_empty(const char * data_type_strin
|
||||
else if (strchr(data_type_string, 'R') != NULL)
|
||||
data_type = RFT;
|
||||
else if (strchr(data_type_string , 'S') != NULL)
|
||||
data_type = SEGMENT;
|
||||
data_type = SEGMENT;
|
||||
else
|
||||
util_abort("%s: Could not determine type of RFT/PLT/SEGMENT data - aborting\n",__func__);
|
||||
|
||||
@ -95,13 +153,24 @@ static ecl_rft_node_type * ecl_rft_node_alloc_empty(const char * data_type_strin
|
||||
|
||||
{
|
||||
ecl_rft_node_type * rft_node = util_malloc(sizeof * rft_node );
|
||||
rft_node->plt_data = NULL;
|
||||
rft_node->rft_data = NULL;
|
||||
rft_node->segment_data = NULL;
|
||||
|
||||
UTIL_TYPE_ID_INIT( rft_node , ECL_RFT_NODE_ID );
|
||||
|
||||
rft_node->cells = vector_alloc_new();
|
||||
rft_node->data_type = data_type;
|
||||
rft_node->sort_perm = NULL;
|
||||
rft_node->sort_perm_in_sync = false;
|
||||
rft_node->cells = util_calloc( size , sizeof * rft_node->cells );
|
||||
if (data_type == RFT)
|
||||
rft_node->rft_data = util_calloc( size , sizeof * rft_node->rft_data );
|
||||
else if (data_type == PLT)
|
||||
rft_node->plt_data = util_calloc( size , sizeof * rft_node->plt_data);
|
||||
else if (data_type == SEGMENT)
|
||||
rft_node->segment_data = util_calloc( size , sizeof * rft_node->segment_data );
|
||||
|
||||
rft_node->__vertical_well = false;
|
||||
rft_node->size = size;
|
||||
rft_node->data_type = data_type;
|
||||
|
||||
return rft_node;
|
||||
}
|
||||
}
|
||||
@ -111,137 +180,112 @@ UTIL_SAFE_CAST_FUNCTION( ecl_rft_node , ECL_RFT_NODE_ID );
|
||||
UTIL_IS_INSTANCE_FUNCTION( ecl_rft_node , ECL_RFT_NODE_ID );
|
||||
|
||||
|
||||
static void ecl_rft_node_append_cell( ecl_rft_node_type * rft_node , ecl_rft_cell_type * cell) {
|
||||
vector_append_owned_ref( rft_node->cells , cell , ecl_rft_cell_free__ );
|
||||
rft_node->sort_perm_in_sync = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void ecl_rft_node_init_RFT_cells( ecl_rft_node_type * rft_node , const ecl_file_type * rft) {
|
||||
const ecl_kw_type * conipos = ecl_file_iget_named_kw( rft , CONIPOS_KW , 0);
|
||||
const ecl_kw_type * conjpos = ecl_file_iget_named_kw( rft , CONJPOS_KW , 0);
|
||||
const ecl_kw_type * conkpos = ecl_file_iget_named_kw( rft , CONKPOS_KW , 0);
|
||||
const ecl_kw_type * depth_kw = ecl_file_iget_named_kw( rft , DEPTH_KW , 0);
|
||||
const ecl_kw_type * swat_kw = ecl_file_iget_named_kw( rft , SWAT_KW , 0);
|
||||
const ecl_kw_type * sgas_kw = ecl_file_iget_named_kw( rft , SGAS_KW , 0);
|
||||
const ecl_kw_type * pressure_kw = ecl_file_iget_named_kw( rft , PRESSURE_KW , 0);
|
||||
|
||||
const float * SW = ecl_kw_get_float_ptr( swat_kw );
|
||||
const float * SG = ecl_kw_get_float_ptr( sgas_kw );
|
||||
const float * P = ecl_kw_get_float_ptr( pressure_kw );
|
||||
const float * depth = ecl_kw_get_float_ptr( depth_kw );
|
||||
const int * i = ecl_kw_get_int_ptr( conipos );
|
||||
const int * j = ecl_kw_get_int_ptr( conjpos );
|
||||
const int * k = ecl_kw_get_int_ptr( conkpos );
|
||||
|
||||
{
|
||||
int c;
|
||||
for (c = 0; c < ecl_kw_get_size( conipos ); c++) {
|
||||
/* The connection coordinates are shifted -= 1; i.e. all internal usage is offset 0. */
|
||||
ecl_rft_cell_type * cell = ecl_rft_cell_alloc_RFT( i[c] - 1 , j[c] - 1 , k[c] - 1 ,
|
||||
depth[c] , P[c] , SW[c] , SG[c]);
|
||||
ecl_rft_node_append_cell( rft_node , cell );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static void ecl_rft_node_init_PLT_cells( ecl_rft_node_type * rft_node , const ecl_file_type * rft) {
|
||||
/* For PLT there is quite a lot of extra information which is not yet internalized. */
|
||||
const ecl_kw_type * conipos = ecl_file_iget_named_kw( rft , CONIPOS_KW , 0);
|
||||
const ecl_kw_type * conjpos = ecl_file_iget_named_kw( rft , CONJPOS_KW , 0);
|
||||
const ecl_kw_type * conkpos = ecl_file_iget_named_kw( rft , CONKPOS_KW , 0);
|
||||
|
||||
const int * i = ecl_kw_get_int_ptr( conipos );
|
||||
const int * j = ecl_kw_get_int_ptr( conjpos );
|
||||
const int * k = ecl_kw_get_int_ptr( conkpos );
|
||||
|
||||
const float * WR = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , CONWRAT_KW , 0));
|
||||
const float * GR = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , CONGRAT_KW , 0));
|
||||
const float * OR = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , CONORAT_KW , 0));
|
||||
const float * P = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , CONPRES_KW , 0));
|
||||
const float * depth = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , CONDEPTH_KW , 0));
|
||||
const float * flowrate = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , CONVTUB_KW , 0));
|
||||
const float * oil_flowrate = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , CONOTUB_KW , 0));
|
||||
const float * gas_flowrate = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , CONGTUB_KW , 0));
|
||||
const float * water_flowrate = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , CONWTUB_KW , 0));
|
||||
const float * connection_start = NULL;
|
||||
|
||||
/* This keyword is ONLY present if we are dealing with a MSW well. */
|
||||
if (ecl_file_has_kw( rft , CONLENST_KW))
|
||||
connection_start = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , CONLENST_KW , 0));
|
||||
|
||||
{
|
||||
int c;
|
||||
for ( c = 0; c < ecl_kw_get_size( conipos ); c++) {
|
||||
ecl_rft_cell_type * cell;
|
||||
double cs = 0;
|
||||
if (connection_start)
|
||||
cs = connection_start[c];
|
||||
|
||||
/* The connection coordinates are shifted -= 1; i.e. all internal usage is offset 0. */
|
||||
cell = ecl_rft_cell_alloc_PLT( i[c] -1 , j[c] -1 , k[c] -1 ,
|
||||
depth[c] , P[c] , OR[c] , GR[c] , WR[c] , cs , flowrate[c] , oil_flowrate[c] , gas_flowrate[c] , water_flowrate[c]);
|
||||
ecl_rft_node_append_cell( rft_node , cell );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static void ecl_rft_node_init_cells( ecl_rft_node_type * rft_node , const ecl_file_type * rft ) {
|
||||
|
||||
if (rft_node->data_type == RFT)
|
||||
ecl_rft_node_init_RFT_cells( rft_node , rft );
|
||||
else if (rft_node->data_type == PLT)
|
||||
ecl_rft_node_init_PLT_cells( rft_node , rft );
|
||||
|
||||
}
|
||||
|
||||
|
||||
ecl_rft_node_type * ecl_rft_node_alloc(const ecl_file_type * rft) {
|
||||
ecl_kw_type * conipos = ecl_file_iget_named_kw(rft , CONIPOS_KW , 0);
|
||||
ecl_kw_type * welletc = ecl_file_iget_named_kw(rft , WELLETC_KW , 0);
|
||||
ecl_rft_node_type * rft_node = ecl_rft_node_alloc_empty(ecl_kw_iget_ptr(welletc , WELLETC_TYPE_INDEX));
|
||||
ecl_rft_node_type * rft_node = ecl_rft_node_alloc_empty(ecl_kw_get_size(conipos) ,
|
||||
ecl_kw_iget_ptr(welletc , WELLETC_TYPE_INDEX));
|
||||
|
||||
if (rft_node != NULL) {
|
||||
ecl_kw_type * date_kw = ecl_file_iget_named_kw( rft , DATE_KW , 0);
|
||||
ecl_kw_type * conjpos = ecl_file_iget_named_kw( rft , CONJPOS_KW , 0);
|
||||
ecl_kw_type * conkpos = ecl_file_iget_named_kw( rft , CONKPOS_KW , 0);
|
||||
ecl_kw_type * depth_kw;
|
||||
if (rft_node->data_type == RFT)
|
||||
depth_kw = ecl_file_iget_named_kw( rft , DEPTH_KW , 0);
|
||||
else
|
||||
depth_kw = ecl_file_iget_named_kw( rft , CONDEPTH_KW , 0);
|
||||
rft_node->well_name = util_alloc_strip_copy( ecl_kw_iget_ptr(welletc , WELLETC_NAME_INDEX));
|
||||
|
||||
|
||||
/* Time information. */
|
||||
{
|
||||
int * time = ecl_kw_get_int_ptr( date_kw );
|
||||
rft_node->recording_date = util_make_date( time[DATE_DAY_INDEX] , time[DATE_MONTH_INDEX] , time[DATE_YEAR_INDEX] );
|
||||
}
|
||||
rft_node->days = ecl_kw_iget_float( ecl_file_iget_named_kw( rft , TIME_KW , 0 ) , 0);
|
||||
if (ecl_file_has_kw( rft , CONLENST_KW))
|
||||
rft_node->MSW = true;
|
||||
else
|
||||
rft_node->MSW = false;
|
||||
|
||||
|
||||
/* Cell information */
|
||||
{
|
||||
const int * i = ecl_kw_get_int_ptr( conipos );
|
||||
const int * j = ecl_kw_get_int_ptr( conjpos );
|
||||
const int * k = ecl_kw_get_int_ptr( conkpos );
|
||||
const float * depth = ecl_kw_get_float_ptr( depth_kw );
|
||||
|
||||
ecl_rft_node_init_cells( rft_node , rft );
|
||||
|
||||
/* The ECLIPSE file has offset-1 coordinates, and that is
|
||||
currently what we store; What a fxxxing mess. */
|
||||
int c;
|
||||
for (c = 0; c < rft_node->size; c++) {
|
||||
rft_node->cells[c].i = i[c];
|
||||
rft_node->cells[c].j = j[c];
|
||||
rft_node->cells[c].k = k[c];
|
||||
rft_node->cells[c].depth = depth[c];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* Now we are done with the information which is common to both RFT and PLT. */
|
||||
if (rft_node->data_type == RFT) {
|
||||
const float * SW = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , SWAT_KW , 0));
|
||||
const float * SG = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , SGAS_KW , 0));
|
||||
const float * P = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , PRESSURE_KW , 0));
|
||||
int c;
|
||||
for (c = 0; c < rft_node->size; c++) {
|
||||
rft_node->rft_data[c].swat = SW[c];
|
||||
rft_node->rft_data[c].sgas = SG[c];
|
||||
rft_node->cells[c].pressure = P[c];
|
||||
}
|
||||
} else if (rft_node->data_type == PLT) {
|
||||
/* For PLT there is quite a lot of extra information which is not yet internalized. */
|
||||
const float * WR = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , CONWRAT_KW , 0));
|
||||
const float * GR = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , CONGRAT_KW , 0));
|
||||
const float * OR = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , CONORAT_KW , 0));
|
||||
const float * P = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , CONPRES_KW , 0));
|
||||
int c;
|
||||
for ( c = 0; c < rft_node->size; c++) {
|
||||
rft_node->plt_data[c].orat = OR[c];
|
||||
rft_node->plt_data[c].grat = GR[c];
|
||||
rft_node->plt_data[c].wrat = WR[c];
|
||||
rft_node->cells[c].pressure = P[c];
|
||||
}
|
||||
} else {
|
||||
/* Segmnet code - not implemented. */
|
||||
}
|
||||
|
||||
/*
|
||||
Checking if the well is monotone in the z-direction; if it is we can
|
||||
reasonably safely try some blocking.
|
||||
*/
|
||||
{
|
||||
int i;
|
||||
double first_delta = rft_node->cells[1].depth - rft_node->cells[0].depth;
|
||||
rft_node->__vertical_well = true;
|
||||
for (i = 1; i < (rft_node->size - 1); i++) {
|
||||
double delta = rft_node->cells[i+1].depth - rft_node->cells[i].depth;
|
||||
if (fabs(delta) > 0) {
|
||||
if (first_delta * delta < 0)
|
||||
rft_node->__vertical_well = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return rft_node;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char * ecl_rft_node_get_well_name(const ecl_rft_node_type * rft_node) {
|
||||
return rft_node->well_name;
|
||||
}
|
||||
|
||||
|
||||
void ecl_rft_node_free(ecl_rft_node_type * rft_node) {
|
||||
|
||||
free(rft_node->well_name);
|
||||
vector_free( rft_node->cells );
|
||||
if (rft_node->sort_perm)
|
||||
int_vector_free( rft_node->sort_perm );
|
||||
|
||||
free(rft_node->cells);
|
||||
util_safe_free(rft_node->segment_data);
|
||||
util_safe_free(rft_node->rft_data);
|
||||
util_safe_free(rft_node->plt_data);
|
||||
free(rft_node);
|
||||
}
|
||||
|
||||
@ -251,10 +295,247 @@ void ecl_rft_node_free__(void * void_node) {
|
||||
|
||||
|
||||
|
||||
void ecl_rft_node_summarize(const ecl_rft_node_type * rft_node , bool print_cells) {
|
||||
int i;
|
||||
printf("--------------------------------------------------------------\n");
|
||||
printf("Well.............: %s \n",rft_node->well_name);
|
||||
printf("Completed cells..: %d \n",rft_node->size);
|
||||
printf("Vertical well....: %d \n",rft_node->__vertical_well);
|
||||
{
|
||||
int day , month , year;
|
||||
util_set_date_values(rft_node->recording_date , &day , &month , &year);
|
||||
printf("Recording date...: %02d/%02d/%4d / %g days after simulation start.\n" , day , month , year , rft_node->days);
|
||||
}
|
||||
printf("-----------------------------------------\n");
|
||||
if (print_cells) {
|
||||
printf(" i j k Depth Pressure\n");
|
||||
printf("-----------------------------------------\n");
|
||||
for (i=0; i < rft_node->size; i++)
|
||||
printf("%2d: %3d %3d %3d | %10.2f %10.2f \n",i,
|
||||
rft_node->cells[i].i ,
|
||||
rft_node->cells[i].j ,
|
||||
rft_node->cells[i].k ,
|
||||
rft_node->cells[i].depth,
|
||||
rft_node->cells[i].pressure);
|
||||
printf("-----------------------------------------\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int ecl_rft_node_get_size(const ecl_rft_node_type * rft_node) { return vector_get_size( rft_node->cells ); }
|
||||
/*
|
||||
For this function to work the ECLIPSE keyword COMPORD must be used.
|
||||
*/
|
||||
void ecl_rft_node_block(const ecl_rft_node_type * rft_node , double epsilon , int size , const double * tvd , int * i, int * j , int *k) {
|
||||
int rft_index , tvd_index;
|
||||
int last_rft_index = 0;
|
||||
bool * blocked = util_calloc(rft_node->size , sizeof * blocked);
|
||||
|
||||
if (!rft_node->__vertical_well) {
|
||||
fprintf(stderr,"**************************************************************************\n");
|
||||
fprintf(stderr,"** WARNING: Trying to block horizontal well: %s from only tvd, this **\n", ecl_rft_node_get_well_name(rft_node));
|
||||
fprintf(stderr,"** is extremely error prone - blocking should be carefully checked. **\n");
|
||||
fprintf(stderr,"**************************************************************************\n");
|
||||
}
|
||||
ecl_rft_node_summarize(rft_node , true);
|
||||
for (tvd_index = 0; tvd_index < size; tvd_index++) {
|
||||
double min_diff = 100000;
|
||||
int min_diff_index = 0;
|
||||
if (rft_node->__vertical_well) {
|
||||
for (rft_index = last_rft_index; rft_index < rft_node->size; rft_index++) {
|
||||
double diff = fabs(tvd[tvd_index] - rft_node->cells[rft_index].depth);
|
||||
if (diff < min_diff) {
|
||||
min_diff = diff;
|
||||
min_diff_index = rft_index;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (rft_index = last_rft_index; rft_index < (rft_node->size - 1); rft_index++) {
|
||||
int next_rft_index = rft_index + 1;
|
||||
if ((rft_node->cells[next_rft_index].depth - tvd[tvd_index]) * (tvd[tvd_index] - rft_node->cells[rft_index].depth) > 0) {
|
||||
/*
|
||||
We have bracketing ... !!
|
||||
*/
|
||||
min_diff_index = rft_index;
|
||||
min_diff = 0;
|
||||
printf("Bracketing: %g | %g | %g \n",rft_node->cells[next_rft_index].depth ,
|
||||
tvd[tvd_index] , rft_node->cells[rft_index].depth);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (min_diff < epsilon) {
|
||||
i[tvd_index] = rft_node->cells[min_diff_index].i;
|
||||
j[tvd_index] = rft_node->cells[min_diff_index].j;
|
||||
k[tvd_index] = rft_node->cells[min_diff_index].k;
|
||||
|
||||
blocked[min_diff_index] = true;
|
||||
last_rft_index = min_diff_index;
|
||||
} else {
|
||||
i[tvd_index] = -1;
|
||||
j[tvd_index] = -1;
|
||||
k[tvd_index] = -1;
|
||||
fprintf(stderr,"%s: Warning: True Vertical Depth:%g (Point:%d/%d) could not be mapped to well_path for well:%s \n",__func__ , tvd[tvd_index] , tvd_index+1 , size , rft_node->well_name);
|
||||
}
|
||||
}
|
||||
free(blocked);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Faen - dette er jeg egentlig *ikke* interessert i ....
|
||||
*/
|
||||
static double * ecl_rft_node_alloc_well_md(const ecl_rft_node_type * rft_node , int fixed_index , double md_offset) {
|
||||
double * md = util_calloc(rft_node->size , sizeof * md );
|
||||
|
||||
|
||||
|
||||
return md;
|
||||
}
|
||||
|
||||
|
||||
void ecl_rft_node_block_static(const ecl_rft_node_type * rft_node , int rft_index_offset , int md_size , int md_index_offset , const double * md , int * i , int * j , int * k) {
|
||||
const double md_offset = md[md_index_offset];
|
||||
double *well_md = ecl_rft_node_alloc_well_md(rft_node , rft_index_offset , md_offset);
|
||||
int index;
|
||||
for (index = 0; index < md_size; index++) {
|
||||
i[index] = -1;
|
||||
j[index] = -1;
|
||||
k[index] = -1;
|
||||
}
|
||||
i[md_index_offset] = rft_node->cells[rft_index_offset].i;
|
||||
j[md_index_offset] = rft_node->cells[rft_index_offset].j;
|
||||
k[md_index_offset] = rft_node->cells[rft_index_offset].k;
|
||||
|
||||
|
||||
free(well_md);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
void ecl_rft_node_block2(const ecl_rft_node_type * rft_node , int tvd_size , const double * md , const double * tvd , int * i, int * j , int *k) {
|
||||
const double epsilon = 1.0;
|
||||
int rft_index ;
|
||||
|
||||
ecl_rft_node_summarize(rft_node , true);
|
||||
{
|
||||
double min_diff = 100000;
|
||||
int min_diff_index = 0;
|
||||
int tvd_index = 0;
|
||||
double local_tvd_peak = 99999999;
|
||||
{
|
||||
int index;
|
||||
for (index = 1; index < (tvd_size - 1); index++)
|
||||
if (tvd[index] < tvd[index+1] && tvd[index] < tvd[index-1])
|
||||
local_tvd_peak = util_double_min(tvd[index] , local_tvd_peak);
|
||||
}
|
||||
|
||||
|
||||
while (min_diff > epsilon) {
|
||||
for (rft_index = 0; rft_index < rft_node->size; rft_index++) {
|
||||
double diff = fabs(tvd[tvd_index] - rft_node->cells[rft_index].depth);
|
||||
if (diff < min_diff) {
|
||||
min_diff = diff;
|
||||
min_diff_index = rft_index;
|
||||
}
|
||||
}
|
||||
if (min_diff > epsilon) {
|
||||
tvd_index++;
|
||||
if (tvd_index == tvd_size) {
|
||||
fprintf(stderr,"%s: could not map tvd:%g to well-path depth - aborting \n",__func__ , tvd[tvd_index]);
|
||||
abort();
|
||||
}
|
||||
|
||||
if (tvd[tvd_index] > local_tvd_peak) {
|
||||
fprintf(stderr,"%s: could not determine offset before well path becomes multivalued - aborting\n",__func__);
|
||||
abort();
|
||||
}
|
||||
}
|
||||
}
|
||||
ecl_rft_node_block_static(rft_node , min_diff_index , tvd_size , tvd_index , md , i , j , k);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void ecl_rft_node_fprintf_rft_obs(const ecl_rft_node_type * rft_node , double epsilon , const char * tvd_file , const char * target_file , double p_std) {
|
||||
FILE * input_stream = util_fopen(tvd_file , "r" );
|
||||
int size = util_count_file_lines(input_stream);
|
||||
double *p = util_calloc(size , sizeof * p );
|
||||
double *tvd = util_calloc(size , sizeof * tvd );
|
||||
double *md = util_calloc(size , sizeof * md );
|
||||
int *i = util_calloc(size , sizeof * i);
|
||||
int *j = util_calloc(size , sizeof * j);
|
||||
int *k = util_calloc(size , sizeof * k);
|
||||
|
||||
{
|
||||
double *arg1 , *arg2;
|
||||
int line;
|
||||
arg1 = p;
|
||||
arg2 = tvd;
|
||||
for (line = 0; line < size; line++)
|
||||
if (fscanf(input_stream , "%lg %lg", &arg1[line] , &arg2[line]) != 2) {
|
||||
fprintf(stderr,"%s: something wrong when reading: %s - aborting \n",__func__ , tvd_file);
|
||||
abort();
|
||||
}
|
||||
}
|
||||
fclose(input_stream);
|
||||
ecl_rft_node_block(rft_node , epsilon , size , tvd , i , j , k);
|
||||
|
||||
{
|
||||
int active_lines = 0;
|
||||
int line;
|
||||
for (line = 0; line < size; line++)
|
||||
if (i[line] != -1)
|
||||
active_lines++;
|
||||
|
||||
if (active_lines > 0) {
|
||||
FILE * output_stream = util_fopen(target_file , "w" );
|
||||
fprintf(output_stream,"%d\n" , active_lines);
|
||||
for (line = 0; line < size; line++)
|
||||
if (i[line] != -1)
|
||||
fprintf(output_stream , "%3d %3d %3d %g %g\n",i[line] , j[line] , k[line] , p[line] , p_std);
|
||||
fclose(output_stream);
|
||||
} else
|
||||
fprintf(stderr,"%s: Warning found no active cells when blocking well:%s to data_file:%s \n",__func__ , rft_node->well_name , tvd_file);
|
||||
}
|
||||
|
||||
free(md);
|
||||
free(p);
|
||||
free(tvd);
|
||||
free(i);
|
||||
free(j);
|
||||
free(k);
|
||||
}
|
||||
|
||||
|
||||
void ecl_rft_node_export_DEPTH(const ecl_rft_node_type * rft_node , const char * path) {
|
||||
FILE * stream;
|
||||
char * full;
|
||||
char * filename = util_alloc_string_copy(ecl_rft_node_get_well_name(rft_node));
|
||||
int i;
|
||||
|
||||
filename = util_strcat_realloc(filename , ".DEPTH");
|
||||
full = util_alloc_filename(path , filename , NULL);
|
||||
|
||||
stream = fopen(full , "w");
|
||||
for (i=0; i < rft_node->size; i++)
|
||||
fprintf(stream , "%d %g \n",i , rft_node->cells[i].depth);
|
||||
fclose(stream);
|
||||
|
||||
/*
|
||||
free(full);
|
||||
free(filename);
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
int ecl_rft_node_get_size(const ecl_rft_node_type * rft_node) { return rft_node->size; }
|
||||
time_t ecl_rft_node_get_date(const ecl_rft_node_type * rft_node) { return rft_node->recording_date; }
|
||||
ecl_rft_enum ecl_rft_node_get_type(const ecl_rft_node_type * rft_node) { return rft_node->data_type; }
|
||||
|
||||
@ -262,87 +543,65 @@ ecl_rft_enum ecl_rft_node_get_type(const ecl_rft_node_type * rft_node) { return
|
||||
/*****************************************************************/
|
||||
/* various functions to access properties at the cell level */
|
||||
|
||||
const ecl_rft_cell_type * ecl_rft_node_iget_cell( const ecl_rft_node_type * rft_node , int index) {
|
||||
return vector_iget_const( rft_node->cells , index );
|
||||
}
|
||||
|
||||
|
||||
static void ecl_rft_node_create_sort_perm( ecl_rft_node_type * rft_node ) {
|
||||
if (rft_node->sort_perm)
|
||||
int_vector_free( rft_node->sort_perm );
|
||||
|
||||
rft_node->sort_perm = vector_alloc_sort_perm( rft_node->cells , ecl_rft_cell_cmp__ );
|
||||
rft_node->sort_perm_in_sync = true;
|
||||
}
|
||||
|
||||
void ecl_rft_node_inplace_sort_cells( ecl_rft_node_type * rft_node ) {
|
||||
vector_sort( rft_node->cells , ecl_rft_cell_cmp__ );
|
||||
rft_node->sort_perm_in_sync = false; // The permutation is no longer sorted; however the vector itself is sorted ....
|
||||
}
|
||||
|
||||
const ecl_rft_cell_type * ecl_rft_node_iget_cell_sorted( ecl_rft_node_type * rft_node , int index) {
|
||||
if (ecl_rft_node_is_RFT( rft_node ))
|
||||
return ecl_rft_node_iget_cell( rft_node , index );
|
||||
static cell_type * ecl_rft_node_iget_cell( const ecl_rft_node_type * rft_node , int index) {
|
||||
if (index < rft_node->size)
|
||||
return &rft_node->cells[index];
|
||||
else {
|
||||
if (!rft_node->sort_perm_in_sync)
|
||||
ecl_rft_node_create_sort_perm( rft_node );
|
||||
|
||||
return vector_iget_const( rft_node->cells , int_vector_iget( rft_node->sort_perm , index ));
|
||||
util_abort("%s: asked for cell:%d max:%d \n",__func__ , index , rft_node->size - 1);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
double ecl_rft_node_iget_depth( const ecl_rft_node_type * rft_node , int index) {
|
||||
const ecl_rft_cell_type * cell = ecl_rft_node_iget_cell( rft_node , index );
|
||||
return ecl_rft_cell_get_depth( cell );
|
||||
const cell_type * cell = ecl_rft_node_iget_cell( rft_node , index );
|
||||
return cell->depth;
|
||||
}
|
||||
|
||||
|
||||
|
||||
double ecl_rft_node_iget_pressure( const ecl_rft_node_type * rft_node , int index) {
|
||||
const ecl_rft_cell_type * cell = ecl_rft_node_iget_cell( rft_node , index );
|
||||
return ecl_rft_cell_get_pressure( cell );
|
||||
const cell_type * cell = ecl_rft_node_iget_cell( rft_node , index );
|
||||
return cell->pressure;
|
||||
}
|
||||
|
||||
|
||||
void ecl_rft_node_iget_ijk( const ecl_rft_node_type * rft_node , int index , int *i , int *j , int *k) {
|
||||
const ecl_rft_cell_type * cell = ecl_rft_node_iget_cell( rft_node , index );
|
||||
|
||||
ecl_rft_cell_get_ijk( cell , i,j,k);
|
||||
const cell_type * cell = ecl_rft_node_iget_cell( rft_node , index );
|
||||
*i = cell->i;
|
||||
*j = cell->j;
|
||||
*k = cell->k;
|
||||
}
|
||||
|
||||
|
||||
const ecl_rft_cell_type * ecl_rft_node_lookup_ijk( const ecl_rft_node_type * rft_node , int i, int j , int k) {
|
||||
int ecl_rft_node_lookup_ijk( const ecl_rft_node_type * rft_node , int i, int j , int k) {
|
||||
int index = 0;
|
||||
int size = ecl_rft_node_get_size( rft_node );
|
||||
while (true) {
|
||||
const ecl_rft_cell_type * cell = ecl_rft_node_iget_cell( rft_node , index );
|
||||
|
||||
if (ecl_rft_cell_ijk_equal( cell , i , j , k ))
|
||||
return cell;
|
||||
const cell_type * cell = ecl_rft_node_iget_cell( rft_node , index );
|
||||
if ((cell->i == (i+1)) && (cell->j == (j+1)) && (cell->k == (k+1))) /* OK - found it. */
|
||||
return index;
|
||||
|
||||
index++;
|
||||
if (index == size) /* Could not find it. */
|
||||
return NULL;
|
||||
if (index == rft_node->size) /* Could not find it. */
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void assert_type_and_index( const ecl_rft_node_type * rft_node , ecl_rft_enum target_type , int index) {
|
||||
if (rft_node->data_type != target_type)
|
||||
util_abort("%s: wrong type \n",__func__);
|
||||
|
||||
if ((index < 0) || (index >= vector_get_size( rft_node->cells )))
|
||||
if ((index < 0) || (index >= rft_node->size))
|
||||
util_abort("%s: invalid index:%d \n",__func__ , index);
|
||||
}
|
||||
|
||||
double ecl_rft_node_iget_sgas( const ecl_rft_node_type * rft_node , int index) {
|
||||
assert_type_and_index( rft_node , RFT , index );
|
||||
{
|
||||
const ecl_rft_cell_type * cell = vector_iget_const( rft_node->cells , index );
|
||||
return ecl_rft_cell_get_sgas( cell );
|
||||
const rft_data_type rft_data = rft_node->rft_data[ index ];
|
||||
return rft_data.sgas;
|
||||
}
|
||||
}
|
||||
|
||||
@ -350,28 +609,17 @@ double ecl_rft_node_iget_sgas( const ecl_rft_node_type * rft_node , int index) {
|
||||
double ecl_rft_node_iget_swat( const ecl_rft_node_type * rft_node , int index) {
|
||||
assert_type_and_index( rft_node , RFT , index );
|
||||
{
|
||||
const ecl_rft_cell_type * cell = vector_iget_const( rft_node->cells , index );
|
||||
return ecl_rft_cell_get_swat( cell );
|
||||
const rft_data_type rft_data = rft_node->rft_data[ index ];
|
||||
return rft_data.swat;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
double ecl_rft_node_iget_soil( const ecl_rft_node_type * rft_node , int index) {
|
||||
assert_type_and_index( rft_node , RFT , index );
|
||||
{
|
||||
const ecl_rft_cell_type * cell = vector_iget_const( rft_node->cells , index );
|
||||
return ecl_rft_cell_get_soil( cell );
|
||||
}
|
||||
}
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
|
||||
double ecl_rft_node_iget_orat( const ecl_rft_node_type * rft_node , int index) {
|
||||
assert_type_and_index( rft_node , PLT , index );
|
||||
{
|
||||
const ecl_rft_cell_type * cell = vector_iget_const( rft_node->cells , index );
|
||||
return ecl_rft_cell_get_orat( cell );
|
||||
const plt_data_type plt_data = rft_node->plt_data[ index ];
|
||||
return plt_data.orat;
|
||||
}
|
||||
}
|
||||
|
||||
@ -379,8 +627,8 @@ double ecl_rft_node_iget_orat( const ecl_rft_node_type * rft_node , int index) {
|
||||
double ecl_rft_node_iget_wrat( const ecl_rft_node_type * rft_node , int index) {
|
||||
assert_type_and_index( rft_node , PLT , index );
|
||||
{
|
||||
const ecl_rft_cell_type * cell = vector_iget_const( rft_node->cells , index);
|
||||
return ecl_rft_cell_get_wrat( cell );
|
||||
const plt_data_type plt_data = rft_node->plt_data[ index ];
|
||||
return plt_data.wrat;
|
||||
}
|
||||
}
|
||||
|
||||
@ -388,36 +636,8 @@ double ecl_rft_node_iget_wrat( const ecl_rft_node_type * rft_node , int index) {
|
||||
double ecl_rft_node_iget_grat( const ecl_rft_node_type * rft_node , int index) {
|
||||
assert_type_and_index( rft_node , PLT , index );
|
||||
{
|
||||
const ecl_rft_cell_type * cell = vector_iget_const( rft_node->cells , index);
|
||||
return ecl_rft_cell_get_grat( cell );
|
||||
const plt_data_type plt_data = rft_node->plt_data[ index ];
|
||||
return plt_data.grat;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool ecl_rft_node_is_MSW( const ecl_rft_node_type * rft_node ) {
|
||||
return rft_node->MSW;
|
||||
}
|
||||
|
||||
|
||||
bool ecl_rft_node_is_PLT( const ecl_rft_node_type * rft_node ) {
|
||||
if (rft_node->data_type == PLT)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ecl_rft_node_is_SEGMENT( const ecl_rft_node_type * rft_node ) {
|
||||
if (rft_node->data_type == SEGMENT)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ecl_rft_node_is_RFT( const ecl_rft_node_type * rft_node ) {
|
||||
if (rft_node->data_type == RFT)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
@ -71,7 +71,6 @@ ecl_rsthead_type * ecl_rsthead_ialloc( const ecl_file_type * rst_file , int occu
|
||||
rsthead->nisegz = data[INTEHEAD_NISEGZ_INDEX];
|
||||
rsthead->nsegmx = data[INTEHEAD_NSEGMX_INDEX];
|
||||
rsthead->nswlmx = data[INTEHEAD_NSWLMX_INDEX];
|
||||
rsthead->nrsegz = data[INTEHEAD_NRSEGZ_INDEX];
|
||||
|
||||
// The only derived quantity
|
||||
rsthead->sim_time = rsthead_date( rsthead->day , rsthead->month , rsthead->year );
|
||||
|
32
ThirdParty/Ert/devel/libecl/src/ecl_sum.c
vendored
32
ThirdParty/Ert/devel/libecl/src/ecl_sum.c
vendored
@ -333,7 +333,6 @@ void ecl_sum_free( ecl_sum_type * ecl_sum ) {
|
||||
|
||||
util_safe_free( ecl_sum->path );
|
||||
util_safe_free( ecl_sum->ext );
|
||||
util_safe_free( ecl_sum->abs_path );
|
||||
|
||||
free( ecl_sum->base );
|
||||
free( ecl_sum->ecl_case );
|
||||
@ -883,6 +882,8 @@ void ecl_sum_fmt_init_summary_x( ecl_sum_fmt_type * fmt ) {
|
||||
#define DATE_STRING_LENGTH 128
|
||||
|
||||
static void __ecl_sum_fprintf_line( const ecl_sum_type * ecl_sum , FILE * stream , int internal_index , const bool_vector_type * has_var , const int_vector_type * var_index , char * date_string , const ecl_sum_fmt_type * fmt) {
|
||||
int ivar , day,month,year;
|
||||
util_set_date_values(ecl_sum_iget_sim_time(ecl_sum , internal_index ) , &day , &month, &year);
|
||||
fprintf(stream , fmt->days_fmt , ecl_sum_iget_sim_days(ecl_sum , internal_index));
|
||||
fprintf(stream , fmt->sep );
|
||||
|
||||
@ -894,15 +895,12 @@ static void __ecl_sum_fprintf_line( const ecl_sum_type * ecl_sum , FILE * stream
|
||||
fprintf(stream , date_string );
|
||||
}
|
||||
|
||||
{
|
||||
int ivar;
|
||||
for (ivar = 0; ivar < int_vector_size( var_index ); ivar++) {
|
||||
if (bool_vector_iget( has_var , ivar )) {
|
||||
fprintf(stream , fmt->sep);
|
||||
fprintf(stream , fmt->value_fmt , ecl_sum_iget(ecl_sum , internal_index, int_vector_iget( var_index , ivar )));
|
||||
}
|
||||
for (ivar = 0; ivar < int_vector_size( var_index ); ivar++) {
|
||||
if (bool_vector_iget( has_var , ivar )) {
|
||||
fprintf(stream , fmt->sep);
|
||||
fprintf(stream , fmt->value_fmt , ecl_sum_iget(ecl_sum , internal_index, int_vector_iget( var_index , ivar )));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stream , fmt->newline);
|
||||
}
|
||||
@ -982,7 +980,6 @@ void ecl_sum_fprintf(const ecl_sum_type * ecl_sum , FILE * stream , const string
|
||||
bool_vector_free( has_var );
|
||||
if (current_locale != NULL)
|
||||
setlocale( LC_NUMERIC , current_locale);
|
||||
free( date_string );
|
||||
}
|
||||
#undef DATE_STRING_LENGTH
|
||||
|
||||
@ -1166,21 +1163,6 @@ char * ecl_sum_alloc_well_key( const ecl_sum_type * ecl_sum , const char * keywo
|
||||
|
||||
|
||||
|
||||
bool ecl_sum_is_oil_producer( const ecl_sum_type * ecl_sum , const char * well) {
|
||||
const char * WOPT_KEY = "WOPT";
|
||||
bool oil_producer = false;
|
||||
|
||||
if (ecl_sum_has_well_var( ecl_sum , well , WOPT_KEY)) {
|
||||
int last_step = ecl_sum_get_data_length( ecl_sum ) - 1;
|
||||
double wopt = ecl_sum_get_well_var( ecl_sum , last_step , well , WOPT_KEY);
|
||||
|
||||
if (wopt > 0)
|
||||
oil_producer = true;
|
||||
}
|
||||
|
||||
return oil_producer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
63
ThirdParty/Ert/devel/libecl/tests/CMakeLists.txt
vendored
63
ThirdParty/Ert/devel/libecl/tests/CMakeLists.txt
vendored
@ -8,20 +8,6 @@ target_link_libraries( ecl_restart_test ecl )
|
||||
add_test( ecl_restart_test ${EXECUTABLE_OUTPUT_PATH}/ecl_restart_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST )
|
||||
|
||||
|
||||
add_executable( ecl_grid_lgr_name ecl_grid_lgr_name.c )
|
||||
target_link_libraries( ecl_grid_lgr_name ecl )
|
||||
set_target_properties( ecl_grid_lgr_name PROPERTIES COMPILE_FLAGS "-Werror")
|
||||
add_test( ecl_grid_lgr_name ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_lgr_name ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/10kcase/TEST10K_FLT_LGR_NNC.EGRID)
|
||||
|
||||
add_executable( ecl_region ecl_region.c )
|
||||
target_link_libraries( ecl_region ecl )
|
||||
add_test( ecl_region ${EXECUTABLE_OUTPUT_PATH}/ecl_region ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID )
|
||||
|
||||
|
||||
add_executable( ecl_grid_case ecl_grid_case.c )
|
||||
target_link_libraries( ecl_grid_case ecl )
|
||||
add_test( ecl_grid_case ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_case ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE )
|
||||
|
||||
|
||||
add_executable( ecl_lgr_test ecl_lgr_test.c )
|
||||
target_link_libraries( ecl_lgr_test ecl )
|
||||
@ -89,35 +75,20 @@ target_link_libraries( ecl_rsthead ecl )
|
||||
add_test( ecl_rsthead ${EXECUTABLE_OUTPUT_PATH}/ecl_rsthead ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST
|
||||
${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/DualPoro/DUALPORO.X0005 )
|
||||
|
||||
add_executable( ecl_rft ecl_rft.c )
|
||||
target_link_libraries( ecl_rft ecl )
|
||||
add_test( ecl_rft_rft ${EXECUTABLE_OUTPUT_PATH}/ecl_rft ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.RFT RFT)
|
||||
add_test( ecl_rft_plt ${EXECUTABLE_OUTPUT_PATH}/ecl_rft ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/RFT/TEST1_1A.RFT PLT)
|
||||
|
||||
add_executable( ecl_rft_cell ecl_rft_cell.c )
|
||||
target_link_libraries( ecl_rft_cell ecl )
|
||||
add_test( ecl_rft_cell ${EXECUTABLE_OUTPUT_PATH}/ecl_rft_cell )
|
||||
|
||||
|
||||
set_property( TEST ecl_fmt PROPERTY LABELS StatoilData )
|
||||
set_property( TEST ecl_coarse_test PROPERTY LABELS StatoilData )
|
||||
set_property( TEST ecl_restart_test PROPERTY LABELS StatoilData )
|
||||
set_property( TEST ecl_lgr_test1 PROPERTY LABELS StatoilData )
|
||||
set_property( TEST ecl_lgr_test2 PROPERTY LABELS StatoilData )
|
||||
set_property( TEST ecl_lgr_test3 PROPERTY LABELS StatoilData )
|
||||
set_property( TEST ecl_grid_lgr_name PROPERTY LABELS StatoilData )
|
||||
set_property( TEST ecl_grid_simple PROPERTY LABELS StatoilData )
|
||||
set_property( TEST ecl_dualp PROPERTY LABELS StatoilData )
|
||||
set_property( TEST ecl_sum_test PROPERTY LABELS StatoilData )
|
||||
set_property( TEST ecl_fortio PROPERTY LABELS StatoilData)
|
||||
set_property( TEST ecl_grid_dims1 PROPERTY LABELS StatoilData )
|
||||
set_property( TEST ecl_grid_dims2 PROPERTY LABELS StatoilData )
|
||||
set_property( TEST ecl_grid_dims3 PROPERTY LABELS StatoilData )
|
||||
set_property( TEST ecl_grid_dims4 PROPERTY LABELS StatoilData )
|
||||
set_property( TEST ecl_grid_dims5 PROPERTY LABELS StatoilData )
|
||||
set_property( TEST ecl_file PROPERTY LABELS StatoilData)
|
||||
set_property( TEST ecl_rsthead PROPERTY LABELS StatoilData)
|
||||
set_property( TEST ecl_region PROPERTY LABELS StatoilData)
|
||||
set_property( TEST ecl_grid_case PROPERTY LABELS StatoilData)
|
||||
set_property( TEST ecl_rft_rft PROPERTY LABELS StatoilData)
|
||||
set_property( TEST ecl_rft_plt PROPERTY LABELS StatoilData)
|
||||
set_property( TEST ecl_fmt PROPERTY LABELS Statoil )
|
||||
set_property( TEST ecl_coarse_test PROPERTY LABELS Statoil )
|
||||
set_property( TEST ecl_restart_test PROPERTY LABELS Statoil )
|
||||
set_property( TEST ecl_lgr_test1 PROPERTY LABELS Statoil )
|
||||
set_property( TEST ecl_lgr_test2 PROPERTY LABELS Statoil )
|
||||
set_property( TEST ecl_lgr_test3 PROPERTY LABELS Statoil )
|
||||
set_property( TEST ecl_grid_simple PROPERTY LABELS Statoil )
|
||||
set_property( TEST ecl_dualp PROPERTY LABELS Statoil )
|
||||
set_property( TEST ecl_sum_test PROPERTY LABELS Statoil )
|
||||
set_property( TEST ecl_fortio PROPERTY LABELS Statoil)
|
||||
set_property( TEST ecl_grid_dims1 PROPERTY LABELS Statoil )
|
||||
set_property( TEST ecl_grid_dims2 PROPERTY LABELS Statoil )
|
||||
set_property( TEST ecl_grid_dims3 PROPERTY LABELS Statoil )
|
||||
set_property( TEST ecl_grid_dims4 PROPERTY LABELS Statoil )
|
||||
set_property( TEST ecl_grid_dims5 PROPERTY LABELS Statoil )
|
||||
set_property( TEST ecl_file PROPERTY LABELS Statoil)
|
||||
set_property( TEST ecl_rsthead PROPERTY LABELS Statoil)
|
||||
|
@ -1,46 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'ecl_grid_case.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
|
||||
#include <ert/ecl/ecl_grid.h>
|
||||
|
||||
|
||||
void test_grid( const char * input , bool expected) {
|
||||
ecl_grid_type * grid = ecl_grid_load_case( input );
|
||||
if (expected) {
|
||||
test_assert_true( ecl_grid_is_instance( grid ));
|
||||
ecl_grid_free( grid );
|
||||
} else
|
||||
test_assert_NULL( grid );
|
||||
}
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
const char * grid_file = argv[1];
|
||||
const char * case_path = argv[2];
|
||||
|
||||
test_grid( grid_file , true );
|
||||
test_grid( case_path , true );
|
||||
test_grid( "/tmp/does/not/exists/file.EGRID" , false );
|
||||
test_grid( "/tmp/does/not/exists/CASE" , false );
|
||||
|
||||
exit(0);
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'ecl_grid_lgr_name.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/util.h>
|
||||
#include <ert/util/test_util.h>
|
||||
|
||||
#include <ert/ecl/ecl_grid.h>
|
||||
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
const char * grid_file = argv[1];
|
||||
ecl_grid_type * ecl_grid = ecl_grid_alloc( grid_file );
|
||||
|
||||
test_assert_int_equal( 1 , ecl_grid_get_num_lgr( ecl_grid ));
|
||||
test_assert_string_equal( "LGR1" , ecl_grid_iget_lgr_name( ecl_grid , 0 ));
|
||||
test_assert_string_equal( NULL , ecl_grid_iget_lgr_name( ecl_grid , 1 ));
|
||||
|
||||
ecl_grid_free( ecl_grid );
|
||||
exit(0);
|
||||
}
|
70
ThirdParty/Ert/devel/libecl/tests/ecl_region.c
vendored
70
ThirdParty/Ert/devel/libecl/tests/ecl_region.c
vendored
@ -1,70 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2012 Statoil ASA, Norway.
|
||||
|
||||
The file 'ecl_region.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
|
||||
#include <ert/ecl/ecl_grid.h>
|
||||
#include <ert/ecl/ecl_region.h>
|
||||
|
||||
void test_list( int volume , int nactive , ecl_region_type * region ) {
|
||||
const int_vector_type * active_list;
|
||||
const int_vector_type * global_list;
|
||||
active_list = ecl_region_get_active_list( region );
|
||||
global_list = ecl_region_get_global_list( region );
|
||||
test_assert_int_equal( nactive , int_vector_size( active_list ));
|
||||
test_assert_int_equal( volume , int_vector_size( global_list ));
|
||||
|
||||
|
||||
ecl_region_deselect_all( region );
|
||||
active_list = ecl_region_get_active_list( region );
|
||||
global_list = ecl_region_get_global_list( region );
|
||||
test_assert_int_equal( 0 , int_vector_size( active_list ));
|
||||
test_assert_int_equal( 0 , int_vector_size( global_list ));
|
||||
}
|
||||
|
||||
|
||||
|
||||
void test_slice( const ecl_grid_type * grid ) {
|
||||
int nx = ecl_grid_get_nx( grid );
|
||||
int ny = ecl_grid_get_ny( grid );
|
||||
int nz = ecl_grid_get_nz( grid );
|
||||
int nactive = ecl_grid_get_nactive( grid );
|
||||
ecl_region_type * region = ecl_region_alloc( grid , false );
|
||||
|
||||
ecl_region_select_i1i2( region , 0 , nx - 1);
|
||||
test_list( nx*ny*nz , nactive , region );
|
||||
ecl_region_select_j1j2( region , 0 , ny - 1);
|
||||
test_list( nx*ny*nz , nactive , region );
|
||||
ecl_region_select_k1k2( region , 0 , nz - 1);
|
||||
test_list( nx*ny*nz , nactive , region );
|
||||
|
||||
ecl_region_free( region );
|
||||
}
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
const char * grid_file = argv[1];
|
||||
ecl_grid_type * grid = ecl_grid_alloc( grid_file );
|
||||
|
||||
test_slice( grid );
|
||||
|
||||
ecl_grid_free( grid );
|
||||
exit(0);
|
||||
}
|
131
ThirdParty/Ert/devel/libecl/tests/ecl_rft.c
vendored
131
ThirdParty/Ert/devel/libecl/tests/ecl_rft.c
vendored
@ -1,131 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'ecl_rft.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/time_t_vector.h>
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/ecl/ecl_rft_file.h>
|
||||
|
||||
|
||||
|
||||
|
||||
// Hardcoded GURBAT values
|
||||
void test_rft( const char * rft_file ) {
|
||||
ecl_rft_file_type * rft = ecl_rft_file_alloc( rft_file );
|
||||
ecl_rft_node_type * rft_node = ecl_rft_file_iget_node( rft , 0 );
|
||||
|
||||
test_assert_true( ecl_rft_node_is_RFT( rft_node ));
|
||||
test_assert_int_equal( 14 , ecl_rft_node_get_size( rft_node ));
|
||||
test_assert_false( ecl_rft_node_is_MSW( rft_node ));
|
||||
|
||||
test_assert_double_equal( 259.146 , ecl_rft_node_iget_pressure( rft_node , 0 ));
|
||||
test_assert_double_equal( 0.0580598 , ecl_rft_node_iget_soil( rft_node , 0 ));
|
||||
test_assert_double_equal( 0.940477 , ecl_rft_node_iget_swat( rft_node , 0 ));
|
||||
test_assert_double_equal( 0.00146271 , ecl_rft_node_iget_sgas( rft_node , 0 ));
|
||||
|
||||
{
|
||||
int i,j,k;
|
||||
|
||||
ecl_rft_node_iget_ijk( rft_node , 0 , &i , &j , &k );
|
||||
test_assert_int_equal( 32 , i );
|
||||
test_assert_int_equal( 53 , j );
|
||||
test_assert_int_equal( 0 , k );
|
||||
|
||||
ecl_rft_node_iget_ijk( rft_node , 13 , &i , &j , &k );
|
||||
test_assert_int_equal( 32 , i );
|
||||
test_assert_int_equal( 54 , j );
|
||||
test_assert_int_equal( 12 , k );
|
||||
|
||||
for (i=0; i < ecl_rft_node_get_size( rft_node ); i++) {
|
||||
const ecl_rft_cell_type * cell1 = ecl_rft_node_iget_cell( rft_node , i );
|
||||
const ecl_rft_cell_type * cell2 = ecl_rft_node_iget_cell_sorted( rft_node , i );
|
||||
|
||||
test_assert_ptr_equal( cell1 , cell2 );
|
||||
}
|
||||
}
|
||||
ecl_rft_node_inplace_sort_cells( rft_node );
|
||||
|
||||
ecl_rft_file_free( rft );
|
||||
}
|
||||
|
||||
|
||||
// Have no such case yet ...
|
||||
void test_plt_msw( const char * plt_file ) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Hardcoded values from a test case with a PLT.
|
||||
void test_plt( const char * plt_file ) {
|
||||
ecl_rft_file_type * plt = ecl_rft_file_alloc( plt_file );
|
||||
ecl_rft_node_type * plt_node = ecl_rft_file_iget_node( plt , 11 );
|
||||
|
||||
test_assert_true( ecl_rft_node_is_PLT( plt_node ));
|
||||
test_assert_false( ecl_rft_node_is_MSW( plt_node ));
|
||||
test_assert_int_equal( 22 , ecl_rft_node_get_size( plt_node ));
|
||||
|
||||
test_assert_double_equal( 244.284 , ecl_rft_node_iget_pressure( plt_node , 0 ));
|
||||
test_assert_double_equal( 167.473 , ecl_rft_node_iget_orat( plt_node , 0 ));
|
||||
test_assert_double_equal( 41682.2 , ecl_rft_node_iget_grat( plt_node , 0 ));
|
||||
test_assert_double_equal( 0.958927 , ecl_rft_node_iget_wrat( plt_node , 0 ));
|
||||
|
||||
{
|
||||
int i,j,k;
|
||||
|
||||
ecl_rft_node_iget_ijk( plt_node , 0 , &i , &j , &k );
|
||||
test_assert_int_equal( 39 , i );
|
||||
test_assert_int_equal( 33 , j );
|
||||
test_assert_int_equal( 16 , k );
|
||||
|
||||
ecl_rft_node_iget_ijk( plt_node , 21 , &i , &j , &k );
|
||||
test_assert_int_equal( 44 , i );
|
||||
test_assert_int_equal( 34 , j );
|
||||
test_assert_int_equal( 7 , k );
|
||||
|
||||
for (i=0; i < ecl_rft_node_get_size( plt_node ); i++) {
|
||||
const ecl_rft_cell_type * cell1 = ecl_rft_node_iget_cell( plt_node , i );
|
||||
const ecl_rft_cell_type * cell2 = ecl_rft_node_iget_cell_sorted( plt_node , i );
|
||||
|
||||
test_assert_ptr_equal( cell1 , cell2 );
|
||||
}
|
||||
ecl_rft_node_inplace_sort_cells( plt_node );
|
||||
}
|
||||
|
||||
ecl_rft_file_free( plt );
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main( int argc , char ** argv) {
|
||||
const char * rft_file = argv[1];
|
||||
const char * mode_string = argv[2];
|
||||
|
||||
if (strcmp( mode_string , "RFT") == 0)
|
||||
test_rft( rft_file );
|
||||
else if (strcmp( mode_string , "PLT") == 0)
|
||||
test_plt( rft_file );
|
||||
else if (strcmp( mode_string , "MSW-PLT") == 0)
|
||||
test_plt_msw( rft_file );
|
||||
else
|
||||
test_error_exit("Second argument:%s not recognized. Valid values are: RFT and PLT" , mode_string);
|
||||
|
||||
exit(0);
|
||||
}
|
147
ThirdParty/Ert/devel/libecl/tests/ecl_rft_cell.c
vendored
147
ThirdParty/Ert/devel/libecl/tests/ecl_rft_cell.c
vendored
@ -1,147 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'ecl_rft_cell.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/time_t_vector.h>
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/ecl/ecl_rft_node.h>
|
||||
#include <ert/ecl/ecl_rft_cell.h>
|
||||
|
||||
|
||||
|
||||
void test_rft_cell() {
|
||||
const int i = 10;
|
||||
const int j = 11;
|
||||
const int k = 12;
|
||||
|
||||
const double depth = 100;
|
||||
const double pressure = 200;
|
||||
const double swat = 0.25;
|
||||
const double sgas = 0.35;
|
||||
|
||||
ecl_rft_cell_type * cell = ecl_rft_cell_alloc_RFT(i,j,k,depth,pressure,swat,sgas);
|
||||
|
||||
test_assert_int_equal( i , ecl_rft_cell_get_i( cell ));
|
||||
test_assert_int_equal( j , ecl_rft_cell_get_j( cell ));
|
||||
test_assert_int_equal( k , ecl_rft_cell_get_k( cell ));
|
||||
|
||||
{
|
||||
int ii,jj,kk;
|
||||
ecl_rft_cell_get_ijk( cell , &ii , &jj , &kk);
|
||||
test_assert_int_equal( i , ii);
|
||||
test_assert_int_equal( j , jj);
|
||||
test_assert_int_equal( k , kk);
|
||||
}
|
||||
|
||||
test_assert_double_equal( depth , ecl_rft_cell_get_depth( cell ));
|
||||
test_assert_double_equal( pressure , ecl_rft_cell_get_pressure( cell ));
|
||||
test_assert_double_equal( swat , ecl_rft_cell_get_swat( cell ));
|
||||
test_assert_double_equal( sgas , ecl_rft_cell_get_sgas( cell ));
|
||||
test_assert_double_equal( 1 - (swat + sgas) , ecl_rft_cell_get_soil( cell ));
|
||||
|
||||
test_assert_double_equal( ECL_RFT_CELL_INVALID_VALUE , ecl_rft_cell_get_orat( cell ));
|
||||
test_assert_double_equal( ECL_RFT_CELL_INVALID_VALUE , ecl_rft_cell_get_grat( cell ));
|
||||
test_assert_double_equal( ECL_RFT_CELL_INVALID_VALUE , ecl_rft_cell_get_wrat( cell ));
|
||||
test_assert_double_equal( ECL_RFT_CELL_INVALID_VALUE , ecl_rft_cell_get_flowrate( cell ));
|
||||
test_assert_double_equal( ECL_RFT_CELL_INVALID_VALUE , ecl_rft_cell_get_connection_start( cell ));
|
||||
test_assert_double_equal( ECL_RFT_CELL_INVALID_VALUE , ecl_rft_cell_get_oil_flowrate( cell ));
|
||||
test_assert_double_equal( ECL_RFT_CELL_INVALID_VALUE , ecl_rft_cell_get_gas_flowrate( cell ));
|
||||
test_assert_double_equal( ECL_RFT_CELL_INVALID_VALUE , ecl_rft_cell_get_water_flowrate( cell ));
|
||||
|
||||
ecl_rft_cell_free( cell );
|
||||
{
|
||||
ecl_rft_cell_type * cell = ecl_rft_cell_alloc_RFT(i,j,k,depth,pressure,swat,sgas);
|
||||
|
||||
test_assert_true( ecl_rft_cell_ijk_equal( cell , i , j , k ));
|
||||
test_assert_false( ecl_rft_cell_ijk_equal( cell , i , j , k + 1 ));
|
||||
|
||||
ecl_rft_cell_free__( cell );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void test_plt_cell() {
|
||||
const int i = 10;
|
||||
const int j = 11;
|
||||
const int k = 12;
|
||||
|
||||
const double depth = 100;
|
||||
const double pressure = 200;
|
||||
const double orat = 0.25;
|
||||
const double grat = 0.35;
|
||||
const double wrat = 0.45;
|
||||
const double flowrate = 100.0;
|
||||
const double connection_start = 891;
|
||||
const double oil_flowrate = 0.891;
|
||||
const double gas_flowrate = 7771;
|
||||
const double water_flowrate = 77614;
|
||||
|
||||
ecl_rft_cell_type * cell = ecl_rft_cell_alloc_PLT(i,j,k,depth,pressure,orat,grat,wrat,connection_start,flowrate,oil_flowrate , gas_flowrate , water_flowrate);
|
||||
|
||||
test_assert_int_equal( i , ecl_rft_cell_get_i( cell ));
|
||||
test_assert_int_equal( j , ecl_rft_cell_get_j( cell ));
|
||||
test_assert_int_equal( k , ecl_rft_cell_get_k( cell ));
|
||||
|
||||
{
|
||||
int ii,jj,kk;
|
||||
ecl_rft_cell_get_ijk( cell , &ii , &jj , &kk);
|
||||
test_assert_int_equal( i , ii);
|
||||
test_assert_int_equal( j , jj);
|
||||
test_assert_int_equal( k , kk);
|
||||
}
|
||||
|
||||
test_assert_double_equal( depth , ecl_rft_cell_get_depth( cell ));
|
||||
test_assert_double_equal( pressure , ecl_rft_cell_get_pressure( cell ));
|
||||
|
||||
test_assert_double_equal( orat , ecl_rft_cell_get_orat( cell ));
|
||||
test_assert_double_equal( grat , ecl_rft_cell_get_grat( cell ));
|
||||
test_assert_double_equal( wrat , ecl_rft_cell_get_wrat( cell ));
|
||||
test_assert_double_equal( connection_start, ecl_rft_cell_get_connection_start( cell ));
|
||||
test_assert_double_equal(flowrate , ecl_rft_cell_get_flowrate( cell ));
|
||||
|
||||
test_assert_double_equal(oil_flowrate , ecl_rft_cell_get_oil_flowrate( cell ));
|
||||
test_assert_double_equal(gas_flowrate , ecl_rft_cell_get_gas_flowrate( cell ));
|
||||
test_assert_double_equal(water_flowrate , ecl_rft_cell_get_water_flowrate( cell ));
|
||||
|
||||
test_assert_double_equal( ECL_RFT_CELL_INVALID_VALUE , ecl_rft_cell_get_swat( cell ));
|
||||
test_assert_double_equal( ECL_RFT_CELL_INVALID_VALUE , ecl_rft_cell_get_sgas( cell ));
|
||||
test_assert_double_equal( ECL_RFT_CELL_INVALID_VALUE , ecl_rft_cell_get_soil( cell ));
|
||||
|
||||
ecl_rft_cell_free( cell );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int main( int argc , char ** argv) {
|
||||
|
||||
test_rft_cell();
|
||||
test_plt_cell();
|
||||
exit(0);
|
||||
}
|
@ -51,12 +51,6 @@ void test_days( const ecl_sum_type * ecl_sum ) {
|
||||
}
|
||||
|
||||
|
||||
void test_is_oil_producer( const ecl_sum_type * ecl_sum) {
|
||||
test_assert_true( ecl_sum_is_oil_producer( ecl_sum , "OP_1"));
|
||||
test_assert_false( ecl_sum_is_oil_producer( ecl_sum , "WI_1"));
|
||||
test_assert_false( ecl_sum_is_oil_producer( ecl_sum , "DoesNotExist"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -67,7 +61,6 @@ int main( int argc , char ** argv) {
|
||||
|
||||
test_time_range( ecl_sum );
|
||||
test_days( ecl_sum );
|
||||
test_is_oil_producer(ecl_sum);
|
||||
|
||||
exit(0);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
add_subdirectory( src )
|
||||
if (BUILD_APPLICATIONS)
|
||||
if (BUILD_APPLICATONS)
|
||||
add_subdirectory( applications )
|
||||
endif()
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
add_executable( well_info_test well_info_test.c )
|
||||
add_executable( segment_info segment_info.c )
|
||||
|
||||
set(program_list well_info_test segment_info )
|
||||
set(program_list well_info_test )
|
||||
foreach(prog ${program_list})
|
||||
target_link_libraries( ${prog} ecl_well ecl)
|
||||
|
||||
|
@ -1,107 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'segment_info.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <unistd.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <ert/util/stringlist.h>
|
||||
#include <ert/util/util.h>
|
||||
#include <ert/util/test_util.h>
|
||||
|
||||
#include <ert/ecl/ecl_util.h>
|
||||
#include <ert/ecl/ecl_file.h>
|
||||
#include <ert/ecl/ecl_rsthead.h>
|
||||
#include <ert/ecl/ecl_kw_magic.h>
|
||||
#include <ert/ecl/ecl_grid.h>
|
||||
|
||||
#include <ert/ecl_well/well_conn_collection.h>
|
||||
#include <ert/ecl_well/well_segment.h>
|
||||
#include <ert/ecl_well/well_const.h>
|
||||
#include <ert/ecl_well/well_segment_collection.h>
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
const char * Xfile = argv[1];
|
||||
ecl_file_type * rst_file = ecl_file_open( Xfile , 0 );
|
||||
ecl_rsthead_type * rst_head = ecl_rsthead_alloc( rst_file );
|
||||
const ecl_kw_type * iwel_kw = ecl_file_iget_named_kw( rst_file , IWEL_KW , 0 );
|
||||
const ecl_kw_type * iseg_kw = ecl_file_iget_named_kw( rst_file , ISEG_KW , 0 );
|
||||
const ecl_kw_type * rseg_kw = ecl_file_iget_named_kw( rst_file , RSEG_KW , 0 );
|
||||
const ecl_kw_type * icon_kw = ecl_file_iget_named_kw( rst_file , ICON_KW , 0 );
|
||||
const ecl_kw_type * zwel_kw = ecl_file_iget_named_kw( rst_file , ZWEL_KW , 0 );
|
||||
|
||||
test_install_SIGNALS();
|
||||
{
|
||||
int well_nr;
|
||||
for (well_nr = 0; well_nr < rst_head->nwells; well_nr++) {
|
||||
const int zwel_offset = rst_head->nzwelz * well_nr;
|
||||
char * well_name = util_alloc_strip_copy(ecl_kw_iget_ptr( zwel_kw , zwel_offset ));
|
||||
|
||||
printf("=================================================================\n");
|
||||
printf("Well: %s ",well_name);
|
||||
{
|
||||
well_conn_collection_type * connections = well_conn_collection_alloc();
|
||||
well_segment_collection_type * segments = well_segment_collection_alloc();
|
||||
|
||||
if (well_segment_collection_load_from_kw( segments , well_nr , iwel_kw , iseg_kw , rseg_kw , rst_head )) {
|
||||
well_branch_collection_type * branches = well_branch_collection_alloc();
|
||||
|
||||
well_conn_collection_load_from_kw( connections , iwel_kw , icon_kw , well_nr , rst_head);
|
||||
well_segment_collection_link( segments );
|
||||
well_segment_collection_add_branches( segments , branches );
|
||||
well_segment_collection_add_connections( segments , ECL_GRID_GLOBAL_GRID , connections );
|
||||
|
||||
printf("\n");
|
||||
printf("Segments:\n");
|
||||
{
|
||||
int is;
|
||||
for (is=0; is < well_segment_collection_get_size( segments ); is++) {
|
||||
well_segment_type * segment = well_segment_collection_iget( segments , is );
|
||||
printf("-----------------------------------------------------------------\n");
|
||||
printf("ID : %d \n",well_segment_get_id( segment ));
|
||||
printf("Outlet : %d \n",well_segment_get_outlet_id( segment ));
|
||||
printf("Branch : %d \n",well_segment_get_branch_id( segment ));
|
||||
printf("Connections : [");
|
||||
{
|
||||
well_conn_collection_type * connections = well_segment_get_global_connections( segment );
|
||||
if (connections) {
|
||||
int ic;
|
||||
for (ic = 0; ic < well_conn_collection_get_size( connections ); ic++) {
|
||||
const well_conn_type * conn = well_conn_collection_iget( connections , ic );
|
||||
printf("(%d , %d , %d) ",well_conn_get_i( conn ), well_conn_get_j( conn ), well_conn_get_k( conn ));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
printf("]\n");
|
||||
}
|
||||
}
|
||||
well_branch_collection_free( branches );
|
||||
} else
|
||||
printf("not MSW well\n\n");
|
||||
|
||||
well_conn_collection_free( connections );
|
||||
well_segment_collection_free( segments );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ecl_file_close( rst_file );
|
||||
ecl_rsthead_free( rst_head );
|
||||
}
|
42
ThirdParty/Ert/devel/libecl_well/include/ert/ecl_well/well_branch.h
vendored
Normal file
42
ThirdParty/Ert/devel/libecl_well/include/ert/ecl_well/well_branch.h
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
Copyright (C) 2012 Statoil ASA, Norway.
|
||||
|
||||
The file 'well_branch.h' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#ifndef __WELL_BRANCH_H__
|
||||
#define __WELL_BRANCH_H__
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <ert/ecl_well/well_conn.h>
|
||||
|
||||
typedef struct well_branch_struct well_branch_type;
|
||||
|
||||
well_branch_type * well_branch_alloc(int branch_nr);
|
||||
void well_branch_free( well_branch_type * branch );
|
||||
void well_branch_add_conn( well_branch_type * branch , well_conn_type * connection );
|
||||
int well_branch_get_length( const well_branch_type * branch );
|
||||
const well_conn_type ** well_branch_get_connections( const well_branch_type * branch );
|
||||
int well_branch_get_nr( const well_branch_type * branch );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
@ -1,50 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'well_branch_collection.h' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __WELL_BRANCH_COLLECTION_H__
|
||||
#define __WELL_BRANCH_COLLECTION_H__
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/type_macros.h>
|
||||
|
||||
#include <ert/ecl_well/well_segment.h>
|
||||
|
||||
typedef struct well_branch_collection_struct well_branch_collection_type;
|
||||
|
||||
well_branch_collection_type * well_branch_collection_alloc();
|
||||
void well_branch_collection_free( well_branch_collection_type * branches );
|
||||
void well_branch_collection_free__( void * arg );
|
||||
bool well_branch_collection_has_branch( const well_branch_collection_type * branches , int branch_id);
|
||||
int well_branch_collection_get_size( const well_branch_collection_type * branches );
|
||||
const well_segment_type * well_branch_collection_iget_start_segment( const well_branch_collection_type * branches , int index );
|
||||
const well_segment_type * well_branch_collection_get_start_segment( const well_branch_collection_type * branches , int branch_id);
|
||||
bool well_branch_collection_add_start_segment( well_branch_collection_type * branches , const well_segment_type * start_segment);
|
||||
|
||||
UTIL_IS_INSTANCE_HEADER( well_branch_collection );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -27,8 +27,6 @@ extern "C" {
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/type_macros.h>
|
||||
|
||||
#include <ert/ecl/ecl_rsthead.h>
|
||||
|
||||
typedef enum {
|
||||
@ -45,17 +43,10 @@ extern "C" {
|
||||
|
||||
void well_conn_free( well_conn_type * conn);
|
||||
void well_conn_free__( void * arg );
|
||||
|
||||
well_conn_type * well_conn_alloc( int i , int j , int k , well_conn_dir_enum dir, bool open);
|
||||
well_conn_type * well_conn_alloc_MSW( int i , int j , int k , well_conn_dir_enum dir, bool open, int segment);
|
||||
well_conn_type * well_conn_alloc_fracture( int i , int j , int k , well_conn_dir_enum dir, bool open);
|
||||
well_conn_type * well_conn_alloc_fracture_MSW( int i , int j , int k , well_conn_dir_enum dir, bool open, int segment);
|
||||
|
||||
bool well_conn_MSW(const well_conn_type * conn);
|
||||
|
||||
well_conn_type * well_conn_alloc_from_kw( const ecl_kw_type * icon_kw , const ecl_rsthead_type * header , int well_nr , int conn_nr);
|
||||
well_conn_type * well_conn_alloc( const ecl_kw_type * icon_kw , const ecl_kw_type * iseg_kw , const ecl_rsthead_type * header , int well_nr , int seg_well_nr , int conn_nr);
|
||||
well_conn_type * well_conn_alloc_wellhead( const ecl_kw_type * iwel_kw , const ecl_rsthead_type * header , int well_nr);
|
||||
|
||||
int well_conn_get_branch(const well_conn_type * conn);
|
||||
int well_conn_get_i(const well_conn_type * conn);
|
||||
int well_conn_get_j(const well_conn_type * conn);
|
||||
int well_conn_get_k(const well_conn_type * conn);
|
||||
@ -64,11 +55,6 @@ extern "C" {
|
||||
int well_conn_get_segment( const well_conn_type * conn );
|
||||
bool well_conn_fracture_connection( const well_conn_type * conn);
|
||||
bool well_conn_matrix_connection( const well_conn_type * conn);
|
||||
bool well_conn_equal( const well_conn_type *conn1 , const well_conn_type * conn2);
|
||||
|
||||
UTIL_IS_INSTANCE_HEADER( well_conn );
|
||||
UTIL_SAFE_CAST_HEADER( well_conn );
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -1,51 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'well_conn_collection.h' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __WELL_CONN_COLLECTION_H__
|
||||
#define __WELL_CONN_COLLECTION_H__
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <ert/util/type_macros.h>
|
||||
|
||||
#include <ert/ecl/ecl_kw.h>
|
||||
|
||||
#include <ert/ecl_well/well_conn.h>
|
||||
|
||||
typedef struct well_conn_collection_struct well_conn_collection_type;
|
||||
|
||||
well_conn_collection_type * well_conn_collection_alloc();
|
||||
void well_conn_collection_free( well_conn_collection_type * wellcc );
|
||||
void well_conn_collection_free__( void * arg );
|
||||
int well_conn_collection_get_size( const well_conn_collection_type * wellcc );
|
||||
const well_conn_type * well_conn_collection_iget_const( const well_conn_collection_type * wellcc , int index);
|
||||
well_conn_type * well_conn_collection_iget(const well_conn_collection_type * wellcc , int index);
|
||||
void well_conn_collection_add( well_conn_collection_type * wellcc , well_conn_type * conn);
|
||||
void well_conn_collection_add_ref( well_conn_collection_type * wellcc , well_conn_type * conn);
|
||||
int well_conn_collection_load_from_kw( well_conn_collection_type * wellcc , const ecl_kw_type * iwel_kw , const ecl_kw_type * icon_kw , int iwell , const ecl_rsthead_type * rst_head);
|
||||
|
||||
UTIL_IS_INSTANCE_HEADER( well_conn_collection );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -39,8 +39,6 @@ extern "C" {
|
||||
#define IWEL_LGR_ITEM 42
|
||||
#define IWEL_SEGMENTED_WELL_NR_ITEM 70
|
||||
|
||||
#define IWEL_SEGMENTED_WELL_NR_NORMAL_VALUE -1
|
||||
|
||||
#define ISEG_OUTLET_ITEM 1
|
||||
#define ISEG_BRANCH_ITEM 3
|
||||
|
||||
@ -61,11 +59,6 @@ extern "C" {
|
||||
#define ICON_DEFAULT_DIR_TARGET ICON_DIRZ
|
||||
|
||||
|
||||
#define RSEG_LENGTH_INDEX 0
|
||||
#define RSEG_DIAMETER_INDEX 2
|
||||
#define RSEG_TOTAL_LENGTH_INDEX 6
|
||||
#define RSEG_DEPTH_INDEX 7
|
||||
|
||||
/*
|
||||
The ECLIPSE documentation says that a certain item in the IWEL array
|
||||
should indicate the type of the well, the available types are the
|
||||
|
48
ThirdParty/Ert/devel/libecl_well/include/ert/ecl_well/well_path.h
vendored
Normal file
48
ThirdParty/Ert/devel/libecl_well/include/ert/ecl_well/well_path.h
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
Copyright (C) 2012 Statoil ASA, Norway.
|
||||
|
||||
The file 'well_path.h' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#ifndef __WELL_PATH_H__
|
||||
#define __WELL_PATH_H__
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/ecl_well/well_conn.h>
|
||||
#include <ert/ecl_well/well_branch.h>
|
||||
|
||||
|
||||
typedef struct well_path_struct well_path_type;
|
||||
|
||||
well_path_type * well_path_alloc(const char * grid_name );
|
||||
void well_path_free( well_path_type * path );
|
||||
void well_path_add_conn( well_path_type * well_path , well_conn_type * conn);
|
||||
well_branch_type * well_path_iget_branch( const well_path_type * well_path , int branch_nr);
|
||||
void well_path_free__(void * arg);
|
||||
int well_path_get_max_branches( const well_path_type * well_path );
|
||||
int well_path_get_num_active_branches( const well_path_type * well_path );
|
||||
const char * well_path_get_grid_name( const well_path_type * well_path );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
@ -1,79 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'well_segment.h' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __WELL_SEGMENT_H__
|
||||
#define __WELL_SEGMENT_H__
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/ecl/ecl_kw.h>
|
||||
#include <ert/ecl/ecl_rsthead.h>
|
||||
|
||||
#include <ert/ecl_well/well_conn_collection.h>
|
||||
#include <ert/ecl_well/well_conn.h>
|
||||
|
||||
/* The values are shifted one down compared to ISEG description in table 6.1 in ECLIPSE file formats reference. */
|
||||
|
||||
#define ECLIPSE_WELL_SEGMENT_OUTLET_END_VALUE -1
|
||||
#define ECLIPSE_WELL_SEGMENT_BRANCH_MAIN_STEM_VALUE 0
|
||||
#define ECLIPSE_WELL_SEGMENT_BRANCH_INACTIVE_VALUE -1
|
||||
|
||||
|
||||
|
||||
typedef struct well_segment_struct well_segment_type;
|
||||
|
||||
well_segment_type * well_segment_alloc_from_kw( const ecl_kw_type * iseg_kw , const ecl_kw_type * rseg_kw , const ecl_rsthead_type * header , int well_nr, int segment_id);
|
||||
well_segment_type * well_segment_alloc(int segment_id , int outlet_segment_id , int branch_id , const double * rseg_data);
|
||||
void well_segment_free(well_segment_type * segment );
|
||||
void well_segment_free__(void * arg);
|
||||
|
||||
bool well_segment_active( const well_segment_type * segment );
|
||||
bool well_segment_main_stem( const well_segment_type * segment );
|
||||
bool well_segment_nearest_wellhead( const well_segment_type * segment );
|
||||
|
||||
int well_segment_get_link_count( const well_segment_type * segment );
|
||||
int well_segment_get_branch_id( const well_segment_type * segment );
|
||||
int well_segment_get_outlet_id( const well_segment_type * segment );
|
||||
int well_segment_get_id( const well_segment_type * segment );
|
||||
well_segment_type * well_segment_get_outlet( const well_segment_type * segment );
|
||||
bool well_segment_link( well_segment_type * segment , well_segment_type * outlet_segment );
|
||||
void well_segment_link_strict( well_segment_type * segment , well_segment_type * outlet_segment );
|
||||
bool well_segment_has_grid_connections( const well_segment_type * segment , const char * grid_name);
|
||||
bool well_segment_has_global_grid_connections( const well_segment_type * segment);
|
||||
bool well_segment_add_connection( well_segment_type * segment , const char * grid_name , well_conn_type * conn);
|
||||
const well_conn_collection_type * well_segment_get_connections(const well_segment_type * segment , const char * grid_name );
|
||||
const well_conn_collection_type * well_segment_get_global_connections(const well_segment_type * segment );
|
||||
bool well_segment_well_is_MSW(int well_nr , const ecl_kw_type * iwel_kw , const ecl_rsthead_type * rst_head);
|
||||
|
||||
double well_segment_get_depth( const well_segment_type * segment );
|
||||
double well_segment_get_length( const well_segment_type * segment );
|
||||
double well_segment_get_total_length( const well_segment_type * segment );
|
||||
double well_segment_get_diameter( const well_segment_type * segment );
|
||||
|
||||
UTIL_IS_INSTANCE_HEADER( well_segment );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'well_segment_collection.h' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef __WELL_SEGMENT_COLLECTION_H__
|
||||
#define __WELL_SEGMENT_COLLECTION_H__
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/ecl/ecl_kw.h>
|
||||
|
||||
#include <ert/ecl_well/well_segment.h>
|
||||
#include <ert/ecl_well/well_conn_collection.h>
|
||||
#include <ert/ecl_well/well_branch_collection.h>
|
||||
|
||||
typedef struct well_segment_collection_struct well_segment_collection_type;
|
||||
|
||||
well_segment_collection_type * well_segment_collection_alloc();
|
||||
void well_segment_collection_free(well_segment_collection_type * segment_collection );
|
||||
int well_segment_collection_get_size( const well_segment_collection_type * segment_collection );
|
||||
void well_segment_collection_add( well_segment_collection_type * segment_collection , well_segment_type * segment);
|
||||
bool well_segment_collection_has_segment( const well_segment_collection_type * segment_collection , int segment_id);
|
||||
well_segment_type * well_segment_collection_get( const well_segment_collection_type * segment_collection , int segment_id);
|
||||
well_segment_type * well_segment_collection_iget( const well_segment_collection_type * segment_collection , int index);
|
||||
int well_segment_collection_load_from_kw( well_segment_collection_type * segment_collection , int well_nr ,
|
||||
const ecl_kw_type * iwel_kw ,
|
||||
const ecl_kw_type * iseg_kw ,
|
||||
const ecl_kw_type * rseg_kw ,
|
||||
const ecl_rsthead_type * rst_head);
|
||||
void well_segment_collection_link(const well_segment_collection_type * segment_collection);
|
||||
void well_segment_collection_add_connections(well_segment_collection_type * segment_collection ,
|
||||
const char * grid_name ,
|
||||
const well_conn_collection_type * connections);
|
||||
void well_segment_collection_add_branches( const well_segment_collection_type * segment_collection ,
|
||||
well_branch_collection_type * branches );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
@ -27,37 +27,16 @@ extern "C" {
|
||||
#include <time.h>
|
||||
|
||||
#include <ert/ecl/ecl_file.h>
|
||||
#include <ert/ecl/ecl_grid.h>
|
||||
|
||||
#include <ert/ecl_well/well_conn.h>
|
||||
#include <ert/ecl_well/well_const.h>
|
||||
#include <ert/ecl_well/well_conn_collection.h>
|
||||
#include <ert/ecl_well/well_segment_collection.h>
|
||||
#include <ert/ecl_well/well_branch_collection.h>
|
||||
|
||||
|
||||
#define GLOBAL_GRID_NAME "GLOBAL" // The name assigned to the global grid for name based lookup.
|
||||
|
||||
typedef struct well_state_struct well_state_type;
|
||||
|
||||
well_state_type * well_state_alloc(const char * well_name , int global_well_nr , bool open, well_type_enum type , int report_nr, time_t valid_from);
|
||||
well_state_type * well_state_alloc_from_file( ecl_file_type * ecl_file , const ecl_grid_type * grid , int report_step , int well_nr);
|
||||
|
||||
void well_state_add_connections( well_state_type * well_state ,
|
||||
const ecl_grid_type * grid ,
|
||||
ecl_file_type * rst_file ,
|
||||
int well_nr);
|
||||
|
||||
bool well_state_add_MSW( well_state_type * well_state ,
|
||||
const ecl_file_type * rst_file ,
|
||||
int well_nr);
|
||||
|
||||
bool well_state_is_MSW( const well_state_type * well_state);
|
||||
|
||||
well_segment_collection_type * well_state_get_segments( const well_state_type * well_state );
|
||||
well_branch_collection_type * well_state_get_branches( const well_state_type * well_state );
|
||||
|
||||
|
||||
well_state_type * well_state_alloc( ecl_file_type * ecl_file , int report_step , int well_nr);
|
||||
void well_state_free( well_state_type * well );
|
||||
const char * well_state_get_name( const well_state_type * well );
|
||||
int well_state_get_report_nr( const well_state_type * well_state );
|
||||
@ -65,18 +44,24 @@ extern "C" {
|
||||
well_conn_type * well_state_iget_connection( const well_state_type * well_state , int index);
|
||||
well_type_enum well_state_get_type( const well_state_type * well_state);
|
||||
bool well_state_is_open( const well_state_type * well_state );
|
||||
int well_state_get_well_nr( const well_state_type * well_state );
|
||||
|
||||
|
||||
const well_conn_type * well_state_iget_wellhead( const well_state_type * well_state , int grid_nr);
|
||||
const well_conn_type * well_state_get_wellhead( const well_state_type * well_state , const char * grid_name);
|
||||
|
||||
void well_state_summarize( const well_state_type * well_state , FILE * stream );
|
||||
well_type_enum well_state_translate_ecl_type_int(int int_type);
|
||||
|
||||
const well_conn_type ** well_state_iget_lgr_connections(const well_state_type * well_state , int grid_nr , int branch_nr );
|
||||
const well_conn_type ** well_state_get_lgr_connections(const well_state_type * well_state , const char * lgr_name , int branch_nr);
|
||||
const well_conn_type ** well_state_get_connections(const well_state_type * well_state , int branch_nr );
|
||||
|
||||
const well_conn_collection_type * well_state_get_grid_connections( const well_state_type * well_state , const char * grid_name);
|
||||
const well_conn_collection_type * well_state_get_global_connections( const well_state_type * well_state );
|
||||
bool well_state_has_grid_connections( const well_state_type * well_state , const char * grid_name);
|
||||
bool well_state_has_global_connections( const well_state_type * well_state );
|
||||
int well_state_iget_num_lgr_connections(const well_state_type * well_state , int grid_nr , int branch_nr );
|
||||
int well_state_get_num_lgr_connections(const well_state_type * well_state , const char * lgr_name , int branch_nr);
|
||||
int well_state_get_num_connections(const well_state_type * well_state , int branch_nr );
|
||||
|
||||
int well_state_iget_lgr_num_branches( const well_state_type * well_state , int grid_nr);
|
||||
int well_state_get_lgr_num_branches( const well_state_type * well_state , const char * lgr_name);
|
||||
int well_state_get_num_branches(const well_state_type * well_state );
|
||||
|
||||
void well_state_summarize( const well_state_type * well_state , FILE * stream );
|
||||
|
||||
UTIL_IS_INSTANCE_HEADER( well_state );
|
||||
|
||||
|
@ -1,10 +1,5 @@
|
||||
set( source_files well_state.c well_conn.c well_info.c well_ts.c well_conn_collection.c well_segment.c well_segment_collection.c well_branch_collection.c)
|
||||
set( header_files well_state.h well_const.h well_conn.h well_info.h well_ts.h well_conn_collection.h well_segment.h well_segment_collection.h well_branch_collection.h)
|
||||
|
||||
if (NOT ERT_WINDOWS)
|
||||
set_property( SOURCE well_branch_collection.c well_segment.c well_segment_collection.c well_conn_collection.c well_conn.c PROPERTY COMPILE_FLAGS "-Werror")
|
||||
endif()
|
||||
|
||||
set( source_files well_state.c well_conn.c well_info.c well_ts.c well_branch.c well_path.c )
|
||||
set( header_files well_state.h well_const.h well_conn.h well_info.h well_ts.h well_branch.h well_path.h )
|
||||
|
||||
include_directories( ${CMAKE_CURRENT_SOURCE_DIR} )
|
||||
include_directories( ${libgeometry_src_path} )
|
||||
|
103
ThirdParty/Ert/devel/libecl_well/src/well_branch.c
vendored
Normal file
103
ThirdParty/Ert/devel/libecl_well/src/well_branch.c
vendored
Normal file
@ -0,0 +1,103 @@
|
||||
/*
|
||||
Copyright (C) 2012 Statoil ASA, Norway.
|
||||
|
||||
The file 'well_branch.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/ecl_well/well_branch.h>
|
||||
#include <ert/ecl_well/well_const.h>
|
||||
#include <ert/ecl_well/well_conn.h>
|
||||
|
||||
/*
|
||||
|
||||
See also documentation on the top of well_path.c for how a path and
|
||||
a branch are related.
|
||||
*/
|
||||
|
||||
struct well_branch_struct {
|
||||
int branch_nr;
|
||||
well_conn_type ** connections;
|
||||
int size;
|
||||
int alloc_size;
|
||||
};
|
||||
|
||||
|
||||
static void well_branch_resize( well_branch_type * branch , int new_size) {
|
||||
if (new_size < branch->alloc_size)
|
||||
util_abort("%s: sorry - can only grow \n",__func__);
|
||||
|
||||
branch->connections = util_realloc( branch->connections , new_size * sizeof * branch->connections );
|
||||
{
|
||||
int i;
|
||||
for (i=branch->alloc_size; i < new_size; i++)
|
||||
branch->connections[i] = NULL;
|
||||
}
|
||||
branch->alloc_size = new_size;
|
||||
}
|
||||
|
||||
|
||||
well_branch_type * well_branch_alloc(int branch_nr) {
|
||||
well_branch_type * branch = util_malloc( sizeof * branch );
|
||||
branch->branch_nr = branch_nr;
|
||||
branch->connections = NULL;
|
||||
branch->alloc_size = 0;
|
||||
branch->size = 0;
|
||||
|
||||
well_branch_resize( branch , 10 );
|
||||
return branch;
|
||||
}
|
||||
|
||||
|
||||
void well_branch_free( well_branch_type * branch ) {
|
||||
int i;
|
||||
for ( i=0; i < branch->alloc_size; i++) {
|
||||
well_conn_type * conn = branch->connections[i];
|
||||
if (conn != NULL)
|
||||
well_conn_free( conn );
|
||||
}
|
||||
free( branch->connections );
|
||||
free( branch );
|
||||
}
|
||||
|
||||
|
||||
int well_branch_get_length( const well_branch_type * branch) {
|
||||
return branch->size;
|
||||
}
|
||||
|
||||
|
||||
const well_conn_type ** well_branch_get_connections( const well_branch_type * branch ) {
|
||||
if (branch->size == 0)
|
||||
return NULL;
|
||||
else
|
||||
return (const well_conn_type **) branch->connections;
|
||||
}
|
||||
|
||||
|
||||
void well_branch_add_conn( well_branch_type * branch, well_conn_type * connection ) {
|
||||
if (branch->size == branch->alloc_size)
|
||||
well_branch_resize(branch , 2*( 1 + branch->alloc_size ));
|
||||
branch->connections[ branch->size ] = connection;
|
||||
branch->size++;
|
||||
}
|
||||
|
||||
|
||||
int well_branch_get_nr( const well_branch_type * branch ) {
|
||||
return branch->branch_nr;
|
||||
}
|
||||
|
@ -1,117 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'well_branch_collection.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/util.h>
|
||||
#include <ert/util/type_macros.h>
|
||||
#include <ert/util/vector.h>
|
||||
#include <ert/util/int_vector.h>
|
||||
|
||||
#include <ert/ecl_well/well_const.h>
|
||||
#include <ert/ecl_well/well_conn.h>
|
||||
#include <ert/ecl_well/well_branch_collection.h>
|
||||
|
||||
|
||||
#define WELL_BRANCH_COLLECTION_TYPE_ID 67177087
|
||||
|
||||
struct well_branch_collection_struct {
|
||||
UTIL_TYPE_ID_DECLARATION;
|
||||
|
||||
vector_type * __start_segments;
|
||||
int_vector_type * index_map;
|
||||
};
|
||||
|
||||
|
||||
UTIL_IS_INSTANCE_FUNCTION( well_branch_collection , WELL_BRANCH_COLLECTION_TYPE_ID )
|
||||
static UTIL_SAFE_CAST_FUNCTION( well_branch_collection , WELL_BRANCH_COLLECTION_TYPE_ID )
|
||||
|
||||
|
||||
well_branch_collection_type * well_branch_collection_alloc() {
|
||||
well_branch_collection_type * branch_collection = util_malloc( sizeof * branch_collection );
|
||||
UTIL_TYPE_ID_INIT( branch_collection , WELL_BRANCH_COLLECTION_TYPE_ID );
|
||||
branch_collection->__start_segments = vector_alloc_new();
|
||||
branch_collection->index_map = int_vector_alloc(0 , -1 );
|
||||
return branch_collection;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void well_branch_collection_free( well_branch_collection_type * branches ) {
|
||||
vector_free( branches->__start_segments );
|
||||
int_vector_free( branches->index_map );
|
||||
free( branches );
|
||||
}
|
||||
|
||||
|
||||
|
||||
void well_branch_collection_free__( void * arg ) {
|
||||
well_branch_collection_type * branches = well_branch_collection_safe_cast( arg );
|
||||
well_branch_collection_free( branches );
|
||||
}
|
||||
|
||||
|
||||
int well_branch_collection_get_size( const well_branch_collection_type * branches ) {
|
||||
return vector_get_size( branches->__start_segments );
|
||||
}
|
||||
|
||||
|
||||
bool well_branch_collection_has_branch( const well_branch_collection_type * branches , int branch_id) {
|
||||
if (int_vector_safe_iget( branches->index_map , branch_id) >= 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const well_segment_type * well_branch_collection_iget_start_segment( const well_branch_collection_type * branches , int index ) {
|
||||
if (index < vector_get_size( branches->__start_segments))
|
||||
return vector_iget_const( branches->__start_segments , index);
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const well_segment_type * well_branch_collection_get_start_segment( const well_branch_collection_type * branches , int branch_id) {
|
||||
int internal_index = int_vector_safe_iget( branches->index_map , branch_id);
|
||||
if (internal_index >= 0)
|
||||
return well_branch_collection_iget_start_segment( branches , internal_index );
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
bool well_branch_collection_add_start_segment( well_branch_collection_type * branches , const well_segment_type * start_segment) {
|
||||
if ((well_segment_get_link_count( start_segment ) == 0) && (well_segment_get_outlet(start_segment))) {
|
||||
int branch_id = well_segment_get_branch_id( start_segment );
|
||||
int current_index = int_vector_safe_iget( branches->index_map , branch_id);
|
||||
if (current_index >= 0)
|
||||
vector_iset_ref( branches->__start_segments , current_index , start_segment);
|
||||
else {
|
||||
int new_index = vector_get_size( branches->__start_segments );
|
||||
vector_append_ref( branches->__start_segments , start_segment);
|
||||
int_vector_iset( branches->index_map , branch_id , new_index);
|
||||
}
|
||||
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
238
ThirdParty/Ert/devel/libecl_well/src/well_conn.c
vendored
238
ThirdParty/Ert/devel/libecl_well/src/well_conn.c
vendored
@ -17,10 +17,8 @@
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <ert/util/util.h>
|
||||
#include <ert/util/type_macros.h>
|
||||
|
||||
#include <ert/ecl/ecl_kw.h>
|
||||
#include <ert/ecl/ecl_rsthead.h>
|
||||
@ -28,151 +26,110 @@
|
||||
#include <ert/ecl_well/well_const.h>
|
||||
#include <ert/ecl_well/well_conn.h>
|
||||
|
||||
|
||||
#define WELL_CONN_NORMAL_WELL_SEGMENT_ID -999
|
||||
#define ECLIPSE_NORMAL_WELL_SEGMENT_ID -1
|
||||
|
||||
/*
|
||||
Observe that when the (ijk) values are initialized they are
|
||||
shifted to zero offset values, to be aligned with the rest of the
|
||||
ert libraries.
|
||||
*/
|
||||
|
||||
#define WELL_CONN_TYPE_ID 702052013
|
||||
|
||||
struct well_conn_struct {
|
||||
UTIL_TYPE_ID_DECLARATION;
|
||||
int i;
|
||||
int j;
|
||||
int k;
|
||||
well_conn_dir_enum dir;
|
||||
bool open;
|
||||
int segment; // -1: Ordinary well
|
||||
bool matrix_connection; // k >= nz => fracture (and k -= nz )
|
||||
int i;
|
||||
int j;
|
||||
int k;
|
||||
well_conn_dir_enum dir;
|
||||
bool open;
|
||||
int segment; // -1: Ordinary well
|
||||
bool matrix_connection; // k >= nz => fracture (and k -= nz )
|
||||
/*-----------------------------------------------------------------*/
|
||||
/* If the segment field == -1 - i.e. an ordinary well, the
|
||||
outlet_segment is rubbish and should not be consulted.
|
||||
*/
|
||||
int branch;
|
||||
int outlet_segment; // -1: This segment flows to the wellhead.
|
||||
};
|
||||
|
||||
|
||||
static void well_conn_set_k( well_conn_type * conn , const ecl_rsthead_type * header , int icon_k) {
|
||||
conn->k = icon_k;
|
||||
conn->matrix_connection = true;
|
||||
|
||||
bool well_conn_equal( const well_conn_type *conn1 , const well_conn_type * conn2) {
|
||||
if (memcmp(conn1 , conn2 , sizeof * conn1) == 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool well_conn_MSW( const well_conn_type * conn ) {
|
||||
if (conn->segment == WELL_CONN_NORMAL_WELL_SEGMENT_ID)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool well_conn_assert_direction( well_conn_dir_enum dir, bool matrix_connection) {
|
||||
if ((dir == well_conn_fracX || dir == well_conn_fracY) && matrix_connection)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
UTIL_IS_INSTANCE_FUNCTION( well_conn , WELL_CONN_TYPE_ID)
|
||||
UTIL_SAFE_CAST_FUNCTION( well_conn , WELL_CONN_TYPE_ID)
|
||||
|
||||
|
||||
static well_conn_type * well_conn_alloc__( int i , int j , int k , well_conn_dir_enum dir , bool open, int segment_id, bool matrix_connection) {
|
||||
if (well_conn_assert_direction( dir , matrix_connection)) {
|
||||
well_conn_type * conn = util_malloc( sizeof * conn );
|
||||
UTIL_TYPE_ID_INIT( conn , WELL_CONN_TYPE_ID );
|
||||
conn->i = i;
|
||||
conn->j = j;
|
||||
conn->k = k;
|
||||
conn->open = open;
|
||||
conn->dir = dir;
|
||||
|
||||
conn->matrix_connection = matrix_connection;
|
||||
if (segment_id == ECLIPSE_NORMAL_WELL_SEGMENT_ID)
|
||||
conn->segment = WELL_CONN_NORMAL_WELL_SEGMENT_ID;
|
||||
else
|
||||
conn->segment = segment_id;
|
||||
|
||||
return conn;
|
||||
} else {
|
||||
printf("assert-direction failed. dir:%d matrix_connection:%d \n",dir , matrix_connection);
|
||||
return NULL;
|
||||
if (header->dualp) {
|
||||
int geometric_nz = header->nz / 2;
|
||||
if (icon_k >= geometric_nz) {
|
||||
conn->k -= geometric_nz;
|
||||
conn->matrix_connection = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
well_conn_type * well_conn_alloc( int i , int j , int k , well_conn_dir_enum dir , bool open) {
|
||||
return well_conn_alloc__(i , j , k , dir , open , WELL_CONN_NORMAL_WELL_SEGMENT_ID , true );
|
||||
|
||||
|
||||
well_conn_type * well_conn_alloc_wellhead( const ecl_kw_type * iwel_kw , const ecl_rsthead_type * header , int well_nr) {
|
||||
const int iwel_offset = header->niwelz * well_nr;
|
||||
int conn_i = ecl_kw_iget_int( iwel_kw , iwel_offset + IWEL_HEADI_ITEM );
|
||||
|
||||
if (conn_i > 0) {
|
||||
well_conn_type * conn = util_malloc( sizeof * conn );
|
||||
|
||||
conn->i = ecl_kw_iget_int( iwel_kw , iwel_offset + IWEL_HEADI_ITEM ) - 1;
|
||||
conn->j = ecl_kw_iget_int( iwel_kw , iwel_offset + IWEL_HEADJ_ITEM ) - 1;
|
||||
{
|
||||
int icon_k = ecl_kw_iget_int( iwel_kw , iwel_offset + IWEL_HEADK_ITEM ) - 1;
|
||||
well_conn_set_k( conn , header , icon_k);
|
||||
}
|
||||
|
||||
conn->open = true; // This is not really specified anywhere.
|
||||
conn->branch = 0;
|
||||
conn->segment = 0;
|
||||
conn->outlet_segment = 0;
|
||||
return conn;
|
||||
} else
|
||||
// The well is completed in this LGR - however the wellhead is in another LGR.
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static well_conn_type * well_conn_alloc__( const ecl_kw_type * icon_kw , const ecl_rsthead_type * header , int icon_offset) {
|
||||
well_conn_type * conn = util_malloc( sizeof * conn );
|
||||
|
||||
conn->i = ecl_kw_iget_int( icon_kw , icon_offset + ICON_I_ITEM ) - 1;
|
||||
conn->j = ecl_kw_iget_int( icon_kw , icon_offset + ICON_J_ITEM ) - 1;
|
||||
{
|
||||
int icon_k = ecl_kw_iget_int( icon_kw , icon_offset + ICON_K_ITEM ) - 1;
|
||||
well_conn_set_k( conn , header , icon_k);
|
||||
}
|
||||
|
||||
well_conn_type * well_conn_alloc_MSW( int i , int j , int k , well_conn_dir_enum dir , bool open, int segment) {
|
||||
return well_conn_alloc__(i , j , k , dir , open , segment , true );
|
||||
conn->segment = ecl_kw_iget_int( icon_kw , icon_offset + ICON_SEGMENT_ITEM ) - 1;
|
||||
|
||||
conn->outlet_segment = -999;
|
||||
conn->branch = -999;
|
||||
return conn;
|
||||
}
|
||||
|
||||
|
||||
|
||||
well_conn_type * well_conn_alloc_fracture( int i , int j , int k , well_conn_dir_enum dir , bool open) {
|
||||
return well_conn_alloc__(i , j , k , dir , open , WELL_CONN_NORMAL_WELL_SEGMENT_ID , false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
well_conn_type * well_conn_alloc_fracture_MSW( int i , int j , int k , well_conn_dir_enum dir , bool open, int segment) {
|
||||
return well_conn_alloc__(i , j , k , dir , open , segment , false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Observe that the (ijk) and branch values are shifted to zero offset to be
|
||||
aligned with the rest of the ert libraries.
|
||||
*/
|
||||
well_conn_type * well_conn_alloc_from_kw( const ecl_kw_type * icon_kw ,
|
||||
const ecl_rsthead_type * header ,
|
||||
int well_nr ,
|
||||
int conn_nr ) {
|
||||
well_conn_type * well_conn_alloc( const ecl_kw_type * icon_kw ,
|
||||
const ecl_kw_type * iseg_kw ,
|
||||
const ecl_rsthead_type * header ,
|
||||
int well_nr ,
|
||||
int seg_well_nr ,
|
||||
int conn_nr ) {
|
||||
|
||||
const int icon_offset = header->niconz * ( header->ncwmax * well_nr + conn_nr );
|
||||
int IC = ecl_kw_iget_int( icon_kw , icon_offset + ICON_IC_ITEM );
|
||||
if (IC > 0) {
|
||||
well_conn_type * conn;
|
||||
int i = ecl_kw_iget_int( icon_kw , icon_offset + ICON_I_ITEM ) - 1;
|
||||
int j = ecl_kw_iget_int( icon_kw , icon_offset + ICON_J_ITEM ) - 1;
|
||||
int k = ecl_kw_iget_int( icon_kw , icon_offset + ICON_K_ITEM ) - 1;
|
||||
int segment = ecl_kw_iget_int( icon_kw , icon_offset + ICON_SEGMENT_ITEM ) - 1;
|
||||
bool matrix_connection = true;
|
||||
bool open;
|
||||
well_conn_dir_enum dir = well_conn_fracX;
|
||||
|
||||
/* Set the status */
|
||||
well_conn_type * conn = well_conn_alloc__( icon_kw , header , icon_offset );
|
||||
{
|
||||
int int_status = ecl_kw_iget_int( icon_kw , icon_offset + ICON_STATUS_ITEM );
|
||||
if (int_status > 0)
|
||||
open = true;
|
||||
conn->open = true;
|
||||
else
|
||||
open = false;
|
||||
conn->open = false;
|
||||
}
|
||||
|
||||
|
||||
/* Set the K value and fracture flag. */
|
||||
{
|
||||
if (header->dualp) {
|
||||
int geometric_nz = header->nz / 2;
|
||||
if (k >= geometric_nz) {
|
||||
k -= geometric_nz;
|
||||
matrix_connection = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Set the direction flag */
|
||||
{
|
||||
int int_direction = ecl_kw_iget_int( icon_kw , icon_offset + ICON_DIRECTION_ITEM );
|
||||
if (int_direction == ICON_DEFAULT_DIR_VALUE)
|
||||
@ -180,27 +137,25 @@ well_conn_type * well_conn_alloc_from_kw( const ecl_kw_type * icon_kw ,
|
||||
|
||||
switch (int_direction) {
|
||||
case(ICON_DIRX):
|
||||
dir = well_conn_dirX;
|
||||
conn->dir = well_conn_dirX;
|
||||
break;
|
||||
case(ICON_DIRY):
|
||||
dir = well_conn_dirY;
|
||||
conn->dir = well_conn_dirY;
|
||||
break;
|
||||
case(ICON_DIRZ):
|
||||
dir = well_conn_dirZ;
|
||||
conn->dir = well_conn_dirZ;
|
||||
break;
|
||||
case(ICON_FRACX):
|
||||
dir = well_conn_fracX;
|
||||
conn->dir = well_conn_fracX;
|
||||
break;
|
||||
case(ICON_FRACY):
|
||||
dir = well_conn_fracY;
|
||||
conn->dir = well_conn_fracY;
|
||||
break;
|
||||
default:
|
||||
util_abort("%s: icon direction value:%d not recognized\n",__func__ , int_direction);
|
||||
}
|
||||
}
|
||||
|
||||
conn = well_conn_alloc__(i,j,k,dir,open,segment,matrix_connection);
|
||||
|
||||
|
||||
/**
|
||||
For multisegmented wells ONLY the global part of the restart
|
||||
file has segment information, i.e. the ?SEG
|
||||
@ -208,9 +163,8 @@ well_conn_type * well_conn_alloc_from_kw( const ecl_kw_type * icon_kw ,
|
||||
MSW + LGR well.
|
||||
*/
|
||||
|
||||
/*
|
||||
if (iseg_kw != NULL) {
|
||||
if (conn->segment != WELL_CONN_NORMAL_WELL_SEGMENT_ID) {
|
||||
if (conn->segment >= 0) {
|
||||
const int iseg_offset = header->nisegz * ( header->nsegmx * seg_well_nr + conn->segment );
|
||||
conn->outlet_segment = ecl_kw_iget_int( iseg_kw , iseg_offset + ISEG_OUTLET_ITEM );
|
||||
conn->branch = ecl_kw_iget_int( iseg_kw , iseg_offset + ISEG_BRANCH_ITEM );
|
||||
@ -222,8 +176,7 @@ well_conn_type * well_conn_alloc_from_kw( const ecl_kw_type * icon_kw ,
|
||||
conn->branch = 0;
|
||||
conn->outlet_segment = 0;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
return conn;
|
||||
} else
|
||||
return NULL; /* IC < 0: Connection not in current LGR. */
|
||||
@ -236,42 +189,11 @@ void well_conn_free( well_conn_type * conn) {
|
||||
|
||||
|
||||
void well_conn_free__( void * arg ) {
|
||||
well_conn_type * conn = well_conn_safe_cast( arg );
|
||||
well_conn_type * conn = (well_conn_type *) arg;
|
||||
well_conn_free( conn );
|
||||
}
|
||||
|
||||
|
||||
well_conn_type * well_conn_alloc_wellhead( const ecl_kw_type * iwel_kw , const ecl_rsthead_type * header , int well_nr) {
|
||||
const int iwel_offset = header->niwelz * well_nr;
|
||||
int conn_i = ecl_kw_iget_int( iwel_kw , iwel_offset + IWEL_HEADI_ITEM ) - 1;
|
||||
|
||||
if (conn_i >= 0) {
|
||||
//well_conn_type * conn = util_malloc( sizeof * conn );
|
||||
int conn_j = ecl_kw_iget_int( iwel_kw , iwel_offset + IWEL_HEADJ_ITEM ) - 1;
|
||||
int conn_k = ecl_kw_iget_int( iwel_kw , iwel_offset + IWEL_HEADK_ITEM ) - 1;
|
||||
bool matrix_connection = true;
|
||||
bool open = true;
|
||||
|
||||
if (header->dualp) {
|
||||
int geometric_nz = header->nz / 2;
|
||||
if (conn_k >= geometric_nz) {
|
||||
conn_k -= geometric_nz;
|
||||
matrix_connection = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (matrix_connection)
|
||||
return well_conn_alloc( conn_i , conn_j , conn_k , open , well_conn_dirZ );
|
||||
else
|
||||
return well_conn_alloc_fracture( conn_i , conn_j , conn_k , open , well_conn_dirZ );
|
||||
} else
|
||||
// The well is completed in this LGR - however the wellhead is in another LGR.
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
@ -288,6 +210,9 @@ int well_conn_get_k(const well_conn_type * conn) {
|
||||
}
|
||||
|
||||
|
||||
int well_conn_get_branch(const well_conn_type * conn) {
|
||||
return conn->branch;
|
||||
}
|
||||
|
||||
well_conn_dir_enum well_conn_get_dir(const well_conn_type * conn) {
|
||||
return conn->dir;
|
||||
@ -297,7 +222,6 @@ bool well_conn_open( const well_conn_type * conn ) {
|
||||
return conn->open;
|
||||
}
|
||||
|
||||
|
||||
int well_conn_get_segment( const well_conn_type * conn ) {
|
||||
return conn->segment;
|
||||
}
|
||||
|
@ -1,115 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'well_conn_collection.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/util.h>
|
||||
#include <ert/util/type_macros.h>
|
||||
#include <ert/util/vector.h>
|
||||
|
||||
#include <ert/ecl/ecl_kw.h>
|
||||
#include <ert/ecl/ecl_rsthead.h>
|
||||
|
||||
#include <ert/ecl_well/well_const.h>
|
||||
#include <ert/ecl_well/well_conn.h>
|
||||
#include <ert/ecl_well/well_conn_collection.h>
|
||||
|
||||
|
||||
#define WELL_CONN_COLLECTION_TYPE_ID 67150087
|
||||
|
||||
struct well_conn_collection_struct {
|
||||
UTIL_TYPE_ID_DECLARATION;
|
||||
vector_type * connection_list;
|
||||
};
|
||||
|
||||
|
||||
UTIL_IS_INSTANCE_FUNCTION( well_conn_collection , WELL_CONN_COLLECTION_TYPE_ID )
|
||||
static UTIL_SAFE_CAST_FUNCTION( well_conn_collection , WELL_CONN_COLLECTION_TYPE_ID )
|
||||
|
||||
|
||||
well_conn_collection_type * well_conn_collection_alloc() {
|
||||
well_conn_collection_type * wellcc = util_malloc( sizeof * wellcc );
|
||||
UTIL_TYPE_ID_INIT( wellcc , WELL_CONN_COLLECTION_TYPE_ID );
|
||||
wellcc->connection_list = vector_alloc_new();
|
||||
return wellcc;
|
||||
}
|
||||
|
||||
/*
|
||||
The collection takes ownership of the connection object and frees it
|
||||
when the collection is discarded.
|
||||
*/
|
||||
|
||||
void well_conn_collection_add( well_conn_collection_type * wellcc , well_conn_type * conn) {
|
||||
vector_append_owned_ref( wellcc->connection_list , conn , well_conn_free__);
|
||||
}
|
||||
|
||||
/*
|
||||
The collection only stores a refernce to the object, which will be destroyed by 'someone else'.
|
||||
*/
|
||||
|
||||
void well_conn_collection_add_ref( well_conn_collection_type * wellcc , well_conn_type * conn) {
|
||||
vector_append_ref( wellcc->connection_list , conn );
|
||||
}
|
||||
|
||||
|
||||
void well_conn_collection_free( well_conn_collection_type * wellcc ) {
|
||||
vector_free( wellcc->connection_list );
|
||||
free( wellcc );
|
||||
}
|
||||
|
||||
void well_conn_collection_free__( void * arg ) {
|
||||
well_conn_collection_type * wellcc = well_conn_collection_safe_cast( arg );
|
||||
well_conn_collection_free( wellcc );
|
||||
}
|
||||
|
||||
|
||||
int well_conn_collection_get_size( const well_conn_collection_type * wellcc ) {
|
||||
return vector_get_size( wellcc->connection_list );
|
||||
}
|
||||
|
||||
|
||||
const well_conn_type * well_conn_collection_iget_const(const well_conn_collection_type * wellcc , int index) {
|
||||
int size = well_conn_collection_get_size( wellcc );
|
||||
if (index < size)
|
||||
return vector_iget_const( wellcc->connection_list , index );
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
well_conn_type * well_conn_collection_iget(const well_conn_collection_type * wellcc , int index) {
|
||||
int size = well_conn_collection_get_size( wellcc );
|
||||
if (index < size)
|
||||
return vector_iget( wellcc->connection_list , index );
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
int well_conn_collection_load_from_kw( well_conn_collection_type * wellcc , const ecl_kw_type * iwel_kw , const ecl_kw_type * icon_kw , int iwell , const ecl_rsthead_type * rst_head) {
|
||||
const int iwel_offset = rst_head->niwelz * iwell;
|
||||
int num_connections = ecl_kw_iget_int( iwel_kw , iwel_offset + IWEL_CONNECTIONS_ITEM );
|
||||
int iconn;
|
||||
|
||||
for (iconn = 0; iconn < num_connections; iconn++) {
|
||||
well_conn_type * conn = well_conn_alloc_from_kw( icon_kw , rst_head , iwell , iconn );
|
||||
if (conn)
|
||||
well_conn_collection_add( wellcc , conn );
|
||||
}
|
||||
return num_connections;
|
||||
}
|
||||
|
29
ThirdParty/Ert/devel/libecl_well/src/well_info.c
vendored
29
ThirdParty/Ert/devel/libecl_well/src/well_info.c
vendored
@ -52,9 +52,22 @@
|
||||
contains a time series for one well.
|
||||
|
||||
well_state_type: The well_state_type datatype contains the
|
||||
state/properties of one well at one particular instant of
|
||||
time. The well_state.c file contains further documentation of
|
||||
the concepts connections, branches and segments.
|
||||
state/properties of one well at one particular instant of time.
|
||||
|
||||
well_path_type: The well_path_type datatype hold information about
|
||||
the path of the well, i.e. which cells it goes through. The
|
||||
well_path_type instance is for one grid only; and if the well
|
||||
goes through LGRs the well_state instance contains one
|
||||
well_path instance for the global grid and additional well_path
|
||||
instances for each LGR.
|
||||
|
||||
well_branch_type: The wells can be split into several
|
||||
branches. The well_branch_type datatype contain a collection of
|
||||
well connections which form a 1-dimensional segment.
|
||||
|
||||
well_conn_type: This is the connection of a well to one cell. This
|
||||
datatype is exported, i.e. calling scope can inspect
|
||||
(read-only!) the members of a well_conn_type instance.
|
||||
|
||||
|
||||
WELL1
|
||||
@ -266,18 +279,18 @@ static void well_info_add_state( well_info_type * well_info , well_state_type *
|
||||
by calling this function repeatedly.
|
||||
|
||||
This function will go through all the wells by number and call the
|
||||
well_state_alloc_from_file() function to create a well state object for each
|
||||
well. The well_state_alloc_from_file() function will iterate through all the
|
||||
well_state_alloc() function to create a well state object for each
|
||||
well. The well_state_alloc() function will iterate through all the
|
||||
grids and assign well properties corresponding to each of the
|
||||
grids, the global grid special-cased to determine is consulted to
|
||||
determine the number of wells.
|
||||
*/
|
||||
|
||||
void well_info_add_wells( well_info_type * well_info , ecl_file_type * rst_file , int report_nr) {
|
||||
int well_nr;
|
||||
ecl_rsthead_type * global_header = ecl_rsthead_alloc( rst_file );
|
||||
int well_nr;
|
||||
for (well_nr = 0; well_nr < global_header->nwells; well_nr++) {
|
||||
well_state_type * well_state = well_state_alloc_from_file( rst_file , well_info->grid , report_nr , well_nr );
|
||||
well_state_type * well_state = well_state_alloc( rst_file , report_nr , well_nr );
|
||||
if (well_state != NULL)
|
||||
well_info_add_state( well_info , well_state );
|
||||
}
|
||||
@ -327,7 +340,7 @@ void well_info_load_rstfile( well_info_type * well_info , const char * filename)
|
||||
well_info_add_wells( well_info , ecl_file , report_nr );
|
||||
else
|
||||
well_info_add_UNRST_wells( well_info , ecl_file );
|
||||
|
||||
|
||||
ecl_file_close( ecl_file );
|
||||
} else
|
||||
util_abort("%s: invalid file type:%s - must be a restart file\n",__func__ , filename);
|
||||
|
185
ThirdParty/Ert/devel/libecl_well/src/well_path.c
vendored
Normal file
185
ThirdParty/Ert/devel/libecl_well/src/well_path.c
vendored
Normal file
@ -0,0 +1,185 @@
|
||||
/*
|
||||
Copyright (C) 2012 Statoil ASA, Norway.
|
||||
|
||||
The file 'well_path.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/ecl_well/well_path.h>
|
||||
#include <ert/ecl_well/well_branch.h>
|
||||
#include <ert/ecl_well/well_const.h>
|
||||
#include <ert/ecl_well/well_conn.h>
|
||||
|
||||
/*
|
||||
This file implements the well_path structure which is container for
|
||||
the grid connections for one grid realisation; i.e. if the well is
|
||||
perforated in LGRs in addition to the global grid the parent
|
||||
well_state structure will have several well_path instances - one for
|
||||
the global grid and one for each LGR.
|
||||
|
||||
The well_path structure consist of one or several well_branch_type
|
||||
instances; the well_branch is a collection of cells which are
|
||||
connected on a 1D line.
|
||||
|
||||
--------------D
|
||||
/
|
||||
/
|
||||
A---------------B----------C
|
||||
|
||||
|
||||
All of this figure is one well; how this structure is connected to
|
||||
one particular grid is described by the well_path structure in this
|
||||
file. The current well consist of two branches: A-B-C and B-D; these
|
||||
are two well_branch instance in the well_path structure.
|
||||
*/
|
||||
|
||||
|
||||
#define WELL_PATH_TYPE_ID 91916433
|
||||
|
||||
struct well_path_struct {
|
||||
UTIL_TYPE_ID_DECLARATION;
|
||||
char * grid_name; // Will be NULL for 'null_path' construction in the well_state object.
|
||||
well_branch_type ** branches;
|
||||
int max_branches; // This might be misleading due to NULL pointers 'inside' the branches array.
|
||||
int alloc_size;
|
||||
};
|
||||
|
||||
|
||||
|
||||
static void well_path_resize( well_path_type * well_path , int new_size) {
|
||||
well_path->branches = util_realloc( well_path->branches , new_size * sizeof * well_path->branches );
|
||||
{
|
||||
int i;
|
||||
for (i=well_path->alloc_size; i < new_size; i++)
|
||||
well_path->branches[i] = NULL;
|
||||
}
|
||||
|
||||
well_path->alloc_size = new_size;
|
||||
}
|
||||
|
||||
static UTIL_SAFE_CAST_FUNCTION( well_path , WELL_PATH_TYPE_ID )
|
||||
|
||||
well_path_type * well_path_alloc(const char * grid_name) {
|
||||
well_path_type * well_path = util_malloc( sizeof * well_path );
|
||||
UTIL_TYPE_ID_INIT( well_path , WELL_PATH_TYPE_ID );
|
||||
well_path->grid_name = util_alloc_string_copy( grid_name );
|
||||
well_path->branches = NULL;
|
||||
well_path->max_branches = 0;
|
||||
well_path->alloc_size = 0;
|
||||
well_path_resize( well_path , 4 );
|
||||
return well_path;
|
||||
}
|
||||
|
||||
|
||||
|
||||
well_branch_type * well_path_add_branch( well_path_type * well_path , int branch_nr) {
|
||||
|
||||
well_branch_type * new_branch = well_branch_alloc( branch_nr );
|
||||
if (branch_nr >= well_path->alloc_size)
|
||||
well_path_resize( well_path , 2 * branch_nr );
|
||||
|
||||
well_path->branches[ branch_nr ] = new_branch;
|
||||
if (branch_nr >= well_path->max_branches)
|
||||
well_path->max_branches = branch_nr + 1;
|
||||
|
||||
return new_branch;
|
||||
}
|
||||
|
||||
|
||||
bool well_path_has_branch( const well_path_type * well_path , int branch_nr ) {
|
||||
if (branch_nr >= 0 && branch_nr < well_path->max_branches) {
|
||||
well_branch_type * branch = well_path->branches[ branch_nr ];
|
||||
if (branch != NULL)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
This will return the maximum branch number; there can be holes in
|
||||
the branches array:
|
||||
|
||||
branches = [ branch0, NULL , branch1 , NULL , branch3]
|
||||
|
||||
In this case the the well_path_get_max_branches() will return five;
|
||||
however there are only three active branches in this case. The
|
||||
alternative function well_path_get_num_active_branches() will count
|
||||
the number of active (i.e. != NULL) branches.
|
||||
*/
|
||||
int well_path_get_max_branches( const well_path_type * well_path ) {
|
||||
return well_path->max_branches;
|
||||
}
|
||||
|
||||
|
||||
int well_path_get_num_active_branches( const well_path_type * well_path) {
|
||||
int branch_nr;
|
||||
int num_active = 0;
|
||||
for (branch_nr = 0; branch_nr < well_path->max_branches; branch_nr++)
|
||||
if (well_path->branches[ branch_nr ] != NULL)
|
||||
num_active++;
|
||||
return num_active;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
Will return NULL if the branch does not exist.
|
||||
*/
|
||||
|
||||
well_branch_type * well_path_iget_branch( const well_path_type * well_path , int branch_nr) {
|
||||
if (well_path_has_branch( well_path , branch_nr ))
|
||||
return well_path->branches[ branch_nr ];
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
void well_path_add_conn( well_path_type * well_path , well_conn_type * conn) {
|
||||
int branch_nr = well_conn_get_branch( conn );
|
||||
if (!well_path_has_branch( well_path , branch_nr))
|
||||
well_path_add_branch( well_path , branch_nr );
|
||||
{
|
||||
well_branch_type * branch = well_path_iget_branch( well_path , branch_nr );
|
||||
well_branch_add_conn( branch , conn );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void well_path_free( well_path_type * well_path ) {
|
||||
int i;
|
||||
for (i=0; i < well_path->alloc_size; i++) {
|
||||
if (well_path->branches[i] != NULL)
|
||||
well_branch_free( well_path->branches[i] );
|
||||
}
|
||||
util_safe_free( well_path->grid_name );
|
||||
free( well_path->branches );
|
||||
free( well_path );
|
||||
}
|
||||
|
||||
void well_path_free__(void * arg) {
|
||||
well_path_type * well_path = well_path_safe_cast( arg );
|
||||
well_path_free( well_path );
|
||||
}
|
||||
|
||||
|
||||
|
||||
const char * well_path_get_grid_name( const well_path_type * well_path ) {
|
||||
return well_path->grid_name;
|
||||
}
|
249
ThirdParty/Ert/devel/libecl_well/src/well_segment.c
vendored
249
ThirdParty/Ert/devel/libecl_well/src/well_segment.c
vendored
@ -1,249 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'well_segment.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/util.h>
|
||||
#include <ert/util/hash.h>
|
||||
|
||||
#include <ert/ecl/ecl_kw.h>
|
||||
#include <ert/ecl/ecl_rsthead.h>
|
||||
#include <ert/ecl/ecl_grid.h>
|
||||
|
||||
#include <ert/ecl_well/well_const.h>
|
||||
#include <ert/ecl_well/well_conn.h>
|
||||
#include <ert/ecl_well/well_segment.h>
|
||||
#include <ert/ecl_well/well_conn_collection.h>
|
||||
|
||||
#define WELL_SEGMENT_TYPE_ID 2209166
|
||||
|
||||
struct well_segment_struct {
|
||||
UTIL_TYPE_ID_DECLARATION;
|
||||
int link_count;
|
||||
int segment_id;
|
||||
int branch_id;
|
||||
int outlet_segment_id; // This is in the global index space given by the ISEG keyword.
|
||||
well_segment_type * outlet_segment;
|
||||
hash_type * connections; // hash_type<grid_name , well_conn_collection>;
|
||||
|
||||
double depth; // The depth of the segment node; furthest away from the wellhead.
|
||||
double length;
|
||||
double total_length; // Total length from wellhead.
|
||||
double diameter; // The tube diametere available for flow.
|
||||
};
|
||||
|
||||
|
||||
UTIL_IS_INSTANCE_FUNCTION( well_segment , WELL_SEGMENT_TYPE_ID )
|
||||
static UTIL_SAFE_CAST_FUNCTION( well_segment , WELL_SEGMENT_TYPE_ID )
|
||||
|
||||
|
||||
well_segment_type * well_segment_alloc(int segment_id , int outlet_segment_id , int branch_id , const double * rseg_data) {
|
||||
well_segment_type * segment = util_malloc( sizeof * segment );
|
||||
UTIL_TYPE_ID_INIT( segment , WELL_SEGMENT_TYPE_ID );
|
||||
|
||||
segment->link_count = 0;
|
||||
segment->segment_id = segment_id;
|
||||
segment->outlet_segment_id = outlet_segment_id;
|
||||
segment->branch_id = branch_id;
|
||||
segment->outlet_segment = NULL;
|
||||
segment->connections = hash_alloc();
|
||||
|
||||
segment->depth = rseg_data[ RSEG_DEPTH_INDEX ];
|
||||
segment->length = rseg_data[ RSEG_LENGTH_INDEX ];
|
||||
segment->total_length = rseg_data[ RSEG_TOTAL_LENGTH_INDEX ];
|
||||
segment->diameter = rseg_data[ RSEG_DIAMETER_INDEX ];
|
||||
|
||||
return segment;
|
||||
}
|
||||
|
||||
|
||||
well_segment_type * well_segment_alloc_from_kw( const ecl_kw_type * iseg_kw , const ecl_kw_type * rseg_kw , const ecl_rsthead_type * header , int well_nr, int segment_id) {
|
||||
if (rseg_kw == NULL) {
|
||||
util_abort("%s: fatal internal error - tried to create well_segment instance without RSEG keyword.\n",__func__);
|
||||
return NULL;
|
||||
} else {
|
||||
const int iseg_offset = header->nisegz * ( header->nsegmx * well_nr + segment_id);
|
||||
const int rseg_offset = header->nrsegz * ( header->nsegmx * well_nr + segment_id);
|
||||
int outlet_segment_id = ecl_kw_iget_int( iseg_kw , iseg_offset + ISEG_OUTLET_ITEM ) - 1;
|
||||
int branch_id = ecl_kw_iget_int( iseg_kw , iseg_offset + ISEG_BRANCH_ITEM ) - 1;
|
||||
const double * rseg_data = ecl_kw_iget_ptr( rseg_kw , rseg_offset );
|
||||
|
||||
well_segment_type * segment = well_segment_alloc( segment_id , outlet_segment_id , branch_id , rseg_data);
|
||||
return segment;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
if (iseg_kw != NULL) {
|
||||
if (conn->segment != WELL_CONN_NORMAL_WELL_SEGMENT_ID) {
|
||||
|
||||
} else {
|
||||
conn->branch = 0;
|
||||
conn->outlet_segment = 0;
|
||||
}
|
||||
} else {
|
||||
conn->branch = 0;
|
||||
conn->outlet_segment = 0;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
void well_segment_free(well_segment_type * segment ) {
|
||||
hash_free( segment->connections );
|
||||
free( segment );
|
||||
}
|
||||
|
||||
void well_segment_free__(void * arg) {
|
||||
well_segment_type * segment = well_segment_safe_cast( arg );
|
||||
well_segment_free( segment );
|
||||
}
|
||||
|
||||
|
||||
bool well_segment_active( const well_segment_type * segment ) {
|
||||
if (segment->branch_id == ECLIPSE_WELL_SEGMENT_BRANCH_INACTIVE_VALUE)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool well_segment_main_stem( const well_segment_type * segment ) {
|
||||
if (segment->branch_id == ECLIPSE_WELL_SEGMENT_BRANCH_MAIN_STEM_VALUE)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool well_segment_nearest_wellhead( const well_segment_type * segment ) {
|
||||
if (segment->outlet_segment_id == ECLIPSE_WELL_SEGMENT_OUTLET_END_VALUE)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
int well_segment_get_link_count( const well_segment_type * segment ) {
|
||||
return segment->link_count;
|
||||
}
|
||||
|
||||
int well_segment_get_branch_id( const well_segment_type * segment ) {
|
||||
return segment->branch_id;
|
||||
}
|
||||
|
||||
int well_segment_get_outlet_id( const well_segment_type * segment ) {
|
||||
return segment->outlet_segment_id;
|
||||
}
|
||||
|
||||
int well_segment_get_id( const well_segment_type * segment ) {
|
||||
return segment->segment_id;
|
||||
}
|
||||
|
||||
|
||||
well_segment_type * well_segment_get_outlet( const well_segment_type * segment ) {
|
||||
return segment->outlet_segment;
|
||||
}
|
||||
|
||||
|
||||
bool well_segment_link( well_segment_type * segment , well_segment_type * outlet_segment ) {
|
||||
if (segment->outlet_segment_id == outlet_segment->segment_id) {
|
||||
segment->outlet_segment = outlet_segment;
|
||||
outlet_segment->link_count++;
|
||||
return true;
|
||||
} else
|
||||
/*
|
||||
This is a quite fatal topological error - and aborting is probaly the wisest
|
||||
thing to do. I.e. the function well_segment_link_strict() is recommended.
|
||||
*/
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void well_segment_link_strict( well_segment_type * segment , well_segment_type * outlet_segment ) {
|
||||
if (!well_segment_link( segment , outlet_segment))
|
||||
util_abort("%s: tried to create invalid link between segments %d and %d \n",segment->segment_id , outlet_segment->segment_id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool well_segment_has_grid_connections( const well_segment_type * segment , const char * grid_name) {
|
||||
return hash_has_key( segment->connections , grid_name );
|
||||
}
|
||||
|
||||
|
||||
bool well_segment_has_global_grid_connections( const well_segment_type * segment) {
|
||||
return well_segment_has_grid_connections( segment , ECL_GRID_GLOBAL_GRID );
|
||||
}
|
||||
|
||||
|
||||
bool well_segment_add_connection( well_segment_type * segment , const char * grid_name , well_conn_type * conn) {
|
||||
int conn_segment_id = well_conn_get_segment( conn );
|
||||
if (conn_segment_id == segment->segment_id) {
|
||||
if (!well_segment_has_grid_connections( segment , grid_name ))
|
||||
hash_insert_hash_owned_ref( segment->connections , grid_name , well_conn_collection_alloc() , well_conn_collection_free__ );
|
||||
|
||||
{
|
||||
well_conn_collection_type * connections = hash_get( segment->connections , grid_name );
|
||||
well_conn_collection_add_ref( connections , conn );
|
||||
}
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
const well_conn_collection_type * well_segment_get_connections(const well_segment_type * segment , const char * grid_name ) {
|
||||
if (well_segment_has_grid_connections( segment , grid_name))
|
||||
return hash_get( segment->connections , grid_name);
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
const well_conn_collection_type * well_segment_get_global_connections(const well_segment_type * segment ) {
|
||||
return well_segment_get_connections( segment , ECL_GRID_GLOBAL_GRID );
|
||||
}
|
||||
|
||||
|
||||
bool well_segment_well_is_MSW(int well_nr , const ecl_kw_type * iwel_kw , const ecl_rsthead_type * rst_head) {
|
||||
int iwel_offset = rst_head->niwelz * well_nr;
|
||||
int segment_well_nr = ecl_kw_iget_int( iwel_kw , iwel_offset + IWEL_SEGMENTED_WELL_NR_ITEM) - 1;
|
||||
|
||||
if (segment_well_nr == IWEL_SEGMENTED_WELL_NR_NORMAL_VALUE)
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
double well_segment_get_depth( const well_segment_type * segment ) {
|
||||
return segment->depth;
|
||||
}
|
||||
|
||||
double well_segment_get_length( const well_segment_type * segment ) {
|
||||
return segment->length;
|
||||
}
|
||||
|
||||
double well_segment_get_total_length( const well_segment_type * segment ) {
|
||||
return segment->total_length;
|
||||
}
|
||||
|
||||
double well_segment_get_diameter( const well_segment_type * segment ) {
|
||||
return segment->diameter;
|
||||
}
|
@ -1,169 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'well_segment_collection.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/util.h>
|
||||
#include <ert/util/vector.h>
|
||||
|
||||
#include <ert/ecl/ecl_kw.h>
|
||||
#include <ert/ecl/ecl_rsthead.h>
|
||||
|
||||
#include <ert/ecl_well/well_const.h>
|
||||
#include <ert/ecl_well/well_segment.h>
|
||||
#include <ert/ecl_well/well_conn.h>
|
||||
#include <ert/ecl_well/well_segment_collection.h>
|
||||
#include <ert/ecl_well/well_conn_collection.h>
|
||||
#include <ert/ecl_well/well_branch_collection.h>
|
||||
|
||||
|
||||
struct well_segment_collection_struct {
|
||||
int_vector_type * segment_index_map;
|
||||
vector_type * __segment_storage;
|
||||
};
|
||||
|
||||
|
||||
|
||||
well_segment_collection_type * well_segment_collection_alloc() {
|
||||
well_segment_collection_type * segment_collection = util_malloc( sizeof * segment_collection );
|
||||
|
||||
segment_collection->__segment_storage = vector_alloc_new();
|
||||
segment_collection->segment_index_map = int_vector_alloc( 0 , -1 );
|
||||
return segment_collection;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void well_segment_collection_free(well_segment_collection_type * segment_collection ) {
|
||||
vector_free( segment_collection->__segment_storage );
|
||||
int_vector_free( segment_collection->segment_index_map );
|
||||
free( segment_collection );
|
||||
}
|
||||
|
||||
|
||||
|
||||
int well_segment_collection_get_size( const well_segment_collection_type * segment_collection ) {
|
||||
return vector_get_size( segment_collection->__segment_storage );
|
||||
}
|
||||
|
||||
|
||||
void well_segment_collection_add( well_segment_collection_type * segment_collection , well_segment_type * segment) {
|
||||
int segment_id = well_segment_get_id( segment );
|
||||
int current_index = int_vector_safe_iget( segment_collection->segment_index_map , segment_id );
|
||||
if (current_index >= 0)
|
||||
vector_iset_owned_ref( segment_collection->__segment_storage , current_index , segment , well_segment_free__);
|
||||
else {
|
||||
int new_index = vector_get_size(segment_collection->__segment_storage);
|
||||
vector_append_owned_ref( segment_collection->__segment_storage , segment , well_segment_free__);
|
||||
int_vector_iset( segment_collection->segment_index_map , segment_id , new_index);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
well_segment_type * well_segment_collection_iget( const well_segment_collection_type * segment_collection , int index) {
|
||||
return vector_iget( segment_collection->__segment_storage , index );
|
||||
}
|
||||
|
||||
|
||||
well_segment_type * well_segment_collection_get( const well_segment_collection_type * segment_collection , int segment_id) {
|
||||
int internal_index = int_vector_safe_iget( segment_collection->segment_index_map , segment_id );
|
||||
if (internal_index >= 0)
|
||||
return well_segment_collection_iget( segment_collection , internal_index );
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
bool well_segment_collection_has_segment( const well_segment_collection_type * segment_collection , int segment_id) {
|
||||
int internal_index = int_vector_safe_iget( segment_collection->segment_index_map , segment_id );
|
||||
if (internal_index >= 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int well_segment_collection_load_from_kw( well_segment_collection_type * segment_collection , int well_nr ,
|
||||
const ecl_kw_type * iwel_kw ,
|
||||
const ecl_kw_type * iseg_kw ,
|
||||
const ecl_kw_type * rseg_kw ,
|
||||
const ecl_rsthead_type * rst_head) {
|
||||
|
||||
int iwel_offset = rst_head->niwelz * well_nr;
|
||||
int segment_well_nr = ecl_kw_iget_int( iwel_kw , iwel_offset + IWEL_SEGMENTED_WELL_NR_ITEM) - 1;
|
||||
int segments_added = 0;
|
||||
|
||||
if (segment_well_nr != IWEL_SEGMENTED_WELL_NR_NORMAL_VALUE) {
|
||||
int segment_id;
|
||||
for (segment_id = 0; segment_id < rst_head->nsegmx; segment_id++) {
|
||||
well_segment_type * segment = well_segment_alloc_from_kw( iseg_kw , rseg_kw , rst_head , segment_well_nr , segment_id );
|
||||
|
||||
if (well_segment_active( segment )) {
|
||||
well_segment_collection_add( segment_collection , segment );
|
||||
segments_added++;
|
||||
} else
|
||||
well_segment_free( segment );
|
||||
}
|
||||
}
|
||||
|
||||
return segments_added;
|
||||
}
|
||||
|
||||
|
||||
void well_segment_collection_link(const well_segment_collection_type * segment_collection) {
|
||||
int index;
|
||||
for (index = 0; index < vector_get_size( segment_collection->__segment_storage); index++) {
|
||||
well_segment_type * segment = well_segment_collection_iget( segment_collection , index );
|
||||
int outlet_segment_id = well_segment_get_outlet_id( segment );
|
||||
if (!well_segment_nearest_wellhead(segment)) {
|
||||
well_segment_type * target_segment = well_segment_collection_get( segment_collection , outlet_segment_id );
|
||||
well_segment_link( segment , target_segment );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void well_segment_collection_add_connections(well_segment_collection_type * segment_collection ,
|
||||
const char * grid_name ,
|
||||
const well_conn_collection_type * connections) {
|
||||
int iconn;
|
||||
for (iconn = 0; iconn < well_conn_collection_get_size( connections ); iconn++) {
|
||||
well_conn_type * conn = well_conn_collection_iget( connections , iconn );
|
||||
if (well_conn_MSW( conn )) {
|
||||
int segment_id = well_conn_get_segment( conn );
|
||||
well_segment_type * segment = well_segment_collection_get( segment_collection , segment_id );
|
||||
well_segment_add_connection( segment , grid_name , conn );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void well_segment_collection_add_branches( const well_segment_collection_type * segment_collection ,
|
||||
well_branch_collection_type * branches ) {
|
||||
int iseg;
|
||||
for (iseg =0; iseg < well_segment_collection_get_size( segment_collection ); iseg++) {
|
||||
const well_segment_type * segment = well_segment_collection_iget( segment_collection , iseg );
|
||||
if (well_segment_get_link_count( segment ) == 0)
|
||||
well_branch_collection_add_start_segment( branches , segment );
|
||||
}
|
||||
}
|
||||
|
681
ThirdParty/Ert/devel/libecl_well/src/well_state.c
vendored
681
ThirdParty/Ert/devel/libecl_well/src/well_state.c
vendored
@ -1,19 +1,19 @@
|
||||
/*
|
||||
Copyright (C) 2011 Statoil ASA, Norway.
|
||||
|
||||
The file 'well_state.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
Copyright (C) 2011 Statoil ASA, Norway.
|
||||
|
||||
The file 'well_state.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -36,126 +36,11 @@
|
||||
#include <ert/ecl/ecl_kw.h>
|
||||
#include <ert/ecl/ecl_kw_magic.h>
|
||||
#include <ert/ecl/ecl_util.h>
|
||||
#include <ert/ecl/ecl_grid.h>
|
||||
|
||||
#include <ert/ecl_well/well_const.h>
|
||||
#include <ert/ecl_well/well_conn.h>
|
||||
#include <ert/ecl_well/well_state.h>
|
||||
#include <ert/ecl_well/well_segment_collection.h>
|
||||
#include <ert/ecl_well/well_branch_collection.h>
|
||||
|
||||
/*
|
||||
|
||||
Connections, segments and branches
|
||||
----------------------------------
|
||||
|
||||
|
||||
+-----+
|
||||
| | <- Wellhead
|
||||
| |
|
||||
+-----+ _________ Segment 2
|
||||
|\ /
|
||||
| \/ Segment 1 Segment 0
|
||||
| \-----0---------------0--<----------------------O <-- Branch: 0
|
||||
\ | | | |
|
||||
\ +-----+ +-----++-----+ +-----+
|
||||
\ | C3 | | C2 || C1 | | C0 |
|
||||
\ | | | || | | |
|
||||
\ +-----+ +-----++-----+ +-----+
|
||||
\
|
||||
Segment 5 \
|
||||
\
|
||||
\ Segment 4 Segment 3
|
||||
\-<--O-------<-------O----------------<------------O <-- Branch: 1
|
||||
| | | |
|
||||
+-----+ +-----+ +-----+ +-----+
|
||||
| C7 | | C6 | | C5 | | C4 |
|
||||
| | | | | | | |
|
||||
+-----+ +-----+ +-----+ +-----+
|
||||
|
||||
|
||||
|
||||
|
||||
The boxes show connections C0 - C7; the connections serve as sinks (or
|
||||
sources in the case of injectors) removing fluids from the
|
||||
reservoir. As ind icated by the use of isolated boxes the ECLIPSE model
|
||||
contains no geomtric concept linking the different connections into a
|
||||
connected 'well-like' object.
|
||||
|
||||
Ordinary wells in the ECLIPSE model are just a collection of
|
||||
connections like these illustrated boxes, and to draw a connected 1D
|
||||
object heuristics of some kind must be used to determine how the
|
||||
various connections should be connected. In particular for wells which
|
||||
consist of multiple branches this heuristic is non obvious.
|
||||
|
||||
More advanced (i.e. newer) wells are modelles as multisegment wells;
|
||||
the important thing about multisegment wells is that the 1D segments
|
||||
constituting the flowpipe are modelled explicitly as 'segments', and
|
||||
the equations of fluid flow are solved by ECLIPSE in these 1D
|
||||
domains. The figure above shows a multisegment well with six segments
|
||||
marked as Segment0 ... Segment5. The segments themselves are quite
|
||||
abstract objects not directly linked to the grid, but indriectly
|
||||
through the connections. In the figure the segment <-> connection
|
||||
links are as follows:
|
||||
|
||||
Segment0: C0, C1
|
||||
Segment1: C2
|
||||
Segment2: C3
|
||||
Segment3: C4, C5
|
||||
Segment4: C6
|
||||
Segment5: C7
|
||||
|
||||
Each segment has an outlet segment, which will link the segments
|
||||
together into a geometry.
|
||||
|
||||
The connection can in general be both to the main global grid, and to
|
||||
an LGR. Hence all questions about connections must be LGR aware. This
|
||||
is in contrast to the segments and branches which are geometric
|
||||
objects, not directly coupled to a specific grid; however the segments
|
||||
have a collection of connections - and these connections are of course
|
||||
coupledte implementation these objects are modelled as such:
|
||||
|
||||
1. The well_state has hash table which is indexed by LGR name, and
|
||||
the values are well_conn_collection instances. The
|
||||
well_conn_collection type is a quite simple collection which can
|
||||
tell how may connections there are, and index based lookup:
|
||||
|
||||
|
||||
well_conn_collection_type * connections = well_state_get_grid_connections( well_state , LGR_NAME);
|
||||
if (connections) {
|
||||
well_conn_type * conn = well_conn_collection_iget( connections , 0 );
|
||||
printf("Have %d connections \n",well_conn_collection_get_size( connections );
|
||||
}
|
||||
|
||||
The connections to the global grid are stored with the 'LGR' name
|
||||
given by the symbole ECL_GRID_GLOBAL_GRID, or alternatively the
|
||||
function well_state_get_global_connections( well_state ) can be
|
||||
used.
|
||||
|
||||
|
||||
|
||||
2. If - AND ONLY IF - the well is a multisegment well, you can query
|
||||
the well_state object for information about segments and branches:
|
||||
|
||||
if (well_state_is_MSW( well_state )) {
|
||||
well_segment_collection_type * segments = well_state_get_segments( well_state );
|
||||
well_branch_collection_type * branches = well_state_get_branches( well_state );
|
||||
int branch_nr;
|
||||
|
||||
for (branch_nr = 0; branch_nr < well_branch_collection_get_size( branches ); branch_nr++) {
|
||||
well_segment_type * segment = well_branch_collection_iget_start_segment( branches , branhc_nr );
|
||||
while (segment) {
|
||||
// Inspect the current segment.
|
||||
segment = well_segment_get_outlet( segment );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
#include <ert/ecl_well/well_path.h>
|
||||
|
||||
#define WELL_STATE_TYPE_ID 613307832
|
||||
|
||||
@ -164,18 +49,16 @@ struct well_state_struct {
|
||||
char * name;
|
||||
time_t valid_from_time;
|
||||
int valid_from_report;
|
||||
int global_well_nr;
|
||||
bool open;
|
||||
well_type_enum type;
|
||||
|
||||
hash_type * connections; // hash<grid_name,well_conn_collection>
|
||||
well_segment_collection_type * segments;
|
||||
well_branch_collection_type * branches;
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
well_path_type * null_path; // This is a valid - empty path instance returned when the well does not have any cells in a particular LGR.
|
||||
|
||||
vector_type * index_wellhead; // An well_conn_type instance representing the wellhead - indexed by grid_nr.
|
||||
hash_type * name_wellhead; // An well_conn_type instance representing the wellhead - indexed by lgr_name.
|
||||
|
||||
vector_type * index_lgr_path; // Contains the various well_path instances indexed by grid_nr - global has grid_nr == 0.
|
||||
hash_type * name_lgr_path; // Contains the different well_path instances indexed by lgr_name
|
||||
};
|
||||
|
||||
|
||||
@ -183,30 +66,34 @@ struct well_state_struct {
|
||||
UTIL_IS_INSTANCE_FUNCTION( well_state , WELL_STATE_TYPE_ID)
|
||||
|
||||
|
||||
well_state_type * well_state_alloc(const char * well_name , int global_well_nr , bool open, well_type_enum type , int report_nr, time_t valid_from) {
|
||||
static well_state_type * well_state_alloc_empty() {
|
||||
well_state_type * well_state = util_malloc( sizeof * well_state );
|
||||
UTIL_TYPE_ID_INIT( well_state , WELL_STATE_TYPE_ID );
|
||||
well_state->index_lgr_path = vector_alloc_new();
|
||||
well_state->name_lgr_path = hash_alloc();
|
||||
|
||||
well_state->index_wellhead = vector_alloc_new();
|
||||
well_state->name_wellhead = hash_alloc();
|
||||
|
||||
well_state->name = util_alloc_string_copy( well_name );
|
||||
well_state->valid_from_time = valid_from;
|
||||
well_state->valid_from_report = report_nr;
|
||||
well_state->open = open;
|
||||
well_state->type = type;
|
||||
well_state->global_well_nr = global_well_nr;
|
||||
well_state->connections = hash_alloc();
|
||||
well_state->segments = well_segment_collection_alloc();
|
||||
well_state->branches = well_branch_collection_alloc();
|
||||
|
||||
/* See documentation of the 'IWEL_UNDOCUMENTED_ZERO' in well_const.h */
|
||||
if ((type == UNDOCUMENTED_ZERO) && open)
|
||||
util_abort("%s: Invalid type value for open wells.\n",__func__ );
|
||||
well_state->null_path = well_path_alloc( NULL );
|
||||
return well_state;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
This function assumes that the ecl_file state has been restricted
|
||||
to one LGR block with the ecl_file_subselect_block() function.
|
||||
*/
|
||||
|
||||
well_path_type * well_state_add_path( well_state_type * well_state , const ecl_file_type * rst_file , const char * grid_name , int grid_nr) {
|
||||
well_path_type * well_path;
|
||||
well_path = well_path_alloc( grid_name );
|
||||
|
||||
vector_safe_iset_owned_ref( well_state->index_lgr_path , grid_nr , well_path , well_path_free__);
|
||||
hash_insert_ref( well_state->name_lgr_path , grid_name , well_path );
|
||||
|
||||
return well_path;
|
||||
}
|
||||
|
||||
|
||||
void well_state_add_wellhead( well_state_type * well_state , const ecl_rsthead_type * header , const ecl_kw_type * iwel_kw , int well_nr , const char * grid_name , int grid_nr) {
|
||||
@ -216,26 +103,72 @@ void well_state_add_wellhead( well_state_type * well_state , const ecl_rsthead_t
|
||||
vector_safe_iset_owned_ref( well_state->index_wellhead , grid_nr , wellhead , well_conn_free__ );
|
||||
hash_insert_ref( well_state->name_wellhead , grid_name , wellhead );
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
This function assumes that the ecl_file state has been restricted
|
||||
to one LGR block with the ecl_file_subselect_block() function.
|
||||
*/
|
||||
|
||||
static void well_state_add_connections( well_state_type * well_state , const ecl_file_type * rst_file , int grid_nr, int well_nr ) {
|
||||
ecl_rsthead_type * header = ecl_rsthead_alloc( rst_file );
|
||||
const ecl_kw_type * icon_kw = ecl_file_iget_named_kw( rst_file , ICON_KW , 0);
|
||||
const ecl_kw_type * iwel_kw = ecl_file_iget_named_kw( rst_file , IWEL_KW , 0);
|
||||
const int iwel_offset = header->niwelz * well_nr;
|
||||
int num_connections = ecl_kw_iget_int( iwel_kw , iwel_offset + IWEL_CONNECTIONS_ITEM );
|
||||
ecl_kw_type * iseg_kw = NULL;
|
||||
bool MSW = false; // MultiSegmentWell
|
||||
int seg_well_nr = ecl_kw_iget_int( iwel_kw , iwel_offset + IWEL_SEGMENTED_WELL_NR_ITEM) - 1; // -1: Ordinary well.
|
||||
well_path_type * path;
|
||||
|
||||
{
|
||||
char * grid_name;
|
||||
|
||||
if (grid_nr > 0) {
|
||||
const ecl_kw_type * lgr_kw = ecl_file_iget_named_kw( rst_file , LGR_KW , 0 );
|
||||
grid_name = util_alloc_strip_copy(ecl_kw_iget_ptr( lgr_kw , 0));
|
||||
} else
|
||||
grid_name = util_alloc_string_copy( GLOBAL_GRID_NAME );
|
||||
|
||||
path = well_state_add_path( well_state , rst_file , grid_name , grid_nr );
|
||||
well_state_add_wellhead( well_state , header , iwel_kw , well_nr , grid_name , grid_nr );
|
||||
free( grid_name );
|
||||
}
|
||||
|
||||
/* The MSW information is only attached to the global grid. */
|
||||
if (seg_well_nr >= 0 && grid_nr == 0)
|
||||
MSW = true;
|
||||
|
||||
if (MSW)
|
||||
iseg_kw = ecl_file_iget_named_kw( rst_file , ISEG_KW , 0 );
|
||||
|
||||
{
|
||||
int conn_nr;
|
||||
for (conn_nr = 0; conn_nr < num_connections; conn_nr++) {
|
||||
well_conn_type * conn = well_conn_alloc( icon_kw , iseg_kw , header , well_nr , seg_well_nr , conn_nr );
|
||||
if (conn != NULL)
|
||||
well_path_add_conn( path , conn );
|
||||
}
|
||||
}
|
||||
ecl_rsthead_free( header );
|
||||
}
|
||||
|
||||
/*
|
||||
This function assumes that the ecl_file state has been restricted
|
||||
to one LGR block with the ecl_file_subselect_block() function.
|
||||
|
||||
Return value: -1 means that the well is not found in this LGR at
|
||||
all.
|
||||
all.
|
||||
*/
|
||||
|
||||
static int well_state_get_lgr_well_nr( const well_state_type * well_state , const ecl_file_type * ecl_file) {
|
||||
int well_nr = -1;
|
||||
|
||||
|
||||
if (ecl_file_has_kw( ecl_file , ZWEL_KW)) {
|
||||
ecl_rsthead_type * header = ecl_rsthead_alloc( ecl_file );
|
||||
const ecl_kw_type * zwel_kw = ecl_file_iget_named_kw( ecl_file , ZWEL_KW , 0 );
|
||||
ecl_rsthead_type * header = ecl_rsthead_alloc( ecl_file ); //
|
||||
const ecl_kw_type * zwel_kw = ecl_file_iget_named_kw( ecl_file , ZWEL_KW , 0);
|
||||
int num_wells = header->nwells;
|
||||
well_nr = 0;
|
||||
while (true) {
|
||||
@ -247,10 +180,10 @@ static int well_state_get_lgr_well_nr( const well_state_type * well_state , cons
|
||||
found = true;
|
||||
else
|
||||
well_nr++;
|
||||
|
||||
|
||||
free( lgr_well_name );
|
||||
}
|
||||
|
||||
|
||||
if (found)
|
||||
break;
|
||||
else if (well_nr == num_wells) {
|
||||
@ -258,7 +191,7 @@ static int well_state_get_lgr_well_nr( const well_state_type * well_state , cons
|
||||
well_nr = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
ecl_rsthead_free( header );
|
||||
}
|
||||
@ -266,217 +199,97 @@ static int well_state_get_lgr_well_nr( const well_state_type * well_state , cons
|
||||
}
|
||||
|
||||
|
||||
|
||||
well_type_enum well_state_translate_ecl_type_int(int int_type) {
|
||||
well_type_enum type = UNDOCUMENTED_ZERO;
|
||||
|
||||
switch (int_type) {
|
||||
/* See documentation of the 'IWEL_UNDOCUMENTED_ZERO' in well_const.h */
|
||||
case(IWEL_UNDOCUMENTED_ZERO):
|
||||
type = UNDOCUMENTED_ZERO;
|
||||
break;
|
||||
case(IWEL_PRODUCER):
|
||||
type = PRODUCER;
|
||||
break;
|
||||
case(IWEL_OIL_INJECTOR):
|
||||
type = OIL_INJECTOR;
|
||||
break;
|
||||
case(IWEL_GAS_INJECTOR):
|
||||
type = GAS_INJECTOR;
|
||||
break;
|
||||
case(IWEL_WATER_INJECTOR):
|
||||
type = WATER_INJECTOR;
|
||||
break;
|
||||
default:
|
||||
util_abort("%s: Invalid type value %d\n",__func__ , int_type);
|
||||
}
|
||||
return type;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
This function assumes that the ecl_file state has been restricted
|
||||
to one LGR block with the ecl_file_subselect_block() function.
|
||||
*/
|
||||
|
||||
static void well_state_add_connections__( well_state_type * well_state ,
|
||||
const ecl_file_type * rst_file ,
|
||||
const char * grid_name ,
|
||||
int grid_nr,
|
||||
int well_nr ) {
|
||||
|
||||
ecl_rsthead_type * header = ecl_rsthead_alloc( rst_file );
|
||||
const ecl_kw_type * icon_kw = ecl_file_iget_named_kw( rst_file , ICON_KW , 0);
|
||||
const ecl_kw_type * iwel_kw = ecl_file_iget_named_kw( rst_file , IWEL_KW , 0);
|
||||
|
||||
//const int iwel_offset = header->niwelz * well_nr;
|
||||
//int seg_well_nr = ecl_kw_iget_int( iwel_kw , iwel_offset + IWEL_SEGMENTED_WELL_NR_ITEM) - 1; // -1: Ordinary well.
|
||||
|
||||
well_state_add_wellhead( well_state , header , iwel_kw , well_nr , grid_name , grid_nr );
|
||||
|
||||
if (!well_state_has_grid_connections( well_state , grid_name ))
|
||||
hash_insert_hash_owned_ref( well_state->connections , grid_name, well_conn_collection_alloc( ) , well_conn_collection_free__ );
|
||||
|
||||
{
|
||||
well_conn_collection_type * wellcc = hash_get( well_state->connections , grid_name );
|
||||
well_conn_collection_load_from_kw( wellcc , iwel_kw , icon_kw , well_nr , header );
|
||||
}
|
||||
ecl_rsthead_free( header );
|
||||
}
|
||||
|
||||
|
||||
static void well_state_add_global_connections( well_state_type * well_state ,
|
||||
const ecl_file_type * rst_file ,
|
||||
int well_nr ) {
|
||||
well_state_add_connections__( well_state , rst_file , ECL_GRID_GLOBAL_GRID , 0 , well_nr );
|
||||
}
|
||||
|
||||
static void well_state_add_LGR_connections( well_state_type * well_state , const ecl_grid_type * grid , ecl_file_type * ecl_file, int global_well_nr ) {
|
||||
// Go through all the LGRs and add connections; both in the bulk
|
||||
// grid and as wellhead.
|
||||
int num_lgr = ecl_grid_get_num_lgr( grid );
|
||||
int lgr_nr;
|
||||
for (lgr_nr = 0; lgr_nr < num_lgr; lgr_nr++) {
|
||||
ecl_file_push_block( ecl_file ); // <-------------------------//
|
||||
{ //
|
||||
ecl_file_subselect_block( ecl_file , LGR_KW , lgr_nr ); //
|
||||
{ // Restrict the file view
|
||||
const char * grid_name = ecl_grid_iget_lgr_name( grid , lgr_nr ); //
|
||||
int well_nr = well_state_get_lgr_well_nr( well_state , ecl_file ); // to one LGR block.
|
||||
if (well_nr >= 0) //
|
||||
well_state_add_connections__( well_state , ecl_file , grid_name , lgr_nr + 1, well_nr ); //
|
||||
} //
|
||||
} //
|
||||
ecl_file_pop_block( ecl_file ); // <-------------------------//
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void well_state_add_connections( well_state_type * well_state ,
|
||||
const ecl_grid_type * grid ,
|
||||
ecl_file_type * rst_file , // Either an open .Xnnnn file or UNRST file restricted to one report step
|
||||
int well_nr) {
|
||||
|
||||
well_state_add_global_connections( well_state , rst_file , well_nr );
|
||||
well_state_add_LGR_connections( well_state , grid , rst_file , well_nr );
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool well_state_add_MSW( well_state_type * well_state ,
|
||||
const ecl_file_type * rst_file ,
|
||||
int well_nr) {
|
||||
|
||||
if (ecl_file_has_kw( rst_file , ISEG_KW)) {
|
||||
ecl_rsthead_type * rst_head = ecl_rsthead_alloc( rst_file );
|
||||
const ecl_kw_type * iwel_kw = ecl_file_iget_named_kw( rst_file , IWEL_KW , 0);
|
||||
const ecl_kw_type * iseg_kw = ecl_file_iget_named_kw( rst_file , ISEG_KW , 0);
|
||||
ecl_kw_type * rseg_kw = NULL;
|
||||
|
||||
int segments;
|
||||
|
||||
if (ecl_file_has_kw( rst_file , RSEG_KW ))
|
||||
/*
|
||||
Here we check that the file has the RSEG_KW keyword, and pass
|
||||
NULL if not. The rseg_kw pointer will later be used in
|
||||
well_segment_collection_load_from_kw() where we test if this
|
||||
is a MSW well. If this indeed is a MSW well the rseg_kw
|
||||
pointer will be used unchecked, if it is then NULL => Crash
|
||||
and burn.
|
||||
*/
|
||||
rseg_kw = ecl_file_iget_named_kw( rst_file , RSEG_KW , 0);
|
||||
|
||||
segments = well_segment_collection_load_from_kw( well_state->segments ,
|
||||
well_nr ,
|
||||
iwel_kw ,
|
||||
iseg_kw ,
|
||||
rseg_kw ,
|
||||
rst_head);
|
||||
|
||||
if (segments) {
|
||||
hash_iter_type * grid_iter = hash_iter_alloc( well_state->connections );
|
||||
while (!hash_iter_is_complete( grid_iter )) {
|
||||
const char * grid_name = hash_iter_get_next_key( grid_iter );
|
||||
const well_conn_collection_type * connections = hash_get( well_state->connections , grid_name );
|
||||
well_segment_collection_add_connections( well_state->segments , grid_name , connections );
|
||||
}
|
||||
hash_iter_free( grid_iter );
|
||||
well_segment_collection_link( well_state->segments );
|
||||
well_segment_collection_add_branches( well_state->segments , well_state->branches );
|
||||
}
|
||||
ecl_rsthead_free( rst_head );
|
||||
return true;
|
||||
} else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool well_state_is_MSW( const well_state_type * well_state) {
|
||||
if (well_segment_collection_get_size( well_state->segments ) > 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
well_state_type * well_state_alloc_from_file( ecl_file_type * ecl_file , const ecl_grid_type * grid , int report_nr , int global_well_nr) {
|
||||
well_state_type * well_state_alloc( ecl_file_type * ecl_file , int report_nr , int global_well_nr) {
|
||||
if (ecl_file_has_kw( ecl_file , IWEL_KW)) {
|
||||
well_state_type * well_state = NULL;
|
||||
ecl_rsthead_type * global_header = ecl_rsthead_alloc( ecl_file );
|
||||
const ecl_kw_type * global_iwel_kw = ecl_file_iget_named_kw( ecl_file , IWEL_KW , 0);
|
||||
const ecl_kw_type * global_zwel_kw = ecl_file_iget_named_kw( ecl_file , ZWEL_KW , 0);
|
||||
|
||||
|
||||
const int iwel_offset = global_header->niwelz * global_well_nr;
|
||||
{
|
||||
char * name;
|
||||
bool open;
|
||||
well_type_enum type = UNDOCUMENTED_ZERO;
|
||||
const int zwel_offset = global_header->nzwelz * global_well_nr;
|
||||
well_state = well_state_alloc_empty();
|
||||
|
||||
well_state->valid_from_time = global_header->sim_time;
|
||||
well_state->valid_from_report = report_nr;
|
||||
well_state->name = util_alloc_strip_copy(ecl_kw_iget_ptr( global_zwel_kw , zwel_offset )); // Hardwired max 8 characters in Well Name
|
||||
|
||||
{
|
||||
int int_state = ecl_kw_iget_int( global_iwel_kw , iwel_offset + IWEL_STATUS_ITEM );
|
||||
if (int_state > 0)
|
||||
open = true;
|
||||
well_state->open = true;
|
||||
else
|
||||
open = false;
|
||||
well_state->open = false;
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
int int_type = ecl_kw_iget_int( global_iwel_kw , iwel_offset + IWEL_TYPE_ITEM);
|
||||
type = well_state_translate_ecl_type_int( int_type );
|
||||
switch (int_type) {
|
||||
/* See documentation of the 'IWEL_UNDOCUMENTED_ZERO' in well_const.h */
|
||||
case(IWEL_UNDOCUMENTED_ZERO):
|
||||
well_state->type = UNDOCUMENTED_ZERO;
|
||||
if (well_state->open)
|
||||
util_abort("%s: Invalid type value %d\n",__func__ , int_type);
|
||||
break;
|
||||
case(IWEL_PRODUCER):
|
||||
well_state->type = PRODUCER;
|
||||
break;
|
||||
case(IWEL_OIL_INJECTOR):
|
||||
well_state->type = OIL_INJECTOR;
|
||||
break;
|
||||
case(IWEL_GAS_INJECTOR):
|
||||
well_state->type = GAS_INJECTOR;
|
||||
break;
|
||||
case(IWEL_WATER_INJECTOR):
|
||||
well_state->type = WATER_INJECTOR;
|
||||
break;
|
||||
default:
|
||||
util_abort("%s: Invalid type value %d\n",__func__ , int_type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Add global connections:
|
||||
well_state_add_connections( well_state , ecl_file , 0 , global_well_nr );
|
||||
|
||||
|
||||
|
||||
// Go through all the LGRs and add connections; both in the bulk
|
||||
// grid and as wellhead.
|
||||
|
||||
{
|
||||
const int zwel_offset = global_header->nzwelz * global_well_nr;
|
||||
name = util_alloc_strip_copy(ecl_kw_iget_ptr( global_zwel_kw , zwel_offset )); // Hardwired max 8 characters in Well Name
|
||||
int num_lgr = ecl_file_get_num_named_kw( ecl_file , LGR_KW );
|
||||
int lgr_nr;
|
||||
for (lgr_nr = 0; lgr_nr < num_lgr; lgr_nr++) {
|
||||
ecl_file_push_block( ecl_file ); // <--------------------
|
||||
{ //
|
||||
ecl_file_subselect_block( ecl_file , LGR_KW , lgr_nr ); //
|
||||
{ // Restrict the file view
|
||||
int well_nr = well_state_get_lgr_well_nr( well_state , ecl_file); // to one LGR block.
|
||||
if (well_nr >= 0) //
|
||||
well_state_add_connections( well_state , ecl_file , lgr_nr + 1, well_nr ); //
|
||||
} //
|
||||
} //
|
||||
ecl_file_pop_block( ecl_file ); // <--------------------
|
||||
}
|
||||
}
|
||||
|
||||
well_state = well_state_alloc(name , global_well_nr , open , type , report_nr , global_header->sim_time);
|
||||
free( name );
|
||||
|
||||
well_state_add_connections( well_state , grid , ecl_file , global_well_nr);
|
||||
if (ecl_file_has_kw( ecl_file , ISEG_KW))
|
||||
well_state_add_MSW( well_state , ecl_file , global_well_nr );
|
||||
}
|
||||
}
|
||||
ecl_rsthead_free( global_header );
|
||||
return well_state;
|
||||
} else
|
||||
} else
|
||||
/* This seems a bit weird - have come over E300 restart files without the IWEL keyword. */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void well_state_free( well_state_type * well ) {
|
||||
hash_free( well->name_lgr_path );
|
||||
vector_free( well->index_lgr_path );
|
||||
|
||||
hash_free( well->name_wellhead );
|
||||
vector_free( well->index_wellhead );
|
||||
hash_free( well->connections );
|
||||
well_segment_collection_free( well->segments );
|
||||
well_branch_collection_free( well->branches );
|
||||
|
||||
well_path_free( well->null_path );
|
||||
|
||||
free( well->name );
|
||||
free( well );
|
||||
@ -508,7 +321,7 @@ const well_conn_type * well_state_get_wellhead( const well_state_type * well_sta
|
||||
}
|
||||
|
||||
|
||||
well_type_enum well_state_get_type( const well_state_type * well_state){
|
||||
well_type_enum well_state_get_type( const well_state_type * well_state){
|
||||
return well_state->type;
|
||||
}
|
||||
|
||||
@ -516,54 +329,146 @@ bool well_state_is_open( const well_state_type * well_state ) {
|
||||
return well_state->open;
|
||||
}
|
||||
|
||||
int well_state_get_well_nr( const well_state_type * well_state ) {
|
||||
return well_state->global_well_nr;
|
||||
}
|
||||
|
||||
|
||||
const char * well_state_get_name( const well_state_type * well_state ) {
|
||||
return well_state->name;
|
||||
}
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
well_path_type * well_state_get_path( const well_state_type * well_state , const char * lgr_name) {
|
||||
if (hash_has_key( well_state->name_lgr_path , lgr_name))
|
||||
return hash_get( well_state->name_lgr_path , lgr_name );
|
||||
else
|
||||
return well_state->null_path;
|
||||
}
|
||||
|
||||
well_path_type * well_state_iget_path( const well_state_type * well_state , int grid_nr) {
|
||||
well_path_type * path = vector_safe_iget( well_state->index_lgr_path , grid_nr );
|
||||
if (path != NULL)
|
||||
return path;
|
||||
else
|
||||
return well_state->null_path;
|
||||
}
|
||||
|
||||
|
||||
const well_conn_type ** well_state_iget_lgr_connections(const well_state_type * well_state , int grid_nr , int branch_nr ) {
|
||||
well_path_type * well_path = well_state_iget_path( well_state , grid_nr );
|
||||
well_branch_type * branch = well_path_iget_branch( well_path , branch_nr );
|
||||
|
||||
if (branch != NULL)
|
||||
return well_branch_get_connections( branch );
|
||||
else
|
||||
return NULL; // Branch does not exist - or has 0 connections.
|
||||
}
|
||||
|
||||
|
||||
const well_conn_type ** well_state_get_lgr_connections(const well_state_type * well_state , const char * lgr_name , int branch_nr) {
|
||||
well_path_type * well_path = well_state_get_path( well_state , lgr_name );
|
||||
well_branch_type * branch = well_path_iget_branch( well_path , branch_nr );
|
||||
if (branch != NULL)
|
||||
return well_branch_get_connections( branch );
|
||||
else
|
||||
return NULL; // Branch does not exist - or has 0 connections.
|
||||
}
|
||||
|
||||
|
||||
const well_conn_type ** well_state_get_connections(const well_state_type * well_state , int branch_nr ) {
|
||||
return well_state_iget_lgr_connections(well_state , 0 , branch_nr );
|
||||
}
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
int well_state_iget_num_lgr_connections(const well_state_type * well_state , int grid_nr , int branch_nr ) {
|
||||
well_path_type * well_path = well_state_iget_path( well_state , grid_nr );
|
||||
well_branch_type * branch = well_path_iget_branch( well_path , branch_nr );
|
||||
if (branch != NULL)
|
||||
return well_branch_get_length( branch );
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
int well_state_get_num_lgr_connections(const well_state_type * well_state , const char * lgr_name , int branch_nr) {
|
||||
well_path_type * well_path = well_state_get_path( well_state , lgr_name );
|
||||
well_branch_type * branch = well_path_iget_branch( well_path , branch_nr );
|
||||
if (branch != NULL)
|
||||
return well_branch_get_length( branch );
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int well_state_get_num_connections(const well_state_type * well_state , int branch_nr ) {
|
||||
return well_state_iget_num_lgr_connections(well_state , 0 , branch_nr );
|
||||
}
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
int well_state_iget_lgr_num_branches( const well_state_type * well_state , int grid_nr) {
|
||||
well_path_type * well_path = well_state_iget_path( well_state , grid_nr );
|
||||
return well_path_get_max_branches( well_path );
|
||||
}
|
||||
|
||||
int well_state_get_lgr_num_branches( const well_state_type * well_state , const char * lgr_name) {
|
||||
well_path_type * well_path = well_state_get_path( well_state , lgr_name );
|
||||
return well_path_get_max_branches( well_path );
|
||||
}
|
||||
|
||||
|
||||
int well_state_get_num_branches(const well_state_type * well_state ) {
|
||||
return well_state_iget_lgr_num_branches( well_state , 0 );
|
||||
}
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
int well_state_get_num_paths( const well_state_type * well_state ) {
|
||||
return vector_get_size( well_state->index_lgr_path );
|
||||
}
|
||||
|
||||
/*****************************************************************/
|
||||
|
||||
void well_state_summarize( const well_state_type * well_state , FILE * stream ) {
|
||||
fprintf(stream , "Well: %s \n" , well_state->name );
|
||||
{
|
||||
int grid_nr;
|
||||
for (grid_nr=0; grid_nr < well_state_get_num_paths( well_state ); grid_nr++) {
|
||||
well_path_type * well_path = well_state_iget_path(well_state , grid_nr );
|
||||
if (well_path_get_grid_name( well_path ) != NULL) {
|
||||
fprintf(stream , " Grid: %-8s\n",well_path_get_grid_name( well_path ));
|
||||
|
||||
{
|
||||
const well_conn_type * global_head = well_state_iget_wellhead( well_state , grid_nr );
|
||||
if (global_head != NULL)
|
||||
fprintf(stream , " Wellhead: (%3d,%3d,%3d)\n" , well_conn_get_i( global_head ) , well_conn_get_j(global_head) , well_conn_get_k( global_head) );
|
||||
else
|
||||
fprintf(stream , " Wellhead: ------------\n" );
|
||||
}
|
||||
|
||||
{
|
||||
int num_branches = well_path_get_max_branches(well_path);
|
||||
int branch_nr;
|
||||
for (branch_nr = 0; branch_nr < num_branches; branch_nr++) {
|
||||
well_branch_type * branch = well_path_iget_branch( well_path , branch_nr );
|
||||
if (branch != NULL) {
|
||||
const well_conn_type ** connections = well_branch_get_connections( branch );
|
||||
int num_connections = well_branch_get_length( branch );
|
||||
int iconn;
|
||||
|
||||
fprintf(stream , " Branch %2d: [" , branch_nr );
|
||||
for (iconn=0; iconn < num_connections; iconn++) {
|
||||
const well_conn_type * conn = connections[ iconn ];
|
||||
fprintf(stream, "(%3d,%3d,%3d)",well_conn_get_i( conn ) , well_conn_get_j( conn ), well_conn_get_k( conn ));
|
||||
if (iconn == (num_connections - 1))
|
||||
fprintf(stream , "]\n");
|
||||
else {
|
||||
fprintf(stream , ", ");
|
||||
if ((iconn + 1) % 10 == 0)
|
||||
fprintf(stream , "\n ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const well_conn_collection_type * well_state_get_grid_connections( const well_state_type * well_state , const char * grid_name) {
|
||||
if (hash_has_key( well_state->connections , grid_name))
|
||||
return hash_get( well_state->connections , grid_name);
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
const well_conn_collection_type * well_state_get_global_connections( const well_state_type * well_state ) {
|
||||
return well_state_get_grid_connections( well_state , ECL_GRID_GLOBAL_GRID );
|
||||
}
|
||||
|
||||
|
||||
bool well_state_has_grid_connections( const well_state_type * well_state , const char * grid_name) {
|
||||
if (hash_has_key( well_state->connections , grid_name))
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool well_state_has_global_connections( const well_state_type * well_state ) {
|
||||
return well_state_has_grid_connections( well_state , ECL_GRID_GLOBAL_GRID );
|
||||
}
|
||||
|
||||
|
||||
well_segment_collection_type * well_state_get_segments( const well_state_type * well_state ) {
|
||||
return well_state->segments;
|
||||
}
|
||||
|
||||
|
||||
well_branch_collection_type * well_state_get_branches( const well_state_type * well_state ) {
|
||||
return well_state->branches;
|
||||
}
|
||||
|
||||
|
@ -1,97 +1,3 @@
|
||||
add_executable( well_conn_collection well_conn_collection.c )
|
||||
target_link_libraries( well_conn_collection ecl_well )
|
||||
set_target_properties( well_conn_collection PROPERTIES COMPILE_FLAGS "-Werror")
|
||||
add_test( well_conn_collection ${EXECUTABLE_OUTPUT_PATH}/well_conn_collection )
|
||||
|
||||
add_executable( well_branch_collection well_branch_collection.c )
|
||||
target_link_libraries( well_branch_collection ecl_well )
|
||||
set_target_properties( well_branch_collection PROPERTIES COMPILE_FLAGS "-Werror")
|
||||
add_test( well_branch_collection ${EXECUTABLE_OUTPUT_PATH}/well_branch_collection )
|
||||
|
||||
add_executable( well_conn well_conn.c )
|
||||
target_link_libraries( well_conn ecl_well )
|
||||
set_target_properties( well_conn PROPERTIES COMPILE_FLAGS "-Werror")
|
||||
add_test( well_conn ${EXECUTABLE_OUTPUT_PATH}/well_conn )
|
||||
|
||||
add_executable( well_state well_state.c )
|
||||
target_link_libraries( well_state ecl_well )
|
||||
set_target_properties( well_state PROPERTIES COMPILE_FLAGS "-Werror")
|
||||
add_test( well_state ${EXECUTABLE_OUTPUT_PATH}/well_state )
|
||||
|
||||
add_executable( well_state_load well_state_load.c )
|
||||
target_link_libraries( well_state_load ecl_well )
|
||||
set_target_properties( well_state_load PROPERTIES COMPILE_FLAGS "-Werror")
|
||||
|
||||
add_executable( well_state_load_missing_RSEG well_state_load_missing_RSEG.c )
|
||||
target_link_libraries( well_state_load_missing_RSEG ecl_well )
|
||||
set_target_properties( well_state_load_missing_RSEG PROPERTIES COMPILE_FLAGS "-Werror")
|
||||
|
||||
|
||||
add_test( well_state_load1 ${EXECUTABLE_OUTPUT_PATH}/well_state_load ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID
|
||||
${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.X0030)
|
||||
|
||||
add_test( well_state_load2 ${EXECUTABLE_OUTPUT_PATH}/well_state_load ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/MSWcase/MSW_CASE.EGRID
|
||||
${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/MSWcase/MSW_CASE.X0021)
|
||||
|
||||
add_test( well_state_load3 ${EXECUTABLE_OUTPUT_PATH}/well_state_load ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Troll/MSW/MSW.EGRID
|
||||
${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Troll/MSW/MSW.X0123)
|
||||
|
||||
add_test( well_state_load4 ${EXECUTABLE_OUTPUT_PATH}/well_state_load ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Troll/MSW_LGR/LGR.EGRID
|
||||
${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Troll/MSW_LGR/LGR.X0095)
|
||||
|
||||
add_test( well_state_load5 ${EXECUTABLE_OUTPUT_PATH}/well_state_load ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/10kcase/TEST10K_FLT_LGR_NNC.EGRID
|
||||
${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/10kcase/TEST10K_FLT_LGR_NNC.X0061)
|
||||
|
||||
add_test( well_state_load_missing_RSEG1 ${EXECUTABLE_OUTPUT_PATH}/well_state_load_missing_RSEG ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/10kcase/TEST10K_FLT_LGR_NNC.EGRID
|
||||
${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/10kcase/TEST10K_FLT_LGR_NNC.X0061)
|
||||
|
||||
add_test( well_state_load_missing_RSEG2 ${EXECUTABLE_OUTPUT_PATH}/well_state_load_missing_RSEG ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Troll/MSW/MSW.EGRID
|
||||
${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Troll/MSW/MSW.X0123)
|
||||
|
||||
|
||||
add_executable( well_segment well_segment.c )
|
||||
target_link_libraries( well_segment ecl_well )
|
||||
set_target_properties( well_segment PROPERTIES COMPILE_FLAGS "-Werror")
|
||||
add_test( well_segment ${EXECUTABLE_OUTPUT_PATH}/well_segment )
|
||||
|
||||
add_executable( well_segment_conn well_segment_conn.c )
|
||||
target_link_libraries( well_segment_conn ecl_well )
|
||||
set_target_properties( well_segment_conn PROPERTIES COMPILE_FLAGS "-Werror")
|
||||
add_test( well_segment_conn ${EXECUTABLE_OUTPUT_PATH}/well_segment_conn )
|
||||
|
||||
add_executable( well_segment_load well_segment_load.c )
|
||||
target_link_libraries( well_segment_load ecl_well )
|
||||
set_target_properties( well_segment_load PROPERTIES COMPILE_FLAGS "-Werror")
|
||||
add_test( well_segment_load ${EXECUTABLE_OUTPUT_PATH}/well_segment_load ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/MSWcase/MSW_CASE.X0021)
|
||||
|
||||
|
||||
add_executable( well_segment_branch_conn_load well_segment_branch_conn_load.c )
|
||||
target_link_libraries( well_segment_branch_conn_load ecl_well )
|
||||
set_target_properties( well_segment_branch_conn_load PROPERTIES COMPILE_FLAGS "-Werror")
|
||||
add_test( well_segment_branch_conn_load ${EXECUTABLE_OUTPUT_PATH}/well_segment_branch_conn_load ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/MSWcase/MSW_CASE.X0021)
|
||||
|
||||
add_executable( well_info well_info.c )
|
||||
target_link_libraries( well_info ecl_well )
|
||||
set_target_properties( well_info PROPERTIES COMPILE_FLAGS "-Werror")
|
||||
add_test( well_info ${EXECUTABLE_OUTPUT_PATH}/well_info ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID )
|
||||
|
||||
|
||||
add_executable( well_segment_collection well_segment_collection.c )
|
||||
target_link_libraries( well_segment_collection ecl_well )
|
||||
set_target_properties( well_segment_collection PROPERTIES COMPILE_FLAGS "-Werror")
|
||||
add_test( well_segment_collection ${EXECUTABLE_OUTPUT_PATH}/well_segment_collection )
|
||||
|
||||
|
||||
add_executable( well_conn_load well_conn_load.c )
|
||||
target_link_libraries( well_conn_load ecl_well )
|
||||
set_target_properties( well_conn_load PROPERTIES COMPILE_FLAGS "-Werror")
|
||||
add_test( well_conn_load1 ${EXECUTABLE_OUTPUT_PATH}/well_conn_load ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.X0030 F)
|
||||
add_test( well_conn_load2 ${EXECUTABLE_OUTPUT_PATH}/well_conn_load ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/10kcase/TEST10K_FLT_LGR_NNC.X0021 F)
|
||||
add_test( well_conn_load3 ${EXECUTABLE_OUTPUT_PATH}/well_conn_load ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/MSWcase/MSW_CASE.X0021 T)
|
||||
add_test( well_conn_load4 ${EXECUTABLE_OUTPUT_PATH}/well_conn_load ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/AmalgLGRcase/TESTCASE_AMALG_LGR.X0021 F)
|
||||
add_test( well_conn_load5 ${EXECUTABLE_OUTPUT_PATH}/well_conn_load ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/DualPoro/DUALPORO.X0009 F)
|
||||
add_test( well_conn_load6 ${EXECUTABLE_OUTPUT_PATH}/well_conn_load ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/0.9.2_LGR/BASE_REF_XY3Z1_T30_WI.X0003 F)
|
||||
|
||||
add_executable( well_ts well_ts.c )
|
||||
target_link_libraries( well_ts ecl_well )
|
||||
add_test( well_ts ${EXECUTABLE_OUTPUT_PATH}/well_ts ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/CO2case/BASE_CASE )
|
||||
@ -106,27 +12,10 @@ add_test( well_dualp ${EXECUTABLE_OUTPUT_PATH}/well_dualp ${PROJECT_SOURCE_DIR}
|
||||
add_executable( well_lgr_load well_lgr_load.c )
|
||||
target_link_libraries( well_lgr_load ecl_well )
|
||||
|
||||
add_test( well_lgr_load1 ${EXECUTABLE_OUTPUT_PATH}/well_lgr_load ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/0.9.2_LGR/BASE_REF_XY3Z1_T30_WI.EGRID ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/0.9.2_LGR/BASE_REF_XY3Z1_T30_WI.X0003)
|
||||
add_test( well_lgr_load2 ${EXECUTABLE_OUTPUT_PATH}/well_lgr_load ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/AmalgLGRcase/TESTCASE_AMALG_LGR.EGRID ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/AmalgLGRcase/TESTCASE_AMALG_LGR.X0016)
|
||||
add_test( well_lgr_load1 ${EXECUTABLE_OUTPUT_PATH}/well_lgr_load ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/0.9.2_LGR/BASE_REF_XY3Z1_T30_WI.X0003)
|
||||
add_test( well_lgr_load2 ${EXECUTABLE_OUTPUT_PATH}/well_lgr_load ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/AmalgLGRcase/TESTCASE_AMALG_LGR.X0016)
|
||||
|
||||
set_property( TEST well_lgr_load1 PROPERTY LABELS StatoilData )
|
||||
set_property( TEST well_lgr_load2 PROPERTY LABELS StatoilData )
|
||||
set_property( TEST well_dualp PROPERTY LABELS StatoilData )
|
||||
set_property( TEST well_state_load1 PROPERTY LABELS StatoilData )
|
||||
set_property( TEST well_state_load2 PROPERTY LABELS StatoilData )
|
||||
set_property( TEST well_state_load3 PROPERTY LABELS StatoilData )
|
||||
set_property( TEST well_state_load4 PROPERTY LABELS StatoilData )
|
||||
set_property( TEST well_state_load5 PROPERTY LABELS StatoilData )
|
||||
set_property( TEST well_state_load_missing_RSEG1 PROPERTY LABELS StatoilData )
|
||||
set_property( TEST well_state_load_missing_RSEG2 PROPERTY LABELS StatoilData )
|
||||
set_property( TEST well_dualp PROPERTY LABELS StatoilData )
|
||||
set_property( TEST well_conn_load1 PROPERTY LABELS StatoilData )
|
||||
set_property( TEST well_conn_load2 PROPERTY LABELS StatoilData )
|
||||
set_property( TEST well_conn_load3 PROPERTY LABELS StatoilData )
|
||||
set_property( TEST well_conn_load4 PROPERTY LABELS StatoilData )
|
||||
set_property( TEST well_conn_load5 PROPERTY LABELS StatoilData )
|
||||
set_property( TEST well_conn_load6 PROPERTY LABELS StatoilData )
|
||||
set_property( TEST well_info PROPERTY LABELS StatoilData )
|
||||
set_property( TEST well_segment_load PROPERTY LABELS StatoilData )
|
||||
set_property( TEST well_segment_branch_conn_load PROPERTY LABELS StatoilData )
|
||||
set_property( TEST well_ts PROPERTY LABELS StatoilData )
|
||||
set_property( TEST well_lgr_load1 PROPERTY LABELS Statoil )
|
||||
set_property( TEST well_lgr_load2 PROPERTY LABELS Statoil )
|
||||
set_property( TEST well_dualp PROPERTY LABELS Statoil )
|
||||
set_property( TEST well_ts PROPERTY LABELS Statoil )
|
||||
|
@ -1,70 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'well_branch_collection.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/stringlist.h>
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/ecl/ecl_util.h>
|
||||
|
||||
|
||||
#include <ert/ecl_well/well_branch_collection.h>
|
||||
#include <ert/ecl_well/well_conn.h>
|
||||
#include <ert/ecl_well/well_const.h>
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
test_install_SIGNALS();
|
||||
|
||||
well_branch_collection_type * branches = well_branch_collection_alloc();
|
||||
double * rseg_data = util_calloc( 100 , sizeof * rseg_data );
|
||||
const double depth = 100;
|
||||
const double length = 20;
|
||||
const double total_length = 200;
|
||||
const double diameter = 10;
|
||||
|
||||
rseg_data[ RSEG_DEPTH_INDEX ] = depth;
|
||||
rseg_data[ RSEG_LENGTH_INDEX ] = length;
|
||||
rseg_data[ RSEG_TOTAL_LENGTH_INDEX ] = total_length;
|
||||
rseg_data[ RSEG_DIAMETER_INDEX ] = diameter;
|
||||
|
||||
test_assert_true( well_branch_collection_is_instance( branches ));
|
||||
test_assert_int_equal( well_branch_collection_get_size( branches ) , 0 );
|
||||
test_assert_NULL( well_branch_collection_iget_start_segment( branches , 0 ));
|
||||
test_assert_NULL( well_branch_collection_get_start_segment( branches , 0 ));
|
||||
test_assert_false( well_branch_collection_has_branch( branches , 0 ));
|
||||
{
|
||||
well_segment_type * segment1 = well_segment_alloc(189 , 99 , 78 , rseg_data);
|
||||
well_segment_type * segment2 = well_segment_alloc(200 , 189 , 78 , rseg_data);
|
||||
|
||||
test_assert_false( well_branch_collection_add_start_segment( branches , segment1 ));
|
||||
|
||||
test_assert_true( well_segment_link( segment2 , segment1 ));
|
||||
test_assert_true( well_branch_collection_add_start_segment( branches , segment2 ));
|
||||
|
||||
test_assert_int_equal( well_branch_collection_get_size( branches ) , 1 );
|
||||
test_assert_true( well_segment_is_instance( well_branch_collection_iget_start_segment( branches , 0 )));
|
||||
test_assert_true( well_segment_is_instance( well_branch_collection_get_start_segment( branches , 78 )));
|
||||
test_assert_true( well_branch_collection_has_branch( branches , 78 ));
|
||||
|
||||
}
|
||||
well_branch_collection_free( branches );
|
||||
|
||||
exit(0);
|
||||
}
|
123
ThirdParty/Ert/devel/libecl_well/tests/well_conn.c
vendored
123
ThirdParty/Ert/devel/libecl_well/tests/well_conn.c
vendored
@ -1,123 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'well_conn.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/stringlist.h>
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/ecl/ecl_util.h>
|
||||
|
||||
|
||||
#include <ert/ecl_well/well_conn_collection.h>
|
||||
#include <ert/ecl_well/well_conn.h>
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
int i = 10;
|
||||
int j = 5;
|
||||
int k = 16;
|
||||
bool open = true;
|
||||
test_install_SIGNALS();
|
||||
|
||||
{
|
||||
well_conn_dir_enum dir = well_conn_dirX;
|
||||
well_conn_type * conn = well_conn_alloc(i,j,k,dir,open);
|
||||
well_conn_type * conn2 = well_conn_alloc(i,j,k,dir,open);
|
||||
well_conn_type * conn3 = well_conn_alloc(i,j,k+1,dir,open);
|
||||
test_assert_not_NULL( conn );
|
||||
test_assert_true( well_conn_is_instance( conn ));
|
||||
test_assert_int_equal( i , well_conn_get_i( conn ));
|
||||
test_assert_int_equal( j , well_conn_get_j( conn ));
|
||||
test_assert_int_equal( k , well_conn_get_k( conn ));
|
||||
test_assert_int_equal( dir , well_conn_get_dir( conn ));
|
||||
test_assert_bool_equal( open , well_conn_open( conn ));
|
||||
test_assert_false( well_conn_MSW( conn ));
|
||||
test_assert_true( well_conn_matrix_connection( conn ));
|
||||
test_assert_true( well_conn_equal( conn , conn2 ));
|
||||
test_assert_false( well_conn_equal( conn , conn3 ));
|
||||
well_conn_free( conn );
|
||||
}
|
||||
|
||||
{
|
||||
well_conn_dir_enum dir = well_conn_fracX;
|
||||
well_conn_type * conn = well_conn_alloc(i,j,k,dir,open);
|
||||
test_assert_NULL( conn );
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
well_conn_dir_enum dir = well_conn_fracX;
|
||||
well_conn_type * conn = well_conn_alloc_fracture(i,j,k,dir,open);
|
||||
test_assert_not_NULL( conn );
|
||||
test_assert_int_equal( i , well_conn_get_i( conn ));
|
||||
test_assert_int_equal( j , well_conn_get_j( conn ));
|
||||
test_assert_int_equal( k , well_conn_get_k( conn ));
|
||||
test_assert_bool_equal( open , well_conn_open( conn ));
|
||||
test_assert_int_equal( dir , well_conn_get_dir( conn ));
|
||||
test_assert_false( well_conn_MSW( conn ));
|
||||
test_assert_false( well_conn_matrix_connection( conn ));
|
||||
test_assert_true( well_conn_fracture_connection( conn ));
|
||||
well_conn_free( conn );
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
well_conn_dir_enum dir = well_conn_dirX;
|
||||
well_conn_type * conn = well_conn_alloc_fracture(i,j,k,dir,open);
|
||||
test_assert_not_NULL( conn );
|
||||
}
|
||||
|
||||
{
|
||||
int segment = 16;
|
||||
well_conn_dir_enum dir = well_conn_dirX;
|
||||
well_conn_type * conn = well_conn_alloc_MSW(i,j,k,dir,open,segment);
|
||||
test_assert_not_NULL( conn );
|
||||
test_assert_int_equal( i , well_conn_get_i( conn ));
|
||||
test_assert_int_equal( j , well_conn_get_j( conn ));
|
||||
test_assert_int_equal( k , well_conn_get_k( conn ));
|
||||
test_assert_int_equal( segment , well_conn_get_segment( conn ));
|
||||
test_assert_bool_equal( open , well_conn_open( conn ));
|
||||
test_assert_int_equal( dir , well_conn_get_dir( conn ));
|
||||
test_assert_true( well_conn_MSW( conn ));
|
||||
test_assert_true( well_conn_matrix_connection( conn ));
|
||||
well_conn_free( conn );
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
int segment = 16;
|
||||
well_conn_dir_enum dir = well_conn_fracX;
|
||||
well_conn_type * conn = well_conn_alloc_fracture_MSW(i,j,k,dir,open,segment);
|
||||
test_assert_not_NULL( conn );
|
||||
test_assert_int_equal( i , well_conn_get_i( conn ));
|
||||
test_assert_int_equal( j , well_conn_get_j( conn ));
|
||||
test_assert_int_equal( k , well_conn_get_k( conn ));
|
||||
test_assert_int_equal( segment , well_conn_get_segment( conn ));
|
||||
test_assert_bool_equal( open , well_conn_open( conn ));
|
||||
test_assert_int_equal( dir , well_conn_get_dir( conn ));
|
||||
test_assert_true( well_conn_MSW( conn ));
|
||||
test_assert_false( well_conn_matrix_connection( conn ));
|
||||
well_conn_free( conn );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'well_conn_collection.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/stringlist.h>
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/ecl/ecl_util.h>
|
||||
|
||||
|
||||
#include <ert/ecl_well/well_conn_collection.h>
|
||||
#include <ert/ecl_well/well_conn.h>
|
||||
|
||||
|
||||
void test_empty() {
|
||||
well_conn_collection_type * wellcc = well_conn_collection_alloc( );
|
||||
test_assert_not_NULL( wellcc );
|
||||
test_assert_true( well_conn_collection_is_instance( wellcc ));
|
||||
|
||||
test_assert_int_equal( 0 , well_conn_collection_get_size( wellcc ));
|
||||
{
|
||||
well_conn_type * conn = well_conn_collection_iget( wellcc , 0 );
|
||||
test_assert_NULL( conn );
|
||||
}
|
||||
{
|
||||
const well_conn_type * conn = well_conn_collection_iget_const( wellcc , 10 );
|
||||
test_assert_NULL( conn );
|
||||
}
|
||||
|
||||
well_conn_collection_free( wellcc );
|
||||
}
|
||||
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
test_empty();
|
||||
exit(0);
|
||||
}
|
@ -1,104 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'well_conn_load.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/stringlist.h>
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/ecl/ecl_util.h>
|
||||
#include <ert/ecl/ecl_file.h>
|
||||
#include <ert/ecl/ecl_rsthead.h>
|
||||
#include <ert/ecl/ecl_kw_magic.h>
|
||||
|
||||
#include <ert/ecl_well/well_conn.h>
|
||||
#include <ert/ecl_well/well_conn_collection.h>
|
||||
#include <ert/ecl_well/well_const.h>
|
||||
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
const char * Xfile = argv[1];
|
||||
bool MSW;
|
||||
ecl_file_type * rst_file = ecl_file_open( Xfile , 0 );
|
||||
ecl_rsthead_type * rst_head = ecl_rsthead_alloc( rst_file );
|
||||
|
||||
test_install_SIGNALS();
|
||||
test_assert_true( util_sscanf_bool( argv[2] , &MSW ));
|
||||
test_assert_not_NULL( rst_file );
|
||||
test_assert_not_NULL( rst_head );
|
||||
|
||||
{
|
||||
int iwell;
|
||||
const ecl_kw_type * iwel_kw = ecl_file_iget_named_kw( rst_file , IWEL_KW , 0 );
|
||||
const ecl_kw_type * icon_kw = ecl_file_iget_named_kw( rst_file , ICON_KW , 0 );
|
||||
bool caseMSW = false;
|
||||
|
||||
for (iwell = 0; iwell < rst_head->nwells; iwell++) {
|
||||
const int iwel_offset = rst_head->niwelz * iwell;
|
||||
int num_connections = ecl_kw_iget_int( iwel_kw , iwel_offset + IWEL_CONNECTIONS_ITEM );
|
||||
int iconn;
|
||||
well_conn_collection_type * wellcc = well_conn_collection_alloc( );
|
||||
well_conn_collection_type * wellcc_ref = well_conn_collection_alloc();
|
||||
|
||||
for (iconn = 0; iconn < num_connections; iconn++) {
|
||||
well_conn_type * conn = well_conn_alloc_from_kw( icon_kw , rst_head , iwell , iconn );
|
||||
|
||||
test_assert_true( well_conn_is_instance( conn ));
|
||||
test_assert_not_NULL( conn );
|
||||
if (!MSW)
|
||||
test_assert_bool_equal( well_conn_MSW( conn ) , MSW);
|
||||
else
|
||||
caseMSW |= well_conn_MSW( conn );
|
||||
|
||||
well_conn_collection_add( wellcc , conn );
|
||||
well_conn_collection_add_ref( wellcc_ref , conn );
|
||||
test_assert_int_equal( iconn + 1 , well_conn_collection_get_size( wellcc ));
|
||||
test_assert_ptr_equal( well_conn_collection_iget_const( wellcc , iconn) , conn);
|
||||
test_assert_ptr_equal( well_conn_collection_iget_const( wellcc_ref , iconn) , conn);
|
||||
}
|
||||
well_conn_collection_free( wellcc_ref );
|
||||
{
|
||||
|
||||
int i;
|
||||
for (i=0; i < well_conn_collection_get_size( wellcc ); i++)
|
||||
test_assert_true( well_conn_is_instance( well_conn_collection_iget_const( wellcc , i )));
|
||||
|
||||
}
|
||||
{
|
||||
well_conn_collection_type * wellcc2 = well_conn_collection_alloc();
|
||||
int i;
|
||||
|
||||
test_assert_int_equal( well_conn_collection_get_size( wellcc ) ,
|
||||
well_conn_collection_load_from_kw( wellcc2 , iwel_kw , icon_kw , iwell , rst_head));
|
||||
|
||||
for (i=0; i < well_conn_collection_get_size( wellcc2 ); i++) {
|
||||
test_assert_true( well_conn_is_instance( well_conn_collection_iget_const( wellcc2 , i )));
|
||||
test_assert_true( well_conn_equal( well_conn_collection_iget_const( wellcc2 , i ) , well_conn_collection_iget_const( wellcc , i )));
|
||||
}
|
||||
well_conn_collection_free( wellcc2 );
|
||||
}
|
||||
well_conn_collection_free( wellcc );
|
||||
}
|
||||
test_assert_bool_equal( caseMSW , MSW);
|
||||
}
|
||||
|
||||
|
||||
exit( 0 );
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'well_conn.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/stringlist.h>
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/ecl/ecl_util.h>
|
||||
#include <ert/ecl/ecl_grid.h>
|
||||
|
||||
|
||||
#include <ert/ecl_well/well_info.h>
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
const char * grid_file = argv[1];
|
||||
|
||||
ecl_grid_type * grid = ecl_grid_alloc( grid_file );
|
||||
test_assert_not_NULL( grid );
|
||||
{
|
||||
well_info_type * well_info = well_info_alloc( grid );
|
||||
test_assert_not_NULL( well_info );
|
||||
well_info_free( well_info );
|
||||
}
|
||||
ecl_grid_free( grid );
|
||||
exit(0);
|
||||
}
|
@ -41,10 +41,12 @@ int main( int argc , char ** argv) {
|
||||
Killing with SIGKILL (-9) will not give a backtrace.*/
|
||||
signal(SIGABRT , util_abort_signal); /* Signal abort. */
|
||||
{
|
||||
ecl_grid_type * grid = ecl_grid_alloc( argv[1] );
|
||||
well_info_type * well_info = well_info_alloc( grid );
|
||||
|
||||
well_info_load_rstfile( well_info , argv[2]);
|
||||
well_info_type * well_info = well_info_alloc( NULL );
|
||||
int i;
|
||||
for (i=1; i < argc; i++) {
|
||||
printf("Loading file: %s \n",argv[i]);
|
||||
well_info_load_rstfile( well_info , argv[i]);
|
||||
}
|
||||
|
||||
// List all wells:
|
||||
{
|
||||
|
@ -1,115 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'well_segment.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/stringlist.h>
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/ecl/ecl_util.h>
|
||||
|
||||
|
||||
#include <ert/ecl_well/well_segment.h>
|
||||
#include <ert/ecl_well/well_const.h>
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
test_install_SIGNALS();
|
||||
double * rseg_data = util_calloc( 100 , sizeof * rseg_data );
|
||||
const double depth = 100;
|
||||
const double length = 20;
|
||||
const double total_length = 200;
|
||||
const double diameter = 10;
|
||||
|
||||
rseg_data[ RSEG_DEPTH_INDEX ] = depth;
|
||||
rseg_data[ RSEG_LENGTH_INDEX ] = length;
|
||||
rseg_data[ RSEG_TOTAL_LENGTH_INDEX ] = total_length;
|
||||
rseg_data[ RSEG_DIAMETER_INDEX ] = diameter;
|
||||
{
|
||||
int segment_id = 78;
|
||||
int outlet_segment_id = 100;
|
||||
int branch_nr = ECLIPSE_WELL_SEGMENT_BRANCH_MAIN_STEM_VALUE;
|
||||
well_segment_type * ws = well_segment_alloc(segment_id , outlet_segment_id , branch_nr, rseg_data);
|
||||
|
||||
test_assert_true( well_segment_is_instance( ws ));
|
||||
test_assert_int_equal( 0 , well_segment_get_link_count( ws ));
|
||||
test_assert_NULL( well_segment_get_outlet( ws ));
|
||||
test_assert_int_equal( well_segment_get_outlet_id( ws ) , outlet_segment_id );
|
||||
test_assert_int_equal( well_segment_get_branch_id( ws ) , branch_nr );
|
||||
test_assert_int_equal( well_segment_get_id( ws ) , segment_id );
|
||||
|
||||
test_assert_false( well_segment_nearest_wellhead( ws ));
|
||||
test_assert_true( well_segment_active( ws ));
|
||||
test_assert_true( well_segment_main_stem( ws ));
|
||||
|
||||
test_assert_double_equal( depth , well_segment_get_depth( ws ));
|
||||
test_assert_double_equal( length , well_segment_get_length( ws ));
|
||||
test_assert_double_equal( total_length , well_segment_get_total_length( ws ));
|
||||
test_assert_double_equal( diameter , well_segment_get_diameter( ws ));
|
||||
|
||||
well_segment_free( ws );
|
||||
}
|
||||
|
||||
{
|
||||
int outlet_segment_id = ECLIPSE_WELL_SEGMENT_OUTLET_END_VALUE;
|
||||
int branch_nr = 100;
|
||||
well_segment_type * ws = well_segment_alloc(12 , outlet_segment_id , branch_nr, rseg_data);
|
||||
|
||||
test_assert_true( well_segment_nearest_wellhead( ws ));
|
||||
test_assert_false( well_segment_main_stem( ws ));
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
int outlet_segment_id = ECLIPSE_WELL_SEGMENT_OUTLET_END_VALUE;
|
||||
int branch_nr = ECLIPSE_WELL_SEGMENT_BRANCH_INACTIVE_VALUE;
|
||||
well_segment_type * ws = well_segment_alloc(89 , outlet_segment_id , branch_nr, rseg_data);
|
||||
|
||||
test_assert_false( well_segment_active( ws ));
|
||||
}
|
||||
|
||||
{
|
||||
int branch_nr = ECLIPSE_WELL_SEGMENT_BRANCH_MAIN_STEM_VALUE;
|
||||
int outlet_id = 0;
|
||||
well_segment_type * outlet = well_segment_alloc(outlet_id , ECLIPSE_WELL_SEGMENT_OUTLET_END_VALUE , branch_nr, rseg_data);
|
||||
well_segment_type * ws = well_segment_alloc(100 , outlet_id , branch_nr, rseg_data);
|
||||
|
||||
test_assert_true( well_segment_link( ws , outlet ));
|
||||
test_assert_ptr_equal( well_segment_get_outlet( ws ) , outlet );
|
||||
test_assert_int_equal( well_segment_get_link_count( outlet ) , 1 );
|
||||
test_assert_ptr_not_equal( ws , well_segment_get_outlet( ws ));
|
||||
|
||||
well_segment_link_strict( ws , outlet ); // This relinks - not very logical; refcount gets wrong.
|
||||
well_segment_free( ws );
|
||||
}
|
||||
|
||||
{
|
||||
int branch_nr = ECLIPSE_WELL_SEGMENT_BRANCH_MAIN_STEM_VALUE;
|
||||
int outlet_id = 0;
|
||||
well_segment_type * outlet = well_segment_alloc(outlet_id , ECLIPSE_WELL_SEGMENT_OUTLET_END_VALUE , branch_nr , rseg_data);
|
||||
well_segment_type * ws = well_segment_alloc(100 , outlet_id + 1, branch_nr, rseg_data);
|
||||
|
||||
test_assert_false( well_segment_link( ws , outlet ));
|
||||
test_assert_NULL( well_segment_get_outlet( ws ) );
|
||||
test_assert_int_equal( well_segment_get_link_count( outlet ) , 0 );
|
||||
|
||||
well_segment_free( ws );
|
||||
}
|
||||
free( rseg_data );
|
||||
exit(0);
|
||||
}
|
@ -1,106 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'well_segment_conn_load.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/stringlist.h>
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/ecl/ecl_util.h>
|
||||
#include <ert/ecl/ecl_file.h>
|
||||
#include <ert/ecl/ecl_rsthead.h>
|
||||
#include <ert/ecl/ecl_kw_magic.h>
|
||||
#include <ert/ecl/ecl_grid.h>
|
||||
|
||||
#include <ert/ecl_well/well_conn_collection.h>
|
||||
#include <ert/ecl_well/well_segment.h>
|
||||
#include <ert/ecl_well/well_const.h>
|
||||
#include <ert/ecl_well/well_segment_collection.h>
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
const char * Xfile = argv[1];
|
||||
ecl_file_type * rst_file = ecl_file_open( Xfile , 0 );
|
||||
ecl_rsthead_type * rst_head = ecl_rsthead_alloc( rst_file );
|
||||
const ecl_kw_type * iwel_kw = ecl_file_iget_named_kw( rst_file , IWEL_KW , 0 );
|
||||
const ecl_kw_type * iseg_kw = ecl_file_iget_named_kw( rst_file , ISEG_KW , 0 );
|
||||
const ecl_kw_type * rseg_kw = ecl_file_iget_named_kw( rst_file , RSEG_KW , 0 );
|
||||
const ecl_kw_type * icon_kw = ecl_file_iget_named_kw( rst_file , ICON_KW , 0 );
|
||||
|
||||
test_install_SIGNALS();
|
||||
test_assert_not_NULL( rst_file );
|
||||
test_assert_not_NULL( rst_head );
|
||||
{
|
||||
int well_nr;
|
||||
for (well_nr = 0; well_nr < rst_head->nwells; well_nr++) {
|
||||
well_conn_collection_type * connections = well_conn_collection_alloc();
|
||||
well_conn_collection_load_from_kw( connections , iwel_kw , icon_kw , well_nr , rst_head);
|
||||
{
|
||||
well_segment_collection_type * segments = well_segment_collection_alloc();
|
||||
|
||||
if (well_segment_collection_load_from_kw( segments , well_nr , iwel_kw , iseg_kw , rseg_kw , rst_head )) {
|
||||
well_branch_collection_type * branches = well_branch_collection_alloc();
|
||||
|
||||
test_assert_true( well_segment_well_is_MSW( well_nr , iwel_kw , rst_head));
|
||||
well_segment_collection_link( segments );
|
||||
{
|
||||
int is;
|
||||
for (is=0; is < well_segment_collection_get_size( segments ); is++) {
|
||||
well_segment_type * segment = well_segment_collection_iget( segments , is );
|
||||
|
||||
if (well_segment_nearest_wellhead( segment ))
|
||||
test_assert_NULL( well_segment_get_outlet( segment ));
|
||||
else
|
||||
test_assert_not_NULL( well_segment_get_outlet( segment ));
|
||||
|
||||
test_assert_int_not_equal( well_segment_get_id( segment ) , well_segment_get_outlet_id( segment ));
|
||||
test_assert_ptr_not_equal( segment , well_segment_get_outlet( segment ));
|
||||
}
|
||||
}
|
||||
well_segment_collection_add_branches( segments , branches );
|
||||
{
|
||||
int ib;
|
||||
for (ib = 0; ib < well_branch_collection_get_size( branches ); ib++) {
|
||||
const well_segment_type * start_segment = well_branch_collection_iget_start_segment( branches , ib );
|
||||
const well_segment_type * segment = start_segment;
|
||||
|
||||
printf("Branch %d " , ib );
|
||||
while (segment) {
|
||||
printf("%d -> ",well_segment_get_id( segment ));
|
||||
segment = well_segment_get_outlet( segment );
|
||||
}
|
||||
printf(" X \n");
|
||||
}
|
||||
}
|
||||
well_segment_collection_add_connections( segments , ECL_GRID_GLOBAL_GRID , connections );
|
||||
well_branch_collection_free( branches );
|
||||
} else
|
||||
test_assert_false( well_segment_well_is_MSW( well_nr , iwel_kw , rst_head ));
|
||||
|
||||
well_segment_collection_free( segments );
|
||||
}
|
||||
well_conn_collection_free( connections );
|
||||
}
|
||||
}
|
||||
|
||||
ecl_file_close( rst_file );
|
||||
ecl_rsthead_free( rst_head );
|
||||
exit(0);
|
||||
}
|
@ -1,87 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'well_segment_collection.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/stringlist.h>
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/ecl/ecl_util.h>
|
||||
|
||||
|
||||
#include <ert/ecl_well/well_segment_collection.h>
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
test_install_SIGNALS();
|
||||
|
||||
double * rseg_data = util_calloc( 100 , sizeof * rseg_data );
|
||||
well_segment_collection_type * sc = well_segment_collection_alloc();
|
||||
test_assert_not_NULL( sc );
|
||||
test_assert_int_equal( well_segment_collection_get_size( sc ) , 0 );
|
||||
|
||||
{
|
||||
int outlet_segment_id = ECLIPSE_WELL_SEGMENT_OUTLET_END_VALUE;
|
||||
int branch_nr = ECLIPSE_WELL_SEGMENT_BRANCH_INACTIVE_VALUE;
|
||||
well_segment_type * ws = well_segment_alloc(89 , outlet_segment_id , branch_nr, rseg_data);
|
||||
|
||||
well_segment_collection_add( sc , ws );
|
||||
test_assert_int_equal( well_segment_collection_get_size( sc ) , 1);
|
||||
test_assert_ptr_equal( well_segment_collection_iget( sc , 0 ) , ws );
|
||||
|
||||
test_assert_false( well_segment_collection_has_segment( sc , 451 ));
|
||||
test_assert_true( well_segment_collection_has_segment( sc , 89 ));
|
||||
test_assert_ptr_equal( well_segment_collection_get( sc , 89 ) , ws );
|
||||
}
|
||||
|
||||
{
|
||||
int outlet_segment_id = ECLIPSE_WELL_SEGMENT_OUTLET_END_VALUE;
|
||||
int branch_nr = ECLIPSE_WELL_SEGMENT_BRANCH_INACTIVE_VALUE;
|
||||
well_segment_type * ws = well_segment_alloc(90 , outlet_segment_id , branch_nr , rseg_data);
|
||||
|
||||
well_segment_collection_add( sc , ws );
|
||||
test_assert_int_equal( well_segment_collection_get_size( sc ) , 2);
|
||||
test_assert_ptr_equal( well_segment_collection_iget( sc , 1 ) , ws );
|
||||
|
||||
test_assert_false( well_segment_collection_has_segment( sc , 451 ));
|
||||
test_assert_true( well_segment_collection_has_segment( sc , 89 ));
|
||||
test_assert_true( well_segment_collection_has_segment( sc , 90 ));
|
||||
test_assert_ptr_equal( well_segment_collection_get( sc , 90 ) , ws );
|
||||
test_assert_NULL( well_segment_collection_get( sc , 76 ));
|
||||
}
|
||||
|
||||
{
|
||||
int outlet_segment_id = ECLIPSE_WELL_SEGMENT_OUTLET_END_VALUE;
|
||||
int branch_nr = ECLIPSE_WELL_SEGMENT_BRANCH_INACTIVE_VALUE;
|
||||
well_segment_type * ws = well_segment_alloc(89 , outlet_segment_id , branch_nr, rseg_data);
|
||||
|
||||
well_segment_collection_add( sc , ws );
|
||||
test_assert_int_equal( well_segment_collection_get_size( sc ) , 2);
|
||||
test_assert_ptr_equal( well_segment_collection_iget( sc , 0 ) , ws );
|
||||
|
||||
test_assert_false( well_segment_collection_has_segment( sc , 451 ));
|
||||
test_assert_true( well_segment_collection_has_segment( sc , 89 ));
|
||||
test_assert_ptr_equal( well_segment_collection_get( sc , 89 ) , ws );
|
||||
}
|
||||
|
||||
free( rseg_data );
|
||||
well_segment_collection_free( sc );
|
||||
|
||||
exit(0);
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'well_segment_conn.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/stringlist.h>
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/ecl/ecl_util.h>
|
||||
#include <ert/ecl/ecl_grid.h>
|
||||
|
||||
#include <ert/ecl_well/well_segment.h>
|
||||
#include <ert/ecl_well/well_conn.h>
|
||||
#include <ert/ecl_well/well_conn_collection.h>
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
test_install_SIGNALS();
|
||||
double * rseg_data = util_calloc( 100 , sizeof * rseg_data );
|
||||
{
|
||||
int segment_id = 78;
|
||||
int outlet_segment_id = 100;
|
||||
int branch_nr = ECLIPSE_WELL_SEGMENT_BRANCH_MAIN_STEM_VALUE;
|
||||
well_segment_type * ws = well_segment_alloc(segment_id , outlet_segment_id , branch_nr, rseg_data);
|
||||
well_conn_type * conn1 = well_conn_alloc_MSW(1,1,1,true,well_conn_dirX,segment_id);
|
||||
well_conn_type * conn2 = well_conn_alloc_MSW(1,1,1,true,well_conn_dirX,segment_id + 1);
|
||||
|
||||
test_assert_false( well_segment_has_global_grid_connections( ws ));
|
||||
|
||||
test_assert_true( well_segment_add_connection( ws , ECL_GRID_GLOBAL_GRID , conn1 ));
|
||||
test_assert_false( well_segment_add_connection( ws , ECL_GRID_GLOBAL_GRID , conn2 ));
|
||||
|
||||
test_assert_true( well_segment_has_grid_connections( ws , ECL_GRID_GLOBAL_GRID ));
|
||||
test_assert_true( well_segment_has_global_grid_connections( ws ));
|
||||
test_assert_false( well_segment_has_grid_connections( ws , "DoesNotExist"));
|
||||
|
||||
test_assert_true( well_conn_collection_is_instance( well_segment_get_connections( ws , ECL_GRID_GLOBAL_GRID)));
|
||||
test_assert_true( well_conn_collection_is_instance( well_segment_get_global_connections( ws)));
|
||||
test_assert_NULL( well_segment_get_connections( ws , "doesNotExist"));
|
||||
}
|
||||
free( rseg_data );
|
||||
exit(0);
|
||||
}
|
@ -1,107 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'well_segment_conn_load.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/stringlist.h>
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/ecl/ecl_util.h>
|
||||
#include <ert/ecl/ecl_file.h>
|
||||
#include <ert/ecl/ecl_rsthead.h>
|
||||
#include <ert/ecl/ecl_kw_magic.h>
|
||||
#include <ert/ecl/ecl_grid.h>
|
||||
|
||||
#include <ert/ecl_well/well_conn_collection.h>
|
||||
#include <ert/ecl_well/well_segment.h>
|
||||
#include <ert/ecl_well/well_const.h>
|
||||
#include <ert/ecl_well/well_segment_collection.h>
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
const char * Xfile = argv[1];
|
||||
ecl_file_type * rst_file = ecl_file_open( Xfile , 0 );
|
||||
ecl_rsthead_type * rst_head = ecl_rsthead_alloc( rst_file );
|
||||
const ecl_kw_type * iwel_kw = ecl_file_iget_named_kw( rst_file , IWEL_KW , 0 );
|
||||
const ecl_kw_type * iseg_kw = ecl_file_iget_named_kw( rst_file , ISEG_KW , 0 );
|
||||
const ecl_kw_type * rseg_kw = ecl_file_iget_named_kw( rst_file , RSEG_KW , 0 );
|
||||
const ecl_kw_type * icon_kw = ecl_file_iget_named_kw( rst_file , ICON_KW , 0 );
|
||||
|
||||
test_install_SIGNALS();
|
||||
test_assert_not_NULL( rst_file );
|
||||
test_assert_not_NULL( rst_head );
|
||||
{
|
||||
int well_nr;
|
||||
for (well_nr = 0; well_nr < rst_head->nwells; well_nr++) {
|
||||
well_conn_collection_type * connections = well_conn_collection_alloc();
|
||||
well_conn_collection_load_from_kw( connections , iwel_kw , icon_kw , well_nr , rst_head);
|
||||
{
|
||||
well_segment_collection_type * segments = well_segment_collection_alloc();
|
||||
|
||||
if (well_segment_collection_load_from_kw( segments , well_nr , iwel_kw , iseg_kw , rseg_kw , rst_head )) {
|
||||
well_branch_collection_type * branches = well_branch_collection_alloc();
|
||||
|
||||
test_assert_true( well_segment_well_is_MSW( well_nr , iwel_kw , rst_head));
|
||||
well_segment_collection_link( segments );
|
||||
{
|
||||
int is;
|
||||
for (is=0; is < well_segment_collection_get_size( segments ); is++) {
|
||||
well_segment_type * segment = well_segment_collection_iget( segments , is );
|
||||
|
||||
if (well_segment_nearest_wellhead( segment ))
|
||||
test_assert_NULL( well_segment_get_outlet( segment ));
|
||||
else
|
||||
test_assert_not_NULL( well_segment_get_outlet( segment ));
|
||||
|
||||
test_assert_ptr_not_equal( segment , well_segment_get_outlet( segment ));
|
||||
}
|
||||
}
|
||||
|
||||
well_segment_collection_add_branches( segments , branches );
|
||||
{
|
||||
int ib;
|
||||
for (ib = 0; ib < well_branch_collection_get_size( branches ); ib++) {
|
||||
const well_segment_type * start_segment = well_branch_collection_iget_start_segment( branches , ib );
|
||||
const well_segment_type * segment = start_segment;
|
||||
|
||||
printf("Branch %d/%d " , ib , well_branch_collection_get_size( branches ) );
|
||||
while (segment) {
|
||||
printf("[%p]%d -> \n",segment , well_segment_get_id( segment ));
|
||||
segment = well_segment_get_outlet( segment );
|
||||
}
|
||||
printf("\n");
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
well_segment_collection_add_connections( segments , ECL_GRID_GLOBAL_GRID , connections );
|
||||
well_branch_collection_free( branches );
|
||||
} else
|
||||
test_assert_false( well_segment_well_is_MSW( well_nr , iwel_kw , rst_head ));
|
||||
|
||||
well_segment_collection_free( segments );
|
||||
}
|
||||
well_conn_collection_free( connections );
|
||||
}
|
||||
}
|
||||
|
||||
ecl_file_close( rst_file );
|
||||
ecl_rsthead_free( rst_head );
|
||||
exit(0);
|
||||
}
|
@ -1,88 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'well_segment_load.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/stringlist.h>
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/ecl/ecl_util.h>
|
||||
#include <ert/ecl/ecl_file.h>
|
||||
#include <ert/ecl/ecl_rsthead.h>
|
||||
#include <ert/ecl/ecl_kw_magic.h>
|
||||
|
||||
#include <ert/ecl_well/well_segment.h>
|
||||
#include <ert/ecl_well/well_const.h>
|
||||
#include <ert/ecl_well/well_segment_collection.h>
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
const char * Xfile = argv[1];
|
||||
ecl_file_type * rst_file = ecl_file_open( Xfile , 0 );
|
||||
ecl_rsthead_type * rst_head = ecl_rsthead_alloc( rst_file );
|
||||
const ecl_kw_type * iwel_kw = ecl_file_iget_named_kw( rst_file , IWEL_KW , 0 );
|
||||
const ecl_kw_type * iseg_kw = ecl_file_iget_named_kw( rst_file , ISEG_KW , 0 );
|
||||
const ecl_kw_type * rseg_kw = ecl_file_iget_named_kw( rst_file , RSEG_KW , 0 );
|
||||
|
||||
test_install_SIGNALS();
|
||||
test_assert_not_NULL( rst_file );
|
||||
test_assert_not_NULL( rst_head );
|
||||
|
||||
{
|
||||
int well_nr;
|
||||
|
||||
for (well_nr = 0; well_nr < rst_head->nwells; well_nr++) {
|
||||
int iwel_offset = rst_head->niwelz * well_nr;
|
||||
well_segment_collection_type * segments = well_segment_collection_alloc();
|
||||
int seg_well_nr = ecl_kw_iget_int( iwel_kw , iwel_offset + IWEL_SEGMENTED_WELL_NR_ITEM) - 1; // -1: Ordinary well.
|
||||
if (seg_well_nr >= 0) {
|
||||
int segment_id;
|
||||
int segment_count = 0;
|
||||
|
||||
for (segment_id = 0; segment_id < rst_head->nsegmx; segment_id++) {
|
||||
well_segment_type * segment = well_segment_alloc_from_kw( iseg_kw , rseg_kw , rst_head , seg_well_nr , segment_id );
|
||||
|
||||
test_assert_true( well_segment_is_instance( segment ));
|
||||
|
||||
if (well_segment_active( segment )) {
|
||||
well_segment_collection_add( segments , segment );
|
||||
test_assert_int_equal( well_segment_collection_get_size( segments ) , segment_count + 1);
|
||||
test_assert_ptr_equal( well_segment_collection_iget( segments , segment_count) , segment );
|
||||
segment_count++;
|
||||
} else
|
||||
well_segment_free( segment );
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
well_segment_collection_type * segments2 = well_segment_collection_alloc();
|
||||
test_assert_int_equal( well_segment_collection_load_from_kw( segments2 , well_nr , iwel_kw , iseg_kw , rseg_kw , rst_head ) ,
|
||||
well_segment_collection_get_size( segments));
|
||||
|
||||
well_segment_collection_link( segments );
|
||||
well_segment_collection_link( segments2 );
|
||||
well_segment_collection_free( segments );
|
||||
well_segment_collection_free( segments2 );
|
||||
}
|
||||
}
|
||||
}
|
||||
ecl_file_close( rst_file );
|
||||
ecl_rsthead_free( rst_head );
|
||||
exit(0);
|
||||
}
|
@ -1,67 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'well_state.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/stringlist.h>
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/ecl/ecl_util.h>
|
||||
|
||||
#include <ert/ecl_well/well_state.h>
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
test_install_SIGNALS();
|
||||
|
||||
test_assert_int_equal( well_state_translate_ecl_type_int( IWEL_UNDOCUMENTED_ZERO) , UNDOCUMENTED_ZERO);
|
||||
test_assert_int_equal( well_state_translate_ecl_type_int( IWEL_PRODUCER) , PRODUCER);
|
||||
test_assert_int_equal( well_state_translate_ecl_type_int( IWEL_WATER_INJECTOR) , WATER_INJECTOR);
|
||||
test_assert_int_equal( well_state_translate_ecl_type_int( IWEL_GAS_INJECTOR) , GAS_INJECTOR);
|
||||
test_assert_int_equal( well_state_translate_ecl_type_int( IWEL_OIL_INJECTOR) , OIL_INJECTOR);
|
||||
|
||||
{
|
||||
const char * well_name = "WELL";
|
||||
int report_nr = 100;
|
||||
int global_well_nr = 67;
|
||||
time_t valid_from = -1;
|
||||
bool open = false;
|
||||
well_type_enum type = GAS_INJECTOR;
|
||||
|
||||
well_state_type * well_state = well_state_alloc(well_name , global_well_nr , open , type , report_nr , valid_from);
|
||||
test_assert_true( well_state_is_instance( well_state) );
|
||||
|
||||
test_assert_false( well_state_is_MSW( well_state ));
|
||||
test_assert_string_equal( well_name , well_state_get_name( well_state ));
|
||||
test_assert_int_equal( global_well_nr , well_state_get_well_nr( well_state ));
|
||||
test_assert_bool_equal( open , well_state_is_open( well_state ));
|
||||
test_assert_int_equal( type , well_state_get_type( well_state ));
|
||||
test_assert_int_equal( report_nr , well_state_get_report_nr( well_state ));
|
||||
test_assert_time_t_equal( valid_from , well_state_get_sim_time( well_state ));
|
||||
|
||||
test_assert_NULL( well_state_get_global_connections( well_state ));
|
||||
test_assert_false( well_state_has_global_connections( well_state ));
|
||||
test_assert_NULL( well_state_get_grid_connections( well_state , "GRID"));
|
||||
test_assert_false( well_state_has_grid_connections( well_state , "GRID"));
|
||||
|
||||
well_state_free( well_state );
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
@ -1,78 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2013 Statoil ASA, Norway.
|
||||
|
||||
The file 'well_state_load.c' is part of ERT - Ensemble based Reservoir Tool.
|
||||
|
||||
ERT is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
for more details.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include <ert/util/test_util.h>
|
||||
#include <ert/util/stringlist.h>
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/ecl/ecl_util.h>
|
||||
#include <ert/ecl/ecl_grid.h>
|
||||
#include <ert/ecl/ecl_file.h>
|
||||
#include <ert/ecl/ecl_kw_magic.h>
|
||||
|
||||
#include <ert/ecl_well/well_state.h>
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
test_install_SIGNALS();
|
||||
{
|
||||
const char * grid_file = argv[1];
|
||||
const char * rst_file_name = argv[2];
|
||||
|
||||
ecl_grid_type * grid = ecl_grid_alloc( grid_file );
|
||||
ecl_file_type * rst_file = ecl_file_open( rst_file_name , 0);
|
||||
ecl_rsthead_type * header = ecl_rsthead_alloc( rst_file );
|
||||
const char * well_name = "WELL";
|
||||
int report_nr = 100;
|
||||
time_t valid_from = -1;
|
||||
bool open = false;
|
||||
well_type_enum type = GAS_INJECTOR;
|
||||
int global_well_nr = 0;
|
||||
|
||||
for (global_well_nr = 0; global_well_nr < header->nwells; global_well_nr++) {
|
||||
well_state_type * well_state = well_state_alloc(well_name , global_well_nr , open , type , report_nr , valid_from);
|
||||
test_assert_true( well_state_is_instance( well_state) );
|
||||
well_state_add_connections( well_state , grid , rst_file , 0 );
|
||||
|
||||
test_assert_true( well_state_has_grid_connections( well_state , ECL_GRID_GLOBAL_GRID ));
|
||||
test_assert_false( well_state_has_grid_connections( well_state , "???" ));
|
||||
test_assert_true( well_state_has_global_connections( well_state ));
|
||||
|
||||
well_state_add_MSW( well_state , rst_file , global_well_nr );
|
||||
{
|
||||
const well_segment_collection_type * segments = well_state_get_segments( well_state );
|
||||
const well_branch_collection_type * branches = well_state_get_branches( well_state );
|
||||
|
||||
if (well_state_is_MSW( well_state )) {
|
||||
test_assert_true( ecl_file_has_kw( rst_file , ISEG_KW ));
|
||||
test_assert_int_not_equal( well_segment_collection_get_size( segments ) , 0);
|
||||
test_assert_int_not_equal( well_branch_collection_get_size( branches ) , 0);
|
||||
} else {
|
||||
test_assert_int_equal( well_segment_collection_get_size( segments ) , 0);
|
||||
test_assert_int_equal( well_branch_collection_get_size( branches ) , 0);
|
||||
test_assert_false( well_state_is_MSW( well_state ));
|
||||
}
|
||||
}
|
||||
well_state_free( well_state );
|
||||
}
|
||||
}
|
||||
|
||||
exit(0);
|
||||
}
|
@ -23,16 +23,13 @@
|
||||
#include <ert/util/util.h>
|
||||
|
||||
#include <ert/ecl/ecl_util.h>
|
||||
#include <ert/ecl/ecl_grid.h>
|
||||
|
||||
#include <ert/ecl_well/well_info.h>
|
||||
|
||||
|
||||
int main(int argc , char ** argv) {
|
||||
const char * case_path = argv[1];
|
||||
char * grid_file = util_alloc_filename(NULL , case_path, "EGRID");
|
||||
stringlist_type * file_list = stringlist_alloc_new( );
|
||||
ecl_grid_type * grid = ecl_grid_alloc( grid_file );
|
||||
ecl_util_select_filelist( NULL , case_path , ECL_RESTART_FILE , false , file_list);
|
||||
|
||||
printf("Searching in:%s \n",case_path);
|
||||
@ -53,7 +50,7 @@ int main(int argc , char ** argv) {
|
||||
}
|
||||
}
|
||||
{
|
||||
well_info_type * well_info = well_info_alloc( grid );
|
||||
well_info_type * well_info = well_info_alloc( NULL );
|
||||
int i;
|
||||
for (i=0; i < stringlist_get_size( file_list ); i++)
|
||||
well_info_load_rstfile( well_info , stringlist_iget(file_list , i));
|
||||
@ -61,7 +58,7 @@ int main(int argc , char ** argv) {
|
||||
}
|
||||
|
||||
{
|
||||
well_info_type * well_info = well_info_alloc( grid );
|
||||
well_info_type * well_info = well_info_alloc( NULL );
|
||||
int i;
|
||||
stringlist_reverse( file_list );
|
||||
for (i=0; i < stringlist_get_size( file_list ); i++)
|
||||
|
@ -114,102 +114,94 @@ from PyQt4 import QtGui, QtCore
|
||||
import sys
|
||||
import os
|
||||
|
||||
|
||||
from ert.ert.ertwrapper import ErtWrapper
|
||||
|
||||
import ert_gui.widgets.util
|
||||
import ert_gui.widgets.help
|
||||
ert_gui.widgets.help.help_prefix = os.getenv("ERT_SHARE_PATH")+ "/gui/help/"
|
||||
ert_gui.widgets.util.img_prefix = os.getenv("ERT_SHARE_PATH")+ "/gui/img/"
|
||||
ert_gui.widgets.help.help_prefix = os.getenv("GERT_SHARE_PATH")+ "/help/"
|
||||
ert_gui.widgets.util.img_prefix = os.getenv("GERT_SHARE_PATH")+ "/img/"
|
||||
|
||||
|
||||
from ert.enkf.enkf_main import EnKFMain
|
||||
|
||||
from ert_gui.newconfig import NewConfigurationDialog
|
||||
|
||||
app = QtGui.QApplication(sys.argv) #Early so that QT is initialized before other imports
|
||||
|
||||
from ert_gui.pages.application import Application
|
||||
from ert_gui.pages.init.initpanel import InitPanel
|
||||
from ert_gui.pages.run.runpanel import RunPanel
|
||||
from ert_gui.pages.config.configpages import ConfigPages
|
||||
from ert_gui.pages.plot.plotpanel import PlotPanel
|
||||
from ert_gui.widgets.helpedwidget import ContentModel
|
||||
from ert_gui.widgets.util import resourceImage, resourceIcon
|
||||
|
||||
|
||||
|
||||
import matplotlib
|
||||
print "PyQt4 version: ", QtCore.qVersion()
|
||||
print "matplotlib version: ", matplotlib.__version__
|
||||
|
||||
def main():
|
||||
app = QtGui.QApplication(sys.argv) #Early so that QT is initialized before other imports
|
||||
from ert_gui.pages.config.configpages import ConfigPages
|
||||
from ert_gui.pages.plot.plotpanel import PlotPanel
|
||||
splash = QtGui.QSplashScreen(resourceImage("splash") , QtCore.Qt.WindowStaysOnTopHint)
|
||||
splash.show()
|
||||
splash.showMessage("Starting up...", color=QtCore.Qt.white)
|
||||
app.processEvents()
|
||||
|
||||
splash = QtGui.QSplashScreen(resourceImage("newsplash") , QtCore.Qt.WindowStaysOnTopHint)
|
||||
splash.show()
|
||||
splash.showMessage("Starting up...", color=QtCore.Qt.white)
|
||||
app.processEvents()
|
||||
window = Application()
|
||||
|
||||
window = Application()
|
||||
splash.showMessage("Bootstrapping...", color=QtCore.Qt.white)
|
||||
app.processEvents()
|
||||
|
||||
splash.showMessage("Bootstrapping...", color=QtCore.Qt.white)
|
||||
app.processEvents()
|
||||
ert = ErtWrapper( )
|
||||
strict = True
|
||||
site_config = os.getenv("ERT_SITE_CONFIG")
|
||||
if len(sys.argv) == 1:
|
||||
print "-----------------------------------------------------------------"
|
||||
print "-- You must supply the name of configuration file as the first --"
|
||||
print "-- commandline argument: --"
|
||||
print "-- --"
|
||||
print "-- bash% gert <config_file> --"
|
||||
print "-- --"
|
||||
print "-- If the configuration file does not exist, gert will create --"
|
||||
print "-- create a new configuration file. --"
|
||||
print "-----------------------------------------------------------------"
|
||||
sys.exit( )
|
||||
|
||||
ert = ErtWrapper( )
|
||||
strict = True
|
||||
site_config = os.getenv("ERT_SITE_CONFIG")
|
||||
if len(sys.argv) == 1:
|
||||
print "-----------------------------------------------------------------"
|
||||
print "-- You must supply the name of configuration file as the first --"
|
||||
print "-- commandline argument: --"
|
||||
print "-- --"
|
||||
print "-- bash% gert <config_file> --"
|
||||
print "-- --"
|
||||
print "-- If the configuration file does not exist, gert will create --"
|
||||
print "-- create a new configuration file. --"
|
||||
print "-----------------------------------------------------------------"
|
||||
#sys.exit(0)
|
||||
enkf_config = sys.argv[1]
|
||||
if not os.path.exists(enkf_config):
|
||||
print "Trying to start new config"
|
||||
new_configuration_dialog = NewConfigurationDialog(enkf_config)
|
||||
success = new_configuration_dialog.exec_()
|
||||
if not success:
|
||||
print "Can not run without a configuration file."
|
||||
sys.exit(1)
|
||||
else:
|
||||
enkf_config = sys.argv[1]
|
||||
if not os.path.exists(enkf_config):
|
||||
print "Trying to start new config"
|
||||
new_configuration_dialog = NewConfigurationDialog(enkf_config)
|
||||
success = new_configuration_dialog.exec_()
|
||||
if not success:
|
||||
print "Can not run without a configuration file."
|
||||
sys.exit(1)
|
||||
else:
|
||||
enkf_config = new_configuration_dialog.getConfigurationPath()
|
||||
firste_case_name = new_configuration_dialog.getCaseName()
|
||||
dbase_type = new_configuration_dialog.getDBaseType()
|
||||
num_realizations = new_configuration_dialog.getNumberOfRealizations()
|
||||
storage_path = new_configuration_dialog.getStoragePath()
|
||||
enkf_config = new_configuration_dialog.getConfigurationPath()
|
||||
firste_case_name = new_configuration_dialog.getCaseName()
|
||||
dbase_type = new_configuration_dialog.getDBaseType()
|
||||
num_realizations = new_configuration_dialog.getNumberOfRealizations()
|
||||
storage_path = new_configuration_dialog.getStoragePath()
|
||||
ert.enkf.enkf_main_create_new_config(enkf_config, storage_path , firste_case_name, dbase_type, num_realizations)
|
||||
strict = False
|
||||
|
||||
EnKFMain.create_new_config(enkf_config, storage_path , firste_case_name, dbase_type, num_realizations)
|
||||
strict = False
|
||||
ert.bootstrap(enkf_config, site_config = site_config, strict = strict)
|
||||
window.setSaveFunction(ert.save)
|
||||
|
||||
ert.bootstrap(enkf_config, site_config = site_config, strict = strict)
|
||||
window.setSaveFunction(ert.save)
|
||||
splash.showMessage("Creating GUI...", color=QtCore.Qt.white)
|
||||
app.processEvents()
|
||||
|
||||
splash.showMessage("Creating GUI...", color=QtCore.Qt.white)
|
||||
app.processEvents()
|
||||
#window.addPage("Configuration", resourceIcon("config"), ConfigPages(window))
|
||||
window.addPage("Init", resourceIcon("db"), InitPanel(window))
|
||||
window.addPage("Run", resourceIcon("run"), RunPanel(window))
|
||||
window.addPage("Plots", resourceIcon("plot"), PlotPanel())
|
||||
|
||||
window.addPage("Configuration", resourceIcon("config"), ConfigPages(window))
|
||||
window.addPage("Init" , resourceIcon("db"), InitPanel(window))
|
||||
window.addPage("Run" , resourceIcon("run"), RunPanel(window))
|
||||
window.addPage("Plots", resourceIcon("plot"), PlotPanel())
|
||||
|
||||
splash.showMessage("Communicating with ERT...", color=QtCore.Qt.white)
|
||||
app.processEvents()
|
||||
|
||||
ContentModel.contentModel = ert
|
||||
ContentModel.updateObservers()
|
||||
|
||||
window.show()
|
||||
splash.finish(window)
|
||||
|
||||
sys.exit(app.exec_())
|
||||
|
||||
if __name__ =="__main__":
|
||||
main()
|
||||
splash.showMessage("Communicating with ERT...", color=QtCore.Qt.white)
|
||||
app.processEvents()
|
||||
|
||||
ContentModel.contentModel = ert
|
||||
ContentModel.updateObservers()
|
||||
|
||||
window.show()
|
||||
splash.finish(window)
|
||||
|
||||
sys.exit(app.exec_())
|
||||
|
||||
|
||||
|
93
ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/analysis.py
vendored
Normal file
93
ThirdParty/Ert/devel/libenkf/applications/ert_gui/lib/ert_gui/pages/config/analysis.py
vendored
Normal file
@ -0,0 +1,93 @@
|
||||
# Copyright (C) 2011 Statoil ASA, Norway.
|
||||
#
|
||||
# The file 'analysis.py' is part of ERT - Ensemble based Reservoir Tool.
|
||||
#
|
||||
# ERT is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# ERT is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
# WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
# FITNESS FOR A PARTICULAR PURPOSE.
|
||||
#
|
||||
# See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
# for more details.
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------------------------------
|
||||
# Analysis tab
|
||||
# ----------------------------------------------------------------------------------------------
|
||||
from ert_gui.widgets.checkbox import CheckBox
|
||||
from ert_gui.widgets.spinnerwidgets import IntegerSpinner, DoubleSpinner, DoubleSpinner
|
||||
import ert_gui.widgets.tablewidgets
|
||||
from ert_gui.widgets.pathchooser import PathChooser
|
||||
from ert_gui.widgets.combochoice import ComboChoice
|
||||
from PyQt4 import QtGui
|
||||
import ert.enkf
|
||||
|
||||
def createAnalysisPage(configPanel, parent):
|
||||
configPanel.startPage("Analysis")
|
||||
|
||||
r = configPanel.addRow(CheckBox(parent, "ENKF rerun", "config/analysis/enkf_rerun", "Perform rerun"))
|
||||
r.getter = lambda ert : ert.enkf.analysis_config_get_rerun(ert.analysis_config)
|
||||
r.setter = lambda ert, value : ert.enkf.analysis_config_set_rerun(ert.analysis_config, value)
|
||||
|
||||
r = configPanel.addRow(IntegerSpinner(parent, "Rerun start", "config/analysis/rerun_start", 0, 100000))
|
||||
r.getter = lambda ert : ert.enkf.analysis_config_get_rerun_start(ert.analysis_config)
|
||||
r.setter = lambda ert, value : ert.enkf.analysis_config_set_rerun_start(ert.analysis_config, value)
|
||||
|
||||
r = configPanel.addRow(PathChooser(parent, "ENKF schedule file", "config/analysis/enkf_sched_file"))
|
||||
r.getter = lambda ert : ert.enkf.model_config_get_enkf_sched_file(ert.enkf.enkf_main_get_model_config(ert.main))
|
||||
r.setter = lambda ert, value : ert.enkf.model_config_set_enkf_sched_file(ert.enkf.enkf_main_get_model_config(ert.main), str(value))
|
||||
|
||||
r = configPanel.addRow(ert_gui.widgets.tablewidgets.KeywordList(parent, "Local config", "config/analysis/local_config"))
|
||||
r.newKeywordPopup = lambda list : QtGui.QFileDialog.getOpenFileName(r, "Select a path", "")
|
||||
|
||||
def get_local_config_files(ert):
|
||||
local_config = ert.enkf.enkf_main_get_local_config(ert.main)
|
||||
config_files_pointer = ert.enkf.local_config_get_config_files(local_config)
|
||||
return ert.getStringList(config_files_pointer)
|
||||
|
||||
r.getter = get_local_config_files
|
||||
|
||||
def add_config_file(ert, value):
|
||||
local_config = ert.enkf.enkf_main_get_local_config(ert.main)
|
||||
ert.enkf.local_config_clear_config_files(local_config)
|
||||
|
||||
for file in value:
|
||||
ert.enkf.local_config_add_config_file(local_config, file)
|
||||
|
||||
r.setter = add_config_file
|
||||
|
||||
r = configPanel.addRow(PathChooser(parent, "Update log", "config/analysis/update_log"))
|
||||
r.getter = lambda ert : ert.enkf.analysis_config_get_log_path(ert.analysis_config)
|
||||
r.setter = lambda ert, value : ert.enkf.analysis_config_set_log_path(ert.analysis_config, str(value))
|
||||
|
||||
|
||||
configPanel.startGroup("EnKF")
|
||||
|
||||
r = configPanel.addRow(DoubleSpinner(parent, "Alpha", "config/analysis/enkf_alpha", 0, 100000, 2))
|
||||
r.getter = lambda ert : ert.enkf.analysis_config_get_alpha(ert.analysis_config)
|
||||
r.setter = lambda ert, value : ert.enkf.analysis_config_set_alpha(ert.analysis_config, value)
|
||||
|
||||
r = configPanel.addRow(CheckBox(parent, "Merge Observations", "config/analysis/enkf_merge_observations", "Perform merge"))
|
||||
r.getter = lambda ert : ert.enkf.analysis_config_get_merge_observations(ert.analysis_config)
|
||||
r.setter = lambda ert, value : ert.enkf.analysis_config_set_merge_observations(ert.analysis_config, value)
|
||||
|
||||
|
||||
enkf_mode_type = {"ENKF_STANDARD" : 10, "ENKF_SQRT" : 20}
|
||||
enkf_mode_type_inverted = {10 : "ENKF_STANDARD" , 20 : "ENKF_SQRT"}
|
||||
r = configPanel.addRow(ComboChoice(parent, enkf_mode_type.keys(), "Mode", "config/analysis/enkf_mode"))
|
||||
r.getter = lambda ert : enkf_mode_type_inverted[ert.enkf.analysis_config_get_enkf_mode(ert.analysis_config)]
|
||||
r.setter = lambda ert, value : ert.enkf.analysis_config_set_enkf_mode(ert.analysis_config, enkf_mode_type[str(value)])
|
||||
|
||||
|
||||
r = configPanel.addRow(DoubleSpinner(parent, "Truncation", "config/analysis/enkf_truncation", 0, 1, 2))
|
||||
r.getter = lambda ert : ert.enkf.analysis_config_get_truncation(ert.analysis_config)
|
||||
r.setter = lambda ert, value : ert.enkf.analysis_config_set_truncation(ert.analysis_config, value)
|
||||
|
||||
|
||||
|
||||
configPanel.endGroup()
|
||||
configPanel.endPage()
|
@ -14,16 +14,16 @@
|
||||
# See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
||||
# for more details.
|
||||
|
||||
|
||||
from ert_gui.widgets.configpanel import ConfigPanel
|
||||
import eclipse
|
||||
import analysis
|
||||
import queuesystem
|
||||
import systemenv
|
||||
import plot
|
||||
import ensemble
|
||||
import observations
|
||||
import simulation
|
||||
import ensemble
|
||||
|
||||
|
||||
class ConfigPages(ConfigPanel):
|
||||
|
@ -27,54 +27,47 @@ def createEclipsePage(configPanel, parent):
|
||||
configPanel.startPage("Eclipse")
|
||||
|
||||
r = configPanel.addRow(PathChooser(parent, "Eclipse Base", "config/eclipse/eclbase", path_format=True))
|
||||
r.initialize = lambda ert : ert.main.ecl_config.get_eclbase
|
||||
r.getter = lambda ert : ert.main.ecl_config.get_eclbase
|
||||
r.setter = lambda ert, value : ert.main.set_eclbase(str(value))
|
||||
r.getter = lambda ert : ert.enkf.ecl_config_get_eclbase(ert.ecl_config)
|
||||
r.setter = lambda ert, value : ert.enkf.enkf_main_set_eclbase(ert.main , str(value))
|
||||
|
||||
r = configPanel.addRow(PathChooser(parent, "Data file", "config/eclipse/data_file", show_files=True))
|
||||
r.initialize = lambda ert : ert.main.ecl_config.get_data_file
|
||||
r.getter = lambda ert : ert.main.ecl_config.get_data_file
|
||||
r.setter = lambda ert, value : ert.main.set_datafile(str(value))
|
||||
r.getter = lambda ert : ert.enkf.ecl_config_get_data_file(ert.ecl_config)
|
||||
r.setter = lambda ert, value : ert.enkf.enkf_main_set_data_file(ert.main , str(value))
|
||||
|
||||
r = configPanel.addRow(PathChooser(parent, "Grid", "config/eclipse/grid", show_files=True))
|
||||
r.initialize = lambda ert : ert.main.ecl_config.get_gridfile
|
||||
r.getter = lambda ert : ert.main.ecl_config.get_gridfile
|
||||
r.setter = lambda ert, value : ert.main.ecl_config.set_gridfile(str(value))
|
||||
r.getter = lambda ert : ert.enkf.ecl_config_get_gridfile(ert.ecl_config)
|
||||
r.setter = lambda ert, value : ert.enkf.ecl_config_set_grid(ert.ecl_config, str(value))
|
||||
|
||||
r = configPanel.addRow(PathChooser(parent, "Schedule file" , "config/eclipse/schedule_file" , show_files = True))
|
||||
r.initialize = lambda ert : ert.main.ecl_config.get_schedule_file
|
||||
r.getter = lambda ert : ert.main.ecl_config.get_schedule_file
|
||||
r.setter = lambda ert, value : ert.main.ecl_config.set_schedule_file( str(value))
|
||||
r.getter = lambda ert : ert.enkf.ecl_config_get_schedule_file(ert.ecl_config)
|
||||
r.setter = lambda ert, value : ert.enkf.ecl_config_set_schedule_file(ert.ecl_config, str(value))
|
||||
|
||||
|
||||
r = configPanel.addRow(PathChooser(parent, "Init section", "config/eclipse/init_section", show_files=True))
|
||||
r.initialize = lambda ert : ert.main.ecl_config.get_init_section
|
||||
r.getter = lambda ert : ert.main.ecl_config.get_init_section
|
||||
r.setter = lambda ert, value : ert.main.ecl_config.set_init_section( str(value))
|
||||
r.getter = lambda ert : ert.enkf.ecl_config_get_init_section(ert.ecl_config)
|
||||
r.setter = lambda ert, value : ert.enkf.ecl_config_set_init_section(ert.ecl_config, str(value))
|
||||
|
||||
|
||||
r = configPanel.addRow(PathChooser(parent, "Refcase", "config/eclipse/refcase", show_files=True))
|
||||
r.initialize = lambda ert : ert.main.ecl_config.get_refcase_name
|
||||
r.getter = lambda ert : ert.main.ecl_config.get_refcase_name
|
||||
r.setter = lambda ert, value : ert.main.ecl_config.load_refcase( str(value))
|
||||
r.getter = lambda ert : ert.enkf.ecl_config_get_refcase_name(ert.ecl_config)
|
||||
r.setter = lambda ert, value : ert.enkf.ecl_config_load_refcase(ert.ecl_config, str(value))
|
||||
|
||||
r = configPanel.addRow(PathChooser(parent, "Schedule prediction file", "config/eclipse/schedule_prediction_file", show_files=True))
|
||||
r.initialize = lambda ert : ert.main.get_schedule_prediction_file
|
||||
r.getter = lambda ert : ert.main.get_schedule_prediction_file
|
||||
r.setter = lambda ert, value : ert.main.set_schedule_prediction_file( ert.nonify( value ))
|
||||
r.getter = lambda ert : ert.enkf.enkf_main_get_schedule_prediction_file(ert.main)
|
||||
r.setter = lambda ert, value : ert.enkf.enkf_main_set_schedule_prediction_file(ert.main, ert.nonify( value ))
|
||||
|
||||
r = configPanel.addRow(KeywordTable(parent, "Data keywords", "config/eclipse/data_kw"))
|
||||
r.getter = lambda ert : ert.getSubstitutionList(ert.main.get_data_kw)
|
||||
r.getter = lambda ert : ert.getSubstitutionList(ert.enkf.enkf_main_get_data_kw(ert.main))
|
||||
|
||||
def add_data_kw(ert, listOfKeywords):
|
||||
ert.main.clear_data_kw
|
||||
ert.enkf.enkf_main_clear_data_kw(ert.main)
|
||||
|
||||
for keyword in listOfKeywords:
|
||||
ert.main.add_data_kw( keyword[0], keyword[1])
|
||||
ert.enkf.enkf_main_add_data_kw(ert.main, keyword[0], keyword[1])
|
||||
|
||||
r.setter = add_data_kw
|
||||
|
||||
r.initialize = lambda ert : ert.getSubstitutionList(ert.main.get_data_kw)
|
||||
|
||||
|
||||
configPanel.addSeparator()
|
||||
|
||||
@ -83,16 +76,16 @@ def createEclipsePage(configPanel, parent):
|
||||
internalPanel.startPage("Static keywords")
|
||||
|
||||
r = internalPanel.addRow(KeywordList(parent, "", "config/eclipse/add_static_kw"))
|
||||
r.getter = lambda ert : ert.main.ecl_config.get_static_kw_list
|
||||
r.getter = lambda ert : ert.getStringList(ert.enkf.ecl_config_get_static_kw_list(ert.ecl_config))
|
||||
|
||||
def add_static_kw(ert, listOfKeywords):
|
||||
ert.main.ecl_config.clear_static_kw
|
||||
ert.enkf.ecl_config_clear_static_kw(ert.ecl_config)
|
||||
|
||||
for keyword in listOfKeywords:
|
||||
ert.main.ecl_config.add_static_kw(keyword)
|
||||
ert.enkf.ecl_config_add_static_kw(ert.ecl_config, keyword)
|
||||
|
||||
r.setter = add_static_kw
|
||||
r.initialize = lambda ert : ert.main.ecl_config.get_static_kw_list
|
||||
|
||||
internalPanel.endPage()
|
||||
|
||||
# todo: add support for fixed length schedule keywords
|
@ -18,23 +18,21 @@
|
||||
# ----------------------------------------------------------------------------------------------
|
||||
# Ensemble tab
|
||||
# ----------------------------------------------------------------------------------------------
|
||||
from PyQt4 import QtCore
|
||||
from PyQt4 import QtGui, QtCore
|
||||
from ert_gui.widgets.spinnerwidgets import IntegerSpinner
|
||||
from parameters.parameterpanel import ParameterPanel
|
||||
from parameters.parameterpanel import ParameterPanel, enums
|
||||
from parameters.parametermodels import SummaryModel, DataModel, FieldModel, KeywordModel
|
||||
import ert.ert.enums as enums
|
||||
import ert.enkf.enkf_config_node
|
||||
import ert.enkf.gen_kw_config
|
||||
import ert.enkf.gen_data_config
|
||||
from ert.ert.enums import field_type
|
||||
from ert.ert.enums import truncation_type
|
||||
from ert.ert.enums import gen_data_file_format
|
||||
|
||||
def createEnsemblePage(configPanel, parent):
|
||||
configPanel.startPage("Ensemble")
|
||||
|
||||
r = configPanel.addRow(IntegerSpinner(parent, "Number of realizations", "config/ensemble/num_realizations", 1, 10000))
|
||||
|
||||
r.initialize = lambda ert : ert.main.ens_size
|
||||
r.getter = lambda ert : ert.main.ens_size
|
||||
r.setter = lambda ert, value : ert.main.resize_ensemble( value)
|
||||
r.getter = lambda ert : ert.enkf.enkf_main_get_ensemble_size(ert.main)
|
||||
r.setter = lambda ert, value : ert.enkf.enkf_main_resize_ensemble(ert.main, value)
|
||||
|
||||
parent.connect(r, QtCore.SIGNAL("contentsChanged()"), lambda : r.modelEmit("ensembleResized()"))
|
||||
|
||||
@ -43,52 +41,52 @@ def createEnsemblePage(configPanel, parent):
|
||||
r = configPanel.addRow(ParameterPanel(parent, "", "")) # no help file necessary
|
||||
parent.connect(r, QtCore.SIGNAL("contentsChanged()"), lambda : r.modelEmit("ensembleUpdated()"))
|
||||
|
||||
|
||||
def getEnsembleParameters(ert):
|
||||
keys = ert.main.ensemble_config.alloc_keylist
|
||||
keys = ert.getStringList(ert.enkf.ensemble_config_alloc_keylist(ert.ensemble_config), free_after_use=True)
|
||||
|
||||
parameters = []
|
||||
for key in keys:
|
||||
node = ert.main.ensemble_config.get_node( key)
|
||||
type = node.get_impl_type
|
||||
data = node.get_ref
|
||||
node = ert.enkf.ensemble_config_get_node(ert.ensemble_config, key)
|
||||
type = ert.enkf.enkf_config_node_get_impl_type(node)
|
||||
data = ert.enkf.enkf_config_node_get_ref(node)
|
||||
#print key, type
|
||||
|
||||
model = None
|
||||
if type == FieldModel.TYPE:
|
||||
model = FieldModel(key)
|
||||
|
||||
field_type = node.field_model.get_type
|
||||
field_type = ert.enkf.field_config_get_type(data)
|
||||
field_type = enums.field_type[field_type]
|
||||
model["type"] = field_type
|
||||
|
||||
truncation = node.field_model.get_truncation_mode
|
||||
truncation = ert.enkf.field_config_get_truncation_mode(data)
|
||||
|
||||
if truncation & enums.truncation_type.TRUNCATE_MAX:
|
||||
model["max"] = node.field_model.get_truncation_max
|
||||
model["max"] = ert.enkf.field_config_get_truncation_max(data)
|
||||
|
||||
if truncation & enums.truncation_type.TRUNCATE_MIN:
|
||||
model["min"] = node.field_model.get_truncation_min
|
||||
model["min"] = ert.enkf.field_config_get_truncation_min(data)
|
||||
|
||||
model["init"] = node.field_model.get_init_transform_name
|
||||
model["output"] = node.field_model.get_output_transform_name
|
||||
model["init"] = ert.enkf.field_config_get_init_transform_name(data)
|
||||
model["output"] = ert.enkf.field_config_get_output_transform_name(data)
|
||||
|
||||
model["init_files"] = node.get_init_file_fmt
|
||||
model["min_std"] = node.get_min_std_file
|
||||
model["enkf_outfile"] = node.get_enkf_outfile
|
||||
model["enkf_infile"] = node.get_enkf_infile
|
||||
model["init_files"] = ert.enkf.field_config_get_init_file_fmt(data)
|
||||
model["min_std"] = ert.enkf.enkf_config_node_get_min_std_file(node)
|
||||
model["enkf_outfile"] = ert.enkf.enkf_config_node_get_enkf_outfile(node)
|
||||
model["enkf_infile"] = ert.enkf.enkf_config_node_get_enkf_infile(node)
|
||||
|
||||
elif type == DataModel.TYPE:
|
||||
model = DataModel(key)
|
||||
|
||||
output_format_value = node.data_model.get_output_format
|
||||
output_format_value = ert.enkf.gen_data_config_get_output_format(data)
|
||||
output_format = gen_data_file_format.resolveValue(output_format_value)
|
||||
|
||||
input_format_value = node.data_model.get_input_format
|
||||
input_format_value = ert.enkf.gen_data_config_get_input_format(data)
|
||||
input_format = gen_data_file_format.resolveValue(input_format_value)
|
||||
|
||||
template_file = node.data_model.get_template_file
|
||||
template_key = node.data_model.get_template_key
|
||||
init_file_fmt = node.get_init_file_fmt
|
||||
template_file = ert.enkf.gen_data_config_get_template_file(data)
|
||||
template_key = ert.enkf.gen_data_config_get_template_key(data)
|
||||
init_file_fmt = ert.enkf.gen_data_config_get_init_file_fmt(data)
|
||||
|
||||
model["output_format"] = output_format
|
||||
model["input_format"] = input_format
|
||||
@ -96,9 +94,9 @@ def createEnsemblePage(configPanel, parent):
|
||||
model["template_key"] = template_key
|
||||
model["init_file_fmt"] = init_file_fmt
|
||||
|
||||
min_std = node.get_min_std_file
|
||||
enkf_outfile = node.get_enkf_outfile
|
||||
enkf_infile = node.get_enkf_infile
|
||||
min_std = ert.enkf.enkf_config_node_get_min_std_file(node)
|
||||
enkf_outfile = ert.enkf.enkf_config_node_get_enkf_outfile(node)
|
||||
enkf_infile = ert.enkf.enkf_config_node_get_enkf_infile(node)
|
||||
|
||||
|
||||
|
||||
@ -108,40 +106,40 @@ def createEnsemblePage(configPanel, parent):
|
||||
|
||||
elif type == KeywordModel.TYPE:
|
||||
model = KeywordModel(key)
|
||||
model["min_std"] = node.get_min_std_file
|
||||
model["enkf_outfile"] = node.get_enkf_outfile
|
||||
model["template"] = node.keyword_model.get_template_file
|
||||
model["init_file"] = node.get_init_file_fmt
|
||||
model["parameter_file"] = node.keyword_model.get_parameter_file
|
||||
model["min_std"] = ert.enkf.enkf_config_node_get_min_std_file(node)
|
||||
model["enkf_outfile"] = ert.enkf.enkf_config_node_get_enkf_outfile(node)
|
||||
model["template"] = ert.enkf.gen_kw_config_get_template_file(data)
|
||||
model["init_file"] = ert.enkf.gen_kw_config_get_init_file_fmt(data)
|
||||
model["parameter_file"] = ert.enkf.gen_kw_config_get_parameter_file(data)
|
||||
elif type == SummaryModel.TYPE:
|
||||
model = SummaryModel(key)
|
||||
else:
|
||||
pass #Unknown type
|
||||
|
||||
#model.setValid(ert.main.enkf_config_node.is_valid)
|
||||
model.setValid(ert.enkf.enkf_config_node_is_valid(node))
|
||||
|
||||
parameters.append(model)
|
||||
|
||||
return parameters
|
||||
|
||||
def removeParameter(ert, parameter_key):
|
||||
ert.main.del_node(ert.main, parameter_key)
|
||||
ert.enkf.enkf_main_del_node(ert.main, parameter_key)
|
||||
|
||||
def insertParameter(ert, parameter):
|
||||
key = parameter.getName()
|
||||
if parameter.getType() == FieldModel.TYPE:
|
||||
grid = ert.main.ecl_config.get_grid
|
||||
node = ert.main.ensemble_config.add_field( key, grid)
|
||||
parameter.setValid(ert.main.enkf_config_node.is_valid)
|
||||
grid = ert.enkf.ecl_config_get_grid(ert.ecl_config)
|
||||
node = ert.enkf.ensemble_config_add_field(ert.ensemble_config, key, grid)
|
||||
parameter.setValid(ert.enkf.enkf_config_node_is_valid(node))
|
||||
elif parameter.getType() == DataModel.TYPE:
|
||||
node = ert.main.ensemble_config.add_gen_data( key)
|
||||
parameter.setValid(ert.main.enkf_config_node.is_valid)
|
||||
node = ert.enkf.ensemble_config_add_gen_data(ert.ensemble_config, key)
|
||||
parameter.setValid(ert.enkf.enkf_config_node_is_valid(node))
|
||||
elif parameter.getType() == KeywordModel.TYPE:
|
||||
node = ert.main.ensemble_config.add_gen_kw( key)
|
||||
parameter.setValid(ert.main.enkf_config_node.is_valid)
|
||||
node = ert.enkf.ensemble_config_add_gen_kw(ert.ensemble_config, key)
|
||||
parameter.setValid(ert.enkf.enkf_config_node_is_valid(node))
|
||||
elif parameter.getType() == SummaryModel.TYPE:
|
||||
parameter.setValid(True)
|
||||
b = ert.main.ensemble_config.add_summary( key)
|
||||
b = ert.enkf.ensemble_config_add_summary(ert.ensemble_config, key)
|
||||
return b > 0 #0 == NULL
|
||||
else:
|
||||
print "Unknown type: ", parameter
|
||||
@ -151,7 +149,7 @@ def createEnsemblePage(configPanel, parent):
|
||||
|
||||
def updateParameter(ert, parameter_model):
|
||||
key = parameter_model.getName()
|
||||
node = ert.main.ensemble_config.get_node( key)
|
||||
node = ert.enkf.ensemble_config_get_node(ert.ensemble_config, key)
|
||||
|
||||
if isinstance(parameter_model, FieldModel):
|
||||
type = parameter_model["type"]
|
||||
@ -167,12 +165,12 @@ def createEnsemblePage(configPanel, parent):
|
||||
maximum = 0.0
|
||||
|
||||
if type == field_type.ECLIPSE_RESTART: #dynamic
|
||||
ert.main.enkf_config_node.update_state_field(node,
|
||||
ert.enkf.enkf_config_node_update_state_field(node,
|
||||
truncate.value(),
|
||||
float(minimum),
|
||||
float(maximum))
|
||||
elif type == field_type.ECLIPSE_PARAMETER: #parameter
|
||||
ert.main.enkf_config_node.update_parameter_field(node,
|
||||
ert.enkf.enkf_config_node_update_parameter_field(node,
|
||||
ert.nonify(parameter_model["enkf_outfile"]),
|
||||
ert.nonify(parameter_model["init_files"]),
|
||||
ert.nonify(parameter_model["min_std"]),
|
||||
@ -182,7 +180,7 @@ def createEnsemblePage(configPanel, parent):
|
||||
parameter_model["init"],
|
||||
parameter_model["output"])
|
||||
elif type == field_type.GENERAL: #general
|
||||
ert.main.enkf_config_node.update_general_field(node,
|
||||
ert.enkf.enkf_config_node_update_general_field(node,
|
||||
ert.nonify(parameter_model["enkf_outfile"]),
|
||||
ert.nonify(parameter_model["enkf_infile"]),
|
||||
ert.nonify(parameter_model["init_files"]),
|
||||
@ -194,7 +192,7 @@ def createEnsemblePage(configPanel, parent):
|
||||
None,
|
||||
parameter_model["output"])
|
||||
|
||||
parameter_model.setValid(ert.main.enkf_config_node.is_valid)
|
||||
parameter_model.setValid(ert.enkf.enkf_config_node_is_valid(node))
|
||||
|
||||
elif isinstance(parameter_model, KeywordModel):
|
||||
enkf_outfile_fmt = parameter_model["enkf_outfile"]
|
||||
@ -202,20 +200,20 @@ def createEnsemblePage(configPanel, parent):
|
||||
parameter_file = parameter_model["parameter_file"]
|
||||
min_std_file = parameter_model["min_std"]
|
||||
init_file_fmt = parameter_model["init_files"]
|
||||
ert.main.enkf_config_node.update_gen_kw(node,
|
||||
ert.enkf.enkf_config_node_update_gen_kw(node,
|
||||
ert.nonify(enkf_outfile_fmt),
|
||||
ert.nonify(template_file),
|
||||
ert.nonify(parameter_file),
|
||||
ert.nonify(min_std_file),
|
||||
ert.nonify(init_file_fmt))
|
||||
parameter_model.setValid(ert.main.enkf_config_node.is_valid)
|
||||
parameter_model.setValid(ert.enkf.enkf_config_node_is_valid(node))
|
||||
elif isinstance(parameter_model, SummaryModel):
|
||||
#should never be called from SummaryModel...
|
||||
raise AssertionError("Summary keys can not be updated!")
|
||||
elif isinstance(parameter_model, DataModel):
|
||||
input_format = gen_data_file_format.resolveName(str(parameter_model["input_format"]))
|
||||
output_format = gen_data_file_format.resolveName(str(parameter_model["output_format"]))
|
||||
ert.main.enkf_config_node.update_gen_data(node,
|
||||
ert.enkf.enkf_config_node_update_gen_data(node,
|
||||
input_format.value(),
|
||||
output_format.value(),
|
||||
ert.nonify(parameter_model["init_file_fmt"]),
|
||||
@ -224,18 +222,17 @@ def createEnsemblePage(configPanel, parent):
|
||||
ert.nonify(parameter_model["enkf_outfile"]),
|
||||
ert.nonify(parameter_model["enkf_infile"]),
|
||||
ert.nonify(parameter_model["min_std"]))
|
||||
parameter_model.setValid(ert.main.enkf_config_node.is_valid)
|
||||
parameter_model.setValid(ert.enkf.enkf_config_node_is_valid(node))
|
||||
else:
|
||||
raise AssertionError("Type is not supported: %s" % (parameter_model.__class__))
|
||||
|
||||
if ert.main.enkf_config_node.is_valid:
|
||||
ert.main.update_node( ert.main , key )
|
||||
if ert.enkf.enkf_config_node_is_valid(node):
|
||||
ert.enkf.enkf_main_update_node( ert.main , key )
|
||||
|
||||
|
||||
|
||||
|
||||
r.getter = getEnsembleParameters
|
||||
r.initialize = getEnsembleParameters
|
||||
r.remove = removeParameter
|
||||
r.insert = insertParameter
|
||||
r.setter = updateParameter
|
@ -52,10 +52,11 @@ class ForwardModelPanel(HelpedWidget):
|
||||
def createWidgets(self, parent):
|
||||
self.searchableList = SearchableList(parent, list_height=150, list_width=150, ignore_case=True, order_editable=True)
|
||||
self.addWidget(self.searchableList)
|
||||
self.connect(self.searchableList, QtCore.SIGNAL('currentItemChanged(QListWidgetItem, QListWidgetItem)'),self.changeParameter)
|
||||
self.connect(self.searchableList, QtCore.SIGNAL('addItem(QListWidgetItem)'), self.addItem)
|
||||
self.connect(self.searchableList, QtCore.SIGNAL('removeItem(QListWidgetItem)'), self.removeItem)
|
||||
self.connect(self.searchableList, QtCore.SIGNAL('orderChanged(QListWidgetItem)'), self.forwardModelChanged)
|
||||
self.connect(self.searchableList, QtCore.SIGNAL('currentItemChanged(QListWidgetItem, QListWidgetItem)'),
|
||||
self.changeParameter)
|
||||
self.connect(self.searchableList, QtCore.SIGNAL('addItem(list)'), self.addItem)
|
||||
self.connect(self.searchableList, QtCore.SIGNAL('removeItem(list)'), self.removeItem)
|
||||
self.connect(self.searchableList, QtCore.SIGNAL('orderChanged(list)'), self.forwardModelChanged)
|
||||
|
||||
|
||||
self.forward_model_panel = ert_gui.widgets.util.createEmptyPanel()
|
@ -87,124 +87,53 @@ class JobConfigPanel(ConfigPanel):
|
||||
|
||||
def jid(ert):
|
||||
"""Returns the pointer to the current job (self.job)"""
|
||||
jl = ert.main.site_config.get_installed_jobs
|
||||
return jl.get_job(self.job.name)
|
||||
jl = ert.enkf.site_config_get_installed_jobs(ert.site_config)
|
||||
return ert.job_queue.ext_joblist_get_job(jl, self.job.name)
|
||||
|
||||
def set_stdin(ert,value):
|
||||
job = jid(ert)
|
||||
job.set_stdin_file(value)
|
||||
|
||||
def get_stdin(ert):
|
||||
job = jid(ert)
|
||||
return job.get_stdin_file
|
||||
|
||||
self.stdin = PathChooser(self, "", "config/systemenv/install_job_stdin", show_files=True, must_be_set=False, must_exist=True)
|
||||
self.stdin.setter = set_stdin
|
||||
self.stdin.getter = get_stdin
|
||||
self.stdin.initialize =get_stdin
|
||||
self.stdin.setter = lambda ert, value : ert.job_queue.ext_job_set_stdin_file(jid(ert), value)
|
||||
self.stdin.getter = lambda ert : ert.job_queue.ext_job_get_stdin_file(jid(ert))
|
||||
|
||||
def set_stdout(ert,value):
|
||||
job = jid(ert)
|
||||
job.set_stdout_file(value)
|
||||
|
||||
def get_stdout(ert):
|
||||
job = jid(ert)
|
||||
return job.get_stdout_file
|
||||
|
||||
self.stdout = PathChooser(self, "", "config/systemenv/install_job_stdout", show_files=True, must_be_set=True, must_exist=False)
|
||||
self.stdout.setter = set_stdout
|
||||
self.stdout.getter = get_stdout
|
||||
self.stdout.initialize = get_stdout
|
||||
self.stdout.setter = lambda ert, value : ert.job_queue.ext_job_set_stdout_file(jid(ert), value)
|
||||
self.stdout.getter = lambda ert : ert.job_queue.ext_job_get_stdout_file(jid(ert))
|
||||
|
||||
def set_stderr(ert,value):
|
||||
job = jid(ert)
|
||||
job.set_stderr_file(value)
|
||||
|
||||
def get_stderr(ert):
|
||||
job = jid(ert)
|
||||
return job.get_stderr_file
|
||||
|
||||
self.stderr = PathChooser(self, "", "config/systemenv/install_job_stderr", show_files=True, must_be_set=True, must_exist=False)
|
||||
self.stderr.setter = set_stderr
|
||||
self.stderr.getter = get_stderr
|
||||
self.stderr.initialize = get_stderr
|
||||
self.stderr.setter = lambda ert, value : ert.job_queue.ext_job_set_stderr_file(jid(ert), value)
|
||||
self.stderr.getter = lambda ert : ert.job_queue.ext_job_get_stderr_file(jid(ert))
|
||||
|
||||
def set_target_file(ert,value):
|
||||
job = jid(ert)
|
||||
job.set_target_file(value)
|
||||
self.target_file = PathChooser(self, "", "config/systemenv/install_job_target_file", show_files=True, must_be_set=False,
|
||||
must_exist=False)
|
||||
self.target_file.setter = lambda ert, value : ert.job_queue.ext_job_set_target_file(jid(ert), value)
|
||||
self.target_file.getter = lambda ert : ert.job_queue.ext_job_get_target_file(jid(ert))
|
||||
|
||||
def get_target_file(ert):
|
||||
job = jid(ert)
|
||||
return job.get_target_file
|
||||
|
||||
self.target_file = PathChooser(self, "", "config/systemenv/install_job_target_file", show_files=True, must_be_set=False, must_exist=False)
|
||||
self.target_file.setter = set_target_file
|
||||
self.target_file.getter = get_target_file
|
||||
self.target_file.initialize = get_target_file
|
||||
|
||||
def set_executable(ert,value):
|
||||
job = jid(ert)
|
||||
job.set_executable(value)
|
||||
|
||||
def get_executable(ert):
|
||||
job = jid(ert)
|
||||
return job.get_executable
|
||||
|
||||
self.executable = PathChooser(self, "", "config/systemenv/install_job_executable", show_files=True, must_be_set=True,
|
||||
must_exist=True, is_executable_file=True)
|
||||
self.executable.setter = set_executable
|
||||
self.executable.getter = get_executable
|
||||
self.executable.setter = lambda ert, value : ert.job_queue.ext_job_set_executable(jid(ert), value)
|
||||
self.executable.getter = lambda ert : ert.job_queue.ext_job_get_executable(jid(ert))
|
||||
|
||||
def setEnv(ert, value):
|
||||
job = jid(ert)
|
||||
job.clear_environment
|
||||
ert.job_queue.ext_job_clear_environment(job)
|
||||
|
||||
for env in value:
|
||||
job.set_environment(env[0], env[1])
|
||||
|
||||
def getEnv(ert):
|
||||
job = jid(ert)
|
||||
return ert.getHash(job.get_environment)
|
||||
ert.job_queue.ext_job_add_environment(job, env[0], env[1])
|
||||
|
||||
self.env = KeywordTable(self, "", "config/systemenv/install_job_env", colHead1="Variable", colHead2="Value")
|
||||
self.env.setter = setEnv
|
||||
self.env.getter = getEnv
|
||||
|
||||
def set_arglist(ert,value):
|
||||
job = jid(ert)
|
||||
job.set_private_args_from_string(value)
|
||||
|
||||
def get_arglist(ert):
|
||||
job = jid(ert)
|
||||
return job.get_private_args_as_string
|
||||
self.env.getter = lambda ert : ert.getHash(ert.job_queue.ext_job_get_environment(jid(ert)))
|
||||
|
||||
self.arglist = StringBox(self, "", "config/systemenv/install_job_arglist")
|
||||
self.arglist.setter = set_arglist
|
||||
self.arglist.getter = get_arglist
|
||||
self.arglist.setter = lambda ert, value : ert.job_queue.ext_job_set_private_args_from_string(jid(ert), value)
|
||||
self.arglist.getter = lambda ert : ert.job_queue.ext_job_get_private_args_as_string(jid(ert))
|
||||
|
||||
def set_max_running(ert,value):
|
||||
job = jid(ert)
|
||||
job.set_max_running(value)
|
||||
|
||||
def get_max_running(ert):
|
||||
job = jid(ert)
|
||||
return job.get_max_running
|
||||
|
||||
self.max_running = IntegerSpinner(self, "", "config/systemenv/install_job_max_running", 0, 10000)
|
||||
self.max_running.setter = set_max_running
|
||||
self.max_running.getter = get_max_running
|
||||
self.max_running.setter = lambda ert, value : ert.job_queue.ext_job_set_max_running(jid(ert), value)
|
||||
self.max_running.getter = lambda ert : ert.job_queue.ext_job_get_max_running(jid(ert))
|
||||
|
||||
def set_max_running_minutes(ert,value):
|
||||
job = jid(ert)
|
||||
job.set_max_running_minutes(value)
|
||||
|
||||
def get_max_running(ert):
|
||||
job = jid(ert)
|
||||
return job.get_max_running_minutes
|
||||
|
||||
self.max_running_minutes = IntegerSpinner(self, "", "config/systemenv/install_job_max_running_minutes", 0, 10000)
|
||||
self.max_running_minutes.setter = set_max_running_minutes
|
||||
self.max_running_minutes.getter = get_max_running_minutes
|
||||
self.max_running_minutes.setter = lambda ert, value : ert.job_queue.ext_job_set_max_running_minutes(jid(ert), value)
|
||||
self.max_running_minutes.getter = lambda ert : ert.job_queue.ext_job_get_max_running_minutes(jid(ert))
|
||||
|
||||
|
||||
self.startPage("Standard")
|
@ -49,9 +49,10 @@ class JobsPanel(HelpedWidget):
|
||||
def createWidgets(self, parent):
|
||||
self.searchableList = SearchableList(parent, list_height=200, list_width=150, ignore_case=True)
|
||||
self.addWidget(self.searchableList)
|
||||
self.connect(self.searchableList , QtCore.SIGNAL('currentItemChanged(QListWidgetItem, QListWidgetItem)'),self.changeParameter)
|
||||
self.connect(self.searchableList , QtCore.SIGNAL('addItem(QListWidgetItem)'), self.addItem)
|
||||
self.connect(self.searchableList , QtCore.SIGNAL('removeItem(QListWidgetItem)'), self.removeItem)
|
||||
self.connect(self.searchableList, QtCore.SIGNAL('currentItemChanged(QListWidgetItem, QListWidgetItem)'),
|
||||
self.changeParameter)
|
||||
self.connect(self.searchableList, QtCore.SIGNAL('addItem(list)'), self.addItem)
|
||||
self.connect(self.searchableList, QtCore.SIGNAL('removeItem(list)'), self.removeItem)
|
||||
|
||||
|
||||
self.jobPanel = ert_gui.widgets.util.createEmptyPanel()
|
@ -22,7 +22,6 @@ from ert_gui.widgets.combochoice import ComboChoice
|
||||
from ert_gui.widgets.pathchooser import PathChooser
|
||||
from ert.ert.enums import history_source_type
|
||||
from ert_gui.widgets.reloadbutton import ReloadButton
|
||||
from ert.sched.history import HistoryType
|
||||
|
||||
def createObservationsPage(configPanel, parent):
|
||||
configPanel.startPage("Observations")
|
||||
@ -30,23 +29,14 @@ def createObservationsPage(configPanel, parent):
|
||||
r = configPanel.addRow(ComboChoice(parent, history_source_type.values(), "History source", "config/observations/history_source"))
|
||||
|
||||
def get_history_source(ert):
|
||||
history_source = ert.main.model_config.get_history_source
|
||||
return history_source_type.resolveValue(history_source.get_source_string)
|
||||
history_source = ert.enkf.model_config_get_history_source(ert.model_config)
|
||||
return history_source_type.resolveValue(history_source)
|
||||
|
||||
r.initialize = get_history_source
|
||||
r.getter = get_history_source
|
||||
|
||||
def set_history_source(ert, value):
|
||||
history_source_enum = history_source_type.resolveName(str(value))
|
||||
sched_file = ert.main.ecl_config.get_sched_file
|
||||
refcase = ert.main.ecl_config.get_refcase
|
||||
if history_source_enum.value() == 0:
|
||||
history = HistoryType.alloc_from_sched_file(sched_file)
|
||||
if history_source_enum.value() == 1:
|
||||
history = HistoryType.alloc_from_refcase(refcase, True)
|
||||
if history_source_enum.value() == 2:
|
||||
history = HistoryType.alloc_from_refcase(refcase, False)
|
||||
ert.main.model_config.set_history_source(history, sched_file, refcase)
|
||||
history_source = history_source_type.resolveName(str(value))
|
||||
ert.enkf.model_config_get_history_source(ert.model_config, history_source.value())
|
||||
|
||||
r.setter = set_history_source
|
||||
|
||||
@ -54,21 +44,19 @@ def createObservationsPage(configPanel, parent):
|
||||
r = configPanel.addRow(PathChooser(parent, "Observations config", "config/observations/obs_config", True))
|
||||
|
||||
def get_obs(ert):
|
||||
obs = ert.main.get_obs
|
||||
return obs.get_config_file
|
||||
obs = ert.enkf.enkf_main_get_obs(ert.main)
|
||||
return ert.enkf.enkf_obs_get_config_file(obs)
|
||||
|
||||
r.initialize = get_obs
|
||||
r.getter = get_obs
|
||||
|
||||
|
||||
def set_obs(ert, value):
|
||||
ert.main.load_obs( str(value))
|
||||
ert.enkf.enkf_main_load_obs(ert.main, str(value))
|
||||
r.setter = set_obs
|
||||
|
||||
|
||||
r = configPanel.addRow(ReloadButton(parent, "Reload Observations", "config/observations/reload_observation", "Reload"))
|
||||
r.initialize = lambda ert : ert.main.reload_obs
|
||||
r.getter = lambda ert : ert.main.reload_obs
|
||||
r.getter = lambda ert : ert.enkf.enkf_main_reload_obs(ert.main)
|
||||
|
||||
|
||||
configPanel.endPage()
|
@ -48,10 +48,10 @@ class FieldPanel(QtGui.QFrame):
|
||||
self.max = DoubleBox(self, "", "config/ensemble/field_max")
|
||||
self.modelWrap(self.max, "max")
|
||||
|
||||
self.init = ComboChoice(self, ["None", "EXP", "EXP0", "LOG", "LN","LN0", "POW10", "ADD", "MUL", "RANDINT", "RANDFLOAT"], "", "config/ensemble/field_init")
|
||||
self.init = ComboChoice(self, ["None", "EXP", "LOG", "POW10", "ADD", "MUL", "RANDINT", "RANDFLOAT"], "", "config/ensemble/field_init")
|
||||
self.modelWrap(self.init, "init")
|
||||
|
||||
self.output = ComboChoice(self, ["None", "EXP", "EXP0", "LOG", "LN","LN0", "POW10", "ADD", "MUL", "RANDINT", "RANDFLOAT"], "", "config/ensemble/field_output")
|
||||
self.output = ComboChoice(self, ["None", "EXP", "LOG", "POW10", "ADD", "MUL", "RANDINT", "RANDFLOAT"], "", "config/ensemble/field_output")
|
||||
self.modelWrap(self.output, "output")
|
||||
|
||||
self.init_files = PathChooser(self, "", "config/ensemble/field_init_files", True)
|
@ -32,7 +32,6 @@ import ert_gui.widgets.util
|
||||
from parametermodels import SummaryModel, FieldModel, DataModel, KeywordModel
|
||||
from PyQt4.QtCore import SIGNAL
|
||||
|
||||
|
||||
class ParameterPanel(HelpedWidget):
|
||||
"""Shows a widget for parameters. The data structure expected and sent to the getter and setter is an array of Parameters."""
|
||||
|
||||
@ -60,8 +59,8 @@ class ParameterPanel(HelpedWidget):
|
||||
self.addWidget(self.pagesWidget)
|
||||
|
||||
self.connect(self.searchableList, QtCore.SIGNAL('currentItemChanged(QListWidgetItem, QListWidgetItem)'), self.changeParameter)
|
||||
self.connect(self.searchableList, QtCore.SIGNAL('addItem(QListWidgetItem)'), self.addItem)
|
||||
self.connect(self.searchableList, QtCore.SIGNAL('removeItem(QListWidgetItem)'), self.removeItem)
|
||||
self.connect(self.searchableList, QtCore.SIGNAL('addItem(list)'), self.addItem)
|
||||
self.connect(self.searchableList, QtCore.SIGNAL('removeItem(list)'), self.removeItem)
|
||||
|
||||
#self.addHelpButton()
|
||||
|
||||
@ -111,7 +110,7 @@ class ParameterPanel(HelpedWidget):
|
||||
list.setCurrentItem(parameter)
|
||||
|
||||
user_data = parameter.getUserData()
|
||||
##self.connect(user_data, SIGNAL('modelChanged(Model)'), self.modelChanged)
|
||||
self.connect(user_data, SIGNAL('modelChanged(Model)'), self.modelChanged)
|
||||
|
||||
def modelChanged(self, parameter_model):
|
||||
"""Called whenever the content of a model changes"""
|
||||
@ -124,7 +123,7 @@ class ParameterPanel(HelpedWidget):
|
||||
for index in range(list.count()):
|
||||
uniqueNames.append(str(list.item(index).text()))
|
||||
|
||||
pd = ParameterDialog(self, Parameter.get_typeIcons() , uniqueNames)
|
||||
pd = ParameterDialog(self, Parameter.typeIcons, uniqueNames)
|
||||
if pd.exec_():
|
||||
parameter = self.createParameter(pd.getTypeName(), pd.getName())
|
||||
ok = self.updateContent(parameter, operation=ContentModel.INSERT)
|
||||
@ -155,9 +154,7 @@ class ParameterPanel(HelpedWidget):
|
||||
|
||||
for parameter in parameters:
|
||||
if parameter is None:
|
||||
sys.stderr.write("Unknown type name!\n")
|
||||
break
|
||||
#raise AssertionError("Unknown type name!")
|
||||
raise AssertionError("Unknown type name!")
|
||||
|
||||
param = Parameter(parameter.name, parameter.TYPE)
|
||||
param.setUserData(parameter)
|
||||
@ -169,65 +166,54 @@ class ParameterPanel(HelpedWidget):
|
||||
self.searchableList.getList().setCurrentRow(0)
|
||||
|
||||
|
||||
|
||||
class Parameter(QtGui.QListWidgetItem):
|
||||
"""ListWidgetItem class that represents a Parameter with an associated icon."""
|
||||
|
||||
typeIcons__ = None
|
||||
|
||||
@classmethod
|
||||
def get_typeIcons(cls):
|
||||
if cls.typeIcons__ is None:
|
||||
typeIcons__ = {FieldModel.TYPE: util.resourceIcon("grid_16"),
|
||||
DataModel.TYPE: util.resourceIcon("data"),
|
||||
SummaryModel.TYPE: util.resourceIcon("summary"),
|
||||
KeywordModel.TYPE: util.resourceIcon("key")}
|
||||
return typeIcons__
|
||||
|
||||
typeIcons = {FieldModel.TYPE: util.resourceIcon("grid_16"),
|
||||
DataModel.TYPE: util.resourceIcon("data"),
|
||||
SummaryModel.TYPE: util.resourceIcon("summary"),
|
||||
KeywordModel.TYPE: util.resourceIcon("key")}
|
||||
|
||||
|
||||
def __init__(self, name, type, icon=None):
|
||||
if icon is None:
|
||||
icon = Parameter.get_typeIcons()[type]
|
||||
|
||||
icon = Parameter.typeIcons[type]
|
||||
|
||||
QtGui.QListWidgetItem.__init__(self, icon, name)
|
||||
self.type = type
|
||||
self.name = name
|
||||
self.user_data = None
|
||||
self.setValid(True)
|
||||
|
||||
|
||||
def getType(self):
|
||||
"""Retruns the type of this parameter"""
|
||||
return self.type
|
||||
|
||||
|
||||
def getName(self):
|
||||
"""Returns the name of this parameter (keyword)"""
|
||||
return self.name
|
||||
|
||||
|
||||
def __ge__(self, other):
|
||||
if self.type.name == other.type.name:
|
||||
return self.name.lower() >= other.name.lower()
|
||||
else:
|
||||
return self.type.name >= other.type.name
|
||||
|
||||
|
||||
def __lt__(self, other):
|
||||
return not self >= other
|
||||
|
||||
|
||||
def setUserData(self, data):
|
||||
"""Set user data for this parameter."""
|
||||
self.user_data = data
|
||||
|
||||
|
||||
def getUserData(self):
|
||||
"""Retrieve the user data."""
|
||||
return self.user_data
|
||||
|
||||
|
||||
def setValid(self, valid):
|
||||
"""Set the validity of this item. An invalid item is colored red"""
|
||||
self.valid = valid
|
||||
|
||||
|
||||
if valid:
|
||||
self.setBackgroundColor(QtCore.Qt.white)
|
||||
else:
|
||||
self.setBackgroundColor(HelpedWidget.STRONG_ERROR_COLOR)
|
||||
|
||||
|
@ -27,39 +27,32 @@ def createPlotPage(configPanel, parent):
|
||||
configPanel.startPage("Plot")
|
||||
|
||||
r = configPanel.addRow(PathChooser(parent, "Output path", "config/plot/path"))
|
||||
r.initialize = lambda ert : ert.main.plot_config.get_path
|
||||
r.getter = lambda ert : ert.main.plot_config.get_path
|
||||
r.setter = lambda ert, value : ert.main.plot_config.set_path( str(value))
|
||||
r.getter = lambda ert : ert.enkf.plot_config_get_path(ert.plot_config)
|
||||
r.setter = lambda ert, value : ert.enkf.plot_config_set_path(ert.plot_config, str(value))
|
||||
|
||||
r = configPanel.addRow(ComboChoice(parent, ["PLPLOT", "TEXT"], "Driver", "config/plot/plot_driver"))
|
||||
r.initialize = lambda ert : ert.main.plot_config.get_driver
|
||||
r.getter = lambda ert : ert.main.plot_config.get_driver
|
||||
r.setter = lambda ert, value : ert.main.plot_config.set_driver( str(value))
|
||||
r.getter = lambda ert : ert.enkf.plot_config_get_driver(ert.plot_config)
|
||||
r.setter = lambda ert, value : ert.enkf.plot_config_set_driver(ert.plot_config, str(value))
|
||||
|
||||
r = configPanel.addRow(IntegerSpinner(parent, "Errorbar max", "config/plot/plot_errorbar_max", 1, 10000000))
|
||||
r.initialize = lambda ert : ert.main.plot_config.get_errorbar_max
|
||||
r.getter = lambda ert : ert.main.plot_config.get_errorbar_max
|
||||
r.setter = lambda ert, value : ert.main.plot_config.set_errorbar_max( value)
|
||||
r.getter = lambda ert : ert.enkf.plot_config_get_errorbar_max(ert.plot_config)
|
||||
r.setter = lambda ert, value : ert.enkf.plot_config_set_errorbar_max(ert.plot_config, value)
|
||||
|
||||
r = configPanel.addRow(IntegerSpinner(parent, "Width", "config/plot/width", 1, 10000))
|
||||
r.initialize = lambda ert : ert.main.plot_config.get_width
|
||||
r.getter = lambda ert : ert.main.plot_config.get_width
|
||||
r.setter = lambda ert, value : ert.main.plot_config.set_width( value)
|
||||
r.getter = lambda ert : ert.enkf.plot_config_get_width(ert.plot_config)
|
||||
r.setter = lambda ert, value : ert.enkf.plot_config_set_width(ert.plot_config, value)
|
||||
|
||||
r = configPanel.addRow(IntegerSpinner(parent, "Height", "config/plot/plot_height", 1, 10000))
|
||||
r.initialize = lambda ert : ert.main.plot_config.get_height
|
||||
r.getter = lambda ert : ert.main.plot_config.get_height
|
||||
r.setter = lambda ert, value : ert.main.plot_config.set_height( value)
|
||||
r.getter = lambda ert : ert.enkf.plot_config_get_height(ert.plot_config)
|
||||
r.setter = lambda ert, value : ert.enkf.plot_config_set_height(ert.plot_config, value)
|
||||
|
||||
r = configPanel.addRow(PathChooser(parent, "Image Viewer", "config/plot/image_viewer", True))
|
||||
r.initialize = lambda ert : ert.main.plot_config.get_viewer
|
||||
r.getter = lambda ert : ert.main.plot_config.get_viewer
|
||||
r.setter = lambda ert, value : ert.main.plot_config.set_viewer( str(value))
|
||||
r.getter = lambda ert : ert.enkf.plot_config_get_viewer(ert.plot_config)
|
||||
r.setter = lambda ert, value : ert.enkf.plot_config_set_viewer(ert.plot_config, str(value))
|
||||
|
||||
r = configPanel.addRow(ComboChoice(parent, ["bmp", "jpg", "png", "tif"], "Image type", "config/plot/image_type"))
|
||||
r.initialize = lambda ert : ert.main.plot_config.get_image_type
|
||||
r.getter = lambda ert : ert.main.plot_config.get_image_type
|
||||
r.setter = lambda ert, value : ert.main.plot_config.set_image_type( str(value))
|
||||
r.getter = lambda ert : ert.enkf.plot_config_get_image_type(ert.plot_config)
|
||||
r.setter = lambda ert, value : ert.enkf.plot_config_set_image_type(ert.plot_config, str(value))
|
||||
|
||||
|
||||
configPanel.endPage()
|
@ -29,28 +29,24 @@ def createQueueSystemPage(configPanel, parent):
|
||||
configPanel.startPage("Queue System")
|
||||
|
||||
r = configPanel.addRow(ComboChoice(parent, ["LSF", "RSH", "LOCAL"], "Queue system", "config/queue_system/queue_system"))
|
||||
r.initialize = lambda ert : ert.main.site_config.get_queue_name
|
||||
r.getter = lambda ert : ert.main.site_config.get_queue_name
|
||||
r.setter = lambda ert, value : ert.main.site_config.set_job_queue(str(value))
|
||||
r.getter = lambda ert : ert.enkf.site_config_get_queue_name(ert.site_config)
|
||||
r.setter = lambda ert, value : ert.enkf.site_config_set_job_queue(ert.site_config, str(value))
|
||||
|
||||
internalPanel = ConfigPanel(parent)
|
||||
|
||||
internalPanel.startPage("LSF")
|
||||
|
||||
r = internalPanel.addRow(StringBox(parent, "LSF Queue", "config/queue_system/lsf_queue"))
|
||||
r.initialize = lambda ert : ert.main.site_config.get_lsf_queue
|
||||
r.getter = lambda ert : ert.main.site_config.get_lsf_queue
|
||||
r.setter = lambda ert, value : ert.main.site_config.set_lsf_queue( str(value))
|
||||
r.getter = lambda ert : ert.enkf.site_config_get_lsf_queue(ert.site_config)
|
||||
r.setter = lambda ert, value : ert.enkf.site_config_set_lsf_queue(ert.site_config, str(value))
|
||||
|
||||
r = internalPanel.addRow(IntegerSpinner(parent, "Max running", "config/queue_system/max_running_lsf", 1, 1000))
|
||||
r.initialize = lambda ert : ert.main.site_config.get_max_running_lsf
|
||||
r.getter = lambda ert : ert.main.site_config.get_max_running_lsf
|
||||
r.setter = lambda ert, value : ert.main.site_config.set_max_running_lsf( value)
|
||||
r.getter = lambda ert : ert.enkf.site_config_get_max_running_lsf(ert.site_config)
|
||||
r.setter = lambda ert, value : ert.enkf.site_config_set_max_running_lsf(ert.site_config, value)
|
||||
|
||||
r = internalPanel.addRow(StringBox(parent, "Resources", "config/queue_system/lsf_resources"))
|
||||
r.initialize = lambda ert : ert.main.site_config.get_lsf_request
|
||||
r.getter = lambda ert : ert.main.site_config.get_lsf_request
|
||||
r.setter = lambda ert, value : ert.main.site_config.set_lsf_request(str(value))
|
||||
r.getter = lambda ert : ert.enkf.site_config_get_lsf_request(ert.site_config)
|
||||
r.setter = lambda ert, value : ert.enkf.site_config_set_lsf_request(ert.site_config, str(value))
|
||||
|
||||
internalPanel.endPage()
|
||||
|
||||
@ -58,22 +54,19 @@ def createQueueSystemPage(configPanel, parent):
|
||||
internalPanel.startPage("RSH")
|
||||
|
||||
r = internalPanel.addRow(PathChooser(parent, "Command", "config/queue_system/rsh_command", show_files=True, must_exist=True, is_executable_file=True))
|
||||
r.initialize = lambda ert : ert.main.site_config.get_rsh_command
|
||||
r.getter = lambda ert : ert.main.site_config.get_rsh_command
|
||||
r.setter = lambda ert, value : ert.main.site_config.set_rsh_command(str(value))
|
||||
r.getter = lambda ert : ert.enkf.site_config_get_rsh_command(ert.site_config)
|
||||
r.setter = lambda ert, value : ert.enkf.site_config_set_rsh_command(ert.site_config, str(value))
|
||||
|
||||
r = internalPanel.addRow(IntegerSpinner(parent, "Max running", "config/queue_system/max_running_rsh", 1, 1000))
|
||||
r.initialize = lambda ert : ert.main.site_config.get_max_running_rsh
|
||||
r.getter = lambda ert : ert.main.site_config.get_max_running_rsh
|
||||
r.setter = lambda ert, value : ert.main.site_config.set_max_running_rsh( value)
|
||||
r.getter = lambda ert : ert.enkf.site_config_get_max_running_rsh(ert.site_config)
|
||||
r.setter = lambda ert, value : ert.enkf.site_config_set_max_running_rsh(ert.site_config, value)
|
||||
|
||||
|
||||
r = internalPanel.addRow(KeywordTable(parent, "Host List", "config/queue_system/rsh_host_list", "Host", "Number of jobs"))
|
||||
r.initialize = lambda ert : ert.getHash(ert.main.site_config.get_rsh_host_list, True)
|
||||
r.getter = lambda ert : ert.getHash(ert.main.site_config.get_rsh_host_list, True)
|
||||
r.getter = lambda ert : ert.getHash(ert.enkf.site_config_get_rsh_host_list(ert.site_config), True)
|
||||
|
||||
def add_rsh_host(ert, listOfKeywords):
|
||||
ert.main.site_config.clear_rsh_host_list
|
||||
ert.enkf.site_config_clear_rsh_host_list(ert.site_config)
|
||||
|
||||
for keyword in listOfKeywords:
|
||||
if keyword[1].strip() == "":
|
||||
@ -81,7 +74,7 @@ def createQueueSystemPage(configPanel, parent):
|
||||
else:
|
||||
max_running = int(keyword[1])
|
||||
|
||||
ert.main.site_config.add_rsh_host( keyword[0], max_running)
|
||||
ert.enkf.site_config_add_rsh_host(ert.site_config, keyword[0], max_running)
|
||||
|
||||
r.setter = add_rsh_host
|
||||
|
||||
@ -91,9 +84,8 @@ def createQueueSystemPage(configPanel, parent):
|
||||
internalPanel.startPage("LOCAL")
|
||||
|
||||
r = internalPanel.addRow(IntegerSpinner(parent, "Max running", "config/queue_system/max_running_local", 1, 1000))
|
||||
r.initialize = lambda ert : ert.main.site_config.get_max_running_local
|
||||
r.getter = lambda ert : ert.main.site_config.get_max_running_local
|
||||
r.setter = lambda ert, value : ert.main.site_config.set_max_running_local(value)
|
||||
r.getter = lambda ert : ert.enkf.site_config_get_max_running_local(ert.site_config)
|
||||
r.setter = lambda ert, value : ert.enkf.site_config_set_max_running_local(ert.site_config, value)
|
||||
|
||||
internalPanel.endPage()
|
||||
configPanel.addRow(internalPanel)
|
@ -31,21 +31,18 @@ from ert.ert.enums import keep_runpath_type
|
||||
from simulations.runtemplatepanel import RunTemplatePanel
|
||||
import ert_gui.widgets.helpedwidget
|
||||
import os
|
||||
from ert.util.stringlist import StringList
|
||||
|
||||
def createSimulationsPage(configPanel, parent):
|
||||
configPanel.startPage("Simulations")
|
||||
|
||||
|
||||
r = configPanel.addRow(IntegerSpinner(parent, "Max submit", "config/simulation/max_submit", 1, 10000))
|
||||
r.initialize = lambda ert : ert.main.site_config.get_max_submit
|
||||
r.getter = lambda ert : ert.main.site_config.get_max_submit
|
||||
r.setter = lambda ert, value : ert.main.site_config.set_max_submit( value)
|
||||
r.getter = lambda ert : ert.enkf.site_config_get_max_submit(ert.site_config)
|
||||
r.setter = lambda ert, value : ert.enkf.site_config_set_max_submit(ert.site_config, value)
|
||||
|
||||
r = configPanel.addRow(IntegerSpinner(parent, "Max internal submit", "config/simulation/max_resample", 1, 10000))
|
||||
r.initialize = lambda ert : ert.main.model_config.get_max_internal_submit
|
||||
r.getter = lambda ert : ert.main.model_config.get_max_internal_submit
|
||||
r.setter = lambda ert, value : ert.main.model_config.set_max_internal_submit( value)
|
||||
r = configPanel.addRow(IntegerSpinner(parent, "Max resample", "config/simulation/max_resample", 1, 10000))
|
||||
r.getter = lambda ert : ert.enkf.model_config_get_max_resample(ert.model_config)
|
||||
r.setter = lambda ert, value : ert.enkf.model_config_set_max_resample(ert.model_config, value)
|
||||
|
||||
|
||||
|
||||
@ -53,23 +50,25 @@ def createSimulationsPage(configPanel, parent):
|
||||
|
||||
|
||||
def get_forward_model(ert):
|
||||
site_config = ert.main.site_config
|
||||
installed_jobs = ert.main.site_config.get_installed_jobs
|
||||
available_jobs = installed_jobs.alloc_list
|
||||
site_config = ert.site_config
|
||||
installed_jobs_pointer = ert.enkf.site_config_get_installed_jobs(site_config)
|
||||
installed_jobs_stringlist_pointer = ert.job_queue.ext_joblist_alloc_list(installed_jobs_pointer)
|
||||
available_jobs = ert.getStringList(installed_jobs_stringlist_pointer , free_after_use=True)
|
||||
|
||||
result = {'available_jobs': available_jobs}
|
||||
|
||||
model_config = ert.main.model_config
|
||||
forward_model = model_config.get_forward_model
|
||||
job_names = forward_model.alloc_joblist
|
||||
|
||||
model_config = ert.model_config
|
||||
forward_model = ert.enkf.model_config_get_forward_model(model_config)
|
||||
name_string_list = ert.job_queue.forward_model_alloc_joblist(forward_model)
|
||||
job_names = ert.getStringList(name_string_list, free_after_use=True)
|
||||
|
||||
forward_model_jobs = []
|
||||
|
||||
count = 0
|
||||
for name in job_names:
|
||||
ext_job = forward_model.iget_job( count)
|
||||
arg_string = ext_job.get_private_args_as_string
|
||||
help_text = ext_job.get_help_text
|
||||
ext_job = ert.job_queue.forward_model_iget_job(forward_model, count)
|
||||
arg_string = ert.job_queue.ext_job_get_private_args_as_string(ext_job)
|
||||
help_text = ert.job_queue.ext_job_get_help_text(ext_job)
|
||||
forward_model_jobs.append((name, arg_string, help_text))
|
||||
count+=1
|
||||
|
||||
@ -78,17 +77,16 @@ def createSimulationsPage(configPanel, parent):
|
||||
return result
|
||||
|
||||
r.getter = get_forward_model
|
||||
r.initialize = get_forward_model
|
||||
|
||||
def update_forward_model(ert, forward_model):
|
||||
forward_model_object = ert.main.model_config.get_forward_model
|
||||
forward_model_object.clear
|
||||
forward_model_pointer = ert.enkf.model_config_get_forward_model(ert.model_config)
|
||||
ert.job_queue.forward_model_clear(forward_model_pointer)
|
||||
|
||||
for job in forward_model:
|
||||
name = job[0]
|
||||
args = job[1]
|
||||
ext_job = forward_model.add_job( name)
|
||||
ext_job.set_private_args_from_string( args)
|
||||
ext_job = ert.job_queue.forward_model_add_job(forward_model_pointer, name)
|
||||
ert.job_queue.ext_job_set_private_args_from_string(ext_job, args)
|
||||
|
||||
r.setter = update_forward_model
|
||||
|
||||
@ -98,19 +96,17 @@ def createSimulationsPage(configPanel, parent):
|
||||
|
||||
|
||||
def get_case_table(ert):
|
||||
return ert.main.model_config.get_case_table_file
|
||||
return ert.enkf.model_config_get_case_table_file(ert.model_config)
|
||||
r.getter = get_case_table
|
||||
r.initialize = get_case_table
|
||||
|
||||
|
||||
def set_case_table(ert, value):
|
||||
if os.path.exists(value):
|
||||
ert.main.set_case_table( ert.nonify(value))
|
||||
ert.enkf.enkf_main_set_case_table(ert.model_config, ert.nonify(value))
|
||||
r.setter = set_case_table
|
||||
|
||||
|
||||
r = configPanel.addRow(PathChooser(parent, "License path", "config/simulation/license_path"))
|
||||
r.getter = lambda ert : ert.main.site_config.get_license_root_path
|
||||
r.initialize = lambda ert : ert.main.site_config.get_license_root_path
|
||||
r.getter = lambda ert : ert.enkf.site_config_get_license_root_path(ert.site_config)
|
||||
|
||||
def ls(string):
|
||||
if string is None:
|
||||
@ -118,7 +114,7 @@ def createSimulationsPage(configPanel, parent):
|
||||
else:
|
||||
return string
|
||||
|
||||
r.setter = lambda ert, value : ert.main.site_config.set_license_root_path( ls(value))
|
||||
r.setter = lambda ert, value : ert.enkf.site_config_set_license_root_path(ert.site_config, ls(value))
|
||||
|
||||
|
||||
|
||||
@ -128,36 +124,33 @@ def createSimulationsPage(configPanel, parent):
|
||||
|
||||
r = internalPanel.addRow(PathChooser(parent, "Runpath", "config/simulation/runpath", path_format=True))
|
||||
|
||||
r.getter = lambda ert : ert.main.model_config.get_runpath_as_char
|
||||
r.initialize = lambda ert : ert.main.model_config.get_runpath_as_char
|
||||
r.setter = lambda ert, value : ert.main.model_config.select_runpath( str(value))
|
||||
r.getter = lambda ert : ert.enkf.model_config_get_runpath_as_char(ert.model_config)
|
||||
r.setter = lambda ert, value : ert.enkf.model_config_set_runpath_fmt(ert.model_config, str(value))
|
||||
parent.connect(r, QtCore.SIGNAL("contentsChanged()"), lambda : r.modelEmit("runpathChanged()"))
|
||||
|
||||
|
||||
r = internalPanel.addRow(CheckBox(parent, "Pre clear", "config/simulation/pre_clear_runpath", "Perform pre clear"))
|
||||
|
||||
r.getter = lambda ert : ert.main.get_pre_clear_runpath
|
||||
r.initialize = lambda ert : ert.main.get_pre_clear_runpath
|
||||
r.setter = lambda ert, value : ert.main.set_pre_clear_runpath( value)
|
||||
r.getter = lambda ert : ert.enkf.enkf_main_get_pre_clear_runpath(ert.main)
|
||||
r.setter = lambda ert, value : ert.enkf.enkf_main_set_pre_clear_runpath(ert.main, value)
|
||||
|
||||
|
||||
r = internalPanel.addRow(RunpathMemberPanel(widgetLabel="Retain runpath", helpLabel="config/simulation/runpath_retain"))
|
||||
def get_runpath_retain_state(ert):
|
||||
ensemble_size = ert.main.ens_size
|
||||
ensemble_size = ert.enkf.enkf_main_get_ensemble_size(ert.main)
|
||||
|
||||
result = []
|
||||
for index in range(ensemble_size):
|
||||
state = ert.main.iget_keep_runpath( index)
|
||||
state = ert.enkf.enkf_main_iget_keep_runpath(ert.main, index)
|
||||
result.append((index, keep_runpath_type.resolveValue(state)))
|
||||
|
||||
return result
|
||||
|
||||
r.getter = get_runpath_retain_state
|
||||
r.initialize = get_runpath_retain_state
|
||||
|
||||
|
||||
def set_runpath_retain_state(ert, items):
|
||||
for item in items:
|
||||
ert.main.iset_keep_runpath(item.member, item.runpath_state.value())
|
||||
ert.enkf.enkf_main_iset_keep_runpath(ert.main, item.member, item.runpath_state.value())
|
||||
|
||||
r.setter = set_runpath_retain_state
|
||||
|
||||
@ -169,27 +162,27 @@ def createSimulationsPage(configPanel, parent):
|
||||
r = internalPanel.addRow(RunTemplatePanel(parent))
|
||||
|
||||
def get_run_templates(ert):
|
||||
templates = ert.main.get_templates
|
||||
template_names = templates.alloc_list
|
||||
|
||||
templates = ert.enkf.enkf_main_get_templates(ert.main)
|
||||
template_list = ert.enkf.ert_template_alloc_list(templates)
|
||||
|
||||
template_names = ert.getStringList(template_list, free_after_use=True)
|
||||
result = []
|
||||
for name in template_names:
|
||||
template = templates.get_template(name)
|
||||
template_file = template.get_template_file
|
||||
target_file = template.get_target_file
|
||||
arguments = template.get_args_as_string
|
||||
template = ert.enkf.ert_template_get_template(templates, name)
|
||||
template_file = ert.enkf.ert_template_get_template_file(template)
|
||||
target_file = ert.enkf.ert_template_get_target_file(template)
|
||||
arguments = ert.enkf.ert_template_get_args_as_string(template)
|
||||
result.append((name, template_file, target_file, arguments))
|
||||
return result
|
||||
|
||||
r.getter = get_run_templates
|
||||
r.initialize = get_run_templates
|
||||
|
||||
def set_run_templates(ert, template_list):
|
||||
templates_object = ert.main.get_templates
|
||||
templates_object.clear
|
||||
templates_pointer = ert.enkf.enkf_main_get_templates(ert.main)
|
||||
ert.enkf.ert_template_clear(templates_pointer)
|
||||
|
||||
for template in template_list:
|
||||
templates_object.add_template( template[0], template[1], template[2], template[3])
|
||||
ert.enkf.ert_template_add_template(templates_pointer, template[0], template[1], template[2], template[3])
|
||||
|
||||
r.setter = set_run_templates
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user