mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
GeoMech: show deformations in grid view (#8123)
Enable support in geomech view to show grid deformations
This commit is contained in:
@@ -404,36 +404,42 @@ float RigFemPart::characteristicElementSize() const
|
||||
{
|
||||
if ( m_characteristicElementSize != std::numeric_limits<float>::infinity() ) return m_characteristicElementSize;
|
||||
|
||||
int elmsToAverageCount = 0;
|
||||
float sumMaxEdgeLength = 0;
|
||||
for ( int elmIdx = 0; elmIdx < elementCount(); elmIdx++ )
|
||||
std::vector<RigElementType> elementPriority = { HEX8P, HEX8 };
|
||||
|
||||
for ( auto elmType : elementPriority )
|
||||
{
|
||||
RigElementType eType = this->elementType( elmIdx );
|
||||
|
||||
if ( ( eType == HEX8P ) || ( eType == HEX8 ) )
|
||||
int elmsToAverageCount = 0;
|
||||
float sumMaxEdgeLength = 0;
|
||||
for ( int elmIdx = 0; elmIdx < elementCount(); elmIdx++ )
|
||||
{
|
||||
const int* elementConn = this->connectivities( elmIdx );
|
||||
cvf::Vec3f nodePos0 = this->nodes().coordinates[elementConn[0]];
|
||||
cvf::Vec3f nodePos1 = this->nodes().coordinates[elementConn[1]];
|
||||
cvf::Vec3f nodePos3 = this->nodes().coordinates[elementConn[3]];
|
||||
cvf::Vec3f nodePos4 = this->nodes().coordinates[elementConn[4]];
|
||||
RigElementType eType = this->elementType( elmIdx );
|
||||
|
||||
float l1 = ( nodePos1 - nodePos0 ).length();
|
||||
float l3 = ( nodePos3 - nodePos0 ).length();
|
||||
float l4 = ( nodePos4 - nodePos0 ).length();
|
||||
if ( eType == elmType )
|
||||
{
|
||||
const int* elementConn = this->connectivities( elmIdx );
|
||||
cvf::Vec3f nodePos0 = this->nodes().coordinates[elementConn[0]];
|
||||
cvf::Vec3f nodePos1 = this->nodes().coordinates[elementConn[1]];
|
||||
cvf::Vec3f nodePos3 = this->nodes().coordinates[elementConn[3]];
|
||||
cvf::Vec3f nodePos4 = this->nodes().coordinates[elementConn[4]];
|
||||
|
||||
float maxLength = l1 > l3 ? l1 : l3;
|
||||
maxLength = maxLength > l4 ? maxLength : l4;
|
||||
float l1 = ( nodePos1 - nodePos0 ).length();
|
||||
float l3 = ( nodePos3 - nodePos0 ).length();
|
||||
float l4 = ( nodePos4 - nodePos0 ).length();
|
||||
|
||||
sumMaxEdgeLength += maxLength;
|
||||
++elmsToAverageCount;
|
||||
float maxLength = l1 > l3 ? l1 : l3;
|
||||
maxLength = maxLength > l4 ? maxLength : l4;
|
||||
|
||||
sumMaxEdgeLength += maxLength;
|
||||
++elmsToAverageCount;
|
||||
}
|
||||
}
|
||||
if ( elmsToAverageCount > 0 )
|
||||
{
|
||||
m_characteristicElementSize = sumMaxEdgeLength / elmsToAverageCount;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
CVF_ASSERT( elmsToAverageCount );
|
||||
|
||||
m_characteristicElementSize = sumMaxEdgeLength / elmsToAverageCount;
|
||||
|
||||
return m_characteristicElementSize;
|
||||
}
|
||||
|
||||
|
||||
@@ -155,3 +155,24 @@ bool RigGeoMechCaseData::readFemParts( std::string* errorMessage, const std::vec
|
||||
*errorMessage = std::string( "Could not read FEM parts" );
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RigGeoMechCaseData::readDisplacements( std::string* errorMessage,
|
||||
int partId,
|
||||
int timeStep,
|
||||
std::vector<cvf::Vec3f>* displacements )
|
||||
{
|
||||
CVF_ASSERT( errorMessage );
|
||||
#ifdef USE_ODB_API
|
||||
if ( m_readerInterface.notNull() && m_readerInterface->isOpen() )
|
||||
{
|
||||
m_readerInterface->readDisplacements( partId, timeStep, 1, displacements );
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
*errorMessage = std::string( "Could not read displacements." );
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -41,6 +41,8 @@ public:
|
||||
bool open( std::string* errorMessage );
|
||||
bool readTimeSteps( std::string* errorMessage, std::vector<std::string>* stepNames );
|
||||
bool readFemParts( std::string* errorMessage, const std::vector<size_t>& timeStepFilter = std::vector<size_t>() );
|
||||
bool readDisplacements( std::string* errorMessage, int partId, int timeStep, std::vector<cvf::Vec3f>* displacements );
|
||||
|
||||
RigFemPartCollection* femParts();
|
||||
const RigFemPartCollection* femParts() const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user