mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2544 Well CF Visualization: Add geometry generator and source info object
rename remove unused move to separate file rename
This commit is contained in:
@@ -0,0 +1,193 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) 2018 Statoil ASA
|
||||
//
|
||||
// ResInsight 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.
|
||||
//
|
||||
// ResInsight 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 "RivWellConnectionFactorPartMgr.h"
|
||||
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaExtractionTools.h"
|
||||
|
||||
#include "RigEclipseWellLogExtractor.h"
|
||||
#include "RigMainGrid.h"
|
||||
#include "RigVirtualPerforationTransmissibilities.h"
|
||||
#include "RigWellLogExtractor.h"
|
||||
#include "RigWellPath.h"
|
||||
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimEclipseView.h"
|
||||
#include "RimLegendConfig.h"
|
||||
#include "RimSimWellInViewCollection.h"
|
||||
#include "RimVirtualPerforationResults.h"
|
||||
#include "RimWellPath.h"
|
||||
|
||||
#include "RiuViewer.h"
|
||||
|
||||
#include "RivWellConnectionFactorGeometryGenerator.h"
|
||||
#include "RivWellConnectionSourceInfo.h"
|
||||
|
||||
#include "cafDisplayCoordTransform.h"
|
||||
#include "cafEffectGenerator.h"
|
||||
#include "cvfDrawableGeo.h"
|
||||
#include "cvfModelBasicList.h"
|
||||
#include "cvfPart.h"
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivWellConnectionFactorPartMgr::RivWellConnectionFactorPartMgr(RimWellPath* well,
|
||||
RimVirtualPerforationResults* virtualPerforationResult)
|
||||
: m_rimWell(well)
|
||||
, m_virtualPerforationResult(virtualPerforationResult)
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivWellConnectionFactorPartMgr::~RivWellConnectionFactorPartMgr() {}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivWellConnectionFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex)
|
||||
{
|
||||
m_geometryGenerator = nullptr;
|
||||
|
||||
RimEclipseView* eclView = nullptr;
|
||||
m_virtualPerforationResult->firstAncestorOrThisOfTypeAsserted(eclView);
|
||||
|
||||
auto coordTransform = eclView->displayCoordTransform();
|
||||
|
||||
RimEclipseCase* eclipseCase = nullptr;
|
||||
m_virtualPerforationResult->firstAncestorOrThisOfTypeAsserted(eclipseCase);
|
||||
|
||||
const RigMainGrid* mainGrid = eclipseCase->mainGrid();
|
||||
|
||||
const RigVirtualPerforationTransmissibilities* trans = eclipseCase->computeAndGetVirtualPerforationTransmissibilities();
|
||||
if (!trans) return;
|
||||
|
||||
auto conn = trans->multipleCompletionsPerEclipseCell(m_rimWell, frameIndex);
|
||||
|
||||
std::vector<WellPathCellIntersectionInfo> wellPathCellIntersections;
|
||||
{
|
||||
RigEclipseWellLogExtractor* extractor = RiaExtractionTools::wellLogExtractorEclipseCase(m_rimWell, eclipseCase);
|
||||
if (extractor)
|
||||
{
|
||||
wellPathCellIntersections = extractor->cellIntersectionInfosAlongWellPath();
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<size_t> mapFromConnectionIndexToGlobalCellIndex;
|
||||
|
||||
std::vector<CompletionVizData> centerColorPairs;
|
||||
for (const auto& cell : conn)
|
||||
{
|
||||
size_t gridIndex = cell.first.globalCellIndex();
|
||||
|
||||
const RigCell& rigCell = mainGrid->cell(gridIndex);
|
||||
|
||||
cvf::Vec3d locationInDomainCoord = rigCell.center();
|
||||
cvf::Vec3d wellPathDirection = cvf::Vec3d::X_AXIS;
|
||||
|
||||
if (!wellPathCellIntersections.empty())
|
||||
{
|
||||
for (const auto& intersectionInfo : wellPathCellIntersections)
|
||||
{
|
||||
if (intersectionInfo.globCellIndex == cell.first.globalCellIndex())
|
||||
{
|
||||
double startMD = intersectionInfo.startMD;
|
||||
double endMD = intersectionInfo.endMD;
|
||||
|
||||
double middleMD = (startMD + endMD) / 2.0;
|
||||
|
||||
locationInDomainCoord = m_rimWell->wellPathGeometry()->interpolatedPointAlongWellPath(middleMD);
|
||||
|
||||
cvf::Vec3d p1;
|
||||
cvf::Vec3d p2;
|
||||
m_rimWell->wellPathGeometry()->twoClosestPoints(locationInDomainCoord, &p1, &p2);
|
||||
|
||||
wellPathDirection = (p2 - p1).getNormalized();
|
||||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cvf::Vec3d displayCoord = coordTransform->transformToDisplayCoord(locationInDomainCoord);
|
||||
|
||||
double transmissibility = HUGE_VAL;
|
||||
if (!cell.second.empty())
|
||||
{
|
||||
transmissibility = cell.second.front().transmissibility();
|
||||
}
|
||||
|
||||
centerColorPairs.push_back(
|
||||
CompletionVizData(displayCoord, wellPathDirection, transmissibility, cell.first.globalCellIndex()));
|
||||
mapFromConnectionIndexToGlobalCellIndex.push_back(cell.first.globalCellIndex());
|
||||
}
|
||||
|
||||
if (!centerColorPairs.empty())
|
||||
{
|
||||
double radius = mainGrid->characteristicIJCellSize() * m_virtualPerforationResult->geometryScaleFactor();
|
||||
|
||||
m_geometryGenerator = new RivWellConnectionFactorGeometryGenerator(centerColorPairs, radius);
|
||||
auto drawable = m_geometryGenerator->createPipeSurface();
|
||||
|
||||
cvf::ref<cvf::Part> part = new cvf::Part;
|
||||
part->setDrawable(drawable.p());
|
||||
|
||||
auto scalarMapper = m_virtualPerforationResult->legendConfig()->scalarMapper();
|
||||
|
||||
// Compute texture coords
|
||||
cvf::ref<cvf::Vec2fArray> textureCoords = new cvf::Vec2fArray();
|
||||
{
|
||||
textureCoords->reserve(drawable->vertexArray()->size());
|
||||
size_t verticesPerItem = drawable->vertexArray()->size() / centerColorPairs.size();
|
||||
|
||||
textureCoords->setAll(cvf::Vec2f(0.5f, 1.0f));
|
||||
|
||||
for (const auto& item : centerColorPairs)
|
||||
{
|
||||
cvf::Vec2f textureCoord = cvf::Vec2f(0.5f, 1.0f);
|
||||
if (item.m_connectionFactor != HUGE_VAL)
|
||||
{
|
||||
textureCoord = scalarMapper->mapToTextureCoord(item.m_connectionFactor);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < verticesPerItem; i++)
|
||||
{
|
||||
textureCoords->add(textureCoord);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
drawable->setTextureCoordArray(textureCoords.p());
|
||||
|
||||
caf::ScalarMapperEffectGenerator effGen(scalarMapper, caf::PO_1);
|
||||
|
||||
bool disableLighting = eclView->isLightingDisabled();
|
||||
effGen.disableLighting(disableLighting);
|
||||
|
||||
cvf::ref<cvf::Effect> eff = effGen.generateCachedEffect();
|
||||
part->setEffect(eff.p());
|
||||
|
||||
cvf::ref<RivWellConnectionSourceInfo> sourceInfo = new RivWellConnectionSourceInfo(m_rimWell, m_geometryGenerator.p());
|
||||
part->setSourceInfo(sourceInfo.p());
|
||||
|
||||
model->addPart(part.p());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user