Proceeded with visualization of NNC vectors.

This commit is contained in:
Ruben Manuel Thoms 2020-09-21 16:44:18 +02:00
parent d365322437
commit af06bb1529
4 changed files with 130 additions and 66 deletions

View File

@ -33,6 +33,7 @@
#include "cafEffectGenerator.h"
#include "cvfDrawableGeo.h"
#include "cvfGeometryTools.h"
#include "cvfModelBasicList.h"
#include "cvfPart.h"
#include "cvfPrimitiveSetIndexedUInt.h"
@ -100,7 +101,7 @@ void RivElementVectorResultPartMgr::appendDynamicGeometryPartsToModel( cvf::Mode
}
float arrowScaling = arrowConstantScaling;
if ( result->scaleMethod() == RimElementVectorResult::RESULT )
if ( result->scaleMethod() == RimElementVectorResult::ScaleMethod::RESULT )
{
arrowScaling = arrowConstantScaling / maxAbsResult;
}
@ -128,18 +129,8 @@ void RivElementVectorResultPartMgr::appendDynamicGeometryPartsToModel( cvf::Mode
}
RigCaseCellResultsData* resultsData = eclipseCaseData->results( RiaDefines::PorosityModelType::MATRIX_MODEL );
RigNNCData* nncData = eclipseCaseData->mainGrid()->nncData();
RigActiveCellInfo* activeCellInfo = eclipseCaseData->activeCellInfo( RiaDefines::PorosityModelType::MATRIX_MODEL );
const std::vector<std::vector<double>>* nncResultVals = nullptr;
if ( result->showNncData() )
{
if ( result->resultAddressCombined().m_resultCatType == RiaDefines::ResultCatType::DYNAMIC_NATIVE )
{
nncResultVals = nncData->dynamicConnectionScalarResult( result->resultAddressCombined() );
}
}
const cvf::Vec3d offset = eclipseCase->mainGrid()->displayModelOffset();
const std::vector<RigCell>& cells = eclipseCase->mainGrid()->globalCellArray();
@ -148,47 +139,19 @@ void RivElementVectorResultPartMgr::appendDynamicGeometryPartsToModel( cvf::Mode
if ( !cells[gcIdx].isInvalid() && activeCellInfo->isActive( gcIdx ) )
{
size_t resultIdx = activeCellInfo->cellResultIndex( gcIdx );
for ( int dir = 0; dir < static_cast<int>( directions.size() ); dir++ )
if ( result->vectorView() == RimElementVectorResult::VectorView::INDIVIDUAL )
{
double resultValue = resultsData->cellScalarResults( resultAddresses[dir], timeStepIndex ).at( resultIdx );
if ( std::abs( resultValue ) >= result->threshold() )
for ( int dir = 0; dir < static_cast<int>( directions.size() ); dir++ )
{
cvf::Vec3d faceCenter = cells[gcIdx].faceCenter( directions[dir] ) - offset;
cvf::Vec3d cellCenter = cells[gcIdx].center() - offset;
cvf::Vec3d faceNormal = ( faceCenter - cellCenter ).getNormalized() * arrowScaling;
if ( result->scaleMethod() == RimElementVectorResult::RESULT )
{
faceNormal *= std::abs( resultValue );
}
tensorVisualizations.push_back(
ElementVectorResultVisualization( faceCenter,
faceNormal,
resultValue,
std::cbrt( cells[gcIdx].volume() / 3.0 ) ) );
}
}
if ( nncResultVals && nncResultVals->size() > 0 && nncResultVals->at( timeStepIndex ).size() > 0 )
{
// The nnc connections can have more connections than reported from Eclipse, clamp the result index to
// Eclipse Results
double resultValue = 0.0;
if ( resultIdx < nncResultVals->at( timeStepIndex ).size() )
{
resultValue = ( *nncResultVals )[timeStepIndex][resultIdx];
}
if ( std::abs( resultValue ) >= result->threshold() )
{
for ( int dir = 0; dir < static_cast<int>( directions.size() ); dir++ )
double resultValue =
resultsData->cellScalarResults( resultAddresses[dir], timeStepIndex ).at( resultIdx );
if ( std::abs( resultValue ) >= result->threshold() )
{
cvf::Vec3d faceCenter = cells[gcIdx].faceCenter( directions[dir] ) - offset;
cvf::Vec3d cellCenter = cells[gcIdx].center() - offset;
cvf::Vec3d faceNormal = ( faceCenter - cellCenter ).getNormalized() * arrowScaling;
if ( result->scaleMethod() == RimElementVectorResult::RESULT )
if ( result->scaleMethod() == RimElementVectorResult::ScaleMethod::RESULT )
{
faceNormal *= std::abs( resultValue );
}
@ -201,6 +164,72 @@ void RivElementVectorResultPartMgr::appendDynamicGeometryPartsToModel( cvf::Mode
}
}
}
else if ( result->vectorView() == RimElementVectorResult::VectorView::AGGREGATED )
{
cvf::Vec3d aggregatedVector;
for ( int dir = 0; dir < static_cast<int>( directions.size() ); dir++ )
{
double resultValue =
resultsData->cellScalarResults( resultAddresses[dir], timeStepIndex ).at( resultIdx );
cvf::Vec3d faceCenter = cells[gcIdx].faceCenter( directions[dir] ) - offset;
cvf::Vec3d cellCenter = cells[gcIdx].center() - offset;
cvf::Vec3d faceNormal = ( faceCenter - cellCenter ).getNormalized() * arrowScaling;
if ( result->scaleMethod() == RimElementVectorResult::ScaleMethod::RESULT )
{
faceNormal *= std::abs( resultValue );
}
aggregatedVector += faceNormal;
}
if ( aggregatedVector.length() > 0 )
{
tensorVisualizations.push_back(
ElementVectorResultVisualization( cells[gcIdx].center() - offset,
aggregatedVector,
aggregatedVector.length(),
std::cbrt( cells[gcIdx].volume() / 3.0 ) ) );
}
}
}
}
RigNNCData* nncData = eclipseCaseData->mainGrid()->nncData();
size_t numNncConnections = nncData->connections().size();
const std::vector<std::vector<double>>* nncResultVals = nullptr;
if ( result->showNncData() )
{
if ( result->resultAddressCombined().m_resultCatType == RiaDefines::ResultCatType::DYNAMIC_NATIVE )
{
nncResultVals = nncData->dynamicConnectionScalarResult( result->resultAddressCombined() );
for ( size_t nIdx = 0; nIdx < numNncConnections; ++nIdx )
{
const RigConnection& conn = nncData->connections()[nIdx];
if ( conn.polygon().size() )
{
double resultValue = 0;
if ( nIdx < nncResultVals->size() )
{
resultValue = nncResultVals->at( timeStepIndex )[nIdx];
}
cvf::Vec3d connCenter =
static_cast<cvf::Vec3d>( cvf::GeometryTools::computePolygonCenter<cvf::Vec3f>( conn.polygon() ) );
cvf::Vec3d connNormal = ( ( connCenter - static_cast<cvf::Vec3d>( conn.polygon()[0] ) ) ^
( connCenter - static_cast<cvf::Vec3d>( conn.polygon()[1] ) ) )
.getNormalized();
if ( result->scaleMethod() == RimElementVectorResult::ScaleMethod::RESULT )
{
connNormal *= std::abs( resultValue );
}
tensorVisualizations.push_back(
ElementVectorResultVisualization( connCenter - offset,
connNormal,
resultValue,
std::cbrt( cells[conn.c1GlobIdx()].volume() / 3.0 ) ) );
}
}
}
}
@ -281,7 +310,7 @@ cvf::ref<cvf::Part>
cvf::ref<cvf::Effect> effect;
auto vectorColors = result.vectorColors();
if ( vectorColors == RimElementVectorResult::RESULT_COLORS )
if ( vectorColors == RimElementVectorResult::TensorColors::RESULT_COLORS )
{
activeScalerMapper = result.legendConfig()->scalarMapper();
createResultColorTextureCoords( lineTexCoords.p(), tensorVisualizations, activeScalerMapper );
@ -332,10 +361,10 @@ void RivElementVectorResultPartMgr::createResultColorTextureCoords(
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::array<cvf::Vec3f, 5>
std::array<cvf::Vec3f, 8>
RivElementVectorResultPartMgr::createArrowVertices( const ElementVectorResultVisualization& evrViz ) const
{
std::array<cvf::Vec3f, 5> vertices;
std::array<cvf::Vec3f, 8> vertices;
cvf::Vec3f headTop = evrViz.faceCenter + evrViz.faceNormal;
cvf::Vec3f shaftStart = evrViz.faceCenter;
@ -353,14 +382,19 @@ std::array<cvf::Vec3f, 5>
cvf::Vec3f headBottom = headTop - ( headTop - shaftStart ).getNormalized() * headLength;
// cvf::Vec3f headBottom = headTop - ( headTop - shaftStart ) * 0.2f;
cvf::Vec3f headBottomDirection = evrViz.faceNormal ^ evrViz.faceCenter;
cvf::Vec3f arrowBottomSegment = headBottomDirection.getNormalized() * headLength / 8.0f;
cvf::Vec3f headBottomDirectionH = evrViz.faceNormal ^ evrViz.faceCenter;
cvf::Vec3f arrowBottomSegmentH = headBottomDirectionH.getNormalized() * headLength / 8.0f;
cvf::Vec3f headBottomDirectionV = headBottomDirectionH ^ evrViz.faceNormal;
cvf::Vec3f arrowBottomSegmentV = headBottomDirectionV.getNormalized() * headLength / 8.0f;
vertices[0] = shaftStart;
vertices[1] = headBottom;
vertices[2] = headBottom + arrowBottomSegment;
vertices[3] = headBottom - arrowBottomSegment;
vertices[2] = headBottom + arrowBottomSegmentH;
vertices[3] = headBottom - arrowBottomSegmentH;
vertices[4] = headTop;
vertices[5] = headBottom + arrowBottomSegmentV;
vertices[6] = headBottom - arrowBottomSegmentV;
vertices[7] = headTop;
return vertices;
}
@ -381,13 +415,15 @@ std::array<uint, 2> RivElementVectorResultPartMgr::createArrowShaftIndices( uint
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::array<uint, 3> RivElementVectorResultPartMgr::createArrowHeadIndices( uint startIndex ) const
std::array<uint, 6> RivElementVectorResultPartMgr::createArrowHeadIndices( uint startIndex ) const
{
std::array<uint, 3> indices;
std::array<uint, 6> indices;
indices[0] = startIndex + 2;
indices[1] = startIndex + 3;
indices[2] = startIndex + 4;
indices[3] = startIndex + 5;
indices[4] = startIndex + 3;
indices[5] = startIndex + 4;
return indices;
}

View File

@ -77,9 +77,9 @@ private:
const std::vector<ElementVectorResultVisualization>& elementVectorResultVisualizations,
const cvf::ScalarMapper* mapper );
std::array<cvf::Vec3f, 5> createArrowVertices( const ElementVectorResultVisualization& tensorVisualization ) const;
std::array<cvf::Vec3f, 8> createArrowVertices( const ElementVectorResultVisualization& tensorVisualization ) const;
std::array<uint, 2> createArrowShaftIndices( uint startIndex ) const;
std::array<uint, 3> createArrowHeadIndices( uint startIndex ) const;
std::array<uint, 6> createArrowHeadIndices( uint startIndex ) const;
private:
caf::PdmPointer<RimEclipseView> m_rimReservoirView;

View File

@ -38,19 +38,28 @@ namespace caf
template <>
void AppEnum<RimElementVectorResult::TensorColors>::setUp()
{
addItem( RimElementVectorResult::RESULT_COLORS, "RESULT_COLORS", "Result Colors" );
addItem( RimElementVectorResult::UNIFORM_COLOR, "UNIFORM_COLOR", "Uniform" );
addItem( RimElementVectorResult::TensorColors::RESULT_COLORS, "RESULT_COLORS", "Result Colors" );
addItem( RimElementVectorResult::TensorColors::UNIFORM_COLOR, "UNIFORM_COLOR", "Uniform" );
setDefault( RimElementVectorResult::RESULT_COLORS );
setDefault( RimElementVectorResult::TensorColors::RESULT_COLORS );
}
template <>
void AppEnum<RimElementVectorResult::ScaleMethod>::setUp()
{
addItem( RimElementVectorResult::RESULT, "RESULT", "Result" );
addItem( RimElementVectorResult::CONSTANT, "CONSTANT", "Constant" );
addItem( RimElementVectorResult::ScaleMethod::RESULT, "RESULT", "Result" );
addItem( RimElementVectorResult::ScaleMethod::CONSTANT, "CONSTANT", "Constant" );
setDefault( RimElementVectorResult::RESULT );
setDefault( RimElementVectorResult::ScaleMethod::RESULT );
}
template <>
void AppEnum<RimElementVectorResult::VectorView>::setUp()
{
addItem( RimElementVectorResult::VectorView::AGGREGATED, "AGGREGATED", "Aggregated" );
addItem( RimElementVectorResult::VectorView::INDIVIDUAL, "INDIVIDUAL", "Individual" );
setDefault( RimElementVectorResult::VectorView::AGGREGATED );
}
} // namespace caf
@ -71,6 +80,8 @@ RimElementVectorResult::RimElementVectorResult()
CAF_PDM_InitField( &m_showResult, "ShowResult", false, "", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_vectorView, "VectorView", "", "", "", "" );
CAF_PDM_InitField( &m_showVectorI, "ShowVectorI", true, "I", "", "", "" );
CAF_PDM_InitField( &m_showVectorJ, "ShowVectorJ", true, "J", "", "", "" );
CAF_PDM_InitField( &m_showVectorK, "ShowVectorK", true, "K", "", "", "" );
@ -112,6 +123,14 @@ bool RimElementVectorResult::showResult() const
return m_showResult();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimElementVectorResult::VectorView RimElementVectorResult::vectorView()
{
return m_vectorView();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -321,6 +340,7 @@ void RimElementVectorResult::defineUiOrdering( QString uiConfigName, caf::PdmUiO
uiOrdering.add( &m_resultName );
caf::PdmUiGroup* visibilityGroup = uiOrdering.addNewGroup( "Visibility" );
visibilityGroup->add( &m_vectorView );
visibilityGroup->add( &m_showVectorI );
visibilityGroup->add( &m_showVectorJ );
visibilityGroup->add( &m_showVectorK );
@ -329,7 +349,7 @@ void RimElementVectorResult::defineUiOrdering( QString uiConfigName, caf::PdmUiO
caf::PdmUiGroup* vectorColorsGroup = uiOrdering.addNewGroup( "Vector Colors" );
vectorColorsGroup->add( &m_vectorColor );
if ( m_vectorColor == UNIFORM_COLOR )
if ( m_vectorColor == TensorColors::UNIFORM_COLOR )
{
vectorColorsGroup->add( &m_uniformVectorColor );
}

View File

@ -44,24 +44,31 @@ class RimElementVectorResult : public caf::PdmObject
CAF_PDM_HEADER_INIT;
public:
enum TensorColors
enum class TensorColors
{
UNIFORM_COLOR,
RESULT_COLORS
};
enum ScaleMethod
enum class ScaleMethod
{
RESULT,
CONSTANT
};
enum class VectorView
{
AGGREGATED,
INDIVIDUAL
};
public:
RimElementVectorResult();
~RimElementVectorResult() override;
void setShowResult( bool enableResult );
bool showResult() const;
VectorView vectorView();
bool showVectorI() const;
bool showVectorJ() const;
bool showVectorK() const;
@ -100,6 +107,7 @@ private:
private:
caf::PdmField<bool> m_showResult;
caf::PdmField<QString> m_resultName;
caf::PdmField<caf::AppEnum<VectorView>> m_vectorView;
caf::PdmField<bool> m_showVectorI;
caf::PdmField<bool> m_showVectorJ;
caf::PdmField<bool> m_showVectorK;