mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Updated to version 0.8.0
This commit is contained in:
@@ -88,7 +88,10 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo(
|
||||
|
||||
CVF_ASSERT(grid != NULL);
|
||||
const std::vector< double >* cellScalarResults = NULL;
|
||||
bool cellScalarResultUseGlobalActiveIndex = true;
|
||||
|
||||
const std::vector< double >* edgeScalarResults[6] = {NULL, NULL, NULL, NULL, NULL, NULL};
|
||||
bool edgeScalarResultUseGlobalActiveIndex[6];
|
||||
|
||||
if (cellResultSlot->hasResult())
|
||||
{
|
||||
@@ -101,6 +104,8 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo(
|
||||
{
|
||||
cellScalarResults = &scalarResultTimeSteps[0];
|
||||
}
|
||||
|
||||
cellScalarResultUseGlobalActiveIndex = grid->mainGrid()->results()->isUsingGlobalActiveIndex(cellResultSlot->gridScalarIndex());
|
||||
}
|
||||
|
||||
size_t resultIndices[6];
|
||||
@@ -115,6 +120,7 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo(
|
||||
{
|
||||
const std::vector< std::vector<double> >& scalarResultTimeSteps = grid->mainGrid()->results()->cellScalarResults(resultIndices[cubeFaceIdx]);
|
||||
edgeScalarResults[cubeFaceIdx] = &scalarResultTimeSteps[0]; // Assuming only static edge results
|
||||
edgeScalarResultUseGlobalActiveIndex[cubeFaceIdx] = grid->mainGrid()->results()->isUsingGlobalActiveIndex(resultIndices[cubeFaceIdx]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -136,7 +142,12 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo(
|
||||
|
||||
float cellColorTextureCoord = 0.5f; // If no results exists, the texture will have a special color
|
||||
size_t cellIndex = quadToCell[quadIdx];
|
||||
size_t resultIndex = grid->cell(cellIndex).globalActiveIndex();
|
||||
|
||||
size_t resultIndex = cellIndex;
|
||||
if (cellScalarResultUseGlobalActiveIndex)
|
||||
{
|
||||
resultIndex = grid->cell(cellIndex).globalActiveIndex();
|
||||
}
|
||||
|
||||
if (cellScalarResults )
|
||||
{
|
||||
@@ -163,6 +174,12 @@ void RivCellEdgeGeometryGenerator::addCellEdgeResultsToDrawableGeo(
|
||||
{
|
||||
edgeColor = -1.0f; // Undefined texture coord. Shader handles this.
|
||||
|
||||
resultIndex = cellIndex;
|
||||
if (edgeScalarResultUseGlobalActiveIndex[cubeFaceIdx])
|
||||
{
|
||||
resultIndex = grid->cell(cellIndex).globalActiveIndex();
|
||||
}
|
||||
|
||||
if (resultIndices[cubeFaceIdx] != cvf::UNDEFINED_SIZE_T && resultIndex != cvf::UNDEFINED_SIZE_T)
|
||||
{
|
||||
double scalarValue = (*(edgeScalarResults[cubeFaceIdx]))[resultIndex];
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "RimReservoirView.h"
|
||||
#include "RimWellCollection.h"
|
||||
#include "RivWellPipesPartMgr.h"
|
||||
#include "RivWellHeadPartMgr.h"
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -52,7 +53,7 @@ void RivReservoirPipesPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasic
|
||||
if (m_reservoirView->wellCollection()->wells.size() != m_wellPipesPartMgrs.size())
|
||||
{
|
||||
m_wellPipesPartMgrs.clear();
|
||||
m_wellPipesPartMgrs.clear();
|
||||
m_wellHeadPartMgrs.clear();
|
||||
|
||||
for (size_t i = 0; i < m_reservoirView->wellCollection()->wells.size(); ++i)
|
||||
{
|
||||
|
||||
@@ -22,10 +22,10 @@
|
||||
|
||||
|
||||
#include "cvfCollection.h"
|
||||
#include "RivWellHeadPartMgr.h"
|
||||
|
||||
class RimReservoirView;
|
||||
class RivWellPipesPartMgr;
|
||||
class RivWellHeadPartMgr;
|
||||
|
||||
class RivReservoirPipesPartMgr : public cvf::Object
|
||||
{
|
||||
|
||||
@@ -601,17 +601,23 @@ void RivReservoirViewPartMgr::computePropertyVisibility(cvf::UByteArray* cellVis
|
||||
}
|
||||
|
||||
const RimCellFilter::FilterModeType filterType = (*pfIt)->filterMode();
|
||||
bool useGlobalActiveIndex = grid->mainGrid()->results()->isUsingGlobalActiveIndex((*pfIt)->resultDefinition->gridScalarIndex());
|
||||
|
||||
#pragma omp parallel for schedule(dynamic)
|
||||
for (int cellIndex = 0; cellIndex < static_cast<int>(grid->cellCount()); cellIndex++)
|
||||
{
|
||||
if ( (*cellVisibility)[cellIndex] )
|
||||
{
|
||||
size_t resultIndex = grid->cell(cellIndex).globalActiveIndex();
|
||||
double value = HUGE_VAL;
|
||||
if (resultIndex != cvf::UNDEFINED_SIZE_T) value = (*scalarResult)[resultIndex];
|
||||
size_t resultIndex = cellIndex;
|
||||
if (useGlobalActiveIndex)
|
||||
{
|
||||
resultIndex = grid->cell(cellIndex).globalActiveIndex();
|
||||
}
|
||||
|
||||
double scalarValue = HUGE_VAL;
|
||||
if (resultIndex != cvf::UNDEFINED_SIZE_T) scalarValue = (*scalarResult)[resultIndex];
|
||||
|
||||
if (lowerBound <= value && value <= upperBound)
|
||||
if (lowerBound <= scalarValue && scalarValue <= upperBound)
|
||||
{
|
||||
if (filterType == RimCellFilter::EXCLUDE)
|
||||
{
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
|
||||
|
||||
#include "RivWellHeadPartMgr.h"
|
||||
|
||||
#include "cvfLibCore.h"
|
||||
|
||||
#include "cvfModelBasicList.h"
|
||||
@@ -38,7 +40,6 @@
|
||||
#include "RigCell.h"
|
||||
|
||||
#include "RivPipeGeometryGenerator.h"
|
||||
#include "RivWellHeadPartMgr.h"
|
||||
#include "RivWellPipesPartMgr.h"
|
||||
|
||||
|
||||
@@ -49,6 +50,8 @@ RivWellHeadPartMgr::RivWellHeadPartMgr(RimReservoirView* reservoirView, RimWell*
|
||||
{
|
||||
m_rimReservoirView = reservoirView;
|
||||
m_rimWell = well;
|
||||
|
||||
m_font = new cvf::FixedAtlasFont(cvf::FixedAtlasFont::LARGE);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -110,7 +113,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex)
|
||||
cvf::ref<RivPipeGeometryGenerator> pipeGeomGenerator = new RivPipeGeometryGenerator;
|
||||
pipeGeomGenerator->setPipeCenterCoords(wellHeadPipeCoords.p());
|
||||
pipeGeomGenerator->setPipeColor(well->wellPipeColor());
|
||||
pipeGeomGenerator->setCrossSectionVertexCount(12);
|
||||
pipeGeomGenerator->setCrossSectionVertexCount(m_rimReservoirView->wellCollection()->pipeCrossSectionVertexCount());
|
||||
|
||||
double pipeRadius = m_rimReservoirView->wellCollection()->pipeRadiusScaleFactor() * m_rimWell->pipeRadiusScaleFactor() * characteristicCellSize;
|
||||
pipeGeomGenerator->setRadius(pipeRadius);
|
||||
@@ -121,6 +124,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex)
|
||||
if (pipeSurface.notNull())
|
||||
{
|
||||
cvf::ref<cvf::Part> part = new cvf::Part;
|
||||
part->setName("RivWellHeadPartMgr: surface " + cvfqt::Utils::fromQString(well->name()));
|
||||
part->setDrawable(pipeSurface.p());
|
||||
|
||||
caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(well->wellPipeColor()), true);
|
||||
@@ -134,6 +138,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex)
|
||||
if (centerLineDrawable.notNull())
|
||||
{
|
||||
cvf::ref<cvf::Part> part = new cvf::Part;
|
||||
part->setName("RivWellHeadPartMgr: centerline " + cvfqt::Utils::fromQString(well->name()));
|
||||
part->setDrawable(centerLineDrawable.p());
|
||||
|
||||
caf::MeshEffectGenerator meshGen(well->wellPipeColor());
|
||||
@@ -172,6 +177,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex)
|
||||
gen.setShaftRelativeRadius(0.5f);
|
||||
gen.setHeadRelativeRadius(1.0f);
|
||||
gen.setHeadRelativeLength(0.4f);
|
||||
gen.setNumSlices(m_rimReservoirView->wellCollection()->pipeCrossSectionVertexCount());
|
||||
gen.generate(&builder);
|
||||
|
||||
cvf::ref<cvf::Vec3fArray> vertices = builder.vertices();
|
||||
@@ -193,6 +199,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex)
|
||||
|
||||
{
|
||||
cvf::ref<cvf::Part> part = new cvf::Part;
|
||||
part->setName("RivWellHeadPartMgr: arrow " + cvfqt::Utils::fromQString(well->name()));
|
||||
part->setDrawable(geo1.p());
|
||||
|
||||
cvf::Color4f headColor(cvf::Color3::GRAY);
|
||||
@@ -226,7 +233,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex)
|
||||
if (m_rimReservoirView->wellCollection()->showWellLabel() && well->showWellLabel())
|
||||
{
|
||||
cvf::ref<cvf::DrawableText> drawableText = new cvf::DrawableText;
|
||||
drawableText->setFont(new cvf::FixedAtlasFont(cvf::FixedAtlasFont::LARGE));
|
||||
drawableText->setFont(m_font.p());
|
||||
drawableText->setCheckPosVisible(false);
|
||||
drawableText->setDrawBorder(false);
|
||||
drawableText->setDrawBackground(false);
|
||||
@@ -239,6 +246,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex)
|
||||
drawableText->addText(cvfString, textCoord);
|
||||
|
||||
cvf::ref<cvf::Part> part = new cvf::Part;
|
||||
part->setName("RivWellHeadPartMgr: text " + cvfString);
|
||||
part->setDrawable(drawableText.p());
|
||||
|
||||
cvf::ref<cvf::Effect> eff = new cvf::Effect;
|
||||
|
||||
@@ -18,14 +18,22 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "cvfBase.h"
|
||||
#include "cvfAssert.h"
|
||||
#include "cvfObject.h"
|
||||
#include "cafPdmPointer.h"
|
||||
#include "cvfCollection.h"
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
class Part;
|
||||
class ModelBasicList;
|
||||
class Transform;
|
||||
class Font;
|
||||
}
|
||||
|
||||
class RimWell;
|
||||
class RimReservoirView;
|
||||
|
||||
class RivWellHeadPartMgr : public cvf::Object
|
||||
{
|
||||
@@ -48,4 +56,6 @@ private:
|
||||
|
||||
cvf::ref<cvf::Transform> m_scaleTransform;
|
||||
cvf::Collection< cvf::Part > m_wellHeadParts;
|
||||
|
||||
cvf::ref<cvf::Font> m_font;
|
||||
};
|
||||
|
||||
@@ -41,6 +41,26 @@ RivWellPipesPartMgr::RivWellPipesPartMgr(RimReservoirView* reservoirView, RimWel
|
||||
m_rimReservoirView = reservoirView;
|
||||
m_rimWell = well;
|
||||
m_needsTransformUpdate = true;
|
||||
|
||||
// Setup a scalar mapper
|
||||
cvf::ref<cvf::ScalarMapperDiscreteLinear> scalarMapper = new cvf::ScalarMapperDiscreteLinear;
|
||||
cvf::Color3ubArray legendColors;
|
||||
legendColors.resize(4);
|
||||
legendColors[0] = cvf::Color3::GRAY;
|
||||
legendColors[1] = cvf::Color3::GREEN;
|
||||
legendColors[2] = cvf::Color3::BLUE;
|
||||
legendColors[3] = cvf::Color3::RED;
|
||||
scalarMapper->setColors(legendColors);
|
||||
scalarMapper->setRange(0.0 , 4.0);
|
||||
scalarMapper->setLevelsFromColorCount(4);
|
||||
|
||||
m_scalarMapper = scalarMapper;
|
||||
|
||||
caf::ScalarMapperEffectGenerator surfEffGen(scalarMapper.p(), true);
|
||||
m_scalarMapperSurfaceEffect = surfEffGen.generateEffect();
|
||||
|
||||
caf::ScalarMapperMeshEffectGenerator meshEffGen(scalarMapper.p());
|
||||
m_scalarMapperMeshEffect = meshEffGen.generateEffect();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -62,25 +82,24 @@ void RivWellPipesPartMgr::buildWellPipeParts()
|
||||
|
||||
std::vector< size_t > pipeBranchIds;
|
||||
std::vector< std::vector <cvf::Vec3d> > pipeBranchesCLCoords;
|
||||
std::vector< std::vector <CellId> > pipeBranchesCellIds;
|
||||
std::vector< std::vector <RigWellResultCell> > pipeBranchesCellIds;
|
||||
|
||||
calculateWellPipeCenterline( pipeBranchIds, pipeBranchesCLCoords, pipeBranchesCellIds);
|
||||
calculateWellPipeCenterline(pipeBranchesCLCoords, pipeBranchesCellIds);
|
||||
|
||||
double characteristicCellSize = m_rimReservoirView->eclipseCase()->reservoirData()->mainGrid()->characteristicCellSize();
|
||||
double pipeRadius = m_rimReservoirView->wellCollection()->pipeRadiusScaleFactor() *m_rimWell->pipeRadiusScaleFactor() * characteristicCellSize;
|
||||
|
||||
for (size_t brIdx = 0; brIdx < pipeBranchIds.size(); ++brIdx)
|
||||
for (size_t brIdx = 0; brIdx < pipeBranchesCellIds.size(); ++brIdx)
|
||||
{
|
||||
m_wellBranches.push_back(RivPipeBranchData());
|
||||
RivPipeBranchData& pbd = m_wellBranches.back();
|
||||
|
||||
pbd.m_branchId = pipeBranchIds[brIdx];
|
||||
pbd.m_cellIds = pipeBranchesCellIds[brIdx];
|
||||
|
||||
pbd.m_pipeGeomGenerator = new RivPipeGeometryGenerator;
|
||||
|
||||
pbd.m_pipeGeomGenerator->setRadius(pipeRadius);
|
||||
pbd.m_pipeGeomGenerator->setCrossSectionVertexCount(12);
|
||||
pbd.m_pipeGeomGenerator->setCrossSectionVertexCount(m_rimReservoirView->wellCollection()->pipeCrossSectionVertexCount());
|
||||
pbd.m_pipeGeomGenerator->setPipeColor( m_rimWell->wellPipeColor());
|
||||
|
||||
cvf::ref<cvf::Vec3dArray> cvfCoords = new cvf::Vec3dArray;
|
||||
@@ -131,12 +150,13 @@ void RivWellPipesPartMgr::buildWellPipeParts()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< size_t >& pipeBranchIds,
|
||||
std::vector< std::vector <cvf::Vec3d> >& pipeBranchesCLCoords,
|
||||
std::vector< std::vector <CellId> >& pipeBranchesCellIds) const
|
||||
void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< std::vector <cvf::Vec3d> >& pipeBranchesCLCoords,
|
||||
std::vector< std::vector <RigWellResultCell> >& pipeBranchesCellIds) const
|
||||
{
|
||||
CVF_ASSERT(m_rimWell.notNull());
|
||||
CVF_ASSERT(m_rimReservoirView.notNull());
|
||||
|
||||
bool isAutoDetectBranches = m_rimReservoirView->wellCollection()->isAutoDetectingBranches();
|
||||
|
||||
RigReservoir* rigReservoir = m_rimReservoirView->eclipseCase()->reservoirData();
|
||||
RigWellResults* wellResults = m_rimWell->wellResults();
|
||||
@@ -151,7 +171,6 @@ void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< size_t >& p
|
||||
if (staticWellFrame.m_wellResultBranches.size() == 0) return;
|
||||
|
||||
// Initialize the return arrays
|
||||
pipeBranchIds.clear();
|
||||
pipeBranchesCLCoords.clear();
|
||||
pipeBranchesCellIds.clear();
|
||||
|
||||
@@ -163,115 +182,134 @@ void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< size_t >& p
|
||||
|
||||
// Loop over all the well branches
|
||||
const std::vector<RigWellResultBranch>& resBranches = staticWellFrame.m_wellResultBranches;
|
||||
|
||||
for (size_t brIdx = 0; brIdx < resBranches.size(); brIdx++)
|
||||
bool hasResultCells = false;
|
||||
if (resBranches.size())
|
||||
{
|
||||
if (resBranches[brIdx].m_wellCells.size() == 0) continue; // Skip empty branches. Do not know why they exist, but they make problems.
|
||||
for (size_t i = 0 ; i < resBranches.size(); ++i)
|
||||
{
|
||||
if (resBranches[i].m_wellCells.size() != 0)
|
||||
{
|
||||
hasResultCells = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (hasResultCells)
|
||||
{
|
||||
// Create a new branch from wellhead
|
||||
|
||||
// Create a new branch
|
||||
pipeBranchIds.push_back(resBranches[brIdx].m_branchNumber);
|
||||
pipeBranchesCLCoords.push_back(std::vector<cvf::Vec3d>());
|
||||
pipeBranchesCellIds.push_back(std::vector <CellId>());
|
||||
|
||||
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(CellId(prevResCell->m_gridIndex, prevResCell->m_gridCellIndex));
|
||||
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(CellId(prevResCell->m_gridIndex, prevResCell->m_gridCellIndex));
|
||||
pipeBranchesCellIds.back().push_back(*prevResCell );
|
||||
|
||||
|
||||
// Loop over all the resultCells in the branch
|
||||
const std::vector<RigWellResultCell>& resBranchCells = resBranches[brIdx].m_wellCells;
|
||||
|
||||
for (size_t cIdx = 0; cIdx < resBranchCells.size(); cIdx++)
|
||||
for (size_t brIdx = 0; brIdx < resBranches.size(); brIdx++)
|
||||
{
|
||||
std::vector<cvf::Vec3d>& branchCLCoords = pipeBranchesCLCoords.back();
|
||||
std::vector<CellId>& branchCellIds = pipeBranchesCellIds.back();
|
||||
if (resBranches[brIdx].m_wellCells.size() == 0)
|
||||
continue; // Skip empty branches. Do not know why they exist, but they make problems.
|
||||
|
||||
const RigWellResultCell& resCell = resBranchCells[cIdx];
|
||||
const RigCell& cell = rigReservoir->cellFromWellResultCell(resCell);
|
||||
// Loop over all the resultCells in the branch
|
||||
const std::vector<RigWellResultCell>& resBranchCells = resBranches[brIdx].m_wellCells;
|
||||
|
||||
// Check if this and the previous cells has shared faces
|
||||
|
||||
cvf::StructGridInterface::FaceType sharedFace;
|
||||
if (rigReservoir->findSharedSourceFace(sharedFace, resCell, *prevResCell))
|
||||
for (int cIdx = 0; cIdx < static_cast<int>(resBranchCells.size()); cIdx++) // Need int because cIdx can temporarily end on -1
|
||||
{
|
||||
branchCLCoords.push_back(cell.faceCenter(sharedFace));
|
||||
branchCellIds.push_back(CellId(resCell.m_gridIndex, resCell.m_gridCellIndex));
|
||||
}
|
||||
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();
|
||||
cvf::Vec3d centerThisCell = cell.center();
|
||||
std::vector<cvf::Vec3d>& branchCLCoords = pipeBranchesCLCoords.back();
|
||||
std::vector<RigWellResultCell>& branchCellIds = pipeBranchesCellIds.back();
|
||||
|
||||
// First make sure this cell is not starting a new "display" branch
|
||||
if ( (prevResCell == whResCell) || (centerThisCell-centerPrevCell).lengthSquared() <= (centerThisCell - whStartPos).lengthSquared())
|
||||
const RigWellResultCell& resCell = resBranchCells[cIdx];
|
||||
const RigCell& cell = rigReservoir->cellFromWellResultCell(resCell);
|
||||
|
||||
// Check if this and the previous cells has shared faces
|
||||
|
||||
cvf::StructGridInterface::FaceType sharedFace;
|
||||
if (rigReservoir->findSharedSourceFace(sharedFace, resCell, *prevResCell))
|
||||
{
|
||||
// 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)
|
||||
{
|
||||
branchCLCoords.push_back(outOfPrevCell);
|
||||
branchCellIds.push_back(CellId(cvf::UNDEFINED_SIZE_T, cvf::UNDEFINED_SIZE_T));
|
||||
}
|
||||
branchCLCoords.push_back(intoThisCell);
|
||||
branchCellIds.push_back(CellId(resCell.m_gridIndex, resCell.m_gridCellIndex));
|
||||
branchCLCoords.push_back(cell.faceCenter(sharedFace));
|
||||
branchCellIds.push_back(resCell);
|
||||
}
|
||||
else
|
||||
{
|
||||
// This cell is further from the previous cell than from the well head,
|
||||
// thus we interpret it as a new branch.
|
||||
// This and the previous cell does not share a face. We need to go out of the previous cell, before entering this.
|
||||
const RigCell& prevCell = rigReservoir->cellFromWellResultCell(*prevResCell);
|
||||
cvf::Vec3d centerPrevCell = prevCell.center();
|
||||
cvf::Vec3d centerThisCell = cell.center();
|
||||
|
||||
// First finish the current branch
|
||||
branchCLCoords.push_back(branchCLCoords.back() + 1.5*(centerPrevCell - branchCLCoords.back()) );
|
||||
// First make sure this cell is not starting a new "display" branch
|
||||
if ( !isAutoDetectBranches || (prevResCell == whResCell)
|
||||
|| (centerThisCell-centerPrevCell).lengthSquared() <= (centerThisCell - whStartPos).lengthSquared())
|
||||
{
|
||||
// Not starting a "display" branch
|
||||
// Create ray and intersect with cells
|
||||
|
||||
// Create new display branch
|
||||
pipeBranchIds.push_back(resBranches[brIdx].m_branchNumber);
|
||||
pipeBranchesCLCoords.push_back(std::vector<cvf::Vec3d>());
|
||||
pipeBranchesCellIds.push_back(std::vector <CellId>());
|
||||
cvf::Ray rayToThisCell;
|
||||
rayToThisCell.setOrigin(centerPrevCell);
|
||||
rayToThisCell.setDirection((centerThisCell - centerPrevCell).getNormalized());
|
||||
|
||||
// Start the new branch by entering the first cell (the wellhead) and intermediate
|
||||
prevResCell = whResCell;
|
||||
pipeBranchesCLCoords.back().push_back(whStartPos);
|
||||
pipeBranchesCellIds.back().push_back(CellId(prevResCell->m_gridIndex, prevResCell->m_gridCellIndex));
|
||||
cvf::Vec3d outOfPrevCell(centerPrevCell);
|
||||
cvf::Vec3d intoThisCell(centerThisCell);
|
||||
|
||||
// Include intermediate
|
||||
pipeBranchesCLCoords.back().push_back(whIntermediate);
|
||||
pipeBranchesCellIds.back().push_back(CellId(prevResCell->m_gridIndex, prevResCell->m_gridCellIndex));
|
||||
bool intersectionOk = prevCell.firstIntersectionPoint(rayToThisCell, &outOfPrevCell);
|
||||
//CVF_ASSERT(intersectionOk);
|
||||
intersectionOk = cell.firstIntersectionPoint(rayToThisCell, &intoThisCell);
|
||||
//CVF_ASSERT(intersectionOk);
|
||||
if ((intoThisCell - outOfPrevCell).lengthSquared() > 1e-3)
|
||||
{
|
||||
branchCLCoords.push_back(outOfPrevCell);
|
||||
branchCellIds.push_back(RigWellResultCell());
|
||||
}
|
||||
branchCLCoords.push_back(intoThisCell);
|
||||
branchCellIds.push_back(resCell);
|
||||
}
|
||||
else
|
||||
{
|
||||
// This cell is further from the previous cell than from the well head,
|
||||
// thus we interpret it as a new branch.
|
||||
|
||||
// Well now we need to step one back to take this cell again, but in the new branch.
|
||||
cIdx--;
|
||||
continue;
|
||||
// First finish the current branch
|
||||
branchCLCoords.push_back(branchCLCoords.back() + 1.5*(centerPrevCell - branchCLCoords.back()) );
|
||||
|
||||
// Create new display branch
|
||||
pipeBranchesCLCoords.push_back(std::vector<cvf::Vec3d>());
|
||||
pipeBranchesCellIds.push_back(std::vector <RigWellResultCell>());
|
||||
|
||||
// Start the new branch by entering the first cell (the wellhead) and intermediate
|
||||
prevResCell = whResCell;
|
||||
pipeBranchesCLCoords.back().push_back(whStartPos);
|
||||
pipeBranchesCellIds.back().push_back(*prevResCell);
|
||||
|
||||
// Include intermediate
|
||||
pipeBranchesCLCoords.back().push_back(whIntermediate);
|
||||
pipeBranchesCellIds.back().push_back(*prevResCell);
|
||||
|
||||
// Well now we need to step one back to take this cell again, but in the new branch.
|
||||
cIdx--;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
prevResCell = &resCell;
|
||||
prevResCell = &resCell;
|
||||
|
||||
// If we are looking at last cell, add the point 0.5 past the center of that cell
|
||||
if (cIdx == resBranchCells.size() -1)
|
||||
{
|
||||
branchCLCoords.push_back(branchCLCoords.back() + 1.5*(cell.center() - branchCLCoords.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());
|
||||
@@ -324,18 +362,6 @@ void RivWellPipesPartMgr::updatePipeResultColor(size_t frameIndex)
|
||||
|
||||
if (frameIndex < wRes->firstResultTimeStep()) return; // Or reset colors or something
|
||||
|
||||
// Setup a scalar mapper
|
||||
cvf::ref<cvf::ScalarMapperDiscreteLinear> scalarMapper = new cvf::ScalarMapperDiscreteLinear;
|
||||
cvf::Color3ubArray legendColors;
|
||||
legendColors.resize(4);
|
||||
legendColors[0] = cvf::Color3::GRAY;
|
||||
legendColors[1] = cvf::Color3::GREEN;
|
||||
legendColors[2] = cvf::Color3::BLUE;
|
||||
legendColors[3] = cvf::Color3::RED;
|
||||
scalarMapper->setColors(legendColors);
|
||||
scalarMapper->setRange(0.0 , 4.0);
|
||||
scalarMapper->setLevelsFromColorCount(4);
|
||||
|
||||
const double closed = -0.1, producing = 1.5, water = 2.5, hcInjection = 3.5; // Closed set to -0.1 instead of 0.5 to workaround bug in the scalar mapper.
|
||||
|
||||
std::list<RivPipeBranchData>::iterator brIt;
|
||||
@@ -345,77 +371,48 @@ void RivWellPipesPartMgr::updatePipeResultColor(size_t frameIndex)
|
||||
|
||||
for (brIt = m_wellBranches.begin(); brIt != m_wellBranches.end(); ++brIt)
|
||||
{
|
||||
size_t branchId = brIt->m_branchId;
|
||||
|
||||
// find corresponding result branch
|
||||
size_t i;
|
||||
for ( i = 0; i < wResFrame.m_wellResultBranches.size(); ++i)
|
||||
{
|
||||
if (wResFrame.m_wellResultBranches[i].m_branchNumber == branchId) break;
|
||||
}
|
||||
|
||||
// Initialize well states to "closed" state
|
||||
wellCellStates.clear();
|
||||
wellCellStates.resize(brIt->m_cellIds.size(), closed);
|
||||
|
||||
// Find result values
|
||||
if (i >= wResFrame.m_wellResultBranches.size())
|
||||
const std::vector <RigWellResultCell>& cellIds = brIt->m_cellIds;
|
||||
|
||||
for (size_t wcIdx = 0; wcIdx < cellIds.size(); ++wcIdx)
|
||||
{
|
||||
// Branch not found in results. Do nothing. Keep the "closed" states
|
||||
}
|
||||
else
|
||||
{
|
||||
const std::vector<RigWellResultCell>& resBranch = wResFrame.m_wellResultBranches[i].m_wellCells;
|
||||
const std::vector <CellId>& cellIds = brIt->m_cellIds;
|
||||
// we need a faster lookup, I guess
|
||||
const RigWellResultCell* wResCell = wResFrame.findResultCell(cellIds[wcIdx].m_gridIndex, cellIds[wcIdx].m_gridCellIndex);
|
||||
|
||||
// Find cellIds[wcIdx] in resBranch
|
||||
// ifFound then give color from cell state
|
||||
// else give closed color
|
||||
|
||||
// The search can be simplified to comparing the current element against
|
||||
// the first unmatched element in the result branch vector since the result is (supposed) to be
|
||||
// a subset of the complete branch where all elements have the same order
|
||||
|
||||
size_t rcIdx = 0; // index to first unmatched element in results
|
||||
for (size_t wcIdx = 0; wcIdx < cellIds.size(); ++wcIdx)
|
||||
if (wResCell == NULL)
|
||||
{
|
||||
if (rcIdx >= resBranch.size())
|
||||
// We cant find any state. This well cell is closed.
|
||||
}
|
||||
else
|
||||
{
|
||||
double cellState = closed;
|
||||
|
||||
if (wResCell->m_isOpen)
|
||||
{
|
||||
// We are beyond the result cells. This well cell is closed.
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( cellIds[wcIdx].gridIndex == resBranch[rcIdx].m_gridIndex
|
||||
&& cellIds[wcIdx].cellIndex == resBranch[rcIdx].m_gridCellIndex)
|
||||
switch (wResFrame.m_productionType)
|
||||
{
|
||||
double cellState = closed;
|
||||
|
||||
if (resBranch[rcIdx].m_isOpen)
|
||||
{
|
||||
switch (wResFrame.m_productionType)
|
||||
{
|
||||
case RigWellResultFrame::PRODUCER:
|
||||
cellState = producing;
|
||||
break;
|
||||
case RigWellResultFrame::OIL_INJECTOR:
|
||||
cellState = hcInjection;
|
||||
break;
|
||||
case RigWellResultFrame::GAS_INJECTOR:
|
||||
cellState = hcInjection;
|
||||
break;
|
||||
case RigWellResultFrame::WATER_INJECTOR:
|
||||
cellState = water;
|
||||
break;
|
||||
case RigWellResultFrame::UNDEFINED_PRODUCTION_TYPE:
|
||||
cellState = closed;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
wellCellStates[wcIdx] = cellState;
|
||||
rcIdx++;
|
||||
case RigWellResultFrame::PRODUCER:
|
||||
cellState = producing;
|
||||
break;
|
||||
case RigWellResultFrame::OIL_INJECTOR:
|
||||
cellState = hcInjection;
|
||||
break;
|
||||
case RigWellResultFrame::GAS_INJECTOR:
|
||||
cellState = hcInjection;
|
||||
break;
|
||||
case RigWellResultFrame::WATER_INJECTOR:
|
||||
cellState = water;
|
||||
break;
|
||||
case RigWellResultFrame::UNDEFINED_PRODUCTION_TYPE:
|
||||
cellState = closed;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
wellCellStates[wcIdx] = cellState;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -430,13 +427,10 @@ void RivWellPipesPartMgr::updatePipeResultColor(size_t frameIndex)
|
||||
surfTexCoords = new cvf::Vec2fArray;
|
||||
}
|
||||
|
||||
brIt->m_pipeGeomGenerator->pipeSurfaceTextureCoords( surfTexCoords.p(), wellCellStates, scalarMapper.p());
|
||||
brIt->m_pipeGeomGenerator->pipeSurfaceTextureCoords( surfTexCoords.p(), wellCellStates, m_scalarMapper.p());
|
||||
brIt->m_surfaceDrawable->setTextureCoordArray( surfTexCoords.p());
|
||||
|
||||
caf::ScalarMapperEffectGenerator surfEffGen(scalarMapper.p(), true);
|
||||
cvf::ref<cvf::Effect> seff = surfEffGen.generateEffect();
|
||||
|
||||
brIt->m_surfacePart->setEffect(seff.p());
|
||||
brIt->m_surfacePart->setEffect(m_scalarMapperSurfaceEffect.p());
|
||||
}
|
||||
|
||||
// Find or create texture coords array for pipe center line
|
||||
@@ -450,7 +444,7 @@ void RivWellPipesPartMgr::updatePipeResultColor(size_t frameIndex)
|
||||
}
|
||||
|
||||
// Calculate new texture coordinates
|
||||
brIt->m_pipeGeomGenerator->centerlineTextureCoords( lineTexCoords.p(), wellCellStates, scalarMapper.p());
|
||||
brIt->m_pipeGeomGenerator->centerlineTextureCoords( lineTexCoords.p(), wellCellStates, m_scalarMapper.p());
|
||||
|
||||
// Set the new texture coordinates
|
||||
|
||||
@@ -458,10 +452,7 @@ void RivWellPipesPartMgr::updatePipeResultColor(size_t frameIndex)
|
||||
|
||||
// Set effects
|
||||
|
||||
caf::ScalarMapperMeshEffectGenerator meshEffGen(scalarMapper.p());
|
||||
cvf::ref<cvf::Effect> meff = meshEffGen.generateEffect();
|
||||
|
||||
brIt->m_centerLinePart->setEffect(meff.p());
|
||||
brIt->m_centerLinePart->setEffect(m_scalarMapperMeshEffect.p());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,12 +20,14 @@
|
||||
|
||||
#include "cafPdmPointer.h"
|
||||
#include <list>
|
||||
#include "RigWellResults.h"
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
class Part;
|
||||
class ModelBasicList;
|
||||
class Transform;
|
||||
class Effect;
|
||||
}
|
||||
|
||||
class RivPipeGeometryGenerator;
|
||||
@@ -54,33 +56,17 @@ private:
|
||||
bool m_needsTransformUpdate;
|
||||
|
||||
void buildWellPipeParts();
|
||||
class CellId
|
||||
{
|
||||
public:
|
||||
CellId() :
|
||||
gridIndex(cvf::UNDEFINED_SIZE_T),
|
||||
cellIndex(cvf::UNDEFINED_SIZE_T)
|
||||
{ }
|
||||
|
||||
CellId(size_t gidx, size_t cIdx) :
|
||||
gridIndex(gidx),
|
||||
cellIndex(cIdx)
|
||||
{ }
|
||||
|
||||
size_t gridIndex;
|
||||
size_t cellIndex;
|
||||
};
|
||||
|
||||
|
||||
//void calculateWellPipeCenterline(std::vector<cvf::Vec3d>& coords) const;
|
||||
|
||||
void calculateWellPipeCenterline(std::vector< size_t >& pipeBranchIds,
|
||||
std::vector< std::vector <cvf::Vec3d> >& pipeBranchesCLCoords,
|
||||
std::vector< std::vector <CellId> >& pipeBranchesCellIds ) const;
|
||||
void calculateWellPipeCenterline(std::vector< std::vector <cvf::Vec3d> >& pipeBranchesCLCoords,
|
||||
std::vector< std::vector <RigWellResultCell> >& pipeBranchesCellIds ) const;
|
||||
|
||||
struct RivPipeBranchData
|
||||
{
|
||||
size_t m_branchId;
|
||||
std::vector <CellId> m_cellIds;
|
||||
std::vector <RigWellResultCell> m_cellIds;
|
||||
//std::vector< std::vector<WellCellStatus> > m_cellStatusPrFrame;
|
||||
cvf::ref<RivPipeGeometryGenerator> m_pipeGeomGenerator;
|
||||
|
||||
cvf::ref<cvf::Part> m_surfacePart;
|
||||
@@ -91,5 +77,8 @@ private:
|
||||
};
|
||||
|
||||
std::list<RivPipeBranchData> m_wellBranches;
|
||||
cvf::Collection< cvf::Part > m_wellPipeParts;
|
||||
|
||||
cvf::ref<cvf::ScalarMapper> m_scalarMapper;
|
||||
cvf::ref<cvf::Effect> m_scalarMapperSurfaceEffect;
|
||||
cvf::ref<cvf::Effect> m_scalarMapperMeshEffect;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user