Tensor flow improvements

New GUI settings for tensor length control, fluid selection, NNC data selection and aggregated visualization. Possibility to change vector start position. Improved vector visualization.
This commit is contained in:
Ruben Thoms
2020-09-29 09:47:38 +02:00
committed by Magne Sjaastad
parent 2feb9d0cd7
commit cc5335d46f
7 changed files with 617 additions and 213 deletions

View File

@@ -20,6 +20,8 @@
#include "RigCaseCellResultsData.h"
#include "RigEclipseCaseData.h"
#include "RigEclipseResultAddress.h"
#include "RigMainGrid.h"
#include "RigNNCData.h"
#include "Rim3dView.h"
#include "RimEclipseCase.h"
@@ -38,19 +40,38 @@ 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::RESULT_LOG, "RESULT_LOG", "Result (logarithmic scaling)" );
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 );
}
template <>
void AppEnum<RimElementVectorResult::VectorSurfaceCrossingLocation>::setUp()
{
addItem( RimElementVectorResult::VectorSurfaceCrossingLocation::VECTOR_ANCHOR, "VECTOR_ANCHOR", "At vector anchor" );
addItem( RimElementVectorResult::VectorSurfaceCrossingLocation::VECTOR_CENTER, "VECTOR_CENTER", "At vector center" );
setDefault( RimElementVectorResult::VectorSurfaceCrossingLocation::VECTOR_ANCHOR );
}
} // namespace caf
@@ -65,15 +86,27 @@ RimElementVectorResult::RimElementVectorResult()
m_legendConfig = new RimRegularLegendConfig();
m_legendConfig.uiCapability()->setUiHidden( true );
CAF_PDM_InitField( &m_resultName, "ResultVariable", QString( "Oil" ), "Value", "", "", "" );
m_resultName.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() );
m_resultName.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP );
CAF_PDM_InitField( &m_showOil, "ShowOil", true, "Oil", "", "", "" );
CAF_PDM_InitField( &m_showGas, "ShowGas", false, "Gas", "", "", "" );
CAF_PDM_InitField( &m_showWater, "ShowWater", true, "Water", "", "", "" );
CAF_PDM_InitField( &m_showResult, "ShowResult", false, "", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_vectorView, "VectorView", "View vectors", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_vectorSurfaceCrossingLocation,
"VectorSurfaceCrossingLocation",
"Vectors touching surface",
"",
"",
"" );
m_vectorSurfaceCrossingLocation.uiCapability()->setUiReadOnly( m_vectorView() ==
RimElementVectorResult::VectorView::AGGREGATED );
CAF_PDM_InitField( &m_showVectorI, "ShowVectorI", true, "I", "", "", "" );
CAF_PDM_InitField( &m_showVectorJ, "ShowVectorJ", true, "J", "", "", "" );
CAF_PDM_InitField( &m_showVectorK, "ShowVectorK", true, "K", "", "", "" );
CAF_PDM_InitField( &m_showNncData, "ShowNncData", true, "Show NNC data", "", "", "" );
CAF_PDM_InitField( &m_threshold, "Threshold", 0.0f, "Threshold", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_vectorColor, "VectorColor", "Color", "", "", "" );
@@ -111,6 +144,38 @@ bool RimElementVectorResult::showResult() const
return m_showResult();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimElementVectorResult::VectorView RimElementVectorResult::vectorView() const
{
return m_vectorView();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimElementVectorResult::showOil() const
{
return m_showOil();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimElementVectorResult::showGas() const
{
return m_showGas();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimElementVectorResult::showWater() const
{
return m_showWater();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -136,6 +201,22 @@ bool RimElementVectorResult::showVectorK() const
return m_showVectorK();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimElementVectorResult::showNncData() const
{
return m_showNncData();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimElementVectorResult::VectorSurfaceCrossingLocation RimElementVectorResult::vectorSuraceCrossingLocation() const
{
return m_vectorSurfaceCrossingLocation();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -181,30 +262,157 @@ const cvf::Color3f& RimElementVectorResult::getUniformVectorColor() const
//--------------------------------------------------------------------------------------------------
void RimElementVectorResult::mappingRange( double& min, double& max ) const
{
min = cvf::UNDEFINED_DOUBLE;
max = cvf::UNDEFINED_DOUBLE;
min = 0.0;
max = 0.0;
Rim3dView* view = nullptr;
firstAncestorOrThisOfType( view );
int currentTimeStep = view->currentTimeStep();
RigEclipseResultAddress resVarAddr = resultAddressCombined();
if ( !resVarAddr.isValid() ) return;
std::vector<RigEclipseResultAddress> resVarAddresses;
size_t directions = 1;
if ( !resultAddressesIJK( resVarAddresses ) ) return;
std::vector<RigEclipseResultAddress> cleanedResVarAddresses;
directions = 0;
std::vector<cvf::Vec3d> unitVectors;
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>( view );
RigCaseCellResultsData* resultsData =
eclipseView->eclipseCase()->eclipseCaseData()->results( RiaDefines::PorosityModelType::MATRIX_MODEL );
resultsData->ensureKnownResultLoaded( resVarAddr );
if ( m_legendConfig->rangeMode() == RimRegularLegendConfig::RangeModeType::AUTOMATIC_ALLTIMESTEPS )
for ( size_t fluidIndex = 0; fluidIndex < resVarAddresses.size(); fluidIndex += 3 )
{
resultsData->minMaxCellScalarValues( resVarAddr, min, max );
if ( showVectorI() )
{
if ( fluidIndex == 0 )
{
directions++;
unitVectors.push_back( cvf::Vec3d( 1, 0, 0 ) );
}
cleanedResVarAddresses.push_back( resVarAddresses.at( 0 + fluidIndex ) );
}
if ( showVectorJ() )
{
if ( fluidIndex == 0 )
{
directions++;
unitVectors.push_back( cvf::Vec3d( 0, 1, 0 ) );
}
cleanedResVarAddresses.push_back( resVarAddresses.at( 1 + fluidIndex ) );
}
if ( showVectorK() )
{
if ( fluidIndex == 0 )
{
directions++;
unitVectors.push_back( cvf::Vec3d( 0, 0, 1 ) );
}
cleanedResVarAddresses.push_back( resVarAddresses.at( 2 + fluidIndex ) );
}
}
else if ( m_legendConfig->rangeMode() == RimRegularLegendConfig::RangeModeType::AUTOMATIC_CURRENT_TIMESTEP )
resVarAddresses = cleanedResVarAddresses;
if ( directions > 0 )
{
resultsData->minMaxCellScalarValues( resVarAddr, currentTimeStep, min, max );
std::vector<double> directionsMax;
directionsMax.resize( directions, 0.0 );
std::vector<double> directionsMin;
directionsMin.resize( directions, 0.0 );
for ( size_t index = 0; index < resVarAddresses.size(); index += directions )
{
cvf::Vec3d aggregatedVectorMax;
cvf::Vec3d aggregatedVectorMin;
for ( size_t dir = 0; dir < directions; dir += 1 )
{
double localMin = cvf::UNDEFINED_DOUBLE;
double localMax = cvf::UNDEFINED_DOUBLE;
RigEclipseResultAddress resVarAddr = resVarAddresses.at( index + dir );
if ( !resVarAddr.isValid() ) return;
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>( view );
RigCaseCellResultsData* resultsData =
eclipseView->eclipseCase()->eclipseCaseData()->results( RiaDefines::PorosityModelType::MATRIX_MODEL );
resultsData->ensureKnownResultLoaded( resVarAddr );
if ( m_legendConfig->rangeMode() == RimRegularLegendConfig::RangeModeType::AUTOMATIC_ALLTIMESTEPS )
{
resultsData->minMaxCellScalarValues( resVarAddr, localMin, localMax );
}
else if ( m_legendConfig->rangeMode() == RimRegularLegendConfig::RangeModeType::AUTOMATIC_CURRENT_TIMESTEP )
{
resultsData->minMaxCellScalarValues( resVarAddr, currentTimeStep, localMin, localMax );
}
if ( vectorView() == RimElementVectorResult::VectorView::AGGREGATED )
{
aggregatedVectorMax += unitVectors.at( dir ) * localMax;
aggregatedVectorMin += unitVectors.at( dir ) * localMin;
}
else
{
directionsMax[dir] += localMax;
directionsMin[dir] += localMin;
}
}
if ( vectorView() == RimElementVectorResult::VectorView::AGGREGATED )
{
directionsMax[0] += aggregatedVectorMax.length();
directionsMin[0] += aggregatedVectorMin.length();
}
}
min = directionsMin.front();
max = directionsMax.front();
if ( vectorView() != RimElementVectorResult::VectorView::AGGREGATED )
{
for ( size_t i = 0; i < directionsMax.size(); i++ )
{
max = std::max<double>( max, directionsMax.at( i ) );
min = std::min<double>( min, directionsMin.at( i ) );
}
}
else
{
max = std::max<double>( max, min );
min = 0.0;
}
}
if ( showNncData() )
{
RigNNCData* nncData =
dynamic_cast<RimEclipseView*>( view )->eclipseCase()->eclipseCaseData()->mainGrid()->nncData();
std::vector<RigEclipseResultAddress> combinedAddresses;
if ( !resultAddressesCombined( combinedAddresses ) ) return;
for ( size_t flIdx = 0; flIdx < combinedAddresses.size(); flIdx++ )
{
if ( combinedAddresses[flIdx].m_resultCatType == RiaDefines::ResultCatType::DYNAMIC_NATIVE )
{
if ( m_legendConfig->rangeMode() == RimRegularLegendConfig::RangeModeType::AUTOMATIC_ALLTIMESTEPS )
{
const std::vector<std::vector<double>>* nncResultVals =
nncData->dynamicConnectionScalarResult( combinedAddresses[flIdx] );
for ( size_t i = 0; i < nncResultVals->size(); i++ )
{
for ( size_t j = 0; j < nncResultVals->at( i ).size(); j++ )
{
max = std::max<double>( max, nncResultVals->at( i ).at( j ) );
min = std::min<double>( min, nncResultVals->at( i ).at( j ) );
}
}
}
else if ( m_legendConfig->rangeMode() == RimRegularLegendConfig::RangeModeType::AUTOMATIC_CURRENT_TIMESTEP )
{
const std::vector<double>* nncResultVals =
nncData->dynamicConnectionScalarResult( combinedAddresses[flIdx],
static_cast<size_t>( currentTimeStep ) );
for ( size_t i = 0; i < nncResultVals->size(); i++ )
{
max = std::max<double>( max, nncResultVals->at( i ) );
min = std::min<double>( min, nncResultVals->at( i ) );
}
}
}
}
}
}
@@ -214,13 +422,29 @@ void RimElementVectorResult::mappingRange( double& min, double& max ) const
void RimElementVectorResult::updateLegendRangesTextAndVisibility( RiuViewer* nativeOrOverrideViewer,
bool isUsingOverrideViewer )
{
m_legendConfig->setTitle( QString( "Element Vector Result: \n" ) + resultName() );
QStringList resultNames;
if ( showOil() )
{
resultNames << QString( "Oil" );
}
if ( showGas() )
{
resultNames << QString( "Gas" );
}
if ( showWater() )
{
resultNames << QString( "Water" );
}
m_legendConfig->setTitle( QString( "Element Vector Result: \n" ) + resultNames.join( ", " ) );
double minResultValue;
double maxResultValue;
mappingRange( minResultValue, maxResultValue );
m_legendConfig->setAutomaticRanges( minResultValue, maxResultValue, minResultValue, maxResultValue );
m_legendConfig->setMappingMode( RimRegularLegendConfig::MappingType::LINEAR_CONTINUOUS );
double posClosestToZero = HUGE_VAL;
double negClosestToZero = -HUGE_VAL;
m_legendConfig->setClosestToZeroValues( posClosestToZero, negClosestToZero, posClosestToZero, negClosestToZero );
@@ -235,27 +459,6 @@ const RimRegularLegendConfig* RimElementVectorResult::legendConfig() const
return m_legendConfig();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimElementVectorResult::resultName() const
{
return m_resultName();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<std::string> RimElementVectorResult::getResultMetaDataForUIFieldSetting()
{
std::vector<std::string> fieldNames;
fieldNames.push_back( "Oil" );
fieldNames.push_back( "Water" );
fieldNames.push_back( "Gas" );
return fieldNames;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -267,6 +470,11 @@ void RimElementVectorResult::fieldChangedByUi( const caf::PdmFieldHandle* change
{
setShowResult( m_showResult );
}
if ( changedField == &m_vectorView )
{
m_vectorSurfaceCrossingLocation.uiCapability()->setUiReadOnly( vectorView() ==
RimElementVectorResult::VectorView::AGGREGATED );
}
RimEclipseView* view;
firstAncestorOrThisOfType( view );
@@ -281,45 +489,28 @@ caf::PdmFieldHandle* RimElementVectorResult::objectToggleField()
return &m_showResult;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo>
RimElementVectorResult::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly )
{
QList<caf::PdmOptionItemInfo> options;
*useOptionsOnly = true;
if ( fieldNeedingOptions == &m_resultName )
{
std::vector<std::string> fieldCompNames = getResultMetaDataForUIFieldSetting();
for ( size_t oIdx = 0; oIdx < fieldCompNames.size(); ++oIdx )
{
options.push_back( caf::PdmOptionItemInfo( QString::fromStdString( fieldCompNames[oIdx] ),
QString::fromStdString( fieldCompNames[oIdx] ) ) );
}
}
return options;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimElementVectorResult::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
uiOrdering.add( &m_resultName );
caf::PdmUiGroup* fluidsGroup = uiOrdering.addNewGroup( "Fluids" );
fluidsGroup->add( &m_showOil );
fluidsGroup->add( &m_showGas );
fluidsGroup->add( &m_showWater );
caf::PdmUiGroup* visibilityGroup = uiOrdering.addNewGroup( "Visibility" );
visibilityGroup->add( &m_vectorView );
visibilityGroup->add( &m_vectorSurfaceCrossingLocation );
visibilityGroup->add( &m_showVectorI );
visibilityGroup->add( &m_showVectorJ );
visibilityGroup->add( &m_showVectorK );
visibilityGroup->add( &m_showNncData );
visibilityGroup->add( &m_threshold );
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 );
}
@@ -334,75 +525,55 @@ void RimElementVectorResult::defineUiOrdering( QString uiConfigName, caf::PdmUiO
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimElementVectorResult::defineEditorAttribute( const caf::PdmFieldHandle* field,
QString uiConfigName,
caf::PdmUiEditorAttribute* attribute )
{
if ( field == &m_resultName )
{
caf::PdmUiListEditorAttribute* listEditAttr = dynamic_cast<caf::PdmUiListEditorAttribute*>( attribute );
if ( listEditAttr )
{
listEditAttr->m_heightHint = 50;
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigEclipseResultAddress RimElementVectorResult::resultAddressCombined() const
{
if ( resultName() == "Oil" )
{
return RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE,
RiaDefines::combinedOilFluxResultName() );
}
else if ( resultName() == "Gas" )
{
return RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE,
RiaDefines::combinedGasFluxResultName() );
}
else if ( resultName() == "Water" )
{
return RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE,
RiaDefines::combinedWaterFluxResultName() );
}
return RigEclipseResultAddress();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimElementVectorResult::resultAddressIJK( std::vector<RigEclipseResultAddress>& addresses ) const
bool RimElementVectorResult::resultAddressesCombined( std::vector<RigEclipseResultAddress>& addresses ) const
{
addresses.clear();
// TODO: use enum??
if ( resultName() == "Oil" )
if ( showOil() )
{
addresses.push_back( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE,
RiaDefines::combinedOilFluxResultName() ) );
}
if ( showGas() )
{
addresses.push_back( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE,
RiaDefines::combinedGasFluxResultName() ) );
}
if ( showWater() )
{
addresses.push_back( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE,
RiaDefines::combinedWaterFluxResultName() ) );
}
return addresses.size() > 0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RimElementVectorResult::resultAddressesIJK( std::vector<RigEclipseResultAddress>& addresses ) const
{
addresses.clear();
if ( showOil() )
{
addresses.push_back( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "FLROILI+" ) );
addresses.push_back( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "FLROILJ+" ) );
addresses.push_back( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "FLROILK+" ) );
return true;
}
else if ( resultName() == "Gas" )
if ( showGas() )
{
addresses.push_back( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "FLRGASI+" ) );
addresses.push_back( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "FLRGASJ+" ) );
addresses.push_back( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "FLRGASK+" ) );
return true;
}
else if ( resultName() == "Water" )
if ( showWater() )
{
addresses.push_back( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "FLRWATI+" ) );
addresses.push_back( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "FLRWATJ+" ) );
addresses.push_back( RigEclipseResultAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "FLRWATK+" ) );
return true;
}
return false;
return addresses.size() > 0;
}
//--------------------------------------------------------------------------------------------------