mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Improved ODB support (#8046)
* Experiments for supporting visualization of new ODB files from WIA workflow * Some more experiments to get odb working for wia results * More work in progress, experimenting to get wellIA result files to load properly * Make sure all part geometries use the same global bounding box * Clean up code * Add some safeguards for data calculations Move parts below grid in project tree * Fix warnings * Add support for C3D8RT elements Add some more safeguards for missing data Remove strange part handling * Support elements with reduced number of integration points by pretending to have 8. * Change integration point mapping to correct order (ref. Stein and Abaqus 2019 doc) * Do not allocate too much memory for element nodal results for 20 element node types * Code cleanup. Revert back to old integration point numbering scheme (ref. Stein) * And, another integration point order update... * Update comments
This commit is contained in:
@@ -89,7 +89,7 @@ void RivFemElmVisibilityCalculator::computeRangeVisibility( cvf::UByteArray*
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivFemElmVisibilityCalculator::computePropertyVisibility( cvf::UByteArray* cellVisibility,
|
||||
const RigFemPart* grid,
|
||||
const RigFemPart* part,
|
||||
int timeStepIndex,
|
||||
const cvf::UByteArray* rangeFilterVisibility,
|
||||
RimGeoMechPropertyFilterCollection* propFilterColl )
|
||||
@@ -98,12 +98,12 @@ void RivFemElmVisibilityCalculator::computePropertyVisibility( cvf::UByteArray*
|
||||
CVF_ASSERT( rangeFilterVisibility != nullptr );
|
||||
CVF_ASSERT( propFilterColl != nullptr );
|
||||
|
||||
CVF_ASSERT( grid->elementCount() > 0 );
|
||||
CVF_ASSERT( rangeFilterVisibility->size() == static_cast<size_t>( grid->elementCount() ) );
|
||||
CVF_ASSERT( part->elementCount() > 0 );
|
||||
CVF_ASSERT( rangeFilterVisibility->size() == static_cast<size_t>( part->elementCount() ) );
|
||||
|
||||
// Copy if not equal
|
||||
if ( cellVisibility != rangeFilterVisibility ) ( *cellVisibility ) = *rangeFilterVisibility;
|
||||
const int elementCount = grid->elementCount();
|
||||
const int elementCount = part->elementCount();
|
||||
|
||||
if ( !propFilterColl->hasActiveFilters() ) return;
|
||||
|
||||
@@ -124,10 +124,11 @@ void RivFemElmVisibilityCalculator::computePropertyVisibility( cvf::UByteArray*
|
||||
resVarAddress.resultPosType = RIG_ELEMENT_NODAL;
|
||||
|
||||
const std::vector<float>& resVals =
|
||||
caseData->femPartResults()->resultValues( resVarAddress, grid->elementPartId(), timeStepIndex );
|
||||
caseData->femPartResults()->resultValues( resVarAddress, part->elementPartId(), timeStepIndex );
|
||||
|
||||
if ( !propertyFilter->isActive() ) continue;
|
||||
if ( !propertyFilter->resultDefinition->hasResult() ) continue;
|
||||
if ( resVals.size() == 0 ) continue;
|
||||
|
||||
const double lowerBound = propertyFilter->lowerBound();
|
||||
const double upperBound = propertyFilter->upperBound();
|
||||
@@ -145,7 +146,7 @@ void RivFemElmVisibilityCalculator::computePropertyVisibility( cvf::UByteArray*
|
||||
{
|
||||
if ( !( *cellVisibility )[cellIndex] ) continue;
|
||||
|
||||
size_t resultValueIndex = grid->elementNodeResultIdx( cellIndex, 0 );
|
||||
size_t resultValueIndex = part->elementNodeResultIdx( cellIndex, 0 );
|
||||
double scalarValue = resVals[resultValueIndex];
|
||||
int intValue = nearbyint( scalarValue );
|
||||
if ( integerSet.find( intValue ) != integerSet.end() )
|
||||
@@ -196,10 +197,10 @@ void RivFemElmVisibilityCalculator::computePropertyVisibility( cvf::UByteArray*
|
||||
{
|
||||
if ( !( *cellVisibility )[cellIndex] ) continue;
|
||||
|
||||
RigElementType eType = grid->elementType( cellIndex );
|
||||
RigElementType eType = part->elementType( cellIndex );
|
||||
int elmNodeCount = RigFemTypes::elementNodeCount( eType );
|
||||
|
||||
const int* elmNodeIndices = grid->connectivities( cellIndex );
|
||||
const int* elmNodeIndices = part->connectivities( cellIndex );
|
||||
for ( int enIdx = 0; enIdx < elmNodeCount; ++enIdx )
|
||||
{
|
||||
size_t resultValueIndex = cvf::UNDEFINED_SIZE_T;
|
||||
@@ -209,7 +210,7 @@ void RivFemElmVisibilityCalculator::computePropertyVisibility( cvf::UByteArray*
|
||||
}
|
||||
else
|
||||
{
|
||||
resultValueIndex = grid->elementNodeResultIdx( cellIndex, enIdx );
|
||||
resultValueIndex = part->elementNodeResultIdx( cellIndex, enIdx );
|
||||
}
|
||||
|
||||
double scalarValue = resVals[resultValueIndex];
|
||||
|
||||
@@ -42,8 +42,9 @@ using namespace cvf;
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivFemPartGeometryGenerator::RivFemPartGeometryGenerator( const RigFemPart* part )
|
||||
RivFemPartGeometryGenerator::RivFemPartGeometryGenerator( const RigFemPart* part, cvf::Vec3d displayOffset )
|
||||
: m_part( part )
|
||||
, m_displayOffset( displayOffset )
|
||||
{
|
||||
CVF_ASSERT( part );
|
||||
m_triangleMapper = new RivFemPartTriangleToElmMapper;
|
||||
@@ -147,7 +148,6 @@ void RivFemPartGeometryGenerator::computeArrays()
|
||||
trianglesToElements.reserve( estimatedQuadVxCount / 2 );
|
||||
trianglesToElementFaces.reserve( estimatedQuadVxCount / 2 );
|
||||
|
||||
cvf::Vec3d displayOffset = m_part->boundingBox().min();
|
||||
const std::vector<cvf::Vec3f>& nodeCoordinates = m_part->nodes().coordinates;
|
||||
|
||||
#pragma omp parallel for schedule( dynamic )
|
||||
@@ -177,13 +177,13 @@ void RivFemPartGeometryGenerator::computeArrays()
|
||||
if ( faceNodeCount == 4 )
|
||||
{
|
||||
cvf::Vec3f quadVxs0( cvf::Vec3d( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[0]]] ) -
|
||||
displayOffset );
|
||||
m_displayOffset );
|
||||
cvf::Vec3f quadVxs1( cvf::Vec3d( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[1]]] ) -
|
||||
displayOffset );
|
||||
m_displayOffset );
|
||||
cvf::Vec3f quadVxs2( cvf::Vec3d( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[2]]] ) -
|
||||
displayOffset );
|
||||
m_displayOffset );
|
||||
cvf::Vec3f quadVxs3( cvf::Vec3d( nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[3]]] ) -
|
||||
displayOffset );
|
||||
m_displayOffset );
|
||||
|
||||
int qNodeIdx[4];
|
||||
qNodeIdx[0] = elmNodeIndices[localElmNodeIndicesForFace[0]];
|
||||
@@ -272,8 +272,6 @@ cvf::ref<cvf::DrawableGeo>
|
||||
|
||||
const int* elmNodeIndices = part->connectivities( elmIdx );
|
||||
|
||||
// cvf::Vec3d displayOffset = part->boundingBox().min();
|
||||
|
||||
for ( int lfIdx = 0; lfIdx < faceCount; ++lfIdx )
|
||||
{
|
||||
int faceNodeCount = 0;
|
||||
|
||||
@@ -64,7 +64,7 @@ private:
|
||||
class RivFemPartGeometryGenerator : public cvf::Object
|
||||
{
|
||||
public:
|
||||
explicit RivFemPartGeometryGenerator( const RigFemPart* part );
|
||||
explicit RivFemPartGeometryGenerator( const RigFemPart* part, cvf::Vec3d displayOffset );
|
||||
~RivFemPartGeometryGenerator() override;
|
||||
|
||||
// Setup methods
|
||||
@@ -102,6 +102,7 @@ private:
|
||||
// Input
|
||||
cvf::cref<RigFemPart> m_part; // The part being processed
|
||||
cvf::cref<cvf::UByteArray> m_elmVisibility;
|
||||
cvf::Vec3d m_displayOffset;
|
||||
|
||||
// Created arrays
|
||||
cvf::ref<cvf::Vec3fArray> m_quadVertices;
|
||||
|
||||
@@ -61,18 +61,25 @@
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivFemPartPartMgr::RivFemPartPartMgr( const RigFemPart* grid )
|
||||
: m_surfaceGenerator( grid )
|
||||
, m_grid( grid )
|
||||
RivFemPartPartMgr::RivFemPartPartMgr( const RigFemPart* part, cvf::Vec3d displayOffset )
|
||||
: m_surfaceGenerator( part, displayOffset )
|
||||
, m_part( part )
|
||||
, m_opacityLevel( 1.0f )
|
||||
, m_defaultColor( cvf::Color3::WHITE )
|
||||
{
|
||||
CVF_ASSERT( grid );
|
||||
m_gridIdx = grid->elementPartId();
|
||||
CVF_ASSERT( part );
|
||||
m_partIdx = part->elementPartId();
|
||||
m_cellVisibility = new cvf::UByteArray;
|
||||
m_surfaceFacesTextureCoords = new cvf::Vec2fArray;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivFemPartPartMgr::~RivFemPartPartMgr()
|
||||
{
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -117,13 +124,13 @@ void RivFemPartPartMgr::generatePartGeometry( RivFemPartGeometryGenerator& geoBu
|
||||
}
|
||||
|
||||
cvf::ref<cvf::Part> part = new cvf::Part;
|
||||
part->setName( "FemPart " + cvf::String( m_gridIdx ) );
|
||||
part->setId( m_gridIdx ); // Use grid index as part ID
|
||||
part->setName( "FemPart " + cvf::String( m_partIdx ) );
|
||||
part->setId( m_partIdx ); // Use part index as part ID
|
||||
part->setDrawable( geo.p() );
|
||||
part->setTransform( m_scaleTransform.p() );
|
||||
|
||||
// Set mapping from triangle face index to element index
|
||||
cvf::ref<RivFemPickSourceInfo> si = new RivFemPickSourceInfo( m_gridIdx, geoBuilder.triangleToElementMapper() );
|
||||
cvf::ref<RivFemPickSourceInfo> si = new RivFemPickSourceInfo( m_partIdx, geoBuilder.triangleToElementMapper() );
|
||||
part->setSourceInfo( si.p() );
|
||||
|
||||
part->updateBoundingBox();
|
||||
@@ -150,7 +157,7 @@ void RivFemPartPartMgr::generatePartGeometry( RivFemPartGeometryGenerator& geoBu
|
||||
}
|
||||
|
||||
cvf::ref<cvf::Part> part = new cvf::Part;
|
||||
part->setName( "Grid mesh " + cvf::String( m_gridIdx ) );
|
||||
part->setName( "Grid mesh " + cvf::String( m_partIdx ) );
|
||||
part->setDrawable( geoMesh.p() );
|
||||
|
||||
part->setTransform( m_scaleTransform.p() );
|
||||
@@ -181,8 +188,11 @@ void RivFemPartPartMgr::appendPartsToModel( cvf::ModelBasicList* model )
|
||||
{
|
||||
CVF_ASSERT( model != nullptr );
|
||||
|
||||
if ( m_surfaceFaces.notNull() ) model->addPart( m_surfaceFaces.p() );
|
||||
if ( m_surfaceGridLines.notNull() ) model->addPart( m_surfaceGridLines.p() );
|
||||
if ( m_part->enabled() )
|
||||
{
|
||||
if ( m_surfaceFaces.notNull() ) model->addPart( m_surfaceFaces.p() );
|
||||
if ( m_surfaceGridLines.notNull() ) model->addPart( m_surfaceGridLines.p() );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -199,6 +209,7 @@ const RivFemPartGeometryGenerator* RivFemPartPartMgr::surfaceGenerator() const
|
||||
void RivFemPartPartMgr::updateCellColor( cvf::Color4f color )
|
||||
{
|
||||
if ( m_surfaceFaces.isNull() ) return;
|
||||
if ( !m_part->enabled() ) return;
|
||||
|
||||
// Set default effect
|
||||
caf::SurfaceEffectGenerator geometryEffgen( color, caf::PO_1 );
|
||||
@@ -234,6 +245,8 @@ void RivFemPartPartMgr::updateCellResultColor( size_t timeStepIndex, RimGeoMechC
|
||||
{
|
||||
CVF_ASSERT( cellResultColors );
|
||||
|
||||
if ( !m_part->enabled() ) return;
|
||||
|
||||
cvf::ref<cvf::Color3ubArray> surfaceFacesColorArray;
|
||||
|
||||
// Outer surface
|
||||
@@ -254,7 +267,7 @@ void RivFemPartPartMgr::updateCellResultColor( size_t timeStepIndex, RimGeoMechC
|
||||
}
|
||||
|
||||
const std::vector<float>& resultValues =
|
||||
caseData->femPartResults()->resultValues( resVarAddress, m_gridIdx, (int)timeStepIndex );
|
||||
caseData->femPartResults()->resultValues( resVarAddress, m_partIdx, (int)timeStepIndex );
|
||||
|
||||
const std::vector<size_t>* vxToResultMapping = nullptr;
|
||||
int vxCount = 0;
|
||||
@@ -329,10 +342,3 @@ void RivFemPartPartMgr::updateCellResultColor( size_t timeStepIndex, RimGeoMechC
|
||||
view->isLightingDisabled() );
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RivFemPartPartMgr::~RivFemPartPartMgr()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ class RigFemPart;
|
||||
class RivFemPartPartMgr : public cvf::Object
|
||||
{
|
||||
public:
|
||||
explicit RivFemPartPartMgr( const RigFemPart* femPart );
|
||||
explicit RivFemPartPartMgr( const RigFemPart* femPart, cvf::Vec3d displayOffset );
|
||||
~RivFemPartPartMgr() override;
|
||||
void setTransform( cvf::Transform* scaleTransform );
|
||||
void setCellVisibility( cvf::UByteArray* cellVisibilities );
|
||||
@@ -63,8 +63,8 @@ private:
|
||||
void generatePartGeometry( RivFemPartGeometryGenerator& geoBuilder );
|
||||
|
||||
private:
|
||||
int m_gridIdx;
|
||||
cvf::cref<RigFemPart> m_grid;
|
||||
int m_partIdx;
|
||||
cvf::cref<RigFemPart> m_part;
|
||||
|
||||
cvf::ref<cvf::Transform> m_scaleTransform;
|
||||
float m_opacityLevel;
|
||||
|
||||
@@ -50,9 +50,11 @@ void RivGeoMechPartMgr::clearAndSetReservoir( const RigGeoMechCaseData* geoMechC
|
||||
{
|
||||
const RigFemPartCollection* femParts = geoMechCase->femParts();
|
||||
|
||||
cvf::Vec3d displayOffset = femParts->boundingBox().min();
|
||||
|
||||
for ( int i = 0; i < femParts->partCount(); ++i )
|
||||
{
|
||||
m_femPartPartMgrs.push_back( new RivFemPartPartMgr( femParts->part( i ) ) );
|
||||
m_femPartPartMgrs.push_back( new RivFemPartPartMgr( femParts->part( i ), displayOffset ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -71,19 +73,19 @@ void RivGeoMechPartMgr::setTransform( cvf::Transform* scaleTransform )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivGeoMechPartMgr::setCellVisibility( size_t gridIndex, cvf::UByteArray* cellVisibilities )
|
||||
void RivGeoMechPartMgr::setCellVisibility( size_t partIndex, cvf::UByteArray* cellVisibilities )
|
||||
{
|
||||
CVF_ASSERT( gridIndex < m_femPartPartMgrs.size() );
|
||||
m_femPartPartMgrs[gridIndex]->setCellVisibility( cellVisibilities );
|
||||
CVF_ASSERT( partIndex < m_femPartPartMgrs.size() );
|
||||
m_femPartPartMgrs[partIndex]->setCellVisibility( cellVisibilities );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
cvf::ref<cvf::UByteArray> RivGeoMechPartMgr::cellVisibility( size_t gridIdx )
|
||||
cvf::ref<cvf::UByteArray> RivGeoMechPartMgr::cellVisibility( size_t partIdx )
|
||||
{
|
||||
CVF_ASSERT( gridIdx < m_femPartPartMgrs.size() );
|
||||
return m_femPartPartMgrs[gridIdx]->cellVisibility();
|
||||
CVF_ASSERT( partIdx < m_femPartPartMgrs.size() );
|
||||
return m_femPartPartMgrs[partIdx]->cellVisibility();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -122,13 +124,13 @@ void RivGeoMechPartMgr::appendGridPartsToModel( cvf::ModelBasicList* model )
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RivGeoMechPartMgr::appendGridPartsToModel( cvf::ModelBasicList* model, const std::vector<size_t>& gridIndices )
|
||||
void RivGeoMechPartMgr::appendGridPartsToModel( cvf::ModelBasicList* model, const std::vector<size_t>& partIndices )
|
||||
{
|
||||
for ( size_t i = 0; i < gridIndices.size(); ++i )
|
||||
for ( size_t i = 0; i < partIndices.size(); ++i )
|
||||
{
|
||||
if ( gridIndices[i] < m_femPartPartMgrs.size() )
|
||||
if ( partIndices[i] < m_femPartPartMgrs.size() )
|
||||
{
|
||||
m_femPartPartMgrs[gridIndices[i]]->appendPartsToModel( model );
|
||||
m_femPartPartMgrs[partIndices[i]]->appendPartsToModel( model );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,10 +202,11 @@ RivGeoMechPartMgr* RivGeoMechVizLogic::getUpdatedPartMgr( RivGeoMechPartMgrCache
|
||||
partMgrToUpdate->clearAndSetReservoir( caseData );
|
||||
}
|
||||
|
||||
partMgrToUpdate->setTransform( m_geomechView->scaleTransform() );
|
||||
|
||||
for ( int femPartIdx = 0; femPartIdx < partCount; ++femPartIdx )
|
||||
{
|
||||
cvf::ref<cvf::UByteArray> elmVisibility = partMgrToUpdate->cellVisibility( femPartIdx );
|
||||
partMgrToUpdate->setTransform( m_geomechView->scaleTransform() );
|
||||
|
||||
if ( pMgrKey.geometryType() == RANGE_FILTERED )
|
||||
{
|
||||
@@ -269,9 +270,12 @@ void RivGeoMechVizLogic::calculateCurrentTotalCellVisibility( cvf::UByteArray* t
|
||||
|
||||
if ( gridCount == 0 ) return;
|
||||
|
||||
RigFemPart* part = m_geomechView->femParts()->part( 0 );
|
||||
int elmCount = part->elementCount();
|
||||
|
||||
int elmCount = 0;
|
||||
for ( int i = 0; i < m_geomechView->femParts()->partCount(); i++ )
|
||||
{
|
||||
RigFemPart* part = m_geomechView->femParts()->part( i );
|
||||
elmCount += part->elementCount();
|
||||
}
|
||||
totalVisibility->resize( elmCount );
|
||||
totalVisibility->setAll( false );
|
||||
|
||||
@@ -282,10 +286,17 @@ void RivGeoMechVizLogic::calculateCurrentTotalCellVisibility( cvf::UByteArray* t
|
||||
CVF_ASSERT( partMgr );
|
||||
if ( partMgr )
|
||||
{
|
||||
cvf::ref<cvf::UByteArray> visibility = partMgr->cellVisibility( 0 );
|
||||
for ( int elmIdx = 0; elmIdx < elmCount; ++elmIdx )
|
||||
int elmOffset = 0;
|
||||
for ( int i = 0; i < m_geomechView->femParts()->partCount(); i++ )
|
||||
{
|
||||
( *totalVisibility )[elmIdx] |= ( *visibility )[elmIdx];
|
||||
RigFemPart* part = m_geomechView->femParts()->part( i );
|
||||
|
||||
cvf::ref<cvf::UByteArray> visibility = partMgr->cellVisibility( i );
|
||||
for ( int elmIdx = 0; elmIdx < part->elementCount(); ++elmIdx )
|
||||
{
|
||||
( *totalVisibility )[elmOffset + elmIdx] |= ( *visibility )[elmIdx];
|
||||
}
|
||||
elmOffset += part->elementCount();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user