(#166) Added support for ternary result mapping

Removed obsolete interface RigResultAccessor2d
This commit is contained in:
Magne Sjaastad 2015-11-23 15:24:03 +01:00
parent 95f500fefd
commit 6cd4e8a0b7
7 changed files with 144 additions and 62 deletions

View File

@ -21,6 +21,9 @@
#include "RigCaseCellResultsData.h"
#include "RigCaseData.h"
#include "RigFemPartCollection.h"
#include "RigFemPartResultsCollection.h"
#include "RigGeoMechCaseData.h"
#include "RigResultAccessor.h"
#include "RigResultAccessorFactory.h"
@ -28,22 +31,20 @@
#include "RimEclipseCase.h"
#include "RimEclipseCellColors.h"
#include "RimEclipseView.h"
#include "RimGeoMechCase.h"
#include "RimGeoMechCellColors.h"
#include "RimGeoMechView.h"
#include "RimTernaryLegendConfig.h"
#include "RivResultToTextureMapper.h"
#include "RivScalarMapperUtils.h"
#include "RivTernaryScalarMapper.h"
#include "RivTernaryTextureCoordsCreator.h"
#include "cvfDrawableGeo.h"
#include "cvfModelBasicList.h"
#include "cvfPart.h"
#include "cvfPrimitiveSetDirect.h"
#include "RimGeoMechView.h"
#include "RimGeoMechCase.h"
#include "RigGeoMechCaseData.h"
#include "RigFemPartCollection.h"
#include "RimGeoMechCellColors.h"
#include "RigFemPartResultsCollection.h"
//--------------------------------------------------------------------------------------------------
@ -94,14 +95,9 @@ void RivCrossSectionPartMgr::updateCellResultColor(size_t timeStepIndex)
{
if (cellResultColors->isTernarySaturationSelected())
{
//RivTernaryTextureCoordsCreator texturer(cellResultColors, cellResultColors->ternaryLegendConfig(),
// timeStepIndex,
// m_grid->gridIndex(),
// m_nativeCrossSectionGenerator->quadToCellFaceMapper());
//
//texturer.createTextureCoords(m_nativeCrossSectionFacesTextureCoords.p());
CVF_ASSERT(false); // Todo
RivTernaryTextureCoordsCreator texturer(cellResultColors, cellResultColors->ternaryLegendConfig(), timeStepIndex);
texturer.createTextureCoords(m_crossSectionFacesTextureCoords.p(), m_crossSectionGenerator->triangleToCellIndex());
const RivTernaryScalarMapper* mapper = cellResultColors->ternaryLegendConfig()->scalarMapper();
RivScalarMapperUtils::applyTernaryTextureResultsToPart(m_crossSectionFaces.p(),

View File

@ -44,10 +44,30 @@ RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator(
size_t gridIndex,
const cvf::StructGridQuadToCellFaceMapper* quadMapper)
{
RigCaseData* eclipseCase = cellResultColors->reservoirView()->eclipseCase()->reservoirData();
CVF_ASSERT(quadMapper);
m_quadMapper = quadMapper;
CVF_ASSERT(quadMapper && eclipseCase );
initData(cellResultColors, ternaryLegendConfig, timeStepIndex, gridIndex);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator(
RimEclipseCellColors* cellResultColors,
RimTernaryLegendConfig* ternaryLegendConfig,
size_t timeStepIndex)
: m_quadMapper(NULL)
{
initData(cellResultColors, ternaryLegendConfig, timeStepIndex, 0);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivTernaryTextureCoordsCreator::initData(RimEclipseCellColors* cellResultColors, RimTernaryLegendConfig* ternaryLegendConfig, size_t timeStepIndex, size_t gridIndex)
{
RigCaseData* eclipseCase = cellResultColors->reservoirView()->eclipseCase()->reservoirData();
size_t resTimeStepIdx = timeStepIndex;
@ -58,11 +78,11 @@ RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator(
cvf::ref<RigResultAccessor> soil = RigResultAccessorFactory::createResultAccessor(eclipseCase, gridIndex, porosityModel, resTimeStepIdx, "SOIL");
cvf::ref<RigResultAccessor> sgas = RigResultAccessorFactory::createResultAccessor(eclipseCase, gridIndex, porosityModel, resTimeStepIdx, "SGAS");
cvf::ref<RigResultAccessor> swat = RigResultAccessorFactory::createResultAccessor(eclipseCase, gridIndex, porosityModel, resTimeStepIdx, "SWAT");
m_resultAccessor = new RigTernaryResultAccessor();
m_resultAccessor->setTernaryResultAccessors(soil.p(), sgas.p(), swat.p());
cvf::ref<RigPipeInCellEvaluator> pipeInCellEval = new RigPipeInCellEvaluator( cellResultColors->reservoirView()->wellCollection()->isWellPipesVisible(timeStepIndex),
cvf::ref<RigPipeInCellEvaluator> pipeInCellEval = new RigPipeInCellEvaluator(cellResultColors->reservoirView()->wellCollection()->isWellPipesVisible(timeStepIndex),
eclipseCase->gridCellToWellIndex(gridIndex));
const RivTernaryScalarMapper* mapper = ternaryLegendConfig->scalarMapper();
@ -76,9 +96,20 @@ RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator(
//--------------------------------------------------------------------------------------------------
void RivTernaryTextureCoordsCreator::createTextureCoords(cvf::Vec2fArray* quadTextureCoords)
{
CVF_ASSERT(m_quadMapper.notNull());
createTextureCoords(quadTextureCoords, m_quadMapper.p(), m_resultAccessor.p(), m_texMapper.p());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivTernaryTextureCoordsCreator::createTextureCoords(cvf::Vec2fArray* triTextureCoords, const std::vector<size_t>& triangleToCellIdx)
{
CVF_ASSERT(m_quadMapper.isNull());
createTextureCoords(triTextureCoords, triangleToCellIdx, m_resultAccessor.p(), m_texMapper.p());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -113,3 +144,33 @@ void RivTernaryTextureCoordsCreator::createTextureCoords(
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivTernaryTextureCoordsCreator::createTextureCoords(cvf::Vec2fArray* textureCoords, const std::vector<size_t>& triangleToCellIdx, const RigTernaryResultAccessor* resultAccessor, const RivTernaryResultToTextureMapper* texMapper)
{
CVF_ASSERT(textureCoords && resultAccessor && texMapper);
size_t numVertices = triangleToCellIdx.size() * 3;
textureCoords->resize(numVertices);
cvf::Vec2f* rawPtr = textureCoords->ptr();
cvf::Vec2d resultValue;
cvf::Vec2f texCoord;
#pragma omp parallel for private(texCoord, resultValue)
for (int i = 0; i < static_cast<int>(triangleToCellIdx.size()); i++)
{
size_t cellIdx = triangleToCellIdx[i];
resultValue = resultAccessor->cellScalarGlobIdx(cellIdx);
texCoord = texMapper->getTexCoord(resultValue.x(), resultValue.y(), cellIdx);
size_t j;
for (j = 0; j < 3; j++)
{
rawPtr[i * 3 + j] = texCoord;
}
}
}

View File

@ -41,20 +41,31 @@ namespace cvf
class RivTernaryTextureCoordsCreator
{
public:
RivTernaryTextureCoordsCreator( RimEclipseCellColors* cellResultColors,
RivTernaryTextureCoordsCreator( RimEclipseCellColors* cellResultColors,
RimTernaryLegendConfig* ternaryLegendConfig,
size_t timeStepIndex,
size_t gridIndex,
const cvf::StructGridQuadToCellFaceMapper* quadMapper);
RivTernaryTextureCoordsCreator( RimEclipseCellColors* cellResultColors,
RimTernaryLegendConfig* ternaryLegendConfig,
size_t timeStepIndex);
void createTextureCoords(cvf::Vec2fArray* quadTextureCoords);
void createTextureCoords(cvf::Vec2fArray* triTextureCoords, const std::vector<size_t>& triangleToCellIdx);
private:
void initData(RimEclipseCellColors* cellResultColors, RimTernaryLegendConfig* ternaryLegendConfig, size_t timeStepIndex, size_t gridIndex);
static void createTextureCoords(cvf::Vec2fArray* quadTextureCoords,
const cvf::StructGridQuadToCellFaceMapper* quadMapper,
const RigTernaryResultAccessor* resultAccessor,
const RivTernaryResultToTextureMapper* texMapper);
static void createTextureCoords(cvf::Vec2fArray* triTextureCoords,
const std::vector<size_t>& triangleToCellIdx,
const RigTernaryResultAccessor* resultAccessor,
const RivTernaryResultToTextureMapper* texMapper);
private:
cvf::cref<cvf::StructGridQuadToCellFaceMapper> m_quadMapper;
cvf::ref<RigTernaryResultAccessor> m_resultAccessor;

View File

@ -32,7 +32,6 @@ ${CEE_CURRENT_LIST_DIR}RigNNCData.h
${CEE_CURRENT_LIST_DIR}cvfGeometryTools.h
${CEE_CURRENT_LIST_DIR}cvfGeometryTools.inl
${CEE_CURRENT_LIST_DIR}RigPipeInCellEvaluator.h
${CEE_CURRENT_LIST_DIR}RigResultAccessor2d.h
${CEE_CURRENT_LIST_DIR}RigTernaryResultAccessor2d.h
${CEE_CURRENT_LIST_DIR}RigEclipseNativeStatCalc.h
${CEE_CURRENT_LIST_DIR}RigEclipseNativeVisibleCellsStatCalc.h

View File

@ -1,37 +0,0 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) Statoil ASA
// Copyright (C) Ceetron Solutions AS
//
// 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#pragma once
#include "cvfBase.h"
#include "cvfObject.h"
#include "cvfVector2.h"
#include "cvfStructGrid.h"
//==================================================================================================
///
//==================================================================================================
class RigResultAccessor2d : public cvf::Object
{
public:
virtual cvf::Vec2d cellScalar(size_t gridLocalCellIndex) const = 0;
virtual cvf::Vec2d cellFaceScalar(size_t gridLocalCellIndex, cvf::StructGridInterface::FaceType faceId) const = 0;
};

View File

@ -96,3 +96,52 @@ cvf::Vec2d RigTernaryResultAccessor::cellFaceScalar(size_t gridLocalCellIndex, c
{
return cellScalar(gridLocalCellIndex);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Vec2d RigTernaryResultAccessor::cellScalarGlobIdx(size_t globCellIndex) const
{
double soil = 0.0;
double sgas = 0.0;
if (m_soilAccessor.notNull())
{
soil = m_soilAccessor->cellScalarGlobIdx(globCellIndex);
if (m_sgasAccessor.notNull())
{
sgas = m_sgasAccessor->cellScalarGlobIdx(globCellIndex);
}
else if (m_swatAccessor.notNull())
{
sgas = 1.0 - soil - m_swatAccessor->cellScalarGlobIdx(globCellIndex);
}
else
{
sgas = 1.0 - soil;
}
}
else
{
if (m_sgasAccessor.notNull())
{
sgas = m_sgasAccessor->cellScalarGlobIdx(globCellIndex);
if (m_swatAccessor.notNull())
{
soil = 1.0 - sgas - m_swatAccessor->cellScalarGlobIdx(globCellIndex);
}
else
{
soil = 1.0 - sgas;
}
}
else if (m_swatAccessor.notNull())
{
soil = 1.0 - m_swatAccessor->cellScalarGlobIdx(globCellIndex);
}
}
return cvf::Vec2d(soil, sgas);
}

View File

@ -19,13 +19,15 @@
#pragma once
#include "RigResultAccessor2d.h"
#include "RigResultAccessor.h"
#include "cvfVector2.h"
//==================================================================================================
///
//==================================================================================================
class RigTernaryResultAccessor : public RigResultAccessor2d
class RigTernaryResultAccessor : public cvf::Object
{
public:
RigTernaryResultAccessor();
@ -35,8 +37,9 @@ public:
/// Returns [SOIL, SGAS] regardless of which one of the three is missing. if Soil or SWat is missing, it is calculated
/// based on the two others
virtual cvf::Vec2d cellScalar(size_t gridLocalCellIndex) const;
virtual cvf::Vec2d cellFaceScalar(size_t gridLocalCellIndex, cvf::StructGridInterface::FaceType faceId) const;
cvf::Vec2d cellScalar(size_t gridLocalCellIndex) const;
cvf::Vec2d cellFaceScalar(size_t gridLocalCellIndex, cvf::StructGridInterface::FaceType faceId) const;
cvf::Vec2d cellScalarGlobIdx(size_t globCellIndex) const;
private:
cvf::ref<RigResultAccessor> m_soilAccessor;