GeoMech: show deformations in grid view (#8123)

Enable support in geomech view to show grid deformations
This commit is contained in:
jonjenssen
2021-10-07 02:12:42 +02:00
committed by GitHub
parent 0e620c8408
commit 7b78c2d35b
17 changed files with 361 additions and 51 deletions

View File

@@ -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;
}