Merge pull request #41 from OPM/internal

Update to internal version 0.9.23 MSW working
This commit is contained in:
Jacob Støren
2013-08-28 01:37:27 -07:00
513 changed files with 18599 additions and 8714 deletions

File diff suppressed because it is too large Load Diff

View File

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

View File

@@ -47,7 +47,6 @@
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -97,7 +96,7 @@ void RivWellPipesPartMgr::buildWellPipeParts()
std::vector< size_t > pipeBranchIds;
std::vector< std::vector <cvf::Vec3d> > pipeBranchesCLCoords;
std::vector< std::vector <RigWellResultCell> > pipeBranchesCellIds;
std::vector< std::vector <RigWellResultPoint> > pipeBranchesCellIds;
calculateWellPipeCenterline(pipeBranchesCLCoords, pipeBranchesCellIds);
@@ -163,10 +162,12 @@ void RivWellPipesPartMgr::buildWellPipeParts()
//--------------------------------------------------------------------------------------------------
///
/// Based on the points and cells, calculate a pipe centerline
/// The returned CellIds is one less than the number of centerline points,
/// and are describing the lines between the points, starting with the first line
//--------------------------------------------------------------------------------------------------
void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< std::vector <cvf::Vec3d> >& pipeBranchesCLCoords,
std::vector< std::vector <RigWellResultCell> >& pipeBranchesCellIds) const
std::vector< std::vector <RigWellResultPoint> >& pipeBranchesCellIds) const
{
CVF_ASSERT(m_rimWell.notNull());
CVF_ASSERT(m_rimReservoirView.notNull());
@@ -176,15 +177,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 (staticWellFrame.m_wellResultBranches.size() == 0)
if (wellResults->m_staticWellCells.m_wellResultBranches.size() == 0)
{
wellResults->computeStaticWellCellPath();
}
if (staticWellFrame.m_wellResultBranches.size() == 0) return;
const RigWellResultFrame& staticWellFrame = wellResults->m_staticWellCells;
if (staticWellFrame.m_wellResultBranches.size() == 0) return;
// Initialize the return arrays
pipeBranchesCLCoords.clear();
pipeBranchesCellIds.clear();
@@ -193,7 +194,7 @@ void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< std::vector
// Match this position with well head position in RivWellHeadPartMgr::buildWellHeadParts()
const RigCell& whCell = rigReservoir->cellFromWellResultCell(staticWellFrame.m_wellHead);
cvf::Vec3d whStartPos = whCell.faceCenter(cvf::StructGridInterface::NEG_K);
const RigWellResultCell* whResCell = &(staticWellFrame.m_wellHead);
const RigWellResultPoint* whResCell = &(staticWellFrame.m_wellHead);
// Loop over all the well branches
const std::vector<RigWellResultBranch>& resBranches = staticWellFrame.m_wellResultBranches;
@@ -202,112 +203,259 @@ void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< std::vector
{
for (size_t i = 0 ; i < resBranches.size(); ++i)
{
if (resBranches[i].m_wellCells.size() != 0)
if (resBranches[i].m_branchResultPoints.size() != 0)
{
hasResultCells = true;
break;
}
}
}
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 RigWellResultPoint* prevWellResPoint = NULL;
CVF_ASSERT(wellResults->isMultiSegmentWell() || resBranches.size() <= 1);
// The centerline is calculated by adding a point when the pipe enters a cell,
// and one when the line leaves the cell.
// For the sake of the loop:
// The currentResultPoint (Cell) and the one we index by the loop variable is the one we calculate the entry point to.
// The previous cell is the one we leave, and calculate the "out-point" from
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.
// Loop over all the resultCells in the branch
const std::vector<RigWellResultCell>& resBranchCells = resBranches[brIdx].m_wellCells;
// Skip empty branches. Do not know why they exist, but they make problems.
bool hasValidData = false;
for (size_t cIdx = 0; cIdx < resBranches[brIdx].m_branchResultPoints.size(); ++cIdx)
{
if (resBranches[brIdx].m_branchResultPoints[cIdx].isValid())
{
hasValidData = true;
break;
}
}
if (!hasValidData) continue;
prevWellResPoint = NULL;
// Find the start the MSW well-branch centerline. Normal wells are started "once" at wellhead in the code above
pipeBranchesCLCoords.push_back(std::vector<cvf::Vec3d>());
pipeBranchesCellIds.push_back(std::vector <RigWellResultPoint>());
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
prevWellResPoint = whResCell;
pipeBranchesCLCoords.back().push_back(whStartPos);
pipeBranchesCellIds.back().push_back(*prevWellResPoint);
pipeBranchesCLCoords.back().push_back(whIntermediate);
pipeBranchesCellIds.back().push_back(*prevWellResPoint);
}
// Loop over all the resultPoints in the branch
const std::vector<RigWellResultPoint>& resBranchCells = resBranches[brIdx].m_branchResultPoints;
for (int cIdx = 0; cIdx < static_cast<int>(resBranchCells.size()); cIdx++) // Need int because cIdx can temporarily end on -1
{
std::vector<cvf::Vec3d>& branchCLCoords = pipeBranchesCLCoords.back();
std::vector<RigWellResultCell>& branchCellIds = pipeBranchesCellIds.back();
std::vector<RigWellResultPoint>& branchCellIds = pipeBranchesCellIds.back();
const RigWellResultCell& resCell = resBranchCells[cIdx];
const RigCell& cell = rigReservoir->cellFromWellResultCell(resCell);
const RigWellResultPoint& currentWellResPoint = resBranchCells[cIdx];
// Ignore invalid cells
if (!currentWellResPoint.isValid())
{
//CVF_ASSERT(false); // Some segments does not get anything yet.
continue;
}
// Add cl contribution for a geometrical resultPoint by adding exit point from previous cell,
// and then the result point position
if (!currentWellResPoint.isCell())
{
// Use the interpolated value of branch head
CVF_ASSERT(currentWellResPoint.isPointValid());
cvf::Vec3d currentPoint = currentWellResPoint.m_bottomPosition;
// If we have a real previous cell, we need to go out of it, before adding the current point
// That is: add a CL-point describing where it leaves the previous cell.
if (prevWellResPoint && prevWellResPoint->isCell())
{
// Create ray between the previous and this position
const RigCell& prevCell = rigReservoir->cellFromWellResultCell(*prevWellResPoint);
cvf::Vec3d centerPreviousCell = prevCell.center();
cvf::Ray rayToThisCell;
rayToThisCell.setOrigin(centerPreviousCell);
rayToThisCell.setDirection((currentPoint - centerPreviousCell).getNormalized());
cvf::Vec3d outOfPrevCell(centerPreviousCell);
int intersectionOk = prevCell.firstIntersectionPoint(rayToThisCell, &outOfPrevCell);
//CVF_ASSERT(intersectionOk);
//CVF_ASSERT(intersectionOk);
if ((currentPoint - outOfPrevCell).lengthSquared() > 1e-3)
{
branchCLCoords.push_back(outOfPrevCell);
branchCellIds.push_back(RigWellResultPoint());
}
}
branchCLCoords.push_back(currentPoint);
branchCellIds.push_back(currentWellResPoint);
prevWellResPoint = &currentWellResPoint;
continue;
}
//
// Handle currentWellResPoint as a real cell result points.
//
const RigCell& cell = rigReservoir->cellFromWellResultCell(currentWellResPoint);
// Check if this and the previous cells has shared faces
cvf::StructGridInterface::FaceType sharedFace;
if (rigReservoir->findSharedSourceFace(sharedFace, resCell, *prevResCell))
if (prevWellResPoint && prevWellResPoint->isCell() && rigReservoir->findSharedSourceFace(sharedFace, currentWellResPoint, *prevWellResPoint))
{
// If they share faces, the shared face center is used as point
// describing the entry of this cell. (And exit of the previous cell)
branchCLCoords.push_back(cell.faceCenter(sharedFace));
branchCellIds.push_back(resCell);
branchCellIds.push_back(currentWellResPoint);
}
else
{
// 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();
// This and the previous cell does not share a face.
// Then we need to calculate the exit of the previous cell, and the entry point into this cell
cvf::Vec3d centerPreviousCell(cvf::Vec3d::ZERO);
cvf::Vec3d centerThisCell = cell.center();
bool distanceToWellHeadIsLonger = true;
// First make sure this cell is not starting a new "display" branch
if ( !isAutoDetectBranches || (prevResCell == whResCell)
|| (centerThisCell-centerPrevCell).lengthSquared() <= (centerThisCell - whStartPos).lengthSquared())
// If we have a previous well result point, use its center as measure point and ray intersection start
// when considering things.
if (prevWellResPoint && prevWellResPoint->isValid())
{
// Not starting a "display" branch
// Create ray and intersect with cells
cvf::Ray rayToThisCell;
rayToThisCell.setOrigin(centerPrevCell);
rayToThisCell.setDirection((centerThisCell - centerPrevCell).getNormalized());
cvf::Vec3d outOfPrevCell(centerPrevCell);
cvf::Vec3d intoThisCell(centerThisCell);
bool intersectionOk = prevCell.firstIntersectionPoint(rayToThisCell, &outOfPrevCell);
//CVF_ASSERT(intersectionOk);
intersectionOk = cell.firstIntersectionPoint(rayToThisCell, &intoThisCell);
//CVF_ASSERT(intersectionOk);
if ((intoThisCell - outOfPrevCell).lengthSquared() > 1e-3)
if (prevWellResPoint->isCell())
{
branchCLCoords.push_back(outOfPrevCell);
branchCellIds.push_back(RigWellResultCell());
const RigCell& prevCell = rigReservoir->cellFromWellResultCell(*prevWellResPoint);
centerPreviousCell = prevCell.center();
}
else
{
centerPreviousCell = prevWellResPoint->m_bottomPosition;
}
distanceToWellHeadIsLonger = (centerThisCell - centerPreviousCell).lengthSquared() <= (centerThisCell - whStartPos).lengthSquared();
}
// First make sure this cell is not starting a new "display" branch for none MSW's
if ( wellResults->isMultiSegmentWell()
|| !isAutoDetectBranches
|| (prevWellResPoint == whResCell)
|| distanceToWellHeadIsLonger)
{
// Not starting a "display" branch for normal wells
// Calculate the exit of the previous cell, and the entry point into this cell
cvf::Vec3d intoThisCell(centerThisCell); // Use cell center as default for "into" point.
if (prevWellResPoint && prevWellResPoint->isValid())
{
// We have a defined previous point
// Create ray between the previous and this cell
cvf::Ray rayToThisCell;
rayToThisCell.setOrigin(centerPreviousCell);
rayToThisCell.setDirection((centerThisCell - centerPreviousCell).getNormalized());
// Intersect with the current cell to find a better entry point than the cell center
int intersectionCount = cell.firstIntersectionPoint(rayToThisCell, &intoThisCell);
bool isPreviousResPointInsideCurrentCell = (intersectionCount % 2); // Must intersect uneven times to be inside. (1 % 2 = 1)
// If we have a real previous cell, we need to go out of it, before entering this.
// That is: add a CL-point describing where it leaves the previous cell.
if ( prevWellResPoint->isCell())
{
cvf::Vec3d outOfPrevCell(centerPreviousCell);
const RigCell& prevCell = rigReservoir->cellFromWellResultCell(*prevWellResPoint);
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(RigWellResultPoint());
}
}
else if (isPreviousResPointInsideCurrentCell)
{
// Since the previous point actually is inside this cell,
/// use that as the entry point into this cell
intoThisCell = centerPreviousCell;
}
}
branchCLCoords.push_back(intoThisCell);
branchCellIds.push_back(resCell);
branchCellIds.push_back(currentWellResPoint);
}
else
{
// Need to start a "display branch" for a Normal Well.
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*(centerPrevCell - branchCLCoords.back()) );
// First finish the current branch in the previous cell
//branchCLCoords.push_back(branchCLCoords.back() + 1.5*(centerPreviousCell - branchCLCoords.back()) );
finishPipeCenterLine(pipeBranchesCLCoords, centerPreviousCell);
// Create new display branch
pipeBranchesCLCoords.push_back(std::vector<cvf::Vec3d>());
pipeBranchesCellIds.push_back(std::vector <RigWellResultCell>());
pipeBranchesCellIds.push_back(std::vector <RigWellResultPoint>());
// Start the new branch by entering the first cell (the wellhead) and intermediate
prevResCell = whResCell;
prevWellResPoint = whResCell;
pipeBranchesCLCoords.back().push_back(whStartPos);
pipeBranchesCellIds.back().push_back(*prevResCell);
pipeBranchesCellIds.back().push_back(*prevWellResPoint);
// Include intermediate
pipeBranchesCLCoords.back().push_back(whIntermediate);
pipeBranchesCellIds.back().push_back(*prevResCell);
pipeBranchesCellIds.back().push_back(*prevWellResPoint);
// Well now we need to step one back to take this cell again, but in the new branch.
cIdx--;
@@ -315,16 +463,25 @@ void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< std::vector
}
}
prevResCell = &resCell;
prevWellResPoint = &currentWellResPoint;
}
// For the last cell, add the point 0.5 past the center of that cell
// Remember that prevWellResPoint actually is the last one in this branch.
cvf::Vec3d centerLastCell;
if (prevWellResPoint && prevWellResPoint->isCell())
{
const RigCell& prevCell = rigReservoir->cellFromWellResultCell(*prevWellResPoint);
centerLastCell = prevCell.center();
finishPipeCenterLine(pipeBranchesCLCoords, centerLastCell);
}
else
{
// Remove the ID that is superfluous since we will not add an ending point
pipeBranchesCellIds.back().pop_back();
}
}
// 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()) );
}
CVF_ASSERT(pipeBranchesCellIds.size() == pipeBranchesCLCoords.size());
@@ -334,6 +491,20 @@ void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< std::vector
}
}
//--------------------------------------------------------------------------------------------------
/// All branches are completed using the point 0.5 past the center of
/// last cell.
//--------------------------------------------------------------------------------------------------
void RivWellPipesPartMgr::finishPipeCenterLine(std::vector< std::vector<cvf::Vec3d> > &pipeBranchesCLCoords, const cvf::Vec3d& lastCellCenter) const
{
CVF_ASSERT(pipeBranchesCLCoords.size());
CVF_ASSERT(pipeBranchesCLCoords.back().size());
cvf::Vec3d entryPointLastCell = pipeBranchesCLCoords.back().back();
pipeBranchesCLCoords.back().push_back(entryPointLastCell + 1.5*(lastCellCenter - entryPointLastCell) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -384,12 +555,17 @@ void RivWellPipesPartMgr::updatePipeResultColor(size_t frameIndex)
wellCellStates.clear();
wellCellStates.resize(brIt->m_cellIds.size(), closed);
const std::vector <RigWellResultCell>& cellIds = brIt->m_cellIds;
const std::vector <RigWellResultPoint>& cellIds = brIt->m_cellIds;
for (size_t wcIdx = 0; wcIdx < cellIds.size(); ++wcIdx)
{
// we need a faster lookup, I guess
const RigWellResultCell* wResCell = wResFrame.findResultCell(cellIds[wcIdx].m_gridIndex, cellIds[wcIdx].m_gridCellIndex);
const RigWellResultPoint* wResCell = NULL;
if (cellIds[wcIdx].isCell())
{
wResCell = wResFrame.findResultCell(cellIds[wcIdx].m_gridIndex, cellIds[wcIdx].m_gridCellIndex);
}
if (wResCell == NULL)
{

View File

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

View File

@@ -560,7 +560,7 @@ void RimReservoirView::createDisplayModel()
if (! this->propertyFilterCollection()->hasActiveFilters())
{
std::vector<RivReservoirViewPartMgr::ReservoirGeometryCacheType> geometryTypesToAdd;
if (this->rangeFilterCollection()->hasActiveFilters() || this->wellCollection()->hasVisibleWellCells())
{
geometryTypesToAdd.push_back(RivReservoirViewPartMgr::RANGE_FILTERED);
@@ -582,7 +582,7 @@ void RimReservoirView::createDisplayModel()
geometryTypesToAdd.push_back(RivReservoirViewPartMgr::INACTIVE);
}
}
size_t frameIdx;
for (frameIdx = 0; frameIdx < frameModels.size(); ++frameIdx)
{
@@ -1044,6 +1044,29 @@ 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 RigWellResultPoint* wellResultCell = wellResultFrame.findResultCell(gridIndex, cellIndex);
if (wellResultCell)
{
resultInfoText->append(QString("(0-based) Branch Id : %1 Segment Id %2\n").arg(wellResultCell->m_ertBranchId).arg(wellResultCell->m_ertSegmentId));
if (wellResultCell->m_branchConnectionCount)
{
resultInfoText->append(QString("Branch Connection Count : %1\n").arg(wellResultCell->m_branchConnectionCount));
resultInfoText->append(QString("Center coord : %1 %2 %3\n").arg(wellResultCell->m_bottomPosition.x()).arg(wellResultCell->m_bottomPosition.y()).arg(wellResultCell->m_bottomPosition.z()));
}
}
}
}
}
@@ -1395,11 +1418,16 @@ void RimReservoirView::calculateVisibleWellCellsIncFence(cvf::UByteArray* visibl
const std::vector<RigWellResultBranch>& wellResSegments = wellResFrames[wfIdx].m_wellResultBranches;
for (size_t wsIdx = 0; wsIdx < wellResSegments.size(); ++wsIdx)
{
const std::vector<RigWellResultCell>& wsResCells = wellResSegments[wsIdx].m_wellCells;
const std::vector<RigWellResultPoint>& wsResCells = wellResSegments[wsIdx].m_branchResultPoints;
for (size_t cIdx = 0; cIdx < wsResCells.size(); ++ cIdx)
{
if (wsResCells[cIdx].m_gridIndex == grid->gridIndex())
{
if (!wsResCells[cIdx].isCell())
{
continue;
}
size_t gridCellIndex = wsResCells[cIdx].m_gridCellIndex;
(*visibleCells)[gridCellIndex] = true;

View File

@@ -199,16 +199,19 @@ bool RimWell::calculateWellPipeVisibility(size_t frameIndex)
const std::vector<RigWellResultBranch>& wellResSegments = wrsf.m_wellResultBranches;
for (size_t wsIdx = 0; wsIdx < wellResSegments.size(); ++wsIdx)
{
const std::vector<RigWellResultCell>& wsResCells = wellResSegments[wsIdx].m_wellCells;
const std::vector<RigWellResultPoint>& wsResCells = wellResSegments[wsIdx].m_branchResultPoints;
for (size_t cIdx = 0; cIdx < wsResCells.size(); ++ cIdx)
{
gridIndex = wsResCells[cIdx].m_gridIndex;
gridCellIndex = wsResCells[cIdx].m_gridCellIndex;
cvf::cref<cvf::UByteArray> cellVisibility = rvMan->cellVisibility(visGridParts[gpIdx], gridIndex, frameIndex);
if ((*cellVisibility)[gridCellIndex])
if (wsResCells[cIdx].isCell())
{
return true;
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;
}
}
}
}

View File

@@ -156,7 +156,7 @@ bool RimWellCollection::hasVisibleWellCells()
const RigWellResultFrame& wellResultFrame = well->wellResults()->m_wellCellsTimeSteps[tIdx];
for (size_t wsIdx = 0; !hasCells && wsIdx < wellResultFrame.m_wellResultBranches.size(); ++wsIdx)
{
if (wellResultFrame.m_wellResultBranches[wsIdx].m_wellCells.size() > 0 ) hasCells = true;
if (wellResultFrame.m_wellResultBranches[wsIdx].m_branchResultPoints.size() > 0 ) hasCells = true;
}
}
}

View File

@@ -173,10 +173,10 @@ void RigCaseData::computeWellCellsPrGrid()
{
RigWellResultBranch& wellSegment = wellCells.m_wellResultBranches[sIdx];
size_t cdIdx;
for (cdIdx = 0; cdIdx < wellSegment.m_wellCells.size(); ++cdIdx)
for (cdIdx = 0; cdIdx < wellSegment.m_branchResultPoints.size(); ++cdIdx)
{
gridIndex = wellSegment.m_wellCells[cdIdx].m_gridIndex;
gridCellIndex = wellSegment.m_wellCells[cdIdx].m_gridCellIndex;
gridIndex = wellSegment.m_branchResultPoints[cdIdx].m_gridIndex;
gridCellIndex = wellSegment.m_branchResultPoints[cdIdx].m_gridCellIndex;
if(gridIndex < m_wellCellsInGrid.size() && gridCellIndex < m_wellCellsInGrid[gridIndex]->size())
{
@@ -227,8 +227,10 @@ cvf::UIntArray* RigCaseData::gridCellToWellIndex(size_t gridIndex)
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigCell& RigCaseData::cellFromWellResultCell(const RigWellResultCell& wellResultCell)
RigCell& RigCaseData::cellFromWellResultCell(const RigWellResultPoint& wellResultCell)
{
CVF_ASSERT(wellResultCell.isCell());
size_t gridIndex = wellResultCell.m_gridIndex;
size_t gridCellIndex = wellResultCell.m_gridCellIndex;
@@ -241,7 +243,7 @@ RigCell& RigCaseData::cellFromWellResultCell(const RigWellResultCell& wellResult
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigCaseData::findSharedSourceFace(cvf::StructGridInterface::FaceType& sharedSourceFace,const RigWellResultCell& sourceWellCellResult, const RigWellResultCell& otherWellCellResult) const
bool RigCaseData::findSharedSourceFace(cvf::StructGridInterface::FaceType& sharedSourceFace,const RigWellResultPoint& sourceWellCellResult, const RigWellResultPoint& otherWellCellResult) const
{
size_t gridIndex = sourceWellCellResult.m_gridIndex;
size_t gridCellIndex = sourceWellCellResult.m_gridCellIndex;
@@ -265,12 +267,17 @@ bool RigCaseData::findSharedSourceFace(cvf::StructGridInterface::FaceType& share
size_t ni, nj, nk;
grid->neighborIJKAtCellFace(i, j, k, sourceFace, &ni, &nj, &nk);
size_t neighborCellIndex = grid->cellIndexFromIJK(ni, nj, nk);
if (neighborCellIndex == otherGridCellIndex)
if (grid->isCellValid(ni, nj, nk))
{
sharedSourceFace = sourceFace;
return true;
size_t neighborCellIndex = grid->cellIndexFromIJK(ni, nj, nk);
if (neighborCellIndex == otherGridCellIndex)
{
sharedSourceFace = sourceFace;
return true;
}
}
}

View File

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

View File

@@ -242,9 +242,11 @@ cvf::Vec3d RigCell::faceCenter(cvf::StructGridInterface::FaceType face) const
//--------------------------------------------------------------------------------------------------
/// Find the intersection between the cell and the ray. The point closest to the ray origin is returned
/// if no intersection is found, the intersection point is untouched.
/// in \a intersectionPoint, while the return value is the total number of intersections with the 24 triangles
/// the cell is interpreted as.
/// If no intersection is found, the intersection point is untouched.
//--------------------------------------------------------------------------------------------------
bool RigCell::firstIntersectionPoint(const cvf::Ray& ray, cvf::Vec3d* intersectionPoint) const
int RigCell::firstIntersectionPoint(const cvf::Ray& ray, cvf::Vec3d* intersectionPoint) const
{
CVF_ASSERT(intersectionPoint != NULL);
@@ -254,6 +256,7 @@ bool RigCell::firstIntersectionPoint(const cvf::Ray& ray, cvf::Vec3d* intersecti
cvf::Vec3d firstIntersection(cvf::Vec3d::ZERO);
double minLsq = HUGE_VAL;
int intersectionCount = 0;
for (face = 0; face < 6 ; ++face)
{
@@ -261,9 +264,6 @@ bool RigCell::firstIntersectionPoint(const cvf::Ray& ray, cvf::Vec3d* intersecti
cvf::Vec3d intersection;
cvf::Vec3d faceCenter = this->faceCenter(static_cast<cvf::StructGridInterface::FaceType>(face));
ray.triangleIntersect(nodes[m_cornerIndices[faceVertexIndices[0]]],
nodes[m_cornerIndices[faceVertexIndices[1]]], faceCenter, &intersection);
for (size_t i = 0; i < 4; ++i)
{
size_t next = i < 3 ? i+1 : 0;
@@ -272,6 +272,7 @@ bool RigCell::firstIntersectionPoint(const cvf::Ray& ray, cvf::Vec3d* intersecti
faceCenter,
&intersection))
{
intersectionCount++;
double lsq = (intersection - ray.origin() ).lengthSquared();
if (lsq < minLsq)
{
@@ -282,12 +283,11 @@ bool RigCell::firstIntersectionPoint(const cvf::Ray& ray, cvf::Vec3d* intersecti
}
}
if (minLsq != HUGE_VAL)
if (intersectionCount > 0)
{
*intersectionPoint = firstIntersection;
return true;
}
return false;
return intersectionCount;
}

View File

@@ -62,7 +62,7 @@ public:
cvf::Vec3d center() const;
cvf::Vec3d faceCenter(cvf::StructGridInterface::FaceType face) const;
bool firstIntersectionPoint(const cvf::Ray& ray, cvf::Vec3d* intersectionPoint) const;
int firstIntersectionPoint(const cvf::Ray& ray, cvf::Vec3d* intersectionPoint) const;
bool isLongPyramidCell(double maxHeightFactor = 5, double nodeNearTolerance = 1e-3 ) const;
private:
caf::SizeTArray8 m_cornerIndices;

View File

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

View File

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

View File

@@ -104,6 +104,14 @@ size_t RigSingleWellResultsData::firstResultTimeStep() const
return cvf::UNDEFINED_SIZE_T;
}
bool operator== (const RigWellResultPoint& p1, const RigWellResultPoint& p2)
{
return
p1.m_gridIndex == p2.m_gridIndex
&& p1.m_gridCellIndex == p2.m_gridCellIndex
&& p1.m_ertBranchId == p2.m_ertBranchId
&& p1.m_ertSegmentId == p2.m_ertSegmentId;
}
//--------------------------------------------------------------------------------------------------
///
@@ -112,16 +120,16 @@ void RigSingleWellResultsData::computeStaticWellCellPath()
{
if (m_wellCellsTimeSteps.size() == 0) return;
std::map < size_t, std::list< RigWellResultCell > > staticWellBranches;
std::map < int, std::list< RigWellResultPoint > > staticWellBranches;
// Add ResultCell data from the first timestep to the final result.
for (size_t bIdx = 0; bIdx < m_wellCellsTimeSteps[0].m_wellResultBranches.size(); ++bIdx)
{
size_t branchNumber = m_wellCellsTimeSteps[0].m_wellResultBranches[bIdx].m_branchNumber;
std::vector<RigWellResultCell>& frameCells = m_wellCellsTimeSteps[0].m_wellResultBranches[bIdx].m_wellCells;
int branchNumber = m_wellCellsTimeSteps[0].m_wellResultBranches[bIdx].m_ertBranchId;
std::vector<RigWellResultPoint>& frameCells = m_wellCellsTimeSteps[0].m_wellResultBranches[bIdx].m_branchResultPoints;
std::list< RigWellResultCell >& branch = staticWellBranches[branchNumber];
std::list< RigWellResultPoint >& branch = staticWellBranches[branchNumber];
for(size_t cIdx = 0; cIdx < frameCells.size(); ++cIdx)
{
@@ -137,37 +145,25 @@ 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_branchNumber;
std::vector<RigWellResultCell>& resBranch = m_wellCellsTimeSteps[tIdx].m_wellResultBranches[bIdx].m_wellCells;
int branchId = m_wellCellsTimeSteps[tIdx].m_wellResultBranches[bIdx].m_ertBranchId;
std::vector<RigWellResultPoint>& resBranch = m_wellCellsTimeSteps[tIdx].m_wellResultBranches[bIdx].m_branchResultPoints;
std::list< RigWellResultCell >& stBranch = staticWellBranches[branchNumber];
std::list< RigWellResultCell >::iterator it;
std::list< RigWellResultCell >::iterator sStartIt;
std::list< RigWellResultCell >::iterator sEndIt;
std::list< RigWellResultPoint >& stBranch = staticWellBranches[branchId];
std::list< RigWellResultPoint >::iterator it;
std::list< RigWellResultPoint >::iterator sStartIt;
std::list< RigWellResultPoint >::iterator sEndIt;
size_t rStartIdx;
size_t rEndIdx;
size_t sGridIdx;
size_t sCellIdx;
size_t rGridIdx;
size_t rCellIdx;
// First detect if we have cells on the start of the result frame, that is not in the static frame
{
sEndIt = stBranch.begin();
bool found = false;
if (stBranch.size())
{
sGridIdx = sEndIt->m_gridIndex;
sCellIdx = sEndIt->m_gridCellIndex;
for (rEndIdx = 0; !found && rEndIdx < resBranch.size(); ++rEndIdx)
{
rGridIdx = resBranch[rEndIdx].m_gridIndex;
rCellIdx = resBranch[rEndIdx].m_gridCellIndex;
if (sGridIdx == rGridIdx && sCellIdx == rCellIdx) { found = true; break; }
if ((*sEndIt) == (resBranch[rEndIdx])) { found = true; break; }
}
}
@@ -202,16 +198,10 @@ void RigSingleWellResultsData::computeStaticWellCellPath()
if (sEndIt != stBranch.end()) ++sEndIt;
for ( ; sEndIt != stBranch.end() ; ++sEndIt)
{
sGridIdx = sEndIt->m_gridIndex;
sCellIdx = sEndIt->m_gridCellIndex;
bool found = false;
for (rEndIdx += 1; !found && rEndIdx < resBranch.size(); ++rEndIdx)
{
rGridIdx = resBranch[rEndIdx].m_gridIndex;
rCellIdx = resBranch[rEndIdx].m_gridCellIndex;
if (sGridIdx == rGridIdx && sCellIdx == rCellIdx) { found = true; break; }
if ((*sEndIt) == (resBranch[rEndIdx])) { found = true; break; }
}
if (found)
@@ -245,27 +235,51 @@ void RigSingleWellResultsData::computeStaticWellCellPath()
// Populate the static well info
std::map < size_t, std::list< RigWellResultCell > >::iterator bIt;
std::map < int, std::list< RigWellResultPoint > >::iterator bIt;
m_staticWellCells.m_wellResultBranches.clear();
m_staticWellCells.m_wellHead = m_wellCellsTimeSteps[0].m_wellHead;
for (bIt = staticWellBranches.begin(); bIt != staticWellBranches.end(); ++bIt)
{
RigWellResultBranch rigBranch;
rigBranch.m_branchNumber = bIt->first;
if (bIt->first >= m_wellCellsTimeSteps[0].m_wellResultBranches.size())
{
continue;
}
std::list< RigWellResultCell >& branch = bIt->second;
std::list< RigWellResultCell >::iterator cIt;
// Copy from first time step
RigWellResultBranch rigBranch = m_wellCellsTimeSteps[0].m_wellResultBranches[bIt->first];
rigBranch.m_ertBranchId = bIt->first;
// Clear well cells, and insert the collection of well cells for the static situation
rigBranch.m_branchResultPoints.clear();
std::list< RigWellResultPoint >& branch = bIt->second;
std::list< RigWellResultPoint >::iterator cIt;
for (cIt = branch.begin(); cIt != branch.end(); ++cIt)
{
RigWellResultCell rwc = *cIt;
RigWellResultPoint rwc = *cIt;
rwc.m_isOpen = false; // Reset the dynamic property
rigBranch.m_wellCells.push_back(*cIt);
rigBranch.m_branchResultPoints.push_back(*cIt);
}
m_staticWellCells.m_wellResultBranches.push_back(rigBranch);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigSingleWellResultsData::setMultiSegmentWell(bool isMultiSegmentWell)
{
m_isMultiSegmentWell = isMultiSegmentWell;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigSingleWellResultsData::isMultiSegmentWell() const
{
return m_isMultiSegmentWell;
}

View File

@@ -25,33 +25,69 @@
#include "RimDefines.h"
#include <QDateTime>
#include <vector>
#include "cvfVector3.h"
struct RigWellResultCell
struct RigWellResultPoint
{
RigWellResultCell() :
RigWellResultPoint() :
m_gridIndex(cvf::UNDEFINED_SIZE_T),
m_gridCellIndex(cvf::UNDEFINED_SIZE_T),
m_branchId(-1),
m_segmentId(-1),
m_isOpen(false)
m_isOpen(false),
m_ertBranchId(-1),
m_ertSegmentId(-1),
m_bottomPosition(cvf::Vec3d::UNDEFINED),
m_branchConnectionCount(0)
{ }
bool isPointValid() const
{
return m_bottomPosition != cvf::Vec3d::UNDEFINED;
}
bool isCell() const
{
return m_gridCellIndex != cvf::UNDEFINED_SIZE_T;
}
bool isValid() const
{
return isCell() || isPointValid();
}
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_bottomPosition;
size_t m_branchConnectionCount;
};
struct RigWellResultBranch
{
RigWellResultBranch() :
m_branchNumber(cvf::UNDEFINED_SIZE_T)
m_branchIndex(cvf::UNDEFINED_SIZE_T),
m_ertBranchId(-1),
m_outletBranchIndex_OBSOLETE(cvf::UNDEFINED_SIZE_T),
m_outletBranchHeadCellIndex_OBSOLETE(cvf::UNDEFINED_SIZE_T)
{}
size_t m_branchNumber;
std::vector<RigWellResultCell> m_wellCells;
size_t m_branchIndex;
int m_ertBranchId;
std::vector<RigWellResultPoint> m_branchResultPoints;
// Grid cell from last connection in outlet segment. For MSW wells, this is either well head or a well result cell in another branch
// For standard wells, this is always well head.
size_t m_outletBranchIndex_OBSOLETE;
size_t m_outletBranchHeadCellIndex_OBSOLETE;
};
class RigWellResultFrame
@@ -65,8 +101,10 @@ public:
m_productionType(UNDEFINED_PRODUCTION_TYPE)
{ }
const RigWellResultCell* findResultCell(size_t gridIndex, size_t gridCellIndex) const
const RigWellResultPoint* findResultCell(size_t gridIndex, size_t gridCellIndex) const
{
CVF_ASSERT(gridIndex != cvf::UNDEFINED_SIZE_T && gridCellIndex != cvf::UNDEFINED_SIZE_T);
if (m_wellHead.m_gridCellIndex == gridCellIndex && m_wellHead.m_gridIndex == gridIndex )
{
return &m_wellHead;
@@ -74,12 +112,12 @@ public:
for (size_t wb = 0; wb < m_wellResultBranches.size(); ++wb)
{
for (size_t wc = 0; wc < m_wellResultBranches[wb].m_wellCells.size(); ++wc)
for (size_t wc = 0; wc < m_wellResultBranches[wb].m_branchResultPoints.size(); ++wc)
{
if ( m_wellResultBranches[wb].m_wellCells[wc].m_gridCellIndex == gridCellIndex
&& m_wellResultBranches[wb].m_wellCells[wc].m_gridIndex == gridIndex )
if ( m_wellResultBranches[wb].m_branchResultPoints[wc].m_gridCellIndex == gridCellIndex
&& m_wellResultBranches[wb].m_branchResultPoints[wc].m_gridIndex == gridIndex )
{
return &(m_wellResultBranches[wb].m_wellCells[wc]);
return &(m_wellResultBranches[wb].m_branchResultPoints[wc]);
}
}
}
@@ -87,9 +125,24 @@ public:
return NULL;
}
const RigWellResultPoint* findResultCellFromOutletSpecification(size_t branchIndex, size_t wellResultCellIndex) const
{
if (branchIndex != cvf::UNDEFINED_SIZE_T && branchIndex < m_wellResultBranches.size())
{
const RigWellResultBranch& resBranch = m_wellResultBranches[branchIndex];
if (wellResultCellIndex != cvf::UNDEFINED_SIZE_T && wellResultCellIndex < resBranch.m_branchResultPoints.size())
{
return (&resBranch.m_branchResultPoints[wellResultCellIndex]);
}
}
return NULL;
}
WellProductionType m_productionType;
bool m_isOpen;
RigWellResultCell m_wellHead;
RigWellResultPoint m_wellHead;
QDateTime m_timestamp;
std::vector<RigWellResultBranch> m_wellResultBranches;
@@ -102,6 +155,11 @@ 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;
@@ -113,6 +171,7 @@ 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;

View File

@@ -160,11 +160,11 @@ void StructGridInterface::neighborIJKAtCellFace(size_t i, size_t j, size_t k, Fa
switch (face)
{
case POS_I : (*ni)++; break;
case NEG_I : (*ni)--; break;
case NEG_I : if (i > 0) (*ni)--; else (*ni) = cvf::UNDEFINED_SIZE_T; break;
case POS_J : (*nj)++; break;
case NEG_J : (*nj)--; break;
case NEG_J : if (j > 0) (*nj)--; else (*nj) = cvf::UNDEFINED_SIZE_T; break;
case POS_K : (*nk)++; break;
case NEG_K : (*nk)--; break;
case NEG_K : if (k > 0) (*nk)--; else (*nk) = cvf::UNDEFINED_SIZE_T; break;
}
}

View File

@@ -1,7 +1,7 @@
set(CMAKE_MAJOR_VERSION 0)
set(CMAKE_MINOR_VERSION 9)
set(CMAKE_PATCH_VERSION 20)
set(CMAKE_PATCH_VERSION 23)
set(PRODUCTVER ${CMAKE_MAJOR_VERSION},${CMAKE_MINOR_VERSION},0,${CMAKE_PATCH_VERSION})
set(STRPRODUCTVER ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION})

23
ThirdParty/Ert/.gitignore vendored Normal file
View File

@@ -0,0 +1,23 @@
*.o
*.so
.svn/
*/.svn/
*.pyc
*~
# /devel/libenkf/src/
/devel/libenkf/src/.faultlist
# /develbranch/libenkf/src/
/develbranch/libenkf/src/.faultlist
# Ignore build catalog
/build
# Ignore pdf from tex-test
/devel/libert_util/tests/data/latex_OK.pdf
# Ignore Statoil test data
/devel/test-data/Statoil
# Ignore the ert_local python file which is needed to run some python tests
/devel/python/python/ert/ecl/ecl_local.py

110
ThirdParty/Ert/README vendored
View File

@@ -207,57 +207,45 @@ in the devel/python/docs directory and in the Python classes
themselves.
5. Testing
5. Test
The ERT is very weak on tests, but that is being improved. There are two different
categories of tests:
CMake tests: CMake has a system for adding and running tests, and
these can be invoked with the command 'make test' after the
normal build process has completed, or alternatively the
'ctest' test-runner which allows more options on which tests to run.
The ert codebase has a small but increasing test coverage. The tests
are typically located in a per-library subdirectory tests/. The test
framework is based on ctest which basically works like this:
Python test: The python directory devel/python/test has several
python unittests. These tests test both the Python wrappers
and the underlying C code and serve as quite good integration
tests. Read the content of devel/python/test/README carfully
before you invoke the Python tests, you might have to update
the local_(csh|bash) scripts to reflect your build output
path.
1. In the CMakeLists.txt file testing is enabled with
ENABLE_TESTING().
2. Tests are added with:
5.1 Test data & labels
add_test( test_name test_executable arg1 arg2 arg3 ... )
Unfortunately a large fraction of the test data is based on Statoil
internal data, and is not available on GitHub. All the tests which are
based on Statoil internal test data are labeled with the label
'Statoil', and using the 'ctest' program you can use the -L and -LE
options to include/exclude tests based on their label.
If the executable exits with status 0 the test has passed,
otherwise it has failed. The executable run by the test can
typically be an executable built as part of the solution, but can
in principle be an arbitrary executable like a dedicated test
runner or e.g. the Python interpreter.
ctest -L Statoil # Run all the tests with the 'Statoil' label
ctest -LE Statoil # Run all the tests without the 'Statoil' label
5.1 Test of C code
The argument to the -L and -LE options are regular expressions,
i.e. in the case above all tests which have a label matching the
regexp 'Statoil' will be run. A test can only have one single label,
but due to to the regexp mechanism we can create a 'list-like'
structure by chaining labels together; by convention the label
elements are joined with ':'. In the example
The main part of the testing infrastructure is small C applications
which are added like this:
set_property( TEST test_name PROPERTY LABELS Statoil:Python )
add_executable( test_exe test_source.c )
target_link_libraries( test_exe lib )
add_test( test_name ${EXECUTABLE_OUTPUT_PATH}/test_exe commandline_arg1 commandline_arg2 )
the labels 'Statoil' and 'Python' are applied to the test. The labels
in use are:
Where the two first lines create the test executable in the normal
way, and the last line adds it as a test.
Statoil: This indicates that the test makes use of Statoil internal
test data, and will fail if the Statoil test data have not
been made available according to the description in
devel/test-data/README.txt
5.2 Test of Python Code
Python: This indicates that the test is a Python unittest, and the
Python interpreter will be the test runner for the test.
In devel/python/test there are several files with Python tests, these
files are executable files and they are invoked directly from the
commandline. A limited number of the tests have been integrated in the
ctest system.
5.2 Test names
5.3 Test names
The tests in the cmake build system follow the naming convention of
the library which functionality they are testing - i.e. all tests in
@@ -269,5 +257,45 @@ can be used to include and exclude tests based on their name
ctest -E ecl # Run all tests NOT matching the regexp 'ecl'
The python tests are not yet integrated into this convention....
5.4 Test labels
Using the cmake set_property() function it is possible to assigne
labels to the test, and the -L and -LE options to ctest can be used to
limit which tests to run. A test can only have one label; in the
current ctest setup different labels are combined into one composite
label with a ":" separator, i.e.
set_property( TEST test_xxx PROPERTY LABELS StatoilData:Python)
will set the 'StatoilData' and 'Python' properties on test_xxx. The
labels currently maintained in the ert test setup are:
StatoilData: This implies that the test makes use of Statoil
internal data. If you are in Statoil/Bergen you can see more
details in file devel/test-data/README for how to make this data
available.
If you are not in Statoil/Bergen you must pass the option: "-EL
StatoilData" to ctest to skip all the tests which require
Statoil data.
StatoilBuild: There is one python test which makes use of Statoil
internal configuration data, this test is labeled with
StatoilBuild. If you want to run this test you must set the
cmake option ECL_LOCAL_TARGET to point to a file which contains
some local configuration settings, e.g. where the ECLIPSE binary
is installed.
Python: This label is used to indicate that we are talking about a
Python test.
LSF: This labels indicates that the test needs a working LSF
environment to run.
ctest -L Statoil # Run all tests labeled with Statoil - both
# StatoilData and StatoilBuild
ctest -EL "Statoil|LSF" # Exclude all tests labeled with Statoil or LSF.

View File

@@ -1,3 +0,0 @@
/lib/
ert_build_config.h
*_vector.[ch]

View File

@@ -22,21 +22,24 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(ERT_WINDOWS TRUE)
add_definitions( -DERT_WINDOWS )
# This symbol must be defined to support large (> 2GB) files on windows.
add_definitions( -DWINDOWS_LFS )
endif()
# Treat warnings as errors if not on Windows
if (ERT_WINDOWS)
set( CMAKE_C_FLAGS "-O2" )
set( CMAKE_CXX_FLAGS "-O2" )
else()
set( CMAKE_C_FLAGS "-g -O2 -Wall -Wno-unknown-pragmas -std=gnu99 " )
set( CMAKE_CXX_FLAGS "-g -O2 -Wall" )
set( CMAKE_C_FLAGS "-std=gnu99 -g -O2 -Wall -Wno-unknown-pragmas " )
set( CMAKE_CXX_FLAGS "-g -Wall -O2 ")
endif()
include(cmake/ert_check.cmake)
include(cmake/ert_find.cmake)
include(cmake/Modules/UseMultiArch.cmake)
include(cmake/ert_link.cmake)
set( INSTALL_GROUP "" CACHE STRING "Group to install as - blank to install as current group")
set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
@@ -46,15 +49,9 @@ if (MSVC)
set( LIBRARY_TYPE STATIC )
set( SHARED_LIB OFF )
else()
if (INSTALL_ERT)
set( LIBRARY_TYPE SHARED )
set( SHARED_LIB ON )
else()
set( LIBRARY_TYPE STATIC )
set( SHARED_LIB OFF )
endif(INSTALL_ERT)
endif(MSVC)
endif()
if (MSVC)

View File

@@ -11,7 +11,11 @@ target_file = sys.argv[2]
(target_path , tail) = os.path.split( target_file )
if not os.path.exists( target_path ):
os.makedirs( target_path )
try:
os.makedirs( target_path )
except:
# When running with make -j 4 there might be a race to create this directory.
pass
shutil.copyfile( src_file , target_file )
try:

View File

@@ -17,6 +17,10 @@ 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 )

View File

@@ -1,3 +1,8 @@
check_function_exists( fseeko HAVE_FSEEKO )
if (HAVE_HFSEEKO)
add_definitions( -DHAVE_FSEEKO )
endif()
check_function_exists( regexec HAVE_REGEXP )
if (HAVE_REGEXP)
add_definitions( -DHAVE_REGEXP )
@@ -84,6 +89,16 @@ if (HAVE_OPENDIR)
add_definitions( -DHAVE__USLEEP )
endif()
# Checking based on compiling. Some of the code generates warnings, so we just cut down to bare-bone compiler flags.
set( CMAKE_C_FLAGS_main ${CMAKE_C_FLAGS} )
set( CMAKE_CXX_FLAGS_main ${CMAKE_CXX_FLAGS} )
if (NOT ERT_WINDOWS)
set( CMAKE_C_FLAGS "-std=gnu99" )
set( CMAKE_CXX_FLAGS "")
endif()
try_compile( HAVE_ISFINITE ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_isfinite.c )
if (HAVE_ISFINITE)
add_definitions( -DHAVE_ISFINITE )
@@ -110,3 +125,5 @@ if (ISREG_POSIX)
add_definitions( -DHAVE_ISREG )
endif()
set( CMAKE_C_FLAGS ${CMAKE_C_FLAGS_main} )
set( CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS_main} )

View File

@@ -0,0 +1,14 @@
if (CMAKE_COMPILER_IS_GNUCC)
option (USE_RUNPATH "Embed original dependency paths in installed library" OFF)
if (USE_RUNPATH)
set (CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
endif (USE_RUNPATH)
else()
set(USE_RUNPATH OFF)
endif()
macro( add_runpath target )
set_target_properties( ${target} PROPERTIES LINK_FLAGS -Wl,--enable-new-dtags)
endmacro()

View File

@@ -10,7 +10,9 @@ if (NEED_LIBDL)
target_link_libraries( analysis dl )
endif()
if (USE_RUNPATH)
add_runpath( analysis )
endif()
# List of modules
set( CMAKE_SHARED_MODULE_PREFIX "" )

View File

@@ -1,2 +1,4 @@
add_subdirectory( src )
add_subdirectory( tests )
if (BUILD_TESTS)
add_subdirectory( tests )
endif()

View File

@@ -5,6 +5,9 @@ add_library( config ${LIBRARY_TYPE} ${source_files} )
set_target_properties( config PROPERTIES VERSION 1.0 SOVERSION 1.0 )
target_link_libraries( config ert_util )
if (USE_RUNPATH)
add_runpath( config )
endif()
if (INSTALL_ERT)
install(TARGETS config DESTINATION ${CMAKE_INSTALL_LIBDIR})

View File

@@ -1,44 +1,44 @@
add_executable( config_append_test config_append_test.c )
target_link_libraries( config_append_test config )
target_link_libraries( config_append_test config test_util )
add_executable( config_node_test config_node_test.c )
target_link_libraries( config_node_test config )
target_link_libraries( config_node_test config test_util )
add_executable( config_typeOK config_typeOK.c )
target_link_libraries( config_typeOK config )
target_link_libraries( config_typeOK config test_util )
add_executable( config_typeFail config_typeFail.c )
target_link_libraries( config_typeFail config )
target_link_libraries( config_typeFail config test_util )
add_executable( config_path_elm config_path_elm.c )
target_link_libraries( config_path_elm config )
target_link_libraries( config_path_elm config test_util )
add_executable( config_root_path config_root_path.c )
target_link_libraries( config_root_path config )
target_link_libraries( config_root_path config test_util )
add_executable( config_include_test config_include_test.c)
target_link_libraries( config_include_test config)
target_link_libraries( config_include_test config test_util )
add_executable( config_content_node config_content_node.c)
target_link_libraries( config_content_node config)
target_link_libraries( config_content_node config test_util )
add_executable( config_content_item config_content_item.c)
target_link_libraries( config_content_item config)
target_link_libraries( config_content_item config test_util )
add_executable( config_argc config_argc.c)
target_link_libraries( config_argc config)
target_link_libraries( config_argc config test_util )
add_executable( config_error config_error.c)
target_link_libraries( config_error config)
target_link_libraries( config_error config test_util )
add_test( config_error ${EXECUTABLE_OUTPUT_PATH}/config_error )
add_executable( config_config config_config.c)
target_link_libraries( config_config config)
target_link_libraries( config_config config test_util )
add_test( config_config ${EXECUTABLE_OUTPUT_PATH}/config_config )
add_executable( config_schema_item config_schema_item.c)
target_link_libraries( config_schema_item config)
target_link_libraries( config_schema_item config test_util )
add_test( config_schema_item ${EXECUTABLE_OUTPUT_PATH}/config_schema_item )
add_test( config_typeOK ${EXECUTABLE_OUTPUT_PATH}/config_typeOK ${CMAKE_CURRENT_SOURCE_DIR}/data/type_testOK )

View File

@@ -22,6 +22,7 @@
#include <ert/util/test_util.h>
#include <ert/util/util.h>
#include <ert/util/test_work_area.h>
#include <ert/config/config.h>
#include <ert/config/config_path_elm.h>
@@ -29,17 +30,19 @@
int main(int argc , char ** argv) {
#ifdef ERT_LINUX
const char * root = "/tmp/root";
const char * rel_path = "rel/path";
const char * abs_path = "/tmp/root/rel/path";
const char * rel_true = "rel/path/XXX";
const char * abs_true = "/tmp/root/rel/path/XXX";
const char * path_true1 = "rel/path/XXX";
const char * path_true2 = "/tmp/root/rel/path/XXX";
#endif
util_make_path( root );
test_work_area_type * work_area = test_work_area_alloc( "config_path_elm" , true );
const char * root = test_work_area_get_cwd( work_area );
char * abs_path = util_alloc_filename( root , "rel/path" , NULL);
char * abs_true = util_alloc_filename( root , "rel/path/XXX" , NULL);
char * path_true2 = util_alloc_filename( root , "rel/path/XXX" , NULL);
chdir( test_work_area_get_original_cwd( work_area ));
config_root_path_type * root_path = config_root_path_alloc( root );
{
config_path_elm_type * path_elm = config_path_elm_alloc( root_path , rel_path );
@@ -54,7 +57,6 @@ int main(int argc , char ** argv) {
config_path_elm_free( path_elm );
}
printf("test1 OK \n");
{
config_path_elm_type * path_elm = config_path_elm_alloc( root_path , abs_path );
@@ -67,7 +69,6 @@ int main(int argc , char ** argv) {
config_path_elm_free( path_elm );
}
printf("test2 OK \n");
config_root_path_free( root_path );
chdir( root );
@@ -85,7 +86,6 @@ int main(int argc , char ** argv) {
config_path_elm_free( path_elm );
}
printf("test3 OK \n");
exit(0);
}

View File

@@ -32,13 +32,13 @@ int main(int argc , char ** argv) {
{
config_root_path_type * root_path = config_root_path_alloc( NULL );
if (!test_string_equal( config_root_path_get_abs_path( root_path ) , cwd ))
if (!test_check_string_equal( config_root_path_get_abs_path( root_path ) , cwd ))
test_error_exit("abs:path:%s expeceted:%s \n",config_root_path_get_abs_path( root_path ) , cwd );
if (!test_string_equal( config_root_path_get_input_path( root_path ) , NULL ))
if (!test_check_string_equal( config_root_path_get_input_path( root_path ) , NULL ))
test_error_exit("input:path:%s expeceted:%s \n",config_root_path_get_input_path( root_path ) , NULL );
if (!test_string_equal( config_root_path_get_rel_path( root_path ) , NULL ))
if (!test_check_string_equal( config_root_path_get_rel_path( root_path ) , NULL ))
test_error_exit("rel:path:%s expeceted:%s \n",config_root_path_get_rel_path( root_path ) , NULL );
@@ -62,10 +62,10 @@ int main(int argc , char ** argv) {
config_root_path_type * root_path1 = config_root_path_alloc( input_path );
config_root_path_type * root_path2 = config_root_path_alloc( rel_path );
if (!test_string_equal( config_root_path_get_rel_path( root_path1 ) , config_root_path_get_rel_path( root_path2 )))
if (!test_check_string_equal( config_root_path_get_rel_path( root_path1 ) , config_root_path_get_rel_path( root_path2 )))
test_error_exit("Rel: %s != %s \n",config_root_path_get_rel_path( root_path1 ) , config_root_path_get_rel_path( root_path2));
if (!test_string_equal( config_root_path_get_abs_path( root_path1 ) , config_root_path_get_abs_path( root_path2 )))
if (!test_check_string_equal( config_root_path_get_abs_path( root_path1 ) , config_root_path_get_abs_path( root_path2 )))
test_error_exit("Abs: %s != %s \n",config_root_path_get_abs_path( root_path1 ) , config_root_path_get_abs_path( root_path2 ));
config_root_path_free( root_path1 );

View File

@@ -1,10 +1,5 @@
add_subdirectory( src )
#if (BUILD_APPLICATIONS OR BUILD_ECL_SUMMARY)
# add_subdirectory( applications )
#endif()
add_subdirectory( applications )
if (BUILD_TESTS)
add_subdirectory( tests )
endif()
add_subdirectory( tests )

View File

@@ -3,6 +3,7 @@ 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 )
@@ -15,7 +16,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 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 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)
else()
# The stupid .x extension creates problems on windows
add_executable( convert convert.c )
@@ -28,13 +29,16 @@ 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 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 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)
endif()
foreach(prog ${program_list})
target_link_libraries( ${prog} ecl ert_util )
if (USE_RUNPATH)
add_runpath( ${prog} )
endif()
#-----------------------------------------------------------------
set (destination ${CMAKE_INSTALL_PREFIX}/bin)
if (INSTALL_ERT)
@@ -51,6 +55,9 @@ if (BUILD_ENS_PLOT)
include_directories( ${PLPLOT_HEADER} )
add_executable( ens_plot.x ens_plot.c )
target_link_libraries( ens_plot.x plot ecl)
if (USE_RUNPATH)
add_runpath( ens_plot.x )
endif()
set (destination ${CMAKE_INSTALL_PREFIX}/bin)
if (INSTALL_ERT)
@@ -67,6 +74,9 @@ endif()
if (BUILD_ECL_SUMMARY)
add_executable( ecl_summary view_summary.c )
target_link_libraries( ecl_summary ecl)
if (USE_RUNPATH)
add_runpath( ecl_summary )
endif()
set (destination ${CMAKE_INSTALL_PREFIX}/bin)
if (INSTALL_ERT)

View File

@@ -1,163 +0,0 @@
# 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

View File

@@ -27,39 +27,32 @@
static void build_key_list( const ecl_sum_type * ecl_sum , stringlist_type * key_list ) {
int iw;
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;
int last_step = ecl_sum_get_data_length( ecl_sum ) - 1;
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 );
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;
}
int main(int argc , char ** argv) {
{
ecl_sum_fmt_type fmt;
bool well_rows = false;
bool include_restart = true;
int arg_offset = 1;
@@ -71,23 +64,49 @@ 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( );
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");
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)
ecl_sum_fprintf(ecl_sum , stream , key_list , false , &fmt);
fclose( stream );
free( csv_file );
}
stringlist_free( well_list );
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 );
}
}
}

View File

@@ -0,0 +1,146 @@
/*
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 );
}
}
}

View File

@@ -25,6 +25,8 @@ extern "C" {
#include <stdbool.h>
#include <ert/util/util.h>
#include <ert/ecl/ecl_kw.h>
#include <ert/ecl/fortio.h>
@@ -35,7 +37,7 @@ typedef struct inv_map_struct inv_map_type;
ecl_file_kw_type * inv_map_get_file_kw( inv_map_type * inv_map , const ecl_kw_type * ecl_kw );
void inv_map_free( inv_map_type * map );
ecl_file_kw_type * ecl_file_kw_alloc( const ecl_kw_type * ecl_kw , long offset);
ecl_file_kw_type * ecl_file_kw_alloc( const ecl_kw_type * ecl_kw , offset_type offset);
void ecl_file_kw_free( ecl_file_kw_type * file_kw );
void ecl_file_kw_free__( void * arg );
ecl_kw_type * ecl_file_kw_get_kw( ecl_file_kw_type * file_kw , fortio_type * fortio, inv_map_type * inv_map);

View File

@@ -30,7 +30,10 @@ extern "C" {
#include <ert/ecl/ecl_coarse_cell.h>
#include <ert/ecl/ecl_kw.h>
#include <ert/ecl/grid_dims.h>
#include <ert/ecl/nnc_info.h>
#define ECL_GRID_GLOBAL_GRID "Global" // used as key in hash tables over grids.
#define ECL_GRID_MAINGRID_LGR_NR 0
typedef double (block_function_ftype) ( const double_vector_type *);
typedef struct ecl_grid_struct ecl_grid_type;
@@ -75,6 +78,10 @@ extern "C" {
int ecl_grid_get_global_index3(const ecl_grid_type * , int , int , int );
int ecl_grid_get_global_index1A(const ecl_grid_type * ecl_grid , int active_index);
int ecl_grid_get_global_index1F(const ecl_grid_type * ecl_grid , int active_fracture_index);
const int_vector_type * ecl_grid_get_nnc_index_list( ecl_grid_type * grid );
const nnc_info_type * ecl_grid_get_cell_nnc_info3( const ecl_grid_type * grid , int i , int j , int k);
const nnc_info_type * ecl_grid_get_cell_nnc_info1( const ecl_grid_type * grid , int global_index);
ecl_grid_type * ecl_grid_alloc_GRDECL_kw( int nx, int ny , int nz , const ecl_kw_type * zcorn_kw , const ecl_kw_type * coord_kw , const ecl_kw_type * actnum_kw , const ecl_kw_type * mapaxes_kw );
ecl_grid_type * ecl_grid_alloc_GRDECL_data(int , int , int , const float * , const float * , const int * , const float * mapaxes);
@@ -83,7 +90,7 @@ extern "C" {
ecl_grid_type * ecl_grid_load_case( const char * case_input );
ecl_grid_type * ecl_grid_alloc_rectangular( int nx , int ny , int nz , double dx , double dy , double dz , const int * actnum);
ecl_grid_type * ecl_grid_alloc_regular( int nx, int ny , int nz , const double * ivec, const double * jvec , const double * kvec , const int * actnum);
bool ecl_grid_exists( const char * case_input );
char * ecl_grid_alloc_case_filename( const char * case_input );
@@ -130,16 +137,19 @@ extern "C" {
void ecl_grid_dump(const ecl_grid_type * grid , FILE * stream);
void ecl_grid_dump_ascii(const ecl_grid_type * grid , bool active_only , FILE * stream);
/* lgr related functions */
const ecl_grid_type * ecl_grid_get_cell_lgr3(const ecl_grid_type * grid , int i, int j , int k);
const ecl_grid_type * ecl_grid_get_cell_lgr1A(const ecl_grid_type * grid , int active_index);
const ecl_grid_type * ecl_grid_get_cell_lgr1(const ecl_grid_type * grid , int global_index );
int ecl_grid_get_num_lgr(const ecl_grid_type * main_grid );
int ecl_grid_get_grid_nr( const ecl_grid_type * ecl_grid );
ecl_grid_type * ecl_grid_iget_lgr(const ecl_grid_type * main_grid , int lgr_nr);
int ecl_grid_get_lgr_nr( const ecl_grid_type * ecl_grid );
ecl_grid_type * ecl_grid_iget_lgr(const ecl_grid_type * main_grid , int lgr_index);
ecl_grid_type * ecl_grid_get_lgr_from_lgr_nr(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_index);
const char * ecl_grid_get_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);
@@ -171,6 +181,8 @@ 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
}

View File

@@ -104,6 +104,7 @@ 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"
@@ -135,9 +136,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
/*****************************************************************/
@@ -230,7 +231,12 @@ 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 CONLENEN_KW "CONLENEN" /* Length to connection end for 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
@@ -264,7 +270,20 @@ extern "C" {
the second element will be the name of the parent. */
#define MAPUNITS_KW "MAPUNITS"
#define GRIDUNIT_KW "GRIDUNIT"
#define NNCHEAD_KW "NNCHEAD" /*Non-neighbour connection header*/
#define NNC1_KW "NNC1" /*Upstream cell numbers for non-neighbour connections*/
#define NNC2_KW "NNC2" /*Downstream cell numbers for non-neighbour connections*/
#define NNCL_KW "NNCL" /*Cell numbers for LGR cells that are connected to global grid cells*/
#define NNCG_KW "NNCG" /*Cell numbers for global cells connected to LGR cells*/
#define NNCHEAD_NUMNNC_INDEX 0 /*Item 1 in non-neighbour connection header: number of NNCs. Only present for main grid*/
#define NNCHEAD_LGR_INDEX 1 /*Item 2 in non-neighbour connection header: LGR number (0 for global grid)*/
#define NNCHEADA_KW "NNCHEADA" /*Header for NNC's between two amalgamated LGRs*/
#define NNA1_KW "NNA1" /*Cell numbers in connecting local grid ILOC1*/
#define NNA2_KW "NNA2" /*Cell numbers in connecting local grid ILOC2*/
#define NNCHEADA_ILOC1_INDEX 0 /*ILOC1: Index of first LGR*/
#define NNCHEADA_ILOC2_INDEX 1 /*ILOC2: Index of second LGR*/
#define NNA_NUMNNC_INDEX 0 /*Item 1 in NNA1 or NNA2 is number of NNCs*/
/* EGRID keywords */
#define LGR_PARENT_KW "LGRPARNT" /* The name of the parent for an LGR. */
@@ -277,7 +296,7 @@ extern "C" {
#define ENDGRID_KW "ENDGRID"
#define ENDLGR_KW "ENDLGR"
#define CORSNUM_KW "CORSNUM"
/* GRID keywords */
#define GRIDHEAD_KW "GRIDHEAD" /* Header information for GRID files. */
#define COORD_KW "COORD" /* Header information for one cell in GRID file. */
@@ -293,7 +312,7 @@ extern "C" {
#define GRIDHEAD_NZ_INDEX 3
#define GRIDHEAD_LGR_INDEX 4
#define GRIDHEAD_SIZE 100
/* Observe that these indices are one value lower than the values used
in the ecl_smspec file. */
#define DIMENS_NX_INDEX 0

View File

@@ -0,0 +1,85 @@
/*
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 connection_end,
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_connection_end( 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

View File

@@ -39,15 +39,13 @@ 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);
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);
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);
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 );

View File

@@ -24,6 +24,7 @@ extern "C" {
#include <stdbool.h>
#include <ert/ecl/ecl_file.h>
#include <ert/ecl/ecl_rft_cell.h>
typedef enum { RFT = 1 ,
PLT = 2 ,
@@ -31,28 +32,34 @@ typedef enum { RFT = 1 ,
typedef struct ecl_rft_node_struct ecl_rft_node_type;
int ecl_rft_node_lookup_ijk( const ecl_rft_node_type * rft_node , int i, int j , int k);
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);
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);
void ecl_rft_node_export_DEPTH(const ecl_rft_node_type * , const char * );
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 );
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
}

View File

@@ -63,6 +63,7 @@ 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;

View File

@@ -87,7 +87,7 @@ typedef struct ecl_smspec_struct ecl_smspec_type;
const smspec_node_type * ecl_smspec_get_block_var_node(const ecl_smspec_type * ecl_smspec , const char * block_var , int block_nr);
int ecl_smspec_get_block_var_params_index(const ecl_smspec_type * ecl_smspec , const char * block_var , int block_nr);
bool ecl_smspec_has_block_var(const ecl_smspec_type * ecl_smspec , const char * block_var , int block_nr);
const smspec_node_type * ecl_smspec_get_block_var_node_ijk(const ecl_smspec_type * ecl_smspec , const char * block_var , int i , int j , int k);
int ecl_smspec_get_block_var_params_index_ijk(const ecl_smspec_type * ecl_smspec , const char * block_var , int i , int j , int k);
bool ecl_smspec_has_block_var_ijk(const ecl_smspec_type * ecl_smspec , const char * block_var , int i , int j , int k);

View File

@@ -200,7 +200,11 @@ 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);
bool ecl_sum_report_step_equal( const ecl_sum_type * ecl_sum1 , const ecl_sum_type * ecl_sum2);
bool ecl_sum_report_step_compatible( const ecl_sum_type * ecl_sum1 , const ecl_sum_type * ecl_sum2);
UTIL_IS_INSTANCE_HEADER( ecl_sum );
#ifdef __cplusplus

View File

@@ -83,6 +83,8 @@ typedef struct ecl_sum_data_struct ecl_sum_data_type ;
int ecl_sum_data_iget_report_end( const ecl_sum_data_type * data , int report_step );
int ecl_sum_data_iget_report_start( const ecl_sum_data_type * data , int report_step );
ecl_sum_tstep_type * ecl_sum_data_add_new_tstep( ecl_sum_data_type * data , int report_step , double sim_days);
bool ecl_sum_data_report_step_equal( const ecl_sum_data_type * data1 , const ecl_sum_data_type * data2);
bool ecl_sum_data_report_step_compatible( const ecl_sum_data_type * data1 , const ecl_sum_data_type * data2);
#ifdef __cplusplus
}

View File

@@ -51,6 +51,7 @@ typedef struct ecl_sum_tstep_struct ecl_sum_tstep_type;
void ecl_sum_tstep_iset( ecl_sum_tstep_type * tstep , int index , float value);
void ecl_sum_tstep_set_from_node( ecl_sum_tstep_type * tstep , const smspec_node_type * smspec_node , float value);
void ecl_sum_tstep_set_from_key( ecl_sum_tstep_type * tstep , const char * gen_key , float value);
bool ecl_sum_tstep_sim_time_equal( const ecl_sum_tstep_type * tstep1 , const ecl_sum_tstep_type * tstep2 );
UTIL_SAFE_CAST_HEADER( ecl_sum_tstep );
UTIL_SAFE_CAST_HEADER_CONST( ecl_sum_tstep );

View File

@@ -26,6 +26,8 @@ extern "C" {
#include <stdio.h>
#include <stdbool.h>
#include <ert/util/util.h>
typedef enum {
FORTIO_NOENTRY = 0, /* File does not exists at all - application error. */
FORTIO_EOF = 1, /* The file / record is empty */
@@ -66,8 +68,8 @@ typedef struct fortio_struct fortio_type;
void fortio_rewind(const fortio_type *fortio);
const char * fortio_filename_ref(const fortio_type * );
bool fortio_fmt_file(const fortio_type *);
long fortio_ftell( const fortio_type * fortio );
int fortio_fseek( fortio_type * fortio , long offset , int whence);
offset_type fortio_ftell( const fortio_type * fortio );
int fortio_fseek( fortio_type * fortio , offset_type offset , int whence);
int fortio_fileno( fortio_type * fortio );
bool fortio_fclose_stream( fortio_type * fortio );

View File

@@ -0,0 +1,42 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
The file 'nnc_index_list.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 __NNC_INDEX_LIST_H__
#define __NNC_INDEX_LIST_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <ert/util/int_vector.h>
#include <ert/util/type_macros.h>
typedef struct nnc_index_list_struct nnc_index_list_type;
UTIL_IS_INSTANCE_HEADER(nnc_index_list);
nnc_index_list_type * nnc_index_list_alloc();
void nnc_index_list_free( nnc_index_list_type * index_list );
void nnc_index_list_add_index(nnc_index_list_type * index_list , int index);
const int_vector_type * nnc_index_list_get_list(nnc_index_list_type * index_list);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,55 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
The file 'nnc_info.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 __NNC_INFO_H__
#define __NNC_INFO_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <ert/util/int_vector.h>
#include <ert/util/type_macros.h>
#include <ert/ecl/nnc_vector.h>
typedef struct nnc_info_struct nnc_info_type;
UTIL_IS_INSTANCE_HEADER(nnc_info);
nnc_info_type * nnc_info_alloc(int lgr_nr);
void nnc_info_free( nnc_info_type * nnc_info );
void nnc_info_add_nnc(nnc_info_type * nnc_info, int lgr_nr, int global_cell_number);
const int_vector_type * nnc_info_iget_index_list(const nnc_info_type * nnc_info, int lgr_index);
nnc_vector_type * nnc_info_iget_vector( const nnc_info_type * nnc_info , int lgr_index);
const int_vector_type * nnc_info_get_index_list(const nnc_info_type * nnc_info, int lgr_nr);
nnc_vector_type * nnc_info_get_vector( const nnc_info_type * nnc_info , int lgr_nr);
const int_vector_type * nnc_info_get_self_index_list(const nnc_info_type * nnc_info);
nnc_vector_type * nnc_info_get_self_vector( const nnc_info_type * nnc_info );
int nnc_info_get_lgr_nr(const nnc_info_type * nnc_info );
int nnc_info_get_size( const nnc_info_type * nnc_info );
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -0,0 +1,44 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
The file 'nnc_vector.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 __NNC_VECTOR_H__
#define __NNC_VECTOR_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <ert/util/int_vector.h>
#include <ert/util/type_macros.h>
typedef struct nnc_vector_struct nnc_vector_type;
UTIL_IS_INSTANCE_HEADER(nnc_vector);
nnc_vector_type * nnc_vector_alloc(int lgr_nr);
void nnc_vector_free( nnc_vector_type * nnc_vector );
void nnc_vector_add_nnc(nnc_vector_type * nnc_vector, int global_cell_number);
const int_vector_type * nnc_vector_get_index_list(const nnc_vector_type * nnc_vector);
int nnc_vector_get_lgr_nr(const nnc_vector_type * nnc_vector );
void nnc_vector_free__(void * arg);
#ifdef __cplusplus
}
#endif
#endif

View File

@@ -61,6 +61,8 @@ typedef enum {ECL_SMSPEC_INVALID_VAR = 0 ,
char * smspec_alloc_group_key( const char * join_string , const char * keyword , const char * wgname);
char * smspec_alloc_well_key( const char * join_string , const char * keyword , const char * wgname);
char * smspec_alloc_region_key( const char * join_string , const char * keyword , int num);
char * smspec_alloc_region_2_region_r1r2_key( const char * join_string , const char * keyword , int r1, int r2);
char * smspec_alloc_region_2_region_num_key( const char * join_string , const char * keyword , int num);
char * smspec_alloc_segment_key( const char * join_string , const char * keyword , const char * wgname , int num);
char * smspec_alloc_block_num_key( const char * join_string , const char * keyword , int num);
char * smspec_alloc_local_well_key( const char * join_string , const char * keyword , const char * lgr_name , const char * wgname);

View File

@@ -2,14 +2,17 @@ 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_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_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 nnc_info.c ecl_grav_common.c nnc_vector.c nnc_index_list.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_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_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 nnc_info.h nnc_vector.h ${ext_header} ecl_grav_common.h nnc_index_list.h)
add_library( ecl ${LIBRARY_TYPE} ${source_files} )
set_target_properties( ecl PROPERTIES VERSION 1.0 SOVERSION 1.0 )
if (USE_RUNPATH)
add_runpath( ecl )
endif()
#-----------------------------------------------------------------
set( OPENMP OFF )

View File

@@ -823,7 +823,7 @@ static void ecl_file_scan( ecl_file_type * ecl_file ) {
fortio_fseek( ecl_file->fortio , 0 , SEEK_SET );
{
ecl_kw_type * work_kw = ecl_kw_alloc_new("WORK-KW" , 0 , ECL_INT_TYPE , NULL);
long current_offset;
offset_type current_offset;
while (true) {
current_offset = fortio_ftell( ecl_file->fortio );
if (ecl_kw_fread_header( work_kw , ecl_file->fortio )) {

View File

@@ -56,7 +56,7 @@ struct inv_map_struct {
struct ecl_file_kw_struct {
UTIL_TYPE_ID_DECLARATION;
long file_offset;
offset_type file_offset;
ecl_type_enum ecl_type;
int kw_size;
char * header;
@@ -135,7 +135,7 @@ UTIL_IS_INSTANCE_FUNCTION( ecl_file_kw , ECL_FILE_KW_TYPE_ID )
static ecl_file_kw_type * ecl_file_kw_alloc__( const char * header , ecl_type_enum ecl_type , int size , long offset) {
static ecl_file_kw_type * ecl_file_kw_alloc__( const char * header , ecl_type_enum ecl_type , int size , offset_type offset) {
ecl_file_kw_type * file_kw = util_malloc( sizeof * file_kw );
UTIL_TYPE_ID_INIT( file_kw , ECL_FILE_KW_TYPE_ID );
@@ -160,7 +160,7 @@ static ecl_file_kw_type * ecl_file_kw_alloc__( const char * header , ecl_type_en
access the ecl_file_kw instances.
*/
ecl_file_kw_type * ecl_file_kw_alloc( const ecl_kw_type * ecl_kw , long offset ) {
ecl_file_kw_type * ecl_file_kw_alloc( const ecl_kw_type * ecl_kw , offset_type offset ) {
return ecl_file_kw_alloc__( ecl_kw_get_header( ecl_kw ) , ecl_kw_get_type( ecl_kw ) , ecl_kw_get_size( ecl_kw ) , offset );
}

View File

@@ -39,7 +39,8 @@
#include <ert/ecl/point.h>
#include <ert/ecl/tetrahedron.h>
#include <ert/ecl/grid_dims.h>
#include <ert/ecl/nnc_info.h>
#include <ert/ecl/nnc_index_list.h>
/*
If openmp is enabled the main loop in ecl_grid_init_GRDECL_data is
@@ -358,6 +359,73 @@
*/
/*
About nnc
---------
When loading a grid file the various NNC related keywords are read
in to assemble information of the NNC. The NNC information is
organized as follows:
1. The field nnc_index_list is a thin wrapper around a int_vector
instance which will return a sorted list of indicies of cells
which have attached NNC information.
2. For cells with NNC's attached the information is kept in a
nnc_info_type structure. For a particular cell the nnc_info
structure keeps track of which other cells this particular cell
is connected to, on a per grid (i.e. LGR) basis.
In the nnc_info structure the different grids are identified
through the lgr_nr.
Example usage:
--------------
ecl_grid_type * grid = ecl_grid_alloc("FILE.EGRID");
// Get a int_vector instance with all the cells which have nnc info
// attached.
const int_vector_type * cells_with_nnc = ecl_grid_get_nnc_index_list( grid );
// Iterate over all the cells with nnc info:
for (int i=0; i < int_vector_size( cells_with_nnc ); i++) {
int cell_index = int_vector_iget( cells_with_nnc , i);
const nnc_info_type * nnc_info = ecl_grid_get_nnc_info1( grid , cell_index);
// Get all the nnc connections from @cell_index to other cells in the same grid
{
const int_vector_type * nnc_list = nnc_info_get_self_index_list( nnc_info );
for (int j=0; j < int_vector_size( nnc_list ); j++)
printf("Cell[%d] -> %d in the same grid \n",cell_index , int_vector_iget(nnc_list , j));
}
{
for (int lgr_index=0; lgr_index < nnc_info_get_size( nnc_info ); lgr_index++) {
nnc_vector_type * nnc_vector = nnc_info_iget_vector( nnc_info , lgr_index );
int lgr_nr = nnc_vector_get_lgr_nr( nnc_vector );
if (lgr_nr != nnc_info_get_lgr_nr( nnc_info )) {
const int_vector_type * nnc_list = nnc_vector_get_index_list( nnc_vector );
for (int j=0; j < int_vector_size( nnc_list ); j++)
printf("Cell[%d] -> %d in lgr:%d/%s \n",cell_index , int_vector_iget(nnc_list , j) , lgr_nr , ecl_grid_get_lgr_name(ecl_grid , lgr_nr));
}
}
}
}
Dual porosity and nnc: In ECLIPSE the connection between the matrix
properties and the fracture properties in a cell is implemented as a
nnc where the fracture cell has global index in the range [nx*ny*nz,
2*nz*ny*nz). In ert we we have not implemented this double covering
in the case of dual porosity models, and therefor NNC involving
fracture cells are not considered.
*/
/*
about tetraheder decomposition
@@ -467,6 +535,7 @@ struct ecl_cell_struct {
int host_cell; /* the global index of the host cell for an lgr cell, set to -1 for normal cells. */
int coarse_group; /* The index of the coarse group holding this cell -1 for non-coarsened cells. */
int cell_flags;
nnc_info_type * nnc_info; /* Non-neighbour connection info*/
};
@@ -476,7 +545,8 @@ struct ecl_cell_struct {
struct ecl_grid_struct {
UTIL_TYPE_ID_DECLARATION;
int grid_nr; /* this corresponds to item 4 in gridhead - 0 for the main grid. */
int lgr_nr; /* EGRID files: corresponds to item 4 in gridhead - 0 for the main grid.
GRID files: 0 for the main grid, then 1 -> number of LGRs in order read from file*/
char * name; /* the name of the file for the main grid - name of the lgr for lgrs. */
int ny,nz,nx;
int size; /* == nx*ny*nz */
@@ -488,6 +558,7 @@ struct ecl_grid_struct {
int * fracture_index_map; /* For fractures: this a list of nx*ny*nz elements, where value -1 means inactive cell .*/
int * inv_fracture_index_map; /* For fractures: this is list of total_active elements - which point back to the index_map. */
nnc_index_list_type * nnc_index_list;
#ifdef LARGE_CELL_MALLOC
ecl_cell_type * cells;
@@ -506,19 +577,20 @@ struct ecl_grid_struct {
/*
the two fields below are for *storing* lgr grid instances. observe
that these fields will be NULL for lgr grids, i.e. grids with
grid_nr > 0.
lgr_nr > 0.
*/
vector_type * LGR_list; /* a vector of ecl_grid instances for lgr's - the index corresponds to the grid_nr. */
vector_type * LGR_list; /* a vector of ecl_grid instances for LGRs - the index corresponds to the order LGRs are read from file*/
int_vector_type * lgr_index_map; /* a vector that maps LGR-nr for EGRID files to index into the LGR_list.*/
hash_type * LGR_hash; /* a hash of pointers to ecl_grid instances - for name based lookup of lgr. */
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;
@@ -826,6 +898,8 @@ static void ecl_cell_init( ecl_cell_type * cell , bool init_valid) {
if (init_valid)
cell->cell_flags = CELL_FLAG_VALID;
cell->nnc_info = NULL;
}
@@ -1089,6 +1163,7 @@ 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.
@@ -1121,6 +1196,14 @@ static void ecl_grid_taint_cells( ecl_grid_type * ecl_grid ) {
static void ecl_grid_free_cells( ecl_grid_type * grid ) {
int i;
for (i=0; i < grid->size; i++) {
ecl_cell_type * cell = ecl_grid_get_cell( grid , i );
if (cell->nnc_info)
nnc_info_free(cell->nnc_info);
}
#ifndef LARGE_CELL_MALLOC
int i;
for (i=0; i < grid->size; i++) {
@@ -1161,7 +1244,7 @@ static void ecl_grid_alloc_cells( ecl_grid_type * grid , bool init_valid) {
is performed.
*/
static ecl_grid_type * ecl_grid_alloc_empty(ecl_grid_type * global_grid , int dualp_flag , int nx , int ny , int nz, int grid_nr , bool init_valid) {
static ecl_grid_type * ecl_grid_alloc_empty(ecl_grid_type * global_grid , int dualp_flag , int nx , int ny , int nz, int lgr_nr, bool init_valid) {
ecl_grid_type * grid = util_malloc(sizeof * grid );
UTIL_TYPE_ID_INIT(grid , ECL_GRID_ID);
grid->total_active = 0;
@@ -1170,7 +1253,7 @@ static ecl_grid_type * ecl_grid_alloc_empty(ecl_grid_type * global_grid , int du
grid->ny = ny;
grid->nz = nz;
grid->size = nx*ny*nz;
grid->grid_nr = grid_nr;
grid->lgr_nr = lgr_nr;
grid->global_grid = global_grid;
grid->coarsening_active = false;
@@ -1181,8 +1264,9 @@ static ecl_grid_type * ecl_grid_alloc_empty(ecl_grid_type * global_grid , int du
grid->index_map = NULL;
grid->fracture_index_map = NULL;
grid->inv_fracture_index_map = NULL;
grid->nnc_index_list = nnc_index_list_alloc( );
ecl_grid_alloc_cells( grid , init_valid );
if (global_grid != NULL) {
/* this is an lgr instance, and we inherit the global grid
@@ -1205,21 +1289,22 @@ static ecl_grid_type * ecl_grid_alloc_empty(ecl_grid_type * global_grid , int du
}
grid->block_dim = 0;
grid->values = NULL;
if (grid_nr == 0) { /* this is the main grid */
grid->LGR_list = vector_alloc_new();
vector_append_ref( grid->LGR_list , grid ); /* adding a 'self' pointer as first inistance - without destructor! */
grid->LGR_hash = hash_alloc();
grid->block_dim = 0;
grid->values = NULL;
if (ECL_GRID_MAINGRID_LGR_NR == lgr_nr) { /* this is the main grid */
grid->LGR_list = vector_alloc_new();
grid->lgr_index_map = int_vector_alloc(0,0);
grid->LGR_hash = hash_alloc();
} else {
grid->LGR_list = NULL;
grid->LGR_hash = NULL;
grid->LGR_list = NULL;
grid->lgr_index_map = NULL;
grid->LGR_hash = NULL;
}
grid->name = NULL;
grid->parent_name = NULL;
grid->parent_grid = NULL;
grid->children = hash_alloc();
grid->coarse_cells = vector_alloc_new();
grid->name = NULL;
grid->parent_name = NULL;
grid->parent_grid = NULL;
grid->children = hash_alloc();
grid->coarse_cells = vector_alloc_new();
return grid;
}
@@ -1321,12 +1406,12 @@ static void ecl_grid_set_cell_GRID(ecl_grid_type * ecl_grid , int coords_size ,
/*
The grid_nr > 0 test essentially checks if this is a LGR; if
this test applies we either have bug - or a GRID file with LGRs
and only 4/5 elements in the coords keywords. In the latter
case we must start using the LGRILG keyword.
The ECL_GRID_MAINGRID_LGR_NR != ecl_grid->lgr_nr test checks if
this is a LGR; if this test applies we either have bug - or a
GRID file with LGRs and only 4/5 elements in the coords keywords.
In the latter case we must start using the LGRILG keyword.
*/
if ((ecl_grid->grid_nr > 0) && (coords_size != 7))
if ((ECL_GRID_MAINGRID_LGR_NR != ecl_grid->lgr_nr) && (coords_size != 7))
util_abort("%s: Need 7 element coords keywords for LGR - or reimplement to use LGRILG keyword.\n",__func__);
switch(coords_size) {
@@ -1698,13 +1783,9 @@ static void ecl_grid_init_mapaxes( ecl_grid_type * ecl_grid , const float * mapa
static void ecl_grid_add_lgr( ecl_grid_type * main_grid , ecl_grid_type * lgr_grid) {
int next_grid_nr = vector_get_size( main_grid->LGR_list );
if (next_grid_nr != lgr_grid->grid_nr)
util_abort("%s: index based insertion of lgr grid failed. next_grid_nr:%d lgr->grid_nr:%d \n",__func__ , next_grid_nr , lgr_grid->grid_nr);
{
vector_append_owned_ref( main_grid->LGR_list , lgr_grid , ecl_grid_free__);
hash_insert_ref( main_grid->LGR_hash , lgr_grid->name , lgr_grid);
}
vector_append_owned_ref( main_grid->LGR_list , lgr_grid , ecl_grid_free__);
int_vector_iset(main_grid->lgr_index_map, lgr_grid->lgr_nr, vector_get_size(main_grid->LGR_list)-1);
hash_insert_ref( main_grid->LGR_hash , lgr_grid->name , lgr_grid);
}
@@ -1763,7 +1844,7 @@ static void ecl_grid_set_lgr_name_EGRID(ecl_grid_type * lgr_grid , const ecl_fil
ecl_kw_type * lgrname_kw = ecl_file_iget_named_kw( ecl_file , LGR_KW , grid_nr - 1);
lgr_grid->name = util_alloc_strip_copy( ecl_kw_iget_ptr( lgrname_kw , 0) ); /* trailing zeros are stripped away. */
if (ecl_file_has_kw( ecl_file , LGR_PARENT_KW)) {
ecl_kw_type * parent_kw = ecl_file_iget_named_kw( ecl_file , LGR_PARENT_KW , grid_nr - 1);
ecl_kw_type * parent_kw = ecl_file_iget_named_kw( ecl_file , LGR_PARENT_KW , grid_nr -1);
char * parent = util_alloc_strip_copy( ecl_kw_iget_ptr( parent_kw , 0));
if (strlen( parent ) > 0)
@@ -1794,7 +1875,7 @@ static void ecl_grid_set_lgr_name_GRID(ecl_grid_type * lgr_grid , const ecl_file
if ((strlen(parent) == 0) || (strcmp(parent , GLOBAL_STRING ) == 0))
free( parent );
else
else
lgr_grid->parent_name = parent;
}
}
@@ -1892,9 +1973,9 @@ void ecl_grid_init_GRDECL_data(ecl_grid_type * ecl_grid , const float * zcorn ,
static ecl_grid_type * ecl_grid_alloc_GRDECL_data__(ecl_grid_type * global_grid ,
int dualp_flag , int nx , int ny , int nz ,
const float * zcorn , const float * coord , const int * actnum, const float * mapaxes, const int * corsnum,
int grid_nr) {
int lgr_nr) {
ecl_grid_type * ecl_grid = ecl_grid_alloc_empty(global_grid , dualp_flag , nx,ny,nz,grid_nr,true);
ecl_grid_type * ecl_grid = ecl_grid_alloc_empty(global_grid , dualp_flag , nx,ny,nz,lgr_nr,true);
if (mapaxes != NULL)
ecl_grid_init_mapaxes( ecl_grid , mapaxes );
@@ -1929,15 +2010,14 @@ static ecl_grid_type * ecl_grid_alloc_GRDECL_kw__(ecl_grid_type * global_grid ,
const ecl_kw_type * coord_kw ,
const ecl_kw_type * actnum_kw , /* Can be NULL */
const ecl_kw_type * mapaxes_kw , /* Can be NULL */
const ecl_kw_type * corsnum_kw , /* Can be NULL */
int grid_nr) {
int gtype, nx,ny,nz;
const ecl_kw_type * corsnum_kw) { /* Can be NULL */
int gtype, nx,ny,nz, lgr_nr;
gtype = ecl_kw_iget_int(gridhead_kw , GRIDHEAD_TYPE_INDEX);
nx = ecl_kw_iget_int(gridhead_kw , GRIDHEAD_NX_INDEX);
ny = ecl_kw_iget_int(gridhead_kw , GRIDHEAD_NY_INDEX);
nz = ecl_kw_iget_int(gridhead_kw , GRIDHEAD_NZ_INDEX);
lgr_nr = ecl_kw_iget_int(gridhead_kw , GRIDHEAD_LGR_INDEX);
/*
The code used to have this test:
@@ -1950,7 +2030,7 @@ static ecl_grid_type * ecl_grid_alloc_GRDECL_kw__(ecl_grid_type * global_grid ,
if (gtype != GRIDHEAD_GRIDTYPE_CORNERPOINT)
util_abort("%s: gtype:%d fatal error when loading grid - must have corner point grid - aborting\n",__func__ , gtype );
{
const float * mapaxes_data = NULL;
const int * actnum_data = NULL;
@@ -1973,7 +2053,7 @@ static ecl_grid_type * ecl_grid_alloc_GRDECL_kw__(ecl_grid_type * global_grid ,
actnum_data,
mapaxes_data,
corsnum_data,
grid_nr);
lgr_nr);
}
}
@@ -1982,7 +2062,7 @@ static ecl_grid_type * ecl_grid_alloc_GRDECL_kw__(ecl_grid_type * global_grid ,
If you create/load ecl_kw instances for the various fields, this
function can be used to create a GRID instance, without going
through a GRID/EGRID file. Does not support LGR or coarsening
hierarchies.
hierarchies.
*/
ecl_grid_type * ecl_grid_alloc_GRDECL_kw( int nx, int ny , int nz ,
@@ -1990,10 +2070,10 @@ ecl_grid_type * ecl_grid_alloc_GRDECL_kw( int nx, int ny , int nz ,
const ecl_kw_type * coord_kw ,
const ecl_kw_type * actnum_kw , /* Can be NULL */
const ecl_kw_type * mapaxes_kw ) { /* Can be NULL */
ecl_kw_type * gridhead_kw = ecl_grid_alloc_gridhead_kw( nx , ny , nz , 0);
ecl_grid_type * ecl_grid = ecl_grid_alloc_GRDECL_kw__(NULL , FILEHEAD_SINGLE_POROSITY , gridhead_kw , zcorn_kw , coord_kw , actnum_kw , mapaxes_kw , NULL , 0);
ecl_grid_type * ecl_grid = ecl_grid_alloc_GRDECL_kw__(NULL , FILEHEAD_SINGLE_POROSITY , gridhead_kw , zcorn_kw , coord_kw , actnum_kw , mapaxes_kw , NULL);
ecl_kw_free( gridhead_kw );
return ecl_grid;
@@ -2001,6 +2081,126 @@ ecl_grid_type * ecl_grid_alloc_GRDECL_kw( int nx, int ny , int nz ,
static void ecl_grid_init_cell_nnc_info(ecl_grid_type * ecl_grid, int global_index) {
ecl_cell_type * grid_cell = ecl_grid_get_cell(ecl_grid, global_index);
if (!grid_cell->nnc_info)
grid_cell->nnc_info = nnc_info_alloc(ecl_grid->lgr_nr);
}
/*
This function populates nnc_info for cells with non neighbour connections
*/
static void ecl_grid_init_nnc_cells( ecl_grid_type * grid1, ecl_grid_type * grid2, const ecl_kw_type * keyword1, const ecl_kw_type * keyword2) {
int * grid1_nnc_cells = ecl_kw_get_int_ptr(keyword1);
int * grid2_nnc_cells = ecl_kw_get_int_ptr(keyword2);
int nnc_count = ecl_kw_get_size(keyword2);
int i;
for (i = 0; i < nnc_count; i++) {
int grid1_cell_index = grid1_nnc_cells[i] -1;
int grid2_cell_index = grid2_nnc_cells[i] -1;
/*
In the ECLIPSE output format grids with dual porosity are (to some
extent ...) modeled as two independent grids stacked on top of
eachother, where the fracture cells have global index in the range
[nx*ny*nz, 2*nx*ny*nz).
The physical connection between the matrix and the fractures in
cell nr c is modelled as an nnc: cell[c] -> cell[c + nx*ny*nz]. In
the ert ecl library we only have cells in the range [0,nx*ny*nz),
and fracture is a property of a cell, we therefor do not include
nnc connections involving fracture cells (i.e. cell_index >=
nx*ny*nz).
*/
if ((FILEHEAD_SINGLE_POROSITY != grid1->dualp_flag) &&
((grid1_cell_index >= grid1->size) ||
(grid2_cell_index >= grid2->size)))
break;
ecl_grid_init_cell_nnc_info(grid1, grid1_cell_index);
ecl_grid_init_cell_nnc_info(grid2, grid2_cell_index);
{
ecl_cell_type * grid1_cell = ecl_grid_get_cell(grid1, grid1_cell_index);
ecl_cell_type * grid2_cell = ecl_grid_get_cell(grid2, grid2_cell_index);
//Add the non-neighbour connection in both directions
nnc_info_add_nnc(grid1_cell->nnc_info, grid2->lgr_nr, grid2_cell_index);
nnc_info_add_nnc(grid2_cell->nnc_info, grid1->lgr_nr, grid1_cell_index);
nnc_index_list_add_index( grid1->nnc_index_list , grid1_cell_index );
nnc_index_list_add_index( grid2->nnc_index_list , grid2_cell_index );
}
}
}
/*
This function reads the non-neighbour connection data from file and initializes the grid structure with the the nnc data
*/
static void ecl_grid_init_nnc(ecl_grid_type * main_grid, ecl_file_type * ecl_file) {
int num_nnchead_kw = ecl_file_get_num_named_kw( ecl_file , NNCHEAD_KW );
int num_nncg_kw = ecl_file_get_num_named_kw( ecl_file , NNCG_KW );
int i;
for (i = 0; i < num_nnchead_kw; i++) {
ecl_kw_type * nnchead_kw = ecl_file_iget_named_kw( ecl_file , NNCHEAD_KW , i);
int lgr_nr = ecl_kw_iget_int(nnchead_kw, NNCHEAD_LGR_INDEX);
ecl_kw_type * keyword1 = NULL;
ecl_kw_type * keyword2 = NULL;
if (ECL_GRID_MAINGRID_LGR_NR == lgr_nr) {
keyword1 = ecl_file_iget_named_kw( ecl_file , NNC1_KW , i);
keyword2 = ecl_file_iget_named_kw( ecl_file , NNC2_KW , i);
} else {
int nnc_lgr_index = (num_nnchead_kw == num_nncg_kw) ? i : i-1; //Subtract 1 if no nnc data for main grid
keyword1 = ecl_file_iget_named_kw( ecl_file , NNCL_KW , nnc_lgr_index);
keyword2 = ecl_file_iget_named_kw( ecl_file , NNCG_KW , nnc_lgr_index);
}
{
ecl_grid_type * grid = (lgr_nr > 0) ? ecl_grid_get_lgr_from_lgr_nr(main_grid, lgr_nr) : main_grid;
ecl_grid_init_nnc_cells(grid, main_grid, keyword1, keyword2);
}
}
}
/*
This function reads the non-neighbour connection data for amalgamated LGRs (that is, non-neighbour
connections between two LGRs) and initializes the grid structure with the nnc data.
*/
static void ecl_grid_init_nnc_amalgamated(ecl_grid_type * main_grid, ecl_file_type * ecl_file) {
int num_nncheada_kw = ecl_file_get_num_named_kw( ecl_file , NNCHEADA_KW );
int i;
for (i = 0; i < num_nncheada_kw; i++) {
ecl_kw_type * nncheada_kw = ecl_file_iget_named_kw( ecl_file , NNCHEADA_KW , i);
int lgr_nr1 = ecl_kw_iget_int(nncheada_kw, NNCHEADA_ILOC1_INDEX);
int lgr_nr2 = ecl_kw_iget_int(nncheada_kw, NNCHEADA_ILOC2_INDEX);
ecl_grid_type * lgr_grid1 = ecl_grid_get_lgr_from_lgr_nr(main_grid, lgr_nr1);
ecl_grid_type * lgr_grid2 = ecl_grid_get_lgr_from_lgr_nr(main_grid, lgr_nr2);
ecl_kw_type * nna1_kw = ecl_file_iget_named_kw( ecl_file , NNA1_KW , i);
ecl_kw_type * nna2_kw = ecl_file_iget_named_kw( ecl_file , NNA2_KW , i);
ecl_grid_init_nnc_cells( lgr_grid1 ,lgr_grid2, nna1_kw, nna2_kw);
}
}
/**
Creating a grid based on a EGRID file is a three step process:
@@ -2044,7 +2244,7 @@ static ecl_grid_type * ecl_grid_alloc_EGRID__( ecl_grid_type * main_grid , const
corsnum_kw = ecl_file_iget_named_kw( ecl_file , CORSNUM_KW , 0);
}
{
ecl_grid_type * ecl_grid = ecl_grid_alloc_GRDECL_kw__( main_grid ,
@@ -2054,10 +2254,9 @@ static ecl_grid_type * ecl_grid_alloc_EGRID__( ecl_grid_type * main_grid , const
coord_kw ,
actnum_kw ,
mapaxes_kw ,
corsnum_kw ,
grid_nr );
if (grid_nr > 0) ecl_grid_set_lgr_name_EGRID(ecl_grid , ecl_file , grid_nr);
corsnum_kw );
if (ECL_GRID_MAINGRID_LGR_NR != grid_nr) ecl_grid_set_lgr_name_EGRID(ecl_grid , ecl_file , grid_nr);
return ecl_grid;
}
}
@@ -2090,6 +2289,10 @@ static ecl_grid_type * ecl_grid_alloc_EGRID(const char * grid_file) {
}
}
main_grid->name = util_alloc_string_copy( grid_file );
ecl_grid_init_nnc(main_grid, ecl_file);
ecl_grid_init_nnc_amalgamated(main_grid, ecl_file);
ecl_file_close( ecl_file );
return main_grid;
}
@@ -2105,7 +2308,7 @@ static ecl_grid_type * ecl_grid_alloc_GRID_data__(ecl_grid_type * global_grid ,
if (dualp_flag != FILEHEAD_SINGLE_POROSITY)
nz = nz / 2;
{
ecl_grid_type * grid = ecl_grid_alloc_empty( global_grid , dualp_flag , nx , ny , nz , grid_nr , false);
ecl_grid_type * grid = ecl_grid_alloc_empty( global_grid , dualp_flag , nx , ny , nz , grid_nr, false);
if (mapaxes != NULL)
ecl_grid_init_mapaxes( grid , mapaxes );
@@ -2343,7 +2546,7 @@ static ecl_grid_type * ecl_grid_alloc_GRID(const char * grid_file) {
*/
ecl_grid_type * ecl_grid_alloc_regular( int nx, int ny , int nz , const double * ivec, const double * jvec , const double * kvec , const int * actnum) {
ecl_grid_type * grid = ecl_grid_alloc_empty(NULL , FILEHEAD_SINGLE_POROSITY , nx , ny , nz , 0,true);
ecl_grid_type * grid = ecl_grid_alloc_empty(NULL , FILEHEAD_SINGLE_POROSITY , nx , ny , nz , 0, true);
const double offset[3] = {0,0,0};
int k,j,i;
@@ -2601,7 +2804,10 @@ 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) {
ecl_grid = ecl_grid_alloc( grid_file );
if (util_file_exists( grid_file ))
ecl_grid = ecl_grid_alloc( grid_file );
free( grid_file );
}
return ecl_grid;
@@ -2946,13 +3152,15 @@ void ecl_grid_free(ecl_grid_type * grid) {
double_vector_free( grid->values[i] );
free( grid->values );
}
if (grid->grid_nr == 0) { /* This is the main grid. */
if (ECL_GRID_MAINGRID_LGR_NR == grid->lgr_nr) { /* This is the main grid. */
vector_free( grid->LGR_list );
int_vector_free( grid->lgr_index_map);
hash_free( grid->LGR_hash );
}
if (grid->coord_kw != NULL)
ecl_kw_free( grid->coord_kw );
nnc_index_list_free( grid->nnc_index_list );
vector_free( grid->coarse_cells );
hash_free( grid->children );
util_safe_free( grid->parent_name );
@@ -3040,10 +3248,10 @@ grid_dims_type ecl_grid_iget_dims( const ecl_grid_type * grid , int grid_nr) {
grid_dims_type dims;
const ecl_grid_type * lgr;
if (grid_nr == 0)
if (grid_nr == 0)
lgr = grid;
else
lgr = ecl_grid_iget_lgr( grid , grid_nr - 1 );
lgr = ecl_grid_iget_lgr(grid, grid_nr - 1);
dims.nx = lgr->nx;
dims.ny = lgr->ny;
@@ -3365,6 +3573,25 @@ double ecl_grid_get_cell_thickness3( const ecl_grid_type * grid , int i , int j
}
const int_vector_type * ecl_grid_get_nnc_index_list( ecl_grid_type * grid ) {
return nnc_index_list_get_list( grid->nnc_index_list );
}
const nnc_info_type * ecl_grid_get_cell_nnc_info1( const ecl_grid_type * grid , int global_index) {
const ecl_cell_type * cell = ecl_grid_get_cell( grid , global_index);
return cell->nnc_info;
}
const nnc_info_type * ecl_grid_get_cell_nnc_info3( const ecl_grid_type * grid , int i , int j , int k) {
const int global_index = ecl_grid_get_global_index3(grid , i,j,k);
return ecl_grid_get_cell_nnc_info1(grid, global_index);
}
/*****************************************************************/
/* Functions to query whether a cell is active or not. */
@@ -3409,7 +3636,7 @@ double ecl_grid_cell_invalid1A(const ecl_grid_type * grid , int active_index) {
/* Functions for LGR query/lookup/... */
static void __assert_main_grid(const ecl_grid_type * ecl_grid) {
if (ecl_grid->grid_nr != 0)
if (ecl_grid->lgr_nr != ECL_GRID_MAINGRID_LGR_NR)
util_abort("%s: tried to get LGR grid from another LGR_grid - only main grid can be used as first input \n",__func__);
}
@@ -3468,20 +3695,37 @@ bool ecl_grid_have_coarse_cells( const ecl_grid_type * main_grid ) {
*/
int ecl_grid_get_num_lgr(const ecl_grid_type * main_grid ) {
__assert_main_grid( main_grid );
return vector_get_size( main_grid->LGR_list ) - 1;
return vector_get_size( main_grid->LGR_list );
}
/**
The lgr_nr has zero offset, not counting the main grid, i.e.
ecl_grid_iget_lgr( ecl_grid , 0);
will return the first LGR - and fail HARD if there are no LGR's.
The lgr_index has zero offset
ecl_grid_iget_lgr( ecl_grid , 0); will return the first lgr
ecl_grid_iget_lgr( ecl_grid , 1); will return the second lgr
The method will fail HARD if lgr_index is out of bounds.
*/
ecl_grid_type * ecl_grid_iget_lgr(const ecl_grid_type * main_grid, int lgr_nr) {
ecl_grid_type * ecl_grid_iget_lgr(const ecl_grid_type * main_grid, int lgr_index) {
__assert_main_grid( main_grid );
return vector_iget( main_grid->LGR_list , lgr_nr + 1);
return vector_iget( main_grid->LGR_list , lgr_index);
}
/*
This function returns the lgr with the given lgr_nr. The lgr_nr is
the fourth element in the GRIDHEAD for EGRID files. The lgr nr is
equal to the grid nr if the grid's are consecutive numbered and
read from file in increasing lgr nr order.
This method can only be used for EGRID files. For GRID files the
lgr_nr is 0 for all grids.
*/
ecl_grid_type * ecl_grid_get_lgr_from_lgr_nr(const ecl_grid_type * main_grid, int lgr_nr) {
__assert_main_grid( main_grid );
{
int lgr_index = int_vector_iget( main_grid->lgr_index_map , lgr_nr );
return vector_iget( main_grid->LGR_list , lgr_index);
}
}
@@ -3523,7 +3767,7 @@ const ecl_grid_type * ecl_grid_get_cell_lgr1A(const ecl_grid_type * grid , int a
Will return the global grid for a lgr. If the input grid is indeed
a global grid itself the function will return NULL.
*/
const ecl_grid_type * ecl_grid_get_global_grid( const ecl_grid_type * grid ) {
const ecl_grid_type * ecl_grid_get_global_grid( const ecl_grid_type * grid ) {
return grid->global_grid;
}
@@ -3541,27 +3785,40 @@ 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_index) {
__assert_main_grid( ecl_grid );
if (lgr_index < (vector_get_size( ecl_grid->LGR_list ))) {
const ecl_grid_type * lgr = vector_iget( ecl_grid->LGR_list , lgr_index);
return lgr->name;
} else
return NULL;
}
const char * ecl_grid_get_lgr_name( const ecl_grid_type * ecl_grid , int lgr_nr) {
__assert_main_grid( ecl_grid );
{
int lgr_index = int_vector_iget( ecl_grid->lgr_index_map , lgr_nr );
return ecl_grid_iget_lgr_name( ecl_grid , lgr_index );
}
}
/*****************************************************************/
/**
This function returns the grid_nr field of the field; this is just
the occurence number in the grid file. Starting with 0 at the main
This function returns the lgr_nr field of the grid; for GRID files, this
is just the occurence number in the grid file. Starting with 0 at the main
grid, and then increasing consecutively through the lgr sections.
Observe that there is A MAJOR POTENTIAL for confusion with the
ecl_grid_iget_lgr() function, the latter does not refer to the main
grid and returns the first lgr section (which has grid_nr == 1) for
input argument 0.
For EGRID files, this is the LGR number (fourth element in the
gridhead).
*/
int ecl_grid_get_grid_nr( const ecl_grid_type * ecl_grid ) {
return ecl_grid->grid_nr;
int ecl_grid_get_lgr_nr( const ecl_grid_type * ecl_grid ) {
return ecl_grid->lgr_nr;
}
const char * ecl_grid_get_name( const ecl_grid_type * ecl_grid ) {
return ecl_grid->name;
}
@@ -3600,7 +3857,7 @@ void ecl_grid_summarize(const ecl_grid_type * ecl_grid) {
printf(" Origo X................: %10.2f \n",ecl_grid->origo[0]);
printf(" Origo Y................: %10.2f \n",ecl_grid->origo[1]);
if (ecl_grid->grid_nr == 0) {
if (ECL_GRID_MAINGRID_LGR_NR == ecl_grid->lgr_nr) {
int grid_nr;
for (grid_nr=1; grid_nr < vector_get_size( ecl_grid->LGR_list ); grid_nr++) {
printf("\n");
@@ -3941,7 +4198,7 @@ bool ecl_grid_test_lgr_consistency( const ecl_grid_type * ecl_grid ) {
static void ecl_grid_dump__(const ecl_grid_type * grid , FILE * stream) {
util_fwrite_int( grid->grid_nr , stream );
util_fwrite_int( grid->lgr_nr , stream );
util_fwrite_string( grid->name , stream );
util_fwrite_int( grid->nx , stream );
util_fwrite_int( grid->nz , stream );
@@ -3962,7 +4219,7 @@ static void ecl_grid_dump__(const ecl_grid_type * grid , FILE * stream) {
static void ecl_grid_dump_ascii__(const ecl_grid_type * grid , bool active_only , FILE * stream) {
fprintf(stream , "Grid nr : %d\n",grid->grid_nr);
fprintf(stream , "Grid nr : %d\n",grid->lgr_nr);
fprintf(stream , "Grid name : %s\n",grid->name);
fprintf(stream , "nx : %6d\n",grid->nx);
fprintf(stream , "ny : %6d\n",grid->ny);
@@ -3994,15 +4251,21 @@ static void ecl_grid_dump_ascii__(const ecl_grid_type * grid , bool active_only
void ecl_grid_dump(const ecl_grid_type * grid , FILE * stream) {
int i;
for (i = 0; i < vector_get_size( grid->LGR_list ); i++)
ecl_grid_dump__( vector_iget_const( grid->LGR_list , i) , stream );
ecl_grid_dump__(grid, stream );
{
int i;
for (i = 0; i < vector_get_size( grid->LGR_list ); i++)
ecl_grid_dump__( vector_iget_const( grid->LGR_list , i) , stream );
}
}
void ecl_grid_dump_ascii(const ecl_grid_type * grid , bool active_only , FILE * stream) {
int i;
for (i = 0; i < vector_get_size( grid->LGR_list ); i++)
ecl_grid_dump_ascii__( vector_iget_const( grid->LGR_list , i) , active_only , stream );
ecl_grid_dump_ascii__( grid , active_only , stream );
{
int i;
for (i = 0; i < vector_get_size( grid->LGR_list ); i++)
ecl_grid_dump_ascii__( vector_iget_const( grid->LGR_list , i) , active_only , stream );
}
}
@@ -4167,6 +4430,8 @@ void ecl_grid_fwrite_GRID( const ecl_grid_type * grid , const char * filename) {
if (grid->coarsening_active)
coords_size = 7;
ecl_grid_fwrite_GRID__( grid , coords_size , fortio );
{
int grid_nr;
for (grid_nr = 0; grid_nr < vector_get_size( grid->LGR_list ); grid_nr++) {
@@ -4578,7 +4843,7 @@ static void ecl_grid_fwrite_EGRID__( ecl_grid_type * grid , fortio_type * fortio
}
}
ecl_grid_fwrite_gridhead_kw( grid->nx , grid->ny , grid->nz , grid->grid_nr , fortio);
ecl_grid_fwrite_gridhead_kw( grid->nx , grid->ny , grid->nz , grid->lgr_nr , fortio);
/* Writing main grid data */
{
{
@@ -4624,6 +4889,8 @@ static void ecl_grid_fwrite_EGRID__( ecl_grid_type * grid , fortio_type * fortio
void ecl_grid_fwrite_EGRID( ecl_grid_type * grid , const char * filename) {
bool fmt_file = false;
fortio_type * fortio = fortio_open_writer( filename , fmt_file , ECL_ENDIAN_FLIP );
ecl_grid_fwrite_EGRID__( grid , fortio );
{
int grid_nr;
for (grid_nr = 0; grid_nr < vector_get_size( grid->LGR_list ); grid_nr++) {

View File

@@ -2374,7 +2374,7 @@ void ecl_kw_inplace_update_file(const ecl_kw_type * ecl_kw , const char * filena
/******************************************************************/
bool ecl_kw_is_kw_file(FILE * stream , bool fmt_file ) {
const long int init_pos = ftell(stream);
const long int init_pos = util_ftell(stream);
bool kw_file;
{
@@ -2394,7 +2394,7 @@ bool ecl_kw_is_kw_file(FILE * stream , bool fmt_file ) {
ecl_kw_free(ecl_kw);
}
fseek(stream , init_pos , SEEK_SET);
util_fseek(stream , init_pos , SEEK_SET);
return kw_file;
}
@@ -2403,7 +2403,7 @@ bool ecl_kw_is_kw_file(FILE * stream , bool fmt_file ) {
bool ecl_kw_is_grdecl_file(FILE * stream) {
const long int init_pos = ftell(stream);
const long int init_pos = util_ftell(stream);
bool grdecl_file;
bool at_eof = false;
util_fskip_chars(stream , " \r\n\t" , &at_eof); /* Skipping intial space */
@@ -2427,7 +2427,7 @@ bool ecl_kw_is_grdecl_file(FILE * stream) {
} while (c == ' ');
}
}
fseek(stream , init_pos , SEEK_SET);
util_fseek(stream , init_pos , SEEK_SET);
return grdecl_file;
}

View File

@@ -71,7 +71,7 @@
bool ecl_kw_grdecl_fseek_next_kw( FILE * stream ) {
long start_pos = ftell( stream );
long start_pos = util_ftell( stream );
long current_pos;
char next_kw[256];
@@ -83,14 +83,14 @@ bool ecl_kw_grdecl_fseek_next_kw( FILE * stream ) {
{
while (true) {
char c;
if (ftell(stream) == 0)
if (util_ftell(stream) == 0)
/*
We are at the very beginning of the file. Can just jump out of
the loop.
*/
break;
fseek( stream , -1 , SEEK_CUR );
util_fseek( stream , -1 , SEEK_CUR );
c = fgetc( stream );
if (c == '\n') {
/*
@@ -98,7 +98,7 @@ bool ecl_kw_grdecl_fseek_next_kw( FILE * stream ) {
have not reached any !isspace() characters on the way and
can go back to start_pos and read from there.
*/
fseek( stream , start_pos , SEEK_SET );
util_fseek( stream , start_pos , SEEK_SET );
break;
}
@@ -111,25 +111,25 @@ bool ecl_kw_grdecl_fseek_next_kw( FILE * stream ) {
util_fskip_lines( stream , 1 );
break;
}
fseek( stream , -2 , SEEK_CUR );
util_fseek( stream , -2 , SEEK_CUR );
}
}
while (true) {
current_pos = ftell( stream );
current_pos = util_ftell( stream );
if (fscanf(stream , "%s" , next_kw) == 1) {
if ((next_kw[0] == next_kw[1]) && (next_kw[0] == ECL_COMMENT_CHAR))
// This is a comment line - skip it.
util_fskip_lines( stream , 1 );
else {
// This is a valid keyword i.e. a non-commented out string; return true.
fseek( stream , current_pos , SEEK_SET );
util_fseek( stream , current_pos , SEEK_SET );
return true;
}
} else {
// EOF reached - return False.
fseek( stream , start_pos , SEEK_SET );
util_fseek( stream , start_pos , SEEK_SET );
return false;
}
}
@@ -167,17 +167,17 @@ char * ecl_kw_grdecl_alloc_next_header( FILE * stream ) {
*/
static bool ecl_kw_grdecl_fseek_kw__(const char * kw , FILE * stream) {
long init_pos = ftell( stream );
long init_pos = util_ftell( stream );
while (true) {
if (ecl_kw_grdecl_fseek_next_kw( stream )) {
char next_kw[256];
fscanf( stream , "%s" , next_kw);
if (strcmp( kw , next_kw ) == 0) {
fseek( stream , -strlen(next_kw) , SEEK_CUR);
util_fseek( stream , -strlen(next_kw) , SEEK_CUR);
return true;
}
} else {
fseek( stream , init_pos , SEEK_SET);
util_fseek( stream , init_pos , SEEK_SET);
return false;
}
}
@@ -274,13 +274,13 @@ bool ecl_kw_grdecl_fseek_kw(const char * kw , bool rewind , FILE * stream) {
if (ecl_kw_grdecl_fseek_kw__(kw , stream))
return true; /* OK - we found the kw between current file pos and EOF. */
else if (rewind) {
long int init_pos = ftell(stream);
long int init_pos = util_ftell(stream);
fseek(stream , 0L , SEEK_SET);
util_fseek(stream , 0L , SEEK_SET);
if (ecl_kw_grdecl_fseek_kw__( kw , stream )) /* Try again from the beginning of the file. */
return true;
else
fseek(stream , init_pos , SEEK_SET); /* Could not find it - reposition to initial position. */
util_fseek(stream , init_pos , SEEK_SET); /* Could not find it - reposition to initial position. */
}
/* OK: If we are here - that means that we failed to find the kw. */

View File

@@ -689,8 +689,9 @@ 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_nx - 1 , j2);
j2 = util_int_min(region->grid_ny - 1 , j2);
{
int i,j,k;
for (k = 0; k < region->grid_nz; k++)
@@ -729,7 +730,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_nx - 1 , k2);
k2 = util_int_min(region->grid_nz - 1 , k2);
{
int i,j,k;
for (k = k1; k <= k2; k++)

View File

@@ -0,0 +1,367 @@
/*
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 connection_end;
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 connection_end, 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->connection_end = connection_end;
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 connection_end,
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 , connection_end , 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_connection_end( const ecl_rft_cell_type * cell ) {
const plt_data_type * data = plt_data_try_cast_const( cell->data );
if (data)
return data->connection_end;
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 1;
}
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 );
}

View File

@@ -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 != NULL) {
if (!util_fnmatch( well_pattern , ecl_rft_node_get_well_name( rft )))
if (well_pattern) {
if (util_fnmatch( well_pattern , ecl_rft_node_get_well_name( rft )) != 0)
continue;
}
@@ -269,8 +269,8 @@ const char * ecl_rft_file_get_filename( const ecl_rft_file_type * rft_file ) {
handle that.
*/
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 );
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 );
}
@@ -301,7 +301,7 @@ const ecl_rft_node_type * ecl_rft_file_iget_node( const ecl_rft_file_type * rft_
const ecl_rft_node_type * ecl_rft_file_iget_well_rft( const ecl_rft_file_type * rft_file , const char * well, 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 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 @@ const ecl_rft_node_type * ecl_rft_file_iget_well_rft( const ecl_rft_file_type *
*/
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;
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;
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,56 +367,6 @@ 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 );
}

View File

@@ -25,12 +25,14 @@
#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
@@ -48,80 +50,20 @@
*/
/**
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. */
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. */
bool MSW;
bool sort_perm_in_sync ;
int_vector_type * sort_perm;
vector_type *cells;
};
@@ -131,7 +73,7 @@ struct ecl_rft_node_struct {
that is not (yet) supported.
*/
static ecl_rft_node_type * ecl_rft_node_alloc_empty(int size , const char * data_type_string) {
static ecl_rft_node_type * ecl_rft_node_alloc_empty(const char * data_type_string) {
ecl_rft_enum data_type = SEGMENT;
/* According to the ECLIPSE documentaton. */
@@ -140,7 +82,7 @@ static ecl_rft_node_type * ecl_rft_node_alloc_empty(int size , const char * data
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__);
@@ -153,24 +95,13 @@ static ecl_rft_node_type * ecl_rft_node_alloc_empty(int size , const char * data
{
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 = 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->cells = vector_alloc_new();
rft_node->data_type = data_type;
rft_node->sort_perm = NULL;
rft_node->sort_perm_in_sync = false;
return rft_node;
}
}
@@ -180,112 +111,146 @@ 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;
const float * connection_end = NULL;
/* The keywords CONLENST_KW and CONLENEN_KW are 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));
if (ecl_file_has_kw( rft , CONLENEN_KW))
connection_end = ecl_kw_get_float_ptr( ecl_file_iget_named_kw( rft , CONLENEN_KW , 0));
{
int c;
for ( c = 0; c < ecl_kw_get_size( conipos ); c++) {
ecl_rft_cell_type * cell;
double cs = 0;
double ce = 0;
if (connection_start)
cs = connection_start[c];
if (connection_end)
ce = connection_end[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 , ce, 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_get_size(conipos) ,
ecl_kw_iget_ptr(welletc , WELLETC_TYPE_INDEX));
ecl_rft_node_type * rft_node = ecl_rft_node_alloc_empty(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);
/* 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 );
if (ecl_file_has_kw( rft , CONLENST_KW))
rft_node->MSW = true;
else
rft_node->MSW = false;
/* 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;
}
}
}
ecl_rft_node_init_cells( rft_node , rft );
}
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);
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);
vector_free( rft_node->cells );
if (rft_node->sort_perm)
int_vector_free( rft_node->sort_perm );
free(rft_node);
}
@@ -295,247 +260,10 @@ 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");
}
}
/*
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; }
int ecl_rft_node_get_size(const ecl_rft_node_type * rft_node) { return vector_get_size( rft_node->cells ); }
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; }
@@ -543,65 +271,87 @@ 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 */
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];
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 );
else {
util_abort("%s: asked for cell:%d max:%d \n",__func__ , index , rft_node->size - 1);
return NULL;
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 ));
}
}
double ecl_rft_node_iget_depth( const ecl_rft_node_type * rft_node , int index) {
const cell_type * cell = ecl_rft_node_iget_cell( rft_node , index );
return cell->depth;
const ecl_rft_cell_type * cell = ecl_rft_node_iget_cell( rft_node , index );
return ecl_rft_cell_get_depth( cell );
}
double ecl_rft_node_iget_pressure( const ecl_rft_node_type * rft_node , int index) {
const cell_type * cell = ecl_rft_node_iget_cell( rft_node , index );
return cell->pressure;
const ecl_rft_cell_type * cell = ecl_rft_node_iget_cell( rft_node , index );
return ecl_rft_cell_get_pressure( cell );
}
void ecl_rft_node_iget_ijk( const ecl_rft_node_type * rft_node , int index , int *i , int *j , int *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 * cell = ecl_rft_node_iget_cell( rft_node , index );
ecl_rft_cell_get_ijk( cell , i,j,k);
}
int ecl_rft_node_lookup_ijk( const ecl_rft_node_type * rft_node , int i, int j , int 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 index = 0;
int size = ecl_rft_node_get_size( rft_node );
while (true) {
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;
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;
index++;
if (index == rft_node->size) /* Could not find it. */
return -1;
if (index == size) /* Could not find it. */
return NULL;
}
}
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 >= rft_node->size))
if ((index < 0) || (index >= vector_get_size( rft_node->cells )))
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 rft_data_type rft_data = rft_node->rft_data[ index ];
return rft_data.sgas;
const ecl_rft_cell_type * cell = vector_iget_const( rft_node->cells , index );
return ecl_rft_cell_get_sgas( cell );
}
}
@@ -609,17 +359,28 @@ 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 rft_data_type rft_data = rft_node->rft_data[ index ];
return rft_data.swat;
const ecl_rft_cell_type * cell = vector_iget_const( rft_node->cells , index );
return ecl_rft_cell_get_swat( cell );
}
}
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 plt_data_type plt_data = rft_node->plt_data[ index ];
return plt_data.orat;
const ecl_rft_cell_type * cell = vector_iget_const( rft_node->cells , index );
return ecl_rft_cell_get_orat( cell );
}
}
@@ -627,8 +388,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 plt_data_type plt_data = rft_node->plt_data[ index ];
return plt_data.wrat;
const ecl_rft_cell_type * cell = vector_iget_const( rft_node->cells , index);
return ecl_rft_cell_get_wrat( cell );
}
}
@@ -636,8 +397,36 @@ 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 plt_data_type plt_data = rft_node->plt_data[ index ];
return plt_data.grat;
const ecl_rft_cell_type * cell = vector_iget_const( rft_node->cells , index);
return ecl_rft_cell_get_grat( cell );
}
}
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;
}

View File

@@ -71,6 +71,7 @@ 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 );

View File

@@ -485,6 +485,7 @@ static ecl_smspec_var_type ecl_smspec_identify_special_var( const char * var ) {
ecl_smspec_var_type ecl_smspec_identify_var_type(const char * var) {
ecl_smspec_var_type var_type = ecl_smspec_identify_special_var( var );
int str_length = strlen(var);
if (var_type == ECL_SMSPEC_INVALID_VAR) {
switch(var[0]) {
case('A'):
@@ -521,10 +522,13 @@ ecl_smspec_var_type ecl_smspec_identify_var_type(const char * var) {
var_type = ECL_SMSPEC_NETWORK_VAR;
break;
case('R'):
if (var[2] == 'F')
var_type = ECL_SMSPEC_REGION_2_REGION_VAR;
else
if (((3 == str_length) && var[2] == 'F') ||
((4 == str_length) && var[3] == 'F')) {
var_type = ECL_SMSPEC_REGION_2_REGION_VAR;
}
else {
var_type = ECL_SMSPEC_REGION_VAR;
}
break;
case('S'):
var_type = ECL_SMSPEC_SEGMENT_VAR;
@@ -649,7 +653,7 @@ static void ecl_smspec_install_gen_keys( ecl_smspec_type * smspec , smspec_node_
hash_insert_ref(smspec->gen_var_index , gen_key1 , smspec_node);
}
/* Insert the (optional) extra mapping for block related variables: */
/* Insert the (optional) extra mapping for block related variables and region_2_region variables: */
{
const char * gen_key2 = smspec_node_get_gen_key2( smspec_node );
if (gen_key2 != NULL)
@@ -751,6 +755,8 @@ static void ecl_smspec_install_special_keys( ecl_smspec_type * ecl_smspec , smsp
break;
case(ECL_SMSPEC_SEGMENT_VAR):
break;
case(ECL_SMSPEC_REGION_2_REGION_VAR):
break;
default:
util_abort("%: Internal error - should never be here ?? \n",__func__);
break;
@@ -778,6 +784,9 @@ bool ecl_smspec_needs_wgname( ecl_smspec_var_type var_type ) {
case(ECL_SMSPEC_REGION_VAR):
return false;
break;
case(ECL_SMSPEC_REGION_2_REGION_VAR):
return false;
break;
case(ECL_SMSPEC_MISC_VAR):
return false;
break;
@@ -821,6 +830,9 @@ bool ecl_smspec_needs_num( ecl_smspec_var_type var_type ) {
case(ECL_SMSPEC_REGION_VAR):
return true;
break;
case(ECL_SMSPEC_REGION_2_REGION_VAR):
return true;
break;
case(ECL_SMSPEC_MISC_VAR):
return false;
break;

View File

@@ -333,6 +333,7 @@ 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 );
@@ -882,8 +883,6 @@ 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 );
@@ -895,12 +894,15 @@ static void __ecl_sum_fprintf_line( const ecl_sum_type * ecl_sum , FILE * stream
fprintf(stream , date_string );
}
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 )));
{
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 )));
}
}
}
}
fprintf(stream , fmt->newline);
}
@@ -980,6 +982,7 @@ 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
@@ -1163,8 +1166,37 @@ 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;
}
bool ecl_sum_report_step_equal( const ecl_sum_type * ecl_sum1 , const ecl_sum_type * ecl_sum2) {
if (ecl_sum1 == ecl_sum2)
return true;
else
return ecl_sum_data_report_step_equal( ecl_sum1->data , ecl_sum2->data );
}
bool ecl_sum_report_step_compatible( const ecl_sum_type * ecl_sum1 , const ecl_sum_type * ecl_sum2) {
if (ecl_sum1 == ecl_sum2)
return true;
else
return ecl_sum_data_report_step_compatible( ecl_sum1->data , ecl_sum2->data );
}

View File

@@ -204,7 +204,7 @@
#define INVALID_MINISTEP_NR -1
struct ecl_sum_data_struct {
@@ -255,8 +255,8 @@ static void ecl_sum_data_clear_index( ecl_sum_data_type * data ) {
data->last_report_step = -1024 * 1024;
data->days_start = 0;
data->sim_length = -1;
data->first_ministep = -1;
data->last_ministep = -1;
data->first_ministep = INVALID_MINISTEP_NR;
data->last_ministep = INVALID_MINISTEP_NR;
data->index_valid = false;
time_interval_reopen( data->sim_time );
}
@@ -268,8 +268,8 @@ ecl_sum_data_type * ecl_sum_data_alloc(ecl_smspec_type * smspec) {
data->smspec = smspec;
data->__min_time = 0;
data->report_first_index = int_vector_alloc( 0 , -1 ); /* This -1 value is hard-wired around in the place - not good. */
data->report_last_index = int_vector_alloc( 0 , -1 );
data->report_first_index = int_vector_alloc( 0 , INVALID_MINISTEP_NR );
data->report_last_index = int_vector_alloc( 0 , INVALID_MINISTEP_NR );
data->sim_time = time_interval_alloc_open();
ecl_sum_data_clear_index( data );
@@ -545,7 +545,7 @@ static int ecl_sum_data_get_index_from_sim_time( const ecl_sum_data_type * data
{
int low_index = 0;
int high_index = vector_get_size( data->data );
int internal_index = -1;
int internal_index = INVALID_MINISTEP_NR;
while (internal_index < 0) {
@@ -1043,7 +1043,7 @@ bool ecl_sum_data_has_report_step(const ecl_sum_data_type * data , int report_st
/**
Returns the last index included in report step @report_step.
Observe that if the dataset does not include @report_step at all,
the function will return -1; this must be checked for in the
the function will return INVALID_MINISTEP_NR; this must be checked for in the
calling scope.
*/
@@ -1056,7 +1056,7 @@ int ecl_sum_data_iget_report_end( const ecl_sum_data_type * data , int report_st
/**
Returns the first index included in report step @report_step.
Observe that if the dataset does not include @report_step at all,
the function will return -1; this must be checked for in the
the function will return INVALID_MINISTEP_NR; this must be checked for in the
calling scope.
*/
@@ -1349,3 +1349,52 @@ int ecl_sum_data_get_length( const ecl_sum_data_type * data ) {
return vector_get_size( data->data );
}
bool ecl_sum_data_report_step_equal( const ecl_sum_data_type * data1 , const ecl_sum_data_type * data2) {
bool equal = true;
if (int_vector_size( data1->report_last_index ) == int_vector_size(data2->report_last_index)) {
int i;
for (i = 0; i < int_vector_size( data1->report_last_index ); i++) {
int time_index1 = int_vector_iget( data1->report_last_index , i );
int time_index2 = int_vector_iget( data2->report_last_index , i );
if ((time_index1 != INVALID_MINISTEP_NR) && (time_index2 != INVALID_MINISTEP_NR)) {
const ecl_sum_tstep_type * ministep1 = ecl_sum_data_iget_ministep( data1 , time_index1 );
const ecl_sum_tstep_type * ministep2 = ecl_sum_data_iget_ministep( data2 , time_index2 );
if (!ecl_sum_tstep_sim_time_equal( ministep1 , ministep2)) {
equal = false;
break;
}
} else if (time_index1 != time_index2) {
equal = false;
break;
}
}
} else
equal = false;
return equal;
}
bool ecl_sum_data_report_step_compatible( const ecl_sum_data_type * data1 , const ecl_sum_data_type * data2) {
bool compatible = true;
int min_size = util_int_min( int_vector_size( data1->report_last_index ) , int_vector_size( data2->report_last_index));
int i;
for (i = 0; i < min_size; i++) {
int time_index1 = int_vector_iget( data1->report_last_index , i );
int time_index2 = int_vector_iget( data2->report_last_index , i );
if ((time_index1 != INVALID_MINISTEP_NR) && (time_index2 != INVALID_MINISTEP_NR)) {
const ecl_sum_tstep_type * ministep1 = ecl_sum_data_iget_ministep( data1 , time_index1 );
const ecl_sum_tstep_type * ministep2 = ecl_sum_data_iget_ministep( data2 , time_index2 );
if (!ecl_sum_tstep_sim_time_equal( ministep1 , ministep2)) {
compatible = false;
break;
}
}
}
return compatible;
}

View File

@@ -289,3 +289,10 @@ void ecl_sum_tstep_set_from_key( ecl_sum_tstep_type * tstep , const char * gen_k
}
bool ecl_sum_tstep_sim_time_equal( const ecl_sum_tstep_type * tstep1 , const ecl_sum_tstep_type * tstep2 ) {
if (tstep1->sim_time == tstep2->sim_time)
return true;
else
return false;
}

View File

@@ -1215,16 +1215,16 @@ time_t ecl_util_get_start_date(const char * data_file) {
util_abort("%s: sorry - could not find START in DATA file %s \n",__func__ , data_file);
{
long int start_pos = ftell( stream );
long int start_pos = util_ftell( stream );
int buffer_size;
/* Look for terminating '/' */
if (!parser_fseek_string( parser , stream , "/" , false , true))
util_abort("%s: sorry - could not find \"/\" termination of START keyword in data_file: \n",__func__ , data_file);
buffer_size = (ftell(stream) - start_pos) ;
buffer_size = (util_ftell(stream) - start_pos) ;
buffer = util_calloc( buffer_size + 1 , sizeof * buffer );
fseek( stream , start_pos , SEEK_SET);
util_fseek( stream , start_pos , SEEK_SET);
util_fread( buffer , sizeof * buffer , buffer_size ,stream , __func__);
buffer[buffer_size] = '\0';
}
@@ -1257,16 +1257,16 @@ int ecl_util_get_num_cpu(const char * data_file) {
char * buffer;
if (parser_fseek_string( parser , stream , "PARALLEL" , true , true)) { /* Seeks case insensitive. */
long int start_pos = ftell( stream );
long int start_pos = util_ftell( stream );
int buffer_size;
/* Look for terminating '/' */
if (!parser_fseek_string( parser , stream , "/" , false , true))
util_abort("%s: sorry - could not find \"/\" termination of PARALLEL keyword in data_file: \n",__func__ , data_file);
buffer_size = (ftell(stream) - start_pos) ;
buffer_size = (util_ftell(stream) - start_pos) ;
buffer = util_calloc( buffer_size + 1 , sizeof * buffer );
fseek( stream , start_pos , SEEK_SET);
util_fseek( stream , start_pos , SEEK_SET);
util_fread( buffer , sizeof * buffer , buffer_size ,stream , __func__);
buffer[buffer_size] = '\0';
@@ -1277,14 +1277,15 @@ int ecl_util_get_num_cpu(const char * data_file) {
for (i=0; i < stringlist_get_size( tokens ); i++) {
item = util_realloc_string_copy( item , stringlist_iget( tokens , i ));
util_strupr( item );
if ( util_string_equal( item , "DISTRIBUTED" )) {
if (( util_string_equal( item , "DISTRIBUTED" )) ||
( util_string_equal( item , "DIST" ))) {
num_cpu = atoi( stringlist_iget( tokens , i - 1));
break;
}
}
free( item );
stringlist_free( tokens );
}
}
free( buffer );
}

View File

@@ -119,7 +119,7 @@ static bool __read_int(FILE * stream , int * value, bool endian_flip) {
static bool fortio_is_fortran_stream__(FILE * stream , bool endian_flip) {
const bool strict_checking = true; /* True: requires that *ALL* records in the file are fortran formatted */
long init_pos = ftell(stream);
offset_type init_pos = util_ftell(stream);
bool is_fortran_stream = false;
int header , tail;
bool cont;
@@ -128,7 +128,7 @@ static bool fortio_is_fortran_stream__(FILE * stream , bool endian_flip) {
cont = false;
if (__read_int(stream , &header , endian_flip)) {
if (header >= 0) {
if (fseek(stream , header , SEEK_CUR) == 0) {
if (util_fseek(stream , (offset_type) header , SEEK_CUR) == 0) {
if (__read_int(stream , &tail , endian_flip)) {
cont = true;
/*
@@ -155,7 +155,7 @@ static bool fortio_is_fortran_stream__(FILE * stream , bool endian_flip) {
}
}
} while (cont);
fseek(stream , init_pos , SEEK_SET);
util_fseek(stream , init_pos , SEEK_SET);
return is_fortran_stream;
}
@@ -423,7 +423,7 @@ void fortio_fclose(fortio_type *fortio) {
bool fortio_is_fortio_file(fortio_type * fortio) {
FILE * stream = fortio->stream;
int init_pos = ftell(stream);
offset_type init_pos = fortio_ftell(fortio);
int elm_read;
bool is_fortio_file = false;
elm_read = fread(&fortio->active_header , sizeof(fortio->active_header) , 1 , fortio->stream);
@@ -433,7 +433,7 @@ bool fortio_is_fortio_file(fortio_type * fortio) {
if (fortio->endian_flip_header)
util_endian_flip_vector(&fortio->active_header , sizeof fortio->active_header , 1);
if (fseek(stream , fortio->active_header , SEEK_CUR) == 0) {
if (fortio_fseek(fortio , (offset_type) fortio->active_header , SEEK_CUR) == 0) {
if (fread(&trailer , sizeof(fortio->active_header) , 1 , fortio->stream) == 1) {
if (fortio->endian_flip_header)
util_endian_flip_vector(&trailer , sizeof trailer , 1);
@@ -444,7 +444,7 @@ bool fortio_is_fortio_file(fortio_type * fortio) {
}
}
fseek(stream , init_pos , SEEK_SET);
fortio_fseek(fortio , init_pos , SEEK_SET);
return is_fortio_file;
}
@@ -527,7 +527,7 @@ void fortio_fread_buffer(fortio_type * fortio, char * buffer , int buffer_size)
int fortio_fskip_record(fortio_type *fortio) {
int record_size = fortio_init_read(fortio);
fseek(fortio->stream , record_size , SEEK_CUR);
fortio_fseek(fortio , (offset_type) record_size , SEEK_CUR);
fortio_complete_read(fortio);
return record_size;
}
@@ -624,7 +624,7 @@ static fortio_status_type fortio_check_record( FILE * stream , bool endian_flip
if (endian_flip)
util_endian_flip_vector(&header , sizeof header , 1);
if (fseek( stream , header , SEEK_CUR ) != 0)
if (util_fseek( stream , (offset_type) header , SEEK_CUR ) != 0)
/* The fseek() failed - i.e. the data section was not sufficiently long. */
status = FORTIO_MISSING_DATA;
else {
@@ -697,13 +697,13 @@ fortio_status_type fortio_check_file( const char * filename , bool endian_flip)
}
long fortio_ftell( const fortio_type * fortio ) {
return ftell( fortio->stream );
offset_type fortio_ftell( const fortio_type * fortio ) {
return util_ftell( fortio->stream );
}
int fortio_fseek( fortio_type * fortio , long offset , int whence) {
int fseek_return = fseek( fortio->stream , offset , whence );
int fortio_fseek( fortio_type * fortio , offset_type offset , int whence) {
int fseek_return = util_fseek( fortio->stream , offset , whence );
/*
if fseek_return != 0 -> util_abort().
*/
@@ -723,6 +723,6 @@ FILE * fortio_get_FILE(const fortio_type *fortio) { return fortio-
int fortio_get_record_size(const fortio_type *fortio) { return fortio->active_header; }
//bool fortio_endian_flip(const fortio_type *fortio) { return fortio->endian_flip_header; }
bool fortio_fmt_file(const fortio_type *fortio) { return fortio->fmt_file; }
void fortio_rewind(const fortio_type *fortio) { rewind(fortio->stream); }
void fortio_rewind(const fortio_type *fortio) { util_rewind(fortio->stream); }
const char * fortio_filename_ref(const fortio_type * fortio) { return (const char *) fortio->filename; }

View File

@@ -0,0 +1,73 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
The file 'nnc_index_list.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/int_vector.h>
#include <ert/util/type_macros.h>
#include <ert/ecl/nnc_index_list.h>
#define NNC_INDEX_LIST_TYPE_ID 87225078
struct nnc_index_list_struct {
UTIL_TYPE_ID_DECLARATION;
int_vector_type *index_list;
int lgr_nr;
bool sorted;
};
UTIL_IS_INSTANCE_FUNCTION( nnc_index_list , NNC_INDEX_LIST_TYPE_ID )
nnc_index_list_type * nnc_index_list_alloc() {
nnc_index_list_type * nnc_index_list = util_malloc( sizeof * nnc_index_list );
UTIL_TYPE_ID_INIT(nnc_index_list , NNC_INDEX_LIST_TYPE_ID);
nnc_index_list->index_list = int_vector_alloc(0 , 0 );
nnc_index_list->sorted = true;
return nnc_index_list;
}
void nnc_index_list_free( nnc_index_list_type * nnc_index_list ) {
int_vector_free( nnc_index_list->index_list );
free( nnc_index_list );
}
const int_vector_type * nnc_index_list_get_list( nnc_index_list_type * nnc_index_list) {
if (!nnc_index_list->sorted)
int_vector_select_unique( nnc_index_list->index_list );
nnc_index_list->sorted = true;
return nnc_index_list->index_list;
}
void nnc_index_list_add_index( nnc_index_list_type * nnc_index_list , int index) {
nnc_index_list->sorted = false;
int_vector_append( nnc_index_list->index_list , index );
}

View File

@@ -0,0 +1,128 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
The file 'nnc_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 <ert/util/util.h>
#include <ert/util/vector.h>
#include <ert/util/type_macros.h>
#include <ert/ecl/nnc_info.h>
#include <ert/ecl/nnc_vector.h>
#define NNC_INFO_TYPE_ID 675415078
struct nnc_info_struct {
UTIL_TYPE_ID_DECLARATION;
vector_type * lgr_list; /*List of int vector * for nnc connections for LGRs*/
int_vector_type * lgr_index_map; /* A vector that maps LGR-nr to index into the LGR_list.*/
int lgr_nr; /* The lgr_nr of the cell holding this nnc_info structure. */
};
UTIL_IS_INSTANCE_FUNCTION( nnc_info , NNC_INFO_TYPE_ID )
nnc_info_type * nnc_info_alloc(int lgr_nr) {
nnc_info_type * nnc_info = util_malloc( sizeof * nnc_info );
UTIL_TYPE_ID_INIT(nnc_info , NNC_INFO_TYPE_ID);
nnc_info->lgr_list = vector_alloc_new();
nnc_info->lgr_index_map = int_vector_alloc(0, -1);
nnc_info->lgr_nr = lgr_nr;
return nnc_info;
}
void nnc_info_free( nnc_info_type * nnc_info ) {
vector_free(nnc_info->lgr_list);
int_vector_free(nnc_info->lgr_index_map);
free (nnc_info);
}
nnc_vector_type * nnc_info_get_vector( const nnc_info_type * nnc_info , int lgr_nr) {
int lgr_index = int_vector_safe_iget( nnc_info->lgr_index_map , lgr_nr );
if (-1 == lgr_index)
return NULL;
else
return vector_iget( nnc_info->lgr_list , lgr_index );
}
nnc_vector_type * nnc_info_iget_vector( const nnc_info_type * nnc_info , int lgr_index) {
return vector_iget( nnc_info->lgr_list , lgr_index );
}
nnc_vector_type * nnc_info_get_self_vector( const nnc_info_type * nnc_info ) {
return nnc_info_get_vector( nnc_info , nnc_info->lgr_nr );
}
static void nnc_info_assert_vector( nnc_info_type * nnc_info , int lgr_nr ) {
nnc_vector_type * nnc_vector = nnc_info_get_vector( nnc_info , lgr_nr);
if (!nnc_vector) {
nnc_vector = nnc_vector_alloc( lgr_nr );
vector_append_owned_ref( nnc_info->lgr_list , nnc_vector , nnc_vector_free__ );
int_vector_iset( nnc_info->lgr_index_map , lgr_nr , vector_get_size( nnc_info->lgr_list ) - 1 );
}
}
void nnc_info_add_nnc(nnc_info_type * nnc_info, int lgr_nr, int global_cell_number) {
nnc_info_assert_vector( nnc_info , lgr_nr );
{
nnc_vector_type * nnc_vector = nnc_info_get_vector( nnc_info , lgr_nr );
nnc_vector_add_nnc( nnc_vector , global_cell_number );
}
}
const int_vector_type * nnc_info_get_index_list(const nnc_info_type * nnc_info, int lgr_nr) {
nnc_vector_type * nnc_vector = nnc_info_get_vector( nnc_info , lgr_nr );
if (nnc_vector)
return nnc_vector_get_index_list( nnc_vector );
else
return NULL;
}
const int_vector_type * nnc_info_iget_index_list(const nnc_info_type * nnc_info, int lgr_index) {
nnc_vector_type * nnc_vector = nnc_info_iget_vector( nnc_info , lgr_index );
return nnc_vector_get_index_list( nnc_vector );
}
const int_vector_type * nnc_info_get_self_index_list(const nnc_info_type * nnc_info) {
return nnc_info_get_index_list( nnc_info , nnc_info->lgr_nr );
}
int nnc_info_get_lgr_nr( const nnc_info_type * nnc_info ) {
return nnc_info->lgr_nr;
}
int nnc_info_get_size( const nnc_info_type * nnc_info ) {
return vector_get_size( nnc_info->lgr_list );
}

View File

@@ -0,0 +1,76 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
The file 'nnc_vector.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/util/vector.h>
#include <ert/util/type_macros.h>
#include <ert/ecl/nnc_vector.h>
#define NNC_VECTOR_TYPE_ID 875615078
struct nnc_vector_struct {
UTIL_TYPE_ID_DECLARATION;
int_vector_type *nnc_index_list;
int lgr_nr;
};
UTIL_IS_INSTANCE_FUNCTION( nnc_vector , NNC_VECTOR_TYPE_ID )
static UTIL_SAFE_CAST_FUNCTION(nnc_vector , NNC_VECTOR_TYPE_ID)
nnc_vector_type * nnc_vector_alloc(int lgr_nr) {
nnc_vector_type * nnc_vector = util_malloc( sizeof * nnc_vector );
UTIL_TYPE_ID_INIT(nnc_vector , NNC_VECTOR_TYPE_ID);
nnc_vector->nnc_index_list = int_vector_alloc(0, 0);
nnc_vector->lgr_nr = lgr_nr;
return nnc_vector;
}
void nnc_vector_free( nnc_vector_type * nnc_vector ) {
int_vector_free( nnc_vector->nnc_index_list );
free( nnc_vector );
}
void nnc_vector_free__(void * arg) {
nnc_vector_type * nnc_vector = nnc_vector_safe_cast( arg );
nnc_vector_free( nnc_vector );
}
void nnc_vector_add_nnc(nnc_vector_type * nnc_vector, int global_cell_number) {
int_vector_append( nnc_vector->nnc_index_list , global_cell_number );
}
const int_vector_type * nnc_vector_get_index_list(const nnc_vector_type * nnc_vector) {
return nnc_vector->nnc_index_list;
}
int nnc_vector_get_lgr_nr( const nnc_vector_type * nnc_vector ) {
return nnc_vector->lgr_nr;
}

View File

@@ -53,7 +53,7 @@
struct smspec_node_struct {
UTIL_TYPE_ID_DECLARATION;
char * gen_key1; /* The main composite key, i.e. WWCT:OP3 for this element. */
char * gen_key2; /* Some of the ijk based elements will have both a xxx:i,j,k and a xxx:num key. Mostly NULL. */
char * gen_key2; /* Some of the ijk based elements will have both a xxx:i,j,k and a xxx:num key. Some of the region_2_region elements will have both a xxx:num and a xxx:r2-r2 key. Mostly NULL. */
ecl_smspec_var_type var_type; /* The variable type */
char * wgname; /* The value of the WGNAMES vector for this element. */
char * keyword; /* The value of the KEYWORDS vector for this elements. */
@@ -89,6 +89,8 @@ struct smspec_node_struct {
#define ECL_SUM_KEYFMT_GROUP "%s%s%s"
#define ECL_SUM_KEYFMT_WELL "%s%s%s"
#define ECL_SUM_KEYFMT_REGION "%s%s%d"
#define ECL_SUM_KEYFMT_REGION_2_REGION_R1R2 "%s%s%d-%d"
#define ECL_SUM_KEYFMT_REGION_2_REGION_NUM "%s%s%d"
#define ECL_SUM_KEYFMT_SEGMENT "%s%s%s%s%d"
#define ECL_SUM_KEYFMT_LOCAL_WELL "%s%s%s%s%s"
@@ -119,6 +121,23 @@ char * smspec_alloc_region_key( const char * join_string , const char * keyword
num );
}
char * smspec_alloc_region_2_region_r1r2_key( const char * join_string , const char * keyword , int r1, int r2) {
return util_alloc_sprintf(ECL_SUM_KEYFMT_REGION_2_REGION_R1R2,
keyword,
join_string,
r1,
r2);
}
char * smspec_alloc_region_2_region_num_key( const char * join_string , const char * keyword , int num) {
return util_alloc_sprintf(ECL_SUM_KEYFMT_REGION_2_REGION_NUM,
keyword ,
join_string ,
num);
}
char * smspec_alloc_block_ijk_key( const char * join_string , const char * keyword , int i , int j , int k) {
return util_alloc_sprintf(ECL_SUM_KEYFMT_BLOCK_IJK ,
keyword,
@@ -308,10 +327,11 @@ static void smspec_node_set_flags( smspec_node_type * smspec_node) {
file.
*/
{
if (smspec_node->var_type == ECL_SMSPEC_COMPLETION_VAR ||
smspec_node->var_type == ECL_SMSPEC_SEGMENT_VAR ||
smspec_node->var_type == ECL_SMSPEC_REGION_VAR ||
smspec_node->var_type == ECL_SMSPEC_BLOCK_VAR ||
if (smspec_node->var_type == ECL_SMSPEC_COMPLETION_VAR ||
smspec_node->var_type == ECL_SMSPEC_SEGMENT_VAR ||
smspec_node->var_type == ECL_SMSPEC_REGION_VAR ||
smspec_node->var_type == ECL_SMSPEC_REGION_2_REGION_VAR ||
smspec_node->var_type == ECL_SMSPEC_BLOCK_VAR ||
smspec_node->var_type == ECL_SMSPEC_AQUIFER_VAR)
smspec_node->need_nums = true;
else
@@ -354,7 +374,7 @@ smspec_node_type * smspec_node_alloc_new(int params_index, float default_value)
node->keyword = NULL;
node->lgr_name = NULL;
node->lgr_ijk = NULL;
smspec_node_set_invalid_flags( node );
return node; // This is NOT usable
}
@@ -446,9 +466,18 @@ static void smspec_node_set_gen_keys( smspec_node_type * smspec_node , const cha
// KEYWORD:NUM
smspec_node->gen_key1 = smspec_alloc_region_key( key_join_string , smspec_node->keyword , smspec_node->num);
break;
case(ECL_SMSPEC_SEGMENT_VAR):
// KEYWORD:WGNAME:NUM
smspec_node->gen_key1 = smspec_alloc_segment_key( key_join_string , smspec_node->keyword , smspec_node->wgname , smspec_node->num);
case (ECL_SMSPEC_SEGMENT_VAR):
// KEYWORD:WGNAME:NUM
smspec_node->gen_key1 = smspec_alloc_segment_key( key_join_string , smspec_node->keyword , smspec_node->wgname , smspec_node->num);
break;
case(ECL_SMSPEC_REGION_2_REGION_VAR):
// KEYWORDS:RXF:NUM and RXF:R1-R2
smspec_node->gen_key1 = smspec_alloc_region_2_region_num_key( key_join_string , smspec_node->keyword , smspec_node->num);
{
int r1 = smspec_node->num % 32768;
int r2 = ((smspec_node->num-r1) / 32768)-10;
smspec_node->gen_key2 = smspec_alloc_region_2_region_r1r2_key( key_join_string , smspec_node->keyword , r1, r2);
}
break;
case(ECL_SMSPEC_MISC_VAR):
// KEYWORD
@@ -549,7 +578,7 @@ bool smspec_node_init( smspec_node_type * smspec_node,
initOK = false;
break;
case(ECL_SMSPEC_SEGMENT_VAR):
if (wgnameOK) {
if (wgnameOK && num >= 0) {
smspec_node_set_wgname( smspec_node , wgname );
smspec_node_set_num( smspec_node , grid_dims , num );
} else
@@ -563,6 +592,10 @@ bool smspec_node_init( smspec_node_type * smspec_node,
/* Region variable : NUM */
smspec_node_set_num( smspec_node , grid_dims , num );
break;
case(ECL_SMSPEC_REGION_2_REGION_VAR):
/* Region 2 region variable : NUM */
smspec_node_set_num( smspec_node , grid_dims , num );
break;
case(ECL_SMSPEC_BLOCK_VAR):
/* A block variable : NUM*/
smspec_node_set_num( smspec_node , grid_dims , num );

View File

@@ -1,94 +1,11 @@
add_executable( ecl_coarse_test ecl_coarse_test.c )
target_link_libraries( ecl_coarse_test ecl )
add_test( ecl_coarse_test ${EXECUTABLE_OUTPUT_PATH}/ecl_coarse_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/LGCcase/LGC_TESTCASE2 )
if (BUILD_TESTS)
include( tests.cmake )
endif()
# The ecl_win64 application is not built as a proper test integrated
# into the CTEST system. Should be invoked manually on Windows.
if (ERT_WINDOWS)
add_executable( ecl_lfs ecl_lfs.c )
target_link_libraries( ecl_lfs ecl ert_util )
endif()
add_executable( ecl_restart_test ecl_restart_test.c )
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_lgr_test ecl_lgr_test.c )
target_link_libraries( ecl_lgr_test ecl )
add_test( ecl_lgr_test1 ${EXECUTABLE_OUTPUT_PATH}/ecl_lgr_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/10kcase/TEST10K_FLT_LGR_NNC.EGRID)
add_test( ecl_lgr_test2 ${EXECUTABLE_OUTPUT_PATH}/ecl_lgr_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/10kcase/TEST10K_FLT_LGR_NNC.GRID)
add_test( ecl_lgr_test3 ${EXECUTABLE_OUTPUT_PATH}/ecl_lgr_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Troll/MSW_LGR/2BRANCHES-CCEWELLPATH-NEW-SCH-TUNED-AR3.EGRID )
add_executable( ecl_grid_simple ecl_grid_simple.c )
target_link_libraries( ecl_grid_simple ecl )
add_test( ecl_grid_simple ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_simple ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID )
add_executable( ecl_grid_dims ecl_grid_dims.c )
target_link_libraries( ecl_grid_dims ecl )
add_test( ecl_grid_dims0 ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_dims )
add_test( ecl_grid_dims1 ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_dims ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.INIT )
add_test( ecl_grid_dims2 ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_dims ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.GRID ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.INIT)
add_test( ecl_grid_dims3 ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_dims ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID )
add_test( ecl_grid_dims4 ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_dims ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.GRID )
add_test( ecl_grid_dims5 ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_dims ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/AmalgLGRcase/TESTCASE_AMALG_LGR.EGRID
${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/AmalgLGRcase/TESTCASE_AMALG_LGR.INIT )
add_executable( ecl_kw_grdecl ecl_kw_grdecl.c )
target_link_libraries( ecl_kw_grdecl ecl )
add_test( ecl_kw_grdecl ${EXECUTABLE_OUTPUT_PATH}/ecl_kw_grdecl )
add_executable( ecl_kw_equal ecl_kw_equal.c )
target_link_libraries( ecl_kw_equal ecl )
add_test( ecl_kw_equal ${EXECUTABLE_OUTPUT_PATH}/ecl_kw_equal )
add_executable( ecl_dualp ecl_dualp.c )
target_link_libraries( ecl_dualp ecl )
add_test( ecl_dualp ${EXECUTABLE_OUTPUT_PATH}/ecl_dualp ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/LGCcase/LGC_TESTCASE2 )
add_executable( ecl_util_month_range ecl_util_month_range.c )
target_link_libraries( ecl_util_month_range ecl )
add_test( ecl_util_month_range ${EXECUTABLE_OUTPUT_PATH}/ecl_util_month_range )
add_executable( ecl_sum_test ecl_sum_test.c )
target_link_libraries( ecl_sum_test ecl )
add_test( ecl_sum_test ${EXECUTABLE_OUTPUT_PATH}/ecl_sum_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE )
add_executable( ecl_fortio ecl_fortio.c )
target_link_libraries( ecl_fortio ecl )
add_test( ecl_fortio ${EXECUTABLE_OUTPUT_PATH}/ecl_fortio ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST )
add_executable( ecl_file ecl_file.c )
target_link_libraries( ecl_file ecl )
add_test( ecl_file ${EXECUTABLE_OUTPUT_PATH}/ecl_file ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST ECLIPSE.UNRST)
add_executable( ecl_fmt ecl_fmt.c )
target_link_libraries( ecl_fmt ecl )
add_test( ecl_fmt ${EXECUTABLE_OUTPUT_PATH}/ecl_fmt ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.DATA)
add_executable( ecl_rsthead ecl_rsthead.c )
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 )
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)

View File

@@ -0,0 +1,2 @@
PARALLEL
4 DISTRIBUTED/

View File

@@ -0,0 +1,2 @@
PARALLEL
4 'DIST'/

View File

@@ -21,6 +21,7 @@
#include <ert/util/test_util.h>
#include <ert/util/util.h>
#include <ert/util/test_work_area.h>
#include <ert/ecl/ecl_file.h>
#include <ert/ecl/ecl_endian_flip.h>
@@ -103,9 +104,12 @@ void test_close_stream1(const char * src_file , const char * target_file ) {
void test_writable(const char * src_file ) {
util_copy_file( src_file , "/tmp/ECL.UNRST" );
test_work_area_type * work_area = test_work_area_alloc("ecl_file_writable" , true);
char * fname = util_split_alloc_filename( src_file );
test_work_area_copy_file( work_area , src_file );
{
ecl_file_type * ecl_file = ecl_file_open( "/tmp/ECL.UNRST" , ECL_FILE_WRITABLE);
ecl_file_type * ecl_file = ecl_file_open( fname , ECL_FILE_WRITABLE);
ecl_kw_type * swat = ecl_file_iget_named_kw( ecl_file , "SWAT" , 0 );
ecl_kw_type * swat0 = ecl_kw_alloc_copy( swat );
test_assert_true( ecl_kw_equal( swat , swat0 ));
@@ -114,26 +118,30 @@ void test_writable(const char * src_file ) {
test_assert_true( ecl_file_writable( ecl_file ));
ecl_file_close( ecl_file );
ecl_file = ecl_file_open( "/tmp/ECL.UNRST" , 0);
ecl_file = ecl_file_open( fname , 0);
swat = ecl_file_iget_named_kw( ecl_file , "SWAT" , 0 );
test_assert_true( util_double_approx_equal( ecl_kw_iget_float( swat , 0 ) , 1000 ));
}
util_unlink_existing( "/tmp/ECL.UNRST" );
test_work_area_free( work_area );
}
int main( int argc , char ** argv) {
const char * src_file = argv[1];
const char * filename = argv[2];
char * target_file = util_alloc_filename("/tmp" , filename , NULL );
const char * target_file = argv[2];
test_flags( src_file );
test_loadall(src_file , target_file );
test_close_stream1( src_file , target_file );
test_close_stream2( src_file , target_file );
test_writable( src_file );
util_unlink_existing( target_file );
{
test_work_area_type * work_area = test_work_area_alloc("ecl_file" , true);
test_work_area_install_file( work_area , src_file );
test_flags( src_file );
test_loadall(src_file , target_file );
test_close_stream1( src_file , target_file);
test_close_stream2( src_file , target_file);
test_writable( src_file );
test_work_area_free( work_area );
}
exit(0);
}

View File

@@ -20,21 +20,22 @@
#include <unistd.h>
#include <ert/util/util.h>
#include <ert/util/test_work_area.h>
#include <ert/util/test_util.h>
#include <ert/ecl/ecl_util.h>
void test_content( const char * src_file , bool fmt_file ) {
char * base_name , *path;
char * target_file;
bool fmt;
util_alloc_file_components( src_file , &path , &base_name , NULL);
target_file = util_alloc_filename( "/tmp" , base_name , NULL );
util_copy_file( src_file , target_file);
test_assert_true( ecl_util_fmt_file( target_file , &fmt ));
test_assert_bool_equal( fmt , fmt_file );
unlink( target_file );
void test_content( test_work_area_type * work_area , const char * src_file , bool fmt_file ) {
test_work_area_install_file( work_area , src_file );
{
char * base_name;
bool fmt;
util_alloc_file_components( src_file , NULL , &base_name , NULL);
util_copy_file( src_file , base_name );
test_assert_true( ecl_util_fmt_file( base_name , &fmt ));
test_assert_bool_equal( fmt , fmt_file );
}
}
@@ -43,11 +44,11 @@ void test_content( const char * src_file , bool fmt_file ) {
void test_small( ) {
bool fmt;
FILE * stream = util_fopen("/tmp/small.txt" , "w");
FILE * stream = util_fopen("small.txt" , "w");
fprintf(stream , "Some bytes\n");
fclose( stream );
test_assert_false( ecl_util_fmt_file( "/tmp/small.txt" , &fmt ));
test_assert_false( ecl_util_fmt_file( "small.txt" , &fmt ));
}
@@ -55,29 +56,32 @@ void test_small( ) {
int main(int argc , char ** argv) {
const char * binary_file = argv[1];
const char * text_file = argv[2];
test_work_area_type * work_area = test_work_area_alloc( "ecl_fmt" , true);
{
const char * binary_file = argv[1];
const char * text_file = argv[2];
bool fmt_file;
bool fmt_file;
test_assert_true( ecl_util_fmt_file( binary_file , &fmt_file ));
test_assert_false( fmt_file );
test_assert_true( ecl_util_fmt_file( binary_file , &fmt_file ));
test_assert_false( fmt_file );
test_assert_true( ecl_util_fmt_file( text_file , &fmt_file ));
test_assert_true( fmt_file );
test_assert_true( ecl_util_fmt_file( text_file , &fmt_file ));
test_assert_true( fmt_file );
test_assert_true( ecl_util_fmt_file( "TEST.EGRID" , &fmt_file ));
test_assert_false( fmt_file );
test_assert_true( ecl_util_fmt_file( "TEST.EGRID" , &fmt_file ));
test_assert_false( fmt_file );
test_assert_true( ecl_util_fmt_file( "TEST.FEGRID" , &fmt_file ));
test_assert_true( fmt_file );
test_assert_true( ecl_util_fmt_file( "TEST.FEGRID" , &fmt_file ));
test_assert_true( fmt_file );
test_assert_false(ecl_util_fmt_file( "TEST_DOES_NOT_EXIST" , &fmt_file ));
test_content( binary_file , false );
test_content( text_file , true );
test_small( );
test_assert_false(ecl_util_fmt_file( "TEST_DOES_NOT_EXIST" , &fmt_file ));
test_content( work_area , binary_file , false );
test_content( work_area , text_file , true );
test_small( );
}
test_work_area_free( work_area );
exit(0);
}

View File

@@ -20,6 +20,7 @@
#include <ert/util/test_util.h>
#include <ert/util/util.h>
#include <ert/util/test_work_area.h>
#include <ert/ecl/fortio.h>
#include <ert/ecl/ecl_endian_flip.h>
@@ -79,10 +80,15 @@ int main( int argc , char ** argv) {
test_existing_read( file );
test_not_existing_read( );
test_write( "/tmp/file.x" , true );
test_write( "/tmp/path/does/not/exist" , false );
test_open_close_read( file );
test_wrapper( file );
test_write( "/tmp/path/does/not/exist" , false );
{
test_work_area_type * work_area = test_work_area_alloc("ecl_fortio.write" , true );
util_make_path("path");
test_write( "path/file.x" , true );
test_work_area_free( work_area );
}
exit(0);
}

View File

@@ -0,0 +1,33 @@
/*
Copyright (C) 2012 Statoil ASA, Norway.
The file 'ecl_get_num_cpu_test.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_util.h>
int main(int argc , char ** argv) {
const char * filename1 = argv[1];
const char * filename2 = argv[2];
int num_cpu = 4;
test_assert_int_equal(ecl_util_get_num_cpu(filename1), num_cpu);
test_assert_int_equal(ecl_util_get_num_cpu(filename2), num_cpu);
exit(0);
}

View File

@@ -0,0 +1,46 @@
/*
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);
}

View File

@@ -0,0 +1,38 @@
/*
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);
}

View File

@@ -20,6 +20,8 @@
#include <ert/util/test_util.h>
#include <ert/util/util.h>
#include <ert/util/test_work_area.h>
#include <ert/ecl/ecl_kw.h>
int main(int argc , char ** argv) {
@@ -30,6 +32,7 @@ int main(int argc , char ** argv) {
ecl_kw_iset_int(ecl_kw , i , i );
{
test_work_area_type * work_area = test_work_area_alloc("ecl_kw_grdecl" , true);
FILE * stream = util_fopen( "FILE.grdecl" , "w");
ecl_kw_fprintf_grdecl(ecl_kw , stream );
@@ -62,7 +65,7 @@ int main(int argc , char ** argv) {
ecl_kw_free( ecl_kw2 );
}
fclose( stream );
test_work_area_free( work_area );
}
ecl_kw_free( ecl_kw );

View File

@@ -0,0 +1,91 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
The file 'ecl_win64.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/rng.h>
#include <ert/ecl/ecl_kw.h>
#include <ert/ecl/ecl_file.h>
#include <ert/ecl/ecl_endian_flip.h>
int main( int argc , char ** argv) {
int num_kw = 1000; // Total file size should roughly exceed 2GB
int kw_size = 600000;
ecl_kw_type * kw = ecl_kw_alloc("KW" , kw_size , ECL_INT_TYPE );
rng_type * rng = rng_alloc( MZRAN , INIT_DEFAULT );
int i;
offset_type file_size;
for (i=0; i < kw_size; i++)
ecl_kw_iset_int( kw , i , rng_get_int( rng , 912732 ));
{
fortio_type * fortio = fortio_open_writer( "LARGE_FILE.UNRST" , false , ECL_ENDIAN_FLIP);
for (i = 0; i < num_kw; i++) {
printf("Writing keyword %d/%d to file:LARGE_FILE.UNRST \n",i+1 , num_kw );
ecl_kw_fwrite( kw , fortio );
}
fortio_fclose( fortio );
}
/*{
fortio_type * fortio = fortio_open_reader( "LARGE_FILE.UNRST" , false , ECL_ENDIAN_FLIP);
for (i = 0; i < num_kw - 1; i++) {
printf("SKipping keyword %d/%d from file:LARGE_FILE.UNRST \n",i+1 , num_kw );
ecl_kw_fskip( fortio );
}
{
ecl_kw_type * file_kw = ecl_kw_fread_alloc( fortio );
if (ecl_kw_equal( kw , file_kw ))
printf("Keyword read back from file correctly :-) \n");
else
printf("Fatal error - keyword different on return ...\n");
ecl_kw_free( file_kw );
}
fortio_fclose( fortio );
}
*/
file_size = util_file_size( "LARGE_FILE.UNRST" );
printf("File size: %lld \n",file_size);
{
fortio_type * fortio = fortio_open_reader( "LARGE_FILE.UNRST" , false , ECL_ENDIAN_FLIP);
printf("Seeking to file end: ");
fortio_fseek( fortio , file_size , SEEK_SET);
fortio_fclose( fortio );
printf("Seek OK \n");
}
printf("Doing ecl_file_open(..)\n");
{
ecl_file_type * file = ecl_file_open( "LARGE_FILE.UNRST" , 0);
ecl_kw_type * file_kw = ecl_file_iget_named_kw( file , "KW" , num_kw - 1);
if (ecl_kw_equal( kw , file_kw ))
printf("Keyword read back from file correctly :-) \n");
else
printf("Fatal error - keyword different on return ...\n");
ecl_file_close( file );
}
remove( "LARGE_FILE.UNRST" );
exit(0);
}

View File

@@ -0,0 +1,44 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
The file 'ecl_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/test_util.h>
#include <ert/ecl/ecl_grid.h>
int main( int argc , char ** argv) {
ecl_grid_type * grid = ecl_grid_alloc( argv[1] );
int num_lgr = ecl_grid_get_num_lgr( grid );
int lgr_index;
for (lgr_index = 0; lgr_index < num_lgr; lgr_index++) {
ecl_grid_type * lgr_from_index = ecl_grid_iget_lgr( grid, lgr_index );
int lgr_nr = ecl_grid_get_lgr_nr( lgr_from_index);
ecl_grid_type * lgr_from_nr = ecl_grid_get_lgr_from_lgr_nr( grid , lgr_nr);
test_assert_ptr_equal( lgr_from_index , lgr_from_nr );
test_assert_string_equal( ecl_grid_get_lgr_name( grid , lgr_nr) , ecl_grid_iget_lgr_name( grid , lgr_index));
printf("Grid[%d:%d] : %s \n",lgr_index , lgr_nr , ecl_grid_iget_lgr_name( grid , lgr_index ));
}
ecl_grid_free( grid );
exit(0);
}

View File

@@ -0,0 +1,103 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
The file 'ecl_nnc_index_list.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/util.h>
#include <ert/util/int_vector.h>
#include <ert/ecl/nnc_index_list.h>
void test_create() {
nnc_index_list_type * index_list = nnc_index_list_alloc();
test_assert_true( nnc_index_list_is_instance( index_list ));
{
const int_vector_type * list = nnc_index_list_get_list( index_list );
test_assert_int_equal( 0 , int_vector_size( list ));
}
nnc_index_list_free( index_list );
}
void test_content() {
nnc_index_list_type * index_list = nnc_index_list_alloc();
nnc_index_list_add_index( index_list , 0 );
nnc_index_list_add_index( index_list , 1 );
nnc_index_list_add_index( index_list , 2 );
nnc_index_list_add_index( index_list , 3 );
{
const int_vector_type * list = nnc_index_list_get_list( index_list );
test_assert_int_equal( 4 , int_vector_size( list ));
test_assert_int_equal( 0 , int_vector_iget( list , 0));
test_assert_int_equal( 1 , int_vector_iget( list , 1));
test_assert_int_equal( 2 , int_vector_iget( list , 2));
test_assert_int_equal( 3 , int_vector_iget( list , 3));
}
nnc_index_list_free( index_list );
}
void test_sort_unique() {
nnc_index_list_type * index_list = nnc_index_list_alloc();
nnc_index_list_add_index( index_list , 3 );
nnc_index_list_add_index( index_list , 1 );
nnc_index_list_add_index( index_list , 2 );
nnc_index_list_add_index( index_list , 0 );
{
const int_vector_type * list = nnc_index_list_get_list( index_list );
test_assert_int_equal( 4 , int_vector_size( list ));
test_assert_int_equal( 0 , int_vector_iget( list , 0));
test_assert_int_equal( 1 , int_vector_iget( list , 1));
test_assert_int_equal( 2 , int_vector_iget( list , 2));
test_assert_int_equal( 3 , int_vector_iget( list , 3));
}
nnc_index_list_add_index( index_list , 3 );
nnc_index_list_add_index( index_list , 1 );
nnc_index_list_add_index( index_list , 2 );
nnc_index_list_add_index( index_list , 0 );
{
const int_vector_type * list = nnc_index_list_get_list( index_list );
test_assert_int_equal( 4 , int_vector_size( list ));
test_assert_int_equal( 0 , int_vector_iget( list , 0));
test_assert_int_equal( 1 , int_vector_iget( list , 1));
test_assert_int_equal( 2 , int_vector_iget( list , 2));
test_assert_int_equal( 3 , int_vector_iget( list , 3));
}
nnc_index_list_free( index_list );
}
int main( int argc , char ** argv) {
test_create();
test_content();
test_sort_unique();
exit(0);
}

View File

@@ -0,0 +1,60 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
The file 'ecl_nnc_index_list_grid.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/util.h>
#include <ert/util/int_vector.h>
#include <ert/ecl/nnc_index_list.h>
#include <ert/ecl/ecl_grid.h>
#include <ert/ecl/ecl_file.h>
int main( int argc , char ** argv) {
const char * egrid_file = argv[1];
ecl_grid_type * grid = ecl_grid_alloc( egrid_file );
ecl_file_type * gfile = ecl_file_open( egrid_file , 0 );
const ecl_kw_type * nnc1_kw = ecl_file_iget_named_kw( gfile , "NNC1" ,0 );
const ecl_kw_type * nnc2_kw = ecl_file_iget_named_kw( gfile , "NNC2" ,0 );
const int_vector_type * index_list = ecl_grid_get_nnc_index_list( grid );
{
int_vector_type * nnc = int_vector_alloc(0,0);
int_vector_set_many( nnc , 0 , ecl_kw_get_ptr( nnc1_kw ) , ecl_kw_get_size( nnc1_kw ));
int_vector_append_many( nnc , ecl_kw_get_ptr( nnc2_kw ) , ecl_kw_get_size( nnc2_kw ));
int_vector_select_unique( nnc );
test_assert_int_equal( int_vector_size( index_list ) , int_vector_size( nnc ));
{
int i;
for (i=0; i < int_vector_size( nnc ); i++)
test_assert_int_equal( int_vector_iget( nnc , i ) - 1 , int_vector_iget(index_list , i ));
}
int_vector_free( nnc );
}
ecl_file_close( gfile );
ecl_grid_free( grid );
exit(0);
}

View File

@@ -0,0 +1,66 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
The file 'ecl_nnc_info_test.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/util.h>
#include <ert/util/int_vector.h>
#include <ert/ecl/ecl_grid.h>
#include <ert/ecl/nnc_info.h>
#include <ert/ecl/nnc_vector.h>
int main(int argc , char ** argv) {
int lgr_nr = 77;
nnc_info_type * nnc_info = nnc_info_alloc(lgr_nr);
test_assert_int_equal( lgr_nr , nnc_info_get_lgr_nr( nnc_info ));
test_assert_true(nnc_info_is_instance(nnc_info));
test_assert_not_NULL(nnc_info);
nnc_info_add_nnc(nnc_info, 1, 110);
nnc_info_add_nnc(nnc_info, 1, 111);
const nnc_vector_type * nnc_vector = nnc_info_get_vector( nnc_info , 1);
const int_vector_type * nnc_cells = nnc_info_get_index_list(nnc_info, 1);
test_assert_int_equal(int_vector_size(nnc_cells), 2);
test_assert_ptr_equal( nnc_cells , nnc_vector_get_index_list( nnc_vector ));
const nnc_vector_type * nnc_vector_null = nnc_info_get_vector( nnc_info , 2);
const int_vector_type * nnc_cells_null = nnc_info_get_index_list(nnc_info, 2);
test_assert_NULL(nnc_cells_null);
test_assert_NULL(nnc_vector_null);
const nnc_vector_type * nnc_vector_self = nnc_info_get_self_vector( nnc_info );
const nnc_vector_type * nnc_vector_77 = nnc_info_get_vector( nnc_info , lgr_nr );
test_assert_ptr_equal( nnc_vector_77 , nnc_vector_self );
const int_vector_type * nnc_cells_77 = nnc_info_get_index_list(nnc_info, lgr_nr);
const int_vector_type * nnc_cells_self = nnc_info_get_self_index_list(nnc_info);
test_assert_ptr_equal( nnc_cells_77 , nnc_cells_self );
test_assert_int_equal( 1 , nnc_info_get_size( nnc_info ));
test_assert_ptr_equal( nnc_info_get_vector( nnc_info , 1 ) , nnc_info_iget_vector( nnc_info , 0 ));
nnc_info_free(nnc_info);
exit(0);
}

View File

@@ -0,0 +1,341 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
The file 'ecl_nnc_test.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/util.h>
#include <ert/util/int_vector.h>
#include <ert/ecl/ecl_grid.h>
#include <ert/ecl/nnc_info.h>
void test_nnc_global_grid( const char * grid_filename ) {
ecl_grid_type * ecl_grid = ecl_grid_alloc( grid_filename );
test_assert_not_NULL( ecl_grid );
const int data[] = {2675, 5235, 7795, 10355, 12915, 15475, 18035, 20595, 23155, 25715, 28275, 30835, 33395};
const nnc_info_type * nnc_info = ecl_grid_get_cell_nnc_info1(ecl_grid, 114);
test_assert_not_NULL( nnc_info );
test_assert_int_equal( ecl_grid_get_lgr_nr( ecl_grid ) , nnc_info_get_lgr_nr( nnc_info ));
const int_vector_type * nnc_cell_number_vec = nnc_info_get_index_list(nnc_info, 0);
test_assert_not_NULL(nnc_cell_number_vec);
test_assert_int_equal(int_vector_size(nnc_cell_number_vec), (sizeof(data)/sizeof(data[0])));
int i;
for (i = 0; i < int_vector_size(nnc_cell_number_vec); i++)
test_assert_int_equal(int_vector_iget(nnc_cell_number_vec, i), data[i]);
ecl_grid_free(ecl_grid);
}
void test_nnc_dual_poro(const char * grid_filename ) {
ecl_grid_type * ecl_grid = ecl_grid_alloc( grid_filename );
test_assert_not_NULL( ecl_grid );
ecl_grid_free(ecl_grid);
}
void test_nnc_lgr( const char * grid_filename ) {
ecl_grid_type * ecl_grid = ecl_grid_alloc( grid_filename );
test_assert_not_NULL( ecl_grid );
//Global grid
const nnc_info_type * nnc_info = ecl_grid_get_cell_nnc_info1(ecl_grid, 125132);
test_assert_not_NULL( nnc_info );
test_assert_int_equal( ecl_grid_get_lgr_nr( ecl_grid ) , nnc_info_get_lgr_nr( nnc_info ));
const int_vector_type * nnc_cell_number_vec = nnc_info_get_index_list(nnc_info, 0);
test_assert_not_NULL(nnc_cell_number_vec);
test_assert_int_equal(int_vector_size(nnc_cell_number_vec), 1);
test_assert_int_equal(int_vector_iget(nnc_cell_number_vec, 0), 151053);
//LGR
const int data[] = {126394, 126305};
ecl_grid_type * lgr_grid = ecl_grid_iget_lgr(ecl_grid, 0);
test_assert_not_NULL( lgr_grid );
const nnc_info_type * lgr_nnc_info = ecl_grid_get_cell_nnc_info1(lgr_grid, 2017-1);
test_assert_not_NULL( lgr_nnc_info );
test_assert_int_equal( ecl_grid_get_lgr_nr( lgr_grid ) , nnc_info_get_lgr_nr( lgr_nnc_info ));
const int_vector_type * lgr_nnc_cell_number_vec = nnc_info_get_index_list(lgr_nnc_info, 0);
test_assert_not_NULL(lgr_nnc_cell_number_vec);
test_assert_int_equal(int_vector_size(lgr_nnc_cell_number_vec), (sizeof(data)/sizeof(data[0])));
int i;
for (i = 0; i < int_vector_size(lgr_nnc_cell_number_vec); i++)
test_assert_int_equal(int_vector_iget(lgr_nnc_cell_number_vec, i), data[i]);
ecl_grid_free(ecl_grid);
}
void test_nnc_multiple_lgr( const char * grid_filename) {
ecl_grid_type * ecl_grid = ecl_grid_alloc( grid_filename );
test_assert_not_NULL( ecl_grid );
{
//Global grid, check NNC for cell with global index 736
int data[] = {11957, 20336, 3528, 6321, 9114, 11907, 20286};
const nnc_info_type * nnc_info = ecl_grid_get_cell_nnc_info1(ecl_grid, 736);
test_assert_not_NULL(nnc_info);
test_assert_int_equal( ecl_grid_get_lgr_nr( ecl_grid ) , nnc_info_get_lgr_nr( nnc_info ));
const int_vector_type * nnc_cell_number_vec = nnc_info_get_index_list(nnc_info, 0);
test_assert_not_NULL(nnc_cell_number_vec);
test_assert_int_equal(int_vector_size(nnc_cell_number_vec), (sizeof(data)/sizeof(data[0])));
int i;
for (i = 0; i < int_vector_size(nnc_cell_number_vec); i++) {
test_assert_int_equal(int_vector_iget(nnc_cell_number_vec, i), data[i]);
}
//Check grid name
test_assert_string_equal(ecl_grid_get_name(ecl_grid), grid_filename);
}
{
//Global grid, check NNC for cell with global index 138291
int data[] = {141035, 143828, 141085, 143878};
const nnc_info_type * nnc_info = ecl_grid_get_cell_nnc_info1(ecl_grid, 138291);
test_assert_not_NULL(nnc_info);
test_assert_int_equal( ecl_grid_get_lgr_nr( ecl_grid ) , nnc_info_get_lgr_nr( nnc_info ));
const int_vector_type * nnc_cell_number_vec = nnc_info_get_index_list(nnc_info, 0);
test_assert_not_NULL(nnc_cell_number_vec);
int i;
for (i = 0; i < int_vector_size(nnc_cell_number_vec); i++) {
test_assert_int_equal(int_vector_iget(nnc_cell_number_vec, i), data[i]);
}
}
{
//LGR nr 1, cell global index 0: check NNCs to main grid
int data[] = {29012, 26220};
ecl_grid_type * lgr_grid = ecl_grid_iget_lgr(ecl_grid, 0);
test_assert_not_NULL(lgr_grid);
const nnc_info_type * nnc_info = ecl_grid_get_cell_nnc_info1(lgr_grid, 0);
test_assert_not_NULL(nnc_info);
test_assert_int_equal( ecl_grid_get_lgr_nr( lgr_grid ) , nnc_info_get_lgr_nr( nnc_info ));
const int_vector_type * nnc_cell_number_vec = nnc_info_get_index_list(nnc_info, 0);
test_assert_not_NULL(nnc_cell_number_vec);
test_assert_int_equal(int_vector_size(nnc_cell_number_vec), (sizeof(data)/sizeof(data[0])));
int i = 0;
for (; i < int_vector_size(nnc_cell_number_vec); ++i)
test_assert_int_equal(int_vector_iget(nnc_cell_number_vec, i), data[i]);
//Check name
test_assert_string_equal(ecl_grid_get_name(lgr_grid), "LG006023");
}
{
//LGR nr 1, cell global index 0: check NNCs to grid with lgr nr 20
int data[] = {12};
ecl_grid_type * lgr_grid = ecl_grid_iget_lgr(ecl_grid, 0);
test_assert_not_NULL(lgr_grid);
const nnc_info_type * nnc_info = ecl_grid_get_cell_nnc_info1(lgr_grid, 0);
test_assert_not_NULL(nnc_info);
test_assert_int_equal( ecl_grid_get_lgr_nr( lgr_grid ) , nnc_info_get_lgr_nr( nnc_info ));
const int_vector_type * nnc_cell_number_vec = nnc_info_get_index_list(nnc_info, 20);
test_assert_not_NULL(nnc_cell_number_vec);
test_assert_int_equal(int_vector_size(nnc_cell_number_vec), (sizeof(data)/sizeof(data[0])));
int i = 0;
for (; i < int_vector_size(nnc_cell_number_vec); i++)
test_assert_int_equal(int_vector_iget(nnc_cell_number_vec, i), data[i]);
}
{
//LGR nr 3, check NNC for cell with global index 8
int data[] = {20681, 23474, 26267, 37440};
ecl_grid_type * lgr_grid = ecl_grid_iget_lgr(ecl_grid, 2);
test_assert_not_NULL(lgr_grid);
const nnc_info_type * nnc_info = ecl_grid_get_cell_nnc_info1(lgr_grid, 8);
test_assert_not_NULL(nnc_info);
test_assert_int_equal( ecl_grid_get_lgr_nr( lgr_grid ) , nnc_info_get_lgr_nr( nnc_info ));
const int_vector_type * nnc_cell_number_vec = nnc_info_get_index_list(nnc_info, 0);
test_assert_not_NULL(nnc_cell_number_vec);
test_assert_int_equal(int_vector_size(nnc_cell_number_vec), (sizeof(data)/sizeof(data[0])));
int i;
for (i = 0; i < int_vector_size(nnc_cell_number_vec); i++)
test_assert_int_equal(int_vector_iget(nnc_cell_number_vec, i), data[i]);
//Check LGR name
test_assert_string_equal(ecl_grid_get_name(lgr_grid), "LG005024");
}
{
//LGR nr 99, check NNC for cell with global index 736
int data[] = {126671, 79142};
ecl_grid_type * lgr_grid = ecl_grid_iget_lgr(ecl_grid, 98-1); //Subtract 1: LGR nr 98 is not present in the test file. LGRs are numbered 1-97 and 99-110 in test file.
test_assert_not_NULL(lgr_grid);
const nnc_info_type * nnc_info = ecl_grid_get_cell_nnc_info1(lgr_grid, 736);
test_assert_not_NULL(nnc_info);
test_assert_int_equal( ecl_grid_get_lgr_nr( lgr_grid ) , nnc_info_get_lgr_nr( nnc_info ));
const int_vector_type * nnc_cell_number_vec = nnc_info_get_index_list(nnc_info, 0);
test_assert_not_NULL(nnc_cell_number_vec);
test_assert_int_equal(int_vector_size(nnc_cell_number_vec), (sizeof(data)/sizeof(data[0])));
int i;
for (i = 0; i < int_vector_size(nnc_cell_number_vec); i++)
test_assert_int_equal(int_vector_iget(nnc_cell_number_vec, i), data[i]);
//Check LGR name
test_assert_string_equal(ecl_grid_get_name(lgr_grid), "LG008021");
}
{
//LGR nr 110, cell with global index 271: Check NNCs to global grid
int data[] = {20191, 22983};
ecl_grid_type * lgr_grid = ecl_grid_iget_lgr(ecl_grid, 109-1); //Subtract 1: LGR nr 98 is not present in the test file. LGRs are numbered 1-97 and 99-110 in test file.
test_assert_not_NULL(lgr_grid);
const nnc_info_type * nnc_info = ecl_grid_get_cell_nnc_info1(lgr_grid, 271);
test_assert_not_NULL(nnc_info);
test_assert_int_equal( ecl_grid_get_lgr_nr( lgr_grid ) , nnc_info_get_lgr_nr( nnc_info ));
const int_vector_type * nnc_cell_number_vec = nnc_info_get_index_list(nnc_info, 0);
test_assert_not_NULL(nnc_cell_number_vec);
test_assert_int_equal(int_vector_size(nnc_cell_number_vec), (sizeof(data)/sizeof(data[0])));
int i;
for (i = 0; i < int_vector_size(nnc_cell_number_vec); i++)
test_assert_int_equal(int_vector_iget(nnc_cell_number_vec, i), data[i]);
//Check LGR name
test_assert_string_equal(ecl_grid_get_name(lgr_grid), "LG003014");
}
{
//LGR nr 110, cell with global index 271: Check NNCs to lgr nr 109
int data[] = {275};
ecl_grid_type * lgr_grid = ecl_grid_iget_lgr(ecl_grid, 109-1); //Subtract 1: LGR nr 98 is not present in the test file. LGRs are numbered 1-97 and 99-110 in test file.
test_assert_not_NULL(lgr_grid);
const nnc_info_type * nnc_info = ecl_grid_get_cell_nnc_info1(lgr_grid, 271);
test_assert_not_NULL(nnc_info);
test_assert_int_equal( ecl_grid_get_lgr_nr( lgr_grid ) , nnc_info_get_lgr_nr( nnc_info ));
const int_vector_type * nnc_cell_number_vec = nnc_info_get_index_list(nnc_info, 109);
test_assert_not_NULL(nnc_cell_number_vec);
test_assert_int_equal(int_vector_size(nnc_cell_number_vec), (sizeof(data)/sizeof(data[0])));
int i;
for (i = 0; i < int_vector_size(nnc_cell_number_vec); i++)
test_assert_int_equal(int_vector_iget(nnc_cell_number_vec, i), data[i]);
}
{
//Test global versus ijk indexing
const nnc_info_type * nnc_info1 = ecl_grid_get_cell_nnc_info1(ecl_grid, 736);
test_assert_not_NULL(nnc_info1);
int i = 0;
int j = 0;
int k = 0;
ecl_grid_get_ijk1(ecl_grid, 736, &i, &j, &k);
const nnc_info_type * nnc_info2 = ecl_grid_get_cell_nnc_info3(ecl_grid, i, j, k);
test_assert_not_NULL(nnc_info2);
test_assert_ptr_equal(nnc_info1, nnc_info2);
}
ecl_grid_free(ecl_grid);
}
void test_nnc_amalgamated_lgrs(const char * grid_filename) {
ecl_grid_type * ecl_grid = ecl_grid_alloc( grid_filename );
test_assert_not_NULL( ecl_grid );
//Get the NNC info for cell with global index 0 in LGR nr 1
ecl_grid_type * lgr_grid = ecl_grid_iget_lgr(ecl_grid, 0);
test_assert_not_NULL(lgr_grid);
const nnc_info_type * nnc_info = ecl_grid_get_cell_nnc_info1(lgr_grid, 0);
test_assert_not_NULL(nnc_info);
//Get the connections that this cell has to LGR 20
const int_vector_type * nnc_lgr_20 = nnc_info_get_index_list(nnc_info, 20);
test_assert_not_NULL(nnc_lgr_20);
test_assert_int_equal(int_vector_size(nnc_lgr_20), 1);
test_assert_int_equal(int_vector_iget(nnc_lgr_20, 0), 12);
ecl_grid_free(ecl_grid);
}
int main(int argc , char ** argv) {
const char * EGRID_file1 = argv[1];
const char * EGRID_file2 = argv[2];
const char * EGRID_file3 = argv[3];
const char * EGRID_file4 = argv[4];
test_nnc_global_grid( EGRID_file1 );
test_nnc_lgr( EGRID_file2 );
test_nnc_multiple_lgr( EGRID_file3 );
test_nnc_amalgamated_lgrs(EGRID_file3);
test_nnc_dual_poro( EGRID_file4 );
exit(0);
}

View File

@@ -0,0 +1,49 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
The file 'ecl_nnc_vector.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/int_vector.h>
#include <ert/ecl/nnc_vector.h>
int main(int argc , char ** argv) {
int lgr_nr = 100;
nnc_vector_type * vector = nnc_vector_alloc( lgr_nr );
test_assert_true( nnc_vector_is_instance( vector ));
test_assert_int_equal( lgr_nr , nnc_vector_get_lgr_nr( vector ));
nnc_vector_add_nnc( vector , 100 );
nnc_vector_add_nnc( vector , 200 );
nnc_vector_add_nnc( vector , 300 );
{
const int_vector_type * index_list = nnc_vector_get_index_list( vector );
test_assert_int_equal( 3 , int_vector_size( index_list ));
test_assert_int_equal( 100 , int_vector_iget( index_list , 0 ));
test_assert_int_equal( 200 , int_vector_iget( index_list , 1 ));
test_assert_int_equal( 300 , int_vector_iget( index_list , 2 ));
}
nnc_vector_free( vector );
exit(0);
}

View File

@@ -0,0 +1,70 @@
/*
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);
}

View File

@@ -0,0 +1,70 @@
/*
Copyright (C) 2012 Statoil ASA, Norway.
The file 'ecl_region2region.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_sum.h>
void has_r2r_key(const ecl_sum_type* ecl_sum) {
test_assert_true(ecl_sum_has_key( ecl_sum , "RGF:393217" ));
test_assert_true(ecl_sum_has_key( ecl_sum , "RGF:1-2" ));
test_assert_true(ecl_sum_has_key( ecl_sum , "ROF:524291" ));
test_assert_true(ecl_sum_has_key( ecl_sum , "RWF:393222" ));
test_assert_true(ecl_sum_has_key( ecl_sum , "RWF:6-2" ));
test_assert_true(ecl_sum_has_key( ecl_sum , "ROF:3-6" ));
test_assert_true(ecl_sum_has_key( ecl_sum , "RNLF:458753" ));
test_assert_true(ecl_sum_has_key( ecl_sum , "RNLF:1-4" ));
}
void get_unit(const ecl_sum_type* ecl_sum) {
test_assert_string_equal(ecl_sum_get_unit( ecl_sum , "RGF:1-2" ), "GFLOW");
test_assert_string_equal(ecl_sum_get_unit( ecl_sum , "ROF:3-6" ), "OFLOW");
test_assert_string_equal(ecl_sum_get_unit( ecl_sum , "RWF:6-2" ), "WFLOW");
test_assert_string_equal(ecl_sum_get_unit( ecl_sum , "RNLF:1-4" ), "NLFLOW");
}
void get_var_params_index(const ecl_sum_type* ecl_sum) {
test_assert_int_equal(ecl_sum_get_general_var_params_index( ecl_sum , "RGF:1-2"), 21917);
test_assert_int_equal(ecl_sum_get_general_var_params_index( ecl_sum , "ROF:3-6"), 21918);
test_assert_int_equal(ecl_sum_get_general_var_params_index( ecl_sum, "RWF:6-2"), 21919);
test_assert_int_equal(ecl_sum_get_general_var_params_index( ecl_sum, "RNLF:1-4"), 21920);
}
int main(int argc , char ** argv) {
const char * headerfile = argv[1];
ecl_sum_type * ecl_sum = ecl_sum_fread_alloc_case( headerfile , ":");
if (ecl_sum) {
has_r2r_key(ecl_sum);
get_unit(ecl_sum);
get_var_params_index(ecl_sum);
}
else
test_error_exit("ecl_region2region_test: Test file not read correctly");
if (ecl_sum)
ecl_sum_free( ecl_sum );
exit(0);
}

View File

@@ -0,0 +1,148 @@
/*
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( 260.6111 , ecl_rft_node_iget_pressure( rft_node , 0 ));
test_assert_double_equal( 0.0581993 , ecl_rft_node_iget_soil( rft_node , 0 ));
test_assert_double_equal( 0.9405648 , ecl_rft_node_iget_swat( rft_node , 0 ));
test_assert_double_equal( 0.00123579 , 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 );
}
void test_plt_msw( 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_true( ecl_rft_node_is_MSW( plt_node ));
test_assert_int_equal( 22 , ecl_rft_node_get_size( plt_node ));
ecl_rft_node_inplace_sort_cells( plt_node );
{
int i;
for (i=1; i < ecl_rft_node_get_size( plt_node ); i++) {
const ecl_rft_cell_type * prev_cell = ecl_rft_node_iget_cell( plt_node , i - 1);
const ecl_rft_cell_type * this_cell = ecl_rft_node_iget_cell( plt_node , i );
test_assert_true( ecl_rft_cell_get_connection_start( prev_cell ) < ecl_rft_cell_get_connection_start( this_cell ));
test_assert_true( ecl_rft_cell_get_connection_end( prev_cell ) < ecl_rft_cell_get_connection_end( this_cell ));
}
}
ecl_rft_file_free( plt );
}
// 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);
}

View File

@@ -0,0 +1,150 @@
/*
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_connection_end( 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 connection_end = 979;
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,connection_end, 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( connection_end, ecl_rft_cell_get_connection_end( 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);
}

View File

@@ -0,0 +1,49 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
The file 'ecl_sum_test.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_sum.h>
int main( int argc , char ** argv) {
const char * case1 = argv[1];
const char * case2 = argv[2];
const char * compatible_string = argv[3];
bool compatible;
ecl_sum_type * ecl_sum1 = ecl_sum_fread_alloc_case( case1 , ":");
ecl_sum_type * ecl_sum2 = ecl_sum_fread_alloc_case( case2 , ":");
test_assert_true( ecl_sum_is_instance( ecl_sum1 ));
test_assert_true( ecl_sum_is_instance( ecl_sum2 ));
test_assert_true( ecl_sum_report_step_compatible( ecl_sum1 , ecl_sum1) );
test_assert_true( util_sscanf_bool( compatible_string , &compatible ));
test_assert_true( ecl_sum_report_step_compatible( ecl_sum1 , ecl_sum1) );
test_assert_true( ecl_sum_report_step_compatible( ecl_sum2 , ecl_sum2) );
test_assert_bool_equal( compatible , ecl_sum_report_step_compatible( ecl_sum1 , ecl_sum2 ));
ecl_sum_free( ecl_sum1 );
ecl_sum_free( ecl_sum2 );
exit(0);
}

View File

@@ -0,0 +1,49 @@
/*
Copyright (C) 2013 Statoil ASA, Norway.
The file 'ecl_sum_test.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_sum.h>
int main( int argc , char ** argv) {
const char * case1 = argv[1];
const char * case2 = argv[2];
const char * equal_string = argv[3];
bool equal;
ecl_sum_type * ecl_sum1 = ecl_sum_fread_alloc_case( case1 , ":");
ecl_sum_type * ecl_sum2 = ecl_sum_fread_alloc_case( case2 , ":");
test_assert_true( ecl_sum_is_instance( ecl_sum1 ));
test_assert_true( ecl_sum_is_instance( ecl_sum2 ));
test_assert_true( ecl_sum_report_step_equal( ecl_sum1 , ecl_sum1) );
test_assert_true( util_sscanf_bool( equal_string , &equal ));
test_assert_true( ecl_sum_report_step_equal( ecl_sum1 , ecl_sum1) );
test_assert_true( ecl_sum_report_step_equal( ecl_sum2 , ecl_sum2) );
test_assert_bool_equal( equal , ecl_sum_report_step_equal( ecl_sum1 , ecl_sum2 ));
ecl_sum_free( ecl_sum1 );
ecl_sum_free( ecl_sum2 );
exit(0);
}

View File

@@ -51,16 +51,25 @@ 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"));
}
int main( int argc , char ** argv) {
const char * casename = argv[1];
ecl_sum_type * ecl_sum = ecl_sum_fread_alloc_case( casename , ":");
test_time_range( ecl_sum );
test_days( ecl_sum );
const char * case1 = argv[1];
ecl_sum_type * ecl_sum1 = ecl_sum_fread_alloc_case( case1 , ":");
test_assert_true( ecl_sum_is_instance( ecl_sum1 ));
test_time_range( ecl_sum1 );
test_days( ecl_sum1 );
test_is_oil_producer(ecl_sum1);
ecl_sum_free( ecl_sum1 );
exit(0);
}

View File

@@ -0,0 +1,175 @@
add_executable( ecl_coarse_test ecl_coarse_test.c )
target_link_libraries( ecl_coarse_test ecl test_util )
add_test( ecl_coarse_test ${EXECUTABLE_OUTPUT_PATH}/ecl_coarse_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/LGCcase/LGC_TESTCASE2 )
add_executable( ecl_restart_test ecl_restart_test.c )
target_link_libraries( ecl_restart_test ecl test_util )
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 test_util )
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 test_util )
add_test( ecl_region ${EXECUTABLE_OUTPUT_PATH}/ecl_region ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID )
add_executable( ecl_region2region ecl_region2region_test.c )
target_link_libraries( ecl_region2region ecl test_util )
add_test( ecl_region2region ${EXECUTABLE_OUTPUT_PATH}/ecl_region2region ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/R2R/R2R.SMSPEC )
add_executable( ecl_grid_case ecl_grid_case.c )
target_link_libraries( ecl_grid_case ecl test_util )
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 test_util )
add_test( ecl_lgr_test1 ${EXECUTABLE_OUTPUT_PATH}/ecl_lgr_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/10kcase/TEST10K_FLT_LGR_NNC.EGRID)
add_test( ecl_lgr_test2 ${EXECUTABLE_OUTPUT_PATH}/ecl_lgr_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/10kcase/TEST10K_FLT_LGR_NNC.GRID)
add_test( ecl_lgr_test3 ${EXECUTABLE_OUTPUT_PATH}/ecl_lgr_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Troll/MSW_LGR/2BRANCHES-CCEWELLPATH-NEW-SCH-TUNED-AR3.EGRID )
add_executable( ecl_grid_simple ecl_grid_simple.c )
target_link_libraries( ecl_grid_simple ecl test_util )
add_test( ecl_grid_simple ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_simple ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID )
add_executable( ecl_grid_dims ecl_grid_dims.c )
target_link_libraries( ecl_grid_dims ecl test_util )
add_test( ecl_grid_dims0 ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_dims )
add_test( ecl_grid_dims1 ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_dims ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.INIT )
add_test( ecl_grid_dims2 ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_dims ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.GRID ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.INIT)
add_test( ecl_grid_dims3 ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_dims ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID )
add_test( ecl_grid_dims4 ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_dims ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.GRID )
add_test( ecl_grid_dims5 ${EXECUTABLE_OUTPUT_PATH}/ecl_grid_dims ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/AmalgLGRcase/TESTCASE_AMALG_LGR.EGRID
${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/AmalgLGRcase/TESTCASE_AMALG_LGR.INIT )
add_executable( ecl_nnc_test ecl_nnc_test.c )
target_link_libraries( ecl_nnc_test ecl test_util )
add_test (ecl_nnc_test ${EXECUTABLE_OUTPUT_PATH}/ecl_nnc_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID
${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/10kcase/TEST10K_FLT_LGR_NNC.EGRID
${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Troll/MSW_LGR/2BRANCHES-CCEWELLPATH-NEW-SCH-TUNED-AR3.EGRID
${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/DualPoro/DUAL_DIFF.EGRID )
add_executable( ecl_nnc_info_test ecl_nnc_info_test.c )
target_link_libraries( ecl_nnc_info_test ecl test_util )
add_test (ecl_nnc_info_test ${EXECUTABLE_OUTPUT_PATH}/ecl_nnc_info_test )
add_executable( ecl_kw_grdecl ecl_kw_grdecl.c )
target_link_libraries( ecl_kw_grdecl ecl test_util )
add_test( ecl_kw_grdecl ${EXECUTABLE_OUTPUT_PATH}/ecl_kw_grdecl )
add_executable( ecl_kw_equal ecl_kw_equal.c )
target_link_libraries( ecl_kw_equal ecl test_util )
add_test( ecl_kw_equal ${EXECUTABLE_OUTPUT_PATH}/ecl_kw_equal )
add_executable( ecl_dualp ecl_dualp.c )
target_link_libraries( ecl_dualp ecl test_util )
add_test( ecl_dualp ${EXECUTABLE_OUTPUT_PATH}/ecl_dualp ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/LGCcase/LGC_TESTCASE2 )
add_executable( ecl_util_month_range ecl_util_month_range.c )
target_link_libraries( ecl_util_month_range ecl test_util )
add_test( ecl_util_month_range ${EXECUTABLE_OUTPUT_PATH}/ecl_util_month_range )
add_executable( ecl_sum_test ecl_sum_test.c )
target_link_libraries( ecl_sum_test ecl test_util )
add_test( ecl_sum_test ${EXECUTABLE_OUTPUT_PATH}/ecl_sum_test ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE )
add_executable( ecl_sum_report_step_equal ecl_sum_report_step_equal.c )
target_link_libraries( ecl_sum_report_step_equal ecl test_util )
add_test( ecl_sum_report_step_equal1 ${EXECUTABLE_OUTPUT_PATH}/ecl_sum_report_step_equal ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Snorre/SNORRE FALSE)
add_test( ecl_sum_report_step_equal2 ${EXECUTABLE_OUTPUT_PATH}/ecl_sum_report_step_equal ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE TRUE)
add_test( ecl_sum_report_step_equal3 ${EXECUTABLE_OUTPUT_PATH}/ecl_sum_report_step_equal ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/modGurbat/extraMinistep/ECLIPSE TRUE)
add_test( ecl_sum_report_step_equal4 ${EXECUTABLE_OUTPUT_PATH}/ecl_sum_report_step_equal ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/modGurbat/short/ECLIPSE FALSE)
add_test( ecl_sum_report_step_equal5 ${EXECUTABLE_OUTPUT_PATH}/ecl_sum_report_step_equal ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/modGurbat/enkf/ECLIPSE FALSE)
add_test( ecl_sum_report_step_equal6 ${EXECUTABLE_OUTPUT_PATH}/ecl_sum_report_step_equal ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Snorre/SNORRE ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Snorre2/SNORRE2 FALSE)
add_executable( ecl_sum_report_step_compatible ecl_sum_report_step_compatible.c )
target_link_libraries( ecl_sum_report_step_compatible ecl test_util )
add_test( ecl_sum_report_step_compatible1 ${EXECUTABLE_OUTPUT_PATH}/ecl_sum_report_step_compatible ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Snorre/SNORRE FALSE)
add_test( ecl_sum_report_step_compatible2 ${EXECUTABLE_OUTPUT_PATH}/ecl_sum_report_step_compatible ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE TRUE)
add_test( ecl_sum_report_step_compatible3 ${EXECUTABLE_OUTPUT_PATH}/ecl_sum_report_step_compatible ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/modGurbat/extraMinistep/ECLIPSE TRUE)
add_test( ecl_sum_report_step_compatible4 ${EXECUTABLE_OUTPUT_PATH}/ecl_sum_report_step_compatible ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/modGurbat/short/ECLIPSE TRUE)
add_test( ecl_sum_report_step_compatible5 ${EXECUTABLE_OUTPUT_PATH}/ecl_sum_report_step_compatible ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/modGurbat/enkf/ECLIPSE TRUE)
add_test( ecl_sum_report_step_compatible6 ${EXECUTABLE_OUTPUT_PATH}/ecl_sum_report_step_equal ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Snorre/SNORRE ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Snorre2/SNORRE2 FALSE)
add_executable( ecl_fortio ecl_fortio.c )
target_link_libraries( ecl_fortio ecl test_util )
add_test( ecl_fortio ${EXECUTABLE_OUTPUT_PATH}/ecl_fortio ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST )
add_executable( ecl_file ecl_file.c )
target_link_libraries( ecl_file ecl test_util )
add_test( ecl_file ${EXECUTABLE_OUTPUT_PATH}/ecl_file ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST ECLIPSE.UNRST)
add_executable( ecl_fmt ecl_fmt.c )
target_link_libraries( ecl_fmt ecl test_util )
add_test( ecl_fmt ${EXECUTABLE_OUTPUT_PATH}/ecl_fmt ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/Gurbat/ECLIPSE.DATA)
add_executable( ecl_rsthead ecl_rsthead.c )
target_link_libraries( ecl_rsthead ecl test_util )
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 test_util )
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_test( ecl_rft_plt ${EXECUTABLE_OUTPUT_PATH}/ecl_rft ${PROJECT_SOURCE_DIR}/test-data/Statoil/ECLIPSE/RFT/RFT2.RFT MSW-PLT)
add_executable( ecl_rft_cell ecl_rft_cell.c )
target_link_libraries( ecl_rft_cell ecl test_util )
add_test( ecl_rft_cell ${EXECUTABLE_OUTPUT_PATH}/ecl_rft_cell )
add_executable( ecl_get_num_cpu ecl_get_num_cpu_test.c )
target_link_libraries( ecl_get_num_cpu ecl test_util )
add_test( ecl_get_num_cpu ${EXECUTABLE_OUTPUT_PATH}/ecl_get_num_cpu ${PROJECT_SOURCE_DIR}/libecl/tests/data/num_cpu1 ${PROJECT_SOURCE_DIR}/libecl/tests/data/num_cpu2)
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_sum_report_step_equal1 PROPERTY LABELS StatoilData )
set_property( TEST ecl_sum_report_step_equal2 PROPERTY LABELS StatoilData )
set_property( TEST ecl_sum_report_step_equal3 PROPERTY LABELS StatoilData )
set_property( TEST ecl_sum_report_step_equal4 PROPERTY LABELS StatoilData )
set_property( TEST ecl_sum_report_step_equal5 PROPERTY LABELS StatoilData )
set_property( TEST ecl_sum_report_step_equal6 PROPERTY LABELS StatoilData )
set_property( TEST ecl_sum_report_step_compatible1 PROPERTY LABELS StatoilData )
set_property( TEST ecl_sum_report_step_compatible2 PROPERTY LABELS StatoilData )
set_property( TEST ecl_sum_report_step_compatible3 PROPERTY LABELS StatoilData )
set_property( TEST ecl_sum_report_step_compatible4 PROPERTY LABELS StatoilData )
set_property( TEST ecl_sum_report_step_compatible5 PROPERTY LABELS StatoilData )
set_property( TEST ecl_sum_report_step_compatible6 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_nnc_test 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_region2region 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)

View File

@@ -1,5 +1,5 @@
add_subdirectory( src )
if (BUILD_APPLICATONS)
if (BUILD_APPLICATIONS)
add_subdirectory( applications )
endif()

View File

@@ -1,8 +1,11 @@
add_executable( well_info_test well_info_test.c )
set(program_list well_info_test )
add_executable( segment_info segment_info.c )
set(program_list segment_info )
foreach(prog ${program_list})
target_link_libraries( ${prog} ecl_well ecl)
if (USE_RUNPATH)
add_runpath( ${prog} )
endif()
#-----------------------------------------------------------------

Some files were not shown because too many files have changed in this diff Show More