#2347 Elm props: Evaluate result type ELEMENT in property visibility

This commit is contained in:
Rebecca Cox
2018-01-10 15:23:00 +01:00
parent 2ce7e2c3d2
commit 5751acf2b9
2 changed files with 126 additions and 120 deletions

View File

@@ -107,140 +107,138 @@ void RivFemElmVisibilityCalculator::computePropertyVisibility(cvf::UByteArray* c
if (cellVisibility != rangeFilterVisibility ) (*cellVisibility) = *rangeFilterVisibility;
const int elementCount = grid->elementCount();
if (propFilterColl->hasActiveFilters())
if (!propFilterColl->hasActiveFilters()) return;
for (size_t i = 0; i < propFilterColl->propertyFilters().size(); i++)
{
for (size_t i = 0; i < propFilterColl->propertyFilters().size(); i++)
RimGeoMechPropertyFilter* propertyFilter = propFilterColl->propertyFilters()[i];
if (!propertyFilter->isActiveAndHasResult()) continue;
const RimCellFilter::FilterModeType filterType = propertyFilter->filterMode();
RigGeoMechCaseData* caseData = propFilterColl->reservoirView()->geoMechCase()->geoMechData();
RigFemResultAddress resVarAddress = propertyFilter->resultDefinition->resultAddress();
// Do a "Hack" to use elm nodal and not nodal POR results
if ( resVarAddress.resultPosType == RIG_NODAL && resVarAddress.fieldName == "POR-Bar" ) resVarAddress.resultPosType = RIG_ELEMENT_NODAL;
const std::vector<float>& resVals = caseData->femPartResults()->resultValues(resVarAddress,
grid->elementPartId(),
timeStepIndex);
if (!propertyFilter->isActive()) continue;
if (!propertyFilter->resultDefinition->hasResult()) continue;
const double lowerBound = propertyFilter->lowerBound();
const double upperBound = propertyFilter->upperBound();
if (propertyFilter->resultDefinition->resultAddress().resultPosType == RIG_FORMATION_NAMES)
{
RimGeoMechPropertyFilter* propertyFilter = propFilterColl->propertyFilters()[i];
if (!propertyFilter->isActiveAndHasResult()) continue;
const RimCellFilter::FilterModeType filterType = propertyFilter->filterMode();
RigGeoMechCaseData* caseData = propFilterColl->reservoirView()->geoMechCase()->geoMechData();
RigFemResultAddress resVarAddress = propertyFilter->resultDefinition->resultAddress();
// Do a "Hack" to use elm nodal and not nodal POR results
if ( resVarAddress.resultPosType == RIG_NODAL && resVarAddress.fieldName == "POR-Bar" ) resVarAddress.resultPosType = RIG_ELEMENT_NODAL;
const std::vector<float>& resVals = caseData->femPartResults()->resultValues(resVarAddress,
grid->elementPartId(),
timeStepIndex);
if (propertyFilter->isActive() && propertyFilter->resultDefinition->hasResult())
std::vector<int> integerVector = propertyFilter->selectedCategoryValues();
std::set<int> integerSet;
for (auto val : integerVector)
{
if (propertyFilter->resultDefinition->resultAddress().resultPosType == RIG_FORMATION_NAMES)
{
std::vector<int> integerVector = propertyFilter->selectedCategoryValues();
std::set<int> integerSet;
for (auto val : integerVector)
{
integerSet.insert(val);
}
integerSet.insert(val);
}
for (int cellIndex = 0; cellIndex < elementCount; cellIndex++)
for (int cellIndex = 0; cellIndex < elementCount; cellIndex++)
{
if (!(*cellVisibility)[cellIndex]) continue;
size_t resultValueIndex = grid->elementNodeResultIdx(cellIndex, 0);
double scalarValue = resVals[resultValueIndex];
int intValue = nearbyint(scalarValue);
if (integerSet.find(intValue) != integerSet.end())
{
if (filterType == RimCellFilter::EXCLUDE)
{
if ((*cellVisibility)[cellIndex])
{
size_t resultValueIndex = grid->elementNodeResultIdx(cellIndex, 0);
double scalarValue = resVals[resultValueIndex];
int intValue = nearbyint(scalarValue);
if (integerSet.find(intValue) != integerSet.end())
{
if (filterType == RimCellFilter::EXCLUDE)
{
(*cellVisibility)[cellIndex] = false;
}
}
else
{
if (filterType == RimCellFilter::INCLUDE)
{
(*cellVisibility)[cellIndex] = false;
}
}
}
(*cellVisibility)[cellIndex] = false;
}
}
else
{
const double lowerBound = propertyFilter->lowerBound();
const double upperBound = propertyFilter->upperBound();
if (resVarAddress.resultPosType != RIG_ELEMENT_NODAL_FACE)
if (filterType == RimCellFilter::INCLUDE)
{
#pragma omp parallel for schedule(dynamic)
for (int cellIndex = 0; cellIndex < elementCount; cellIndex++)
{
if ( (*cellVisibility)[cellIndex] )
{
RigElementType eType = grid->elementType(cellIndex);
int elmNodeCount = RigFemTypes::elmentNodeCount(eType);
const int* elmNodeIndices = grid->connectivities(cellIndex);
for(int enIdx = 0; enIdx < elmNodeCount; ++enIdx)
{
size_t resultValueIndex = cvf::UNDEFINED_SIZE_T;
if (resVarAddress.resultPosType == RIG_NODAL)
{
resultValueIndex = elmNodeIndices[enIdx];
}
else
{
resultValueIndex = grid->elementNodeResultIdx(cellIndex, enIdx);
}
double scalarValue = resVals[resultValueIndex];
if (lowerBound <= scalarValue && scalarValue <= upperBound)
{
if (filterType == RimCellFilter::EXCLUDE)
{
(*cellVisibility)[cellIndex] = false;
}
}
else
{
if (filterType == RimCellFilter::INCLUDE)
{
(*cellVisibility)[cellIndex] = false;
}
}
}
}
}
}
else
{
#pragma omp parallel for schedule(dynamic)
for(int cellIndex = 0; cellIndex < elementCount; cellIndex++)
{
if((*cellVisibility)[cellIndex])
{
for(int fpIdx = 0; fpIdx < 24; ++fpIdx)
{
double scalarValue = resVals[cellIndex*24 + fpIdx];
if(lowerBound <= scalarValue && scalarValue <= upperBound)
{
if(filterType == RimCellFilter::EXCLUDE)
{
(*cellVisibility)[cellIndex] = false;
}
}
else
{
if(filterType == RimCellFilter::INCLUDE)
{
(*cellVisibility)[cellIndex] = false;
}
}
}
}
}
(*cellVisibility)[cellIndex] = false;
}
}
}
}
else if (resVarAddress.resultPosType == RIG_ELEMENT)
{
#pragma omp parallel for schedule(dynamic)
for (int cellIndex = 0; cellIndex < elementCount; cellIndex++)
{
if (!(*cellVisibility)[cellIndex]) continue;
double scalarValue = resVals[cellIndex];
evaluateAndSetCellVisibiliy(scalarValue, lowerBound, upperBound, filterType, cellVisibility, cellIndex);
}
}
else if (resVarAddress.resultPosType == RIG_ELEMENT_NODAL_FACE)
{
#pragma omp parallel for schedule(dynamic)
for (int cellIndex = 0; cellIndex < elementCount; cellIndex++)
{
if (!(*cellVisibility)[cellIndex]) continue;
for (int fpIdx = 0; fpIdx < 24; ++fpIdx)
{
double scalarValue = resVals[cellIndex * 24 + fpIdx];
evaluateAndSetCellVisibiliy(scalarValue, lowerBound, upperBound, filterType, cellVisibility, cellIndex);
}
}
}
else
{
#pragma omp parallel for schedule(dynamic)
for (int cellIndex = 0; cellIndex < elementCount; cellIndex++)
{
if (!(*cellVisibility)[cellIndex]) continue;
RigElementType eType = grid->elementType(cellIndex);
int elmNodeCount = RigFemTypes::elmentNodeCount(eType);
const int* elmNodeIndices = grid->connectivities(cellIndex);
for (int enIdx = 0; enIdx < elmNodeCount; ++enIdx)
{
size_t resultValueIndex = cvf::UNDEFINED_SIZE_T;
if (resVarAddress.resultPosType == RIG_NODAL)
{
resultValueIndex = elmNodeIndices[enIdx];
}
else
{
resultValueIndex = grid->elementNodeResultIdx(cellIndex, enIdx);
}
double scalarValue = resVals[resultValueIndex];
evaluateAndSetCellVisibiliy(scalarValue, lowerBound, upperBound, filterType, cellVisibility, cellIndex);
}
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivFemElmVisibilityCalculator::evaluateAndSetCellVisibiliy(double scalarValue, double lowerBound, double upperBound, const RimCellFilter::FilterModeType filterType, cvf::UByteArray* cellVisibility, int cellIndex)
{
if (lowerBound <= scalarValue && scalarValue <= upperBound)
{
if (filterType == RimCellFilter::EXCLUDE)
{
(*cellVisibility)[cellIndex] = false;
}
}
else
{
if (filterType == RimCellFilter::INCLUDE)
{
(*cellVisibility)[cellIndex] = false;
}
}
}

View File

@@ -18,9 +18,12 @@
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cvfBase.h"
#include "cvfArray.h"
#include "RimCellFilter.h"
namespace cvf
{
class CellRangeFilter;
@@ -43,6 +46,11 @@ public:
const cvf::UByteArray* rangeFilterVisibility,
RimGeoMechPropertyFilterCollection* propFilterColl);
static void evaluateAndSetCellVisibiliy(double scalarValue, double lowerBound, double upperBound,
const RimCellFilter::FilterModeType filterType,
cvf::UByteArray* cellVisibility, int cellIndex);
static void computeOverriddenCellVisibility(cvf::UByteArray* elmVisibilities,
const RigFemPart* femPart ,
RimViewController* masterViewLink);