Skip to content

Commit

Permalink
Work in progress
Browse files Browse the repository at this point in the history
Some cleanup and refactoring
Keep track of steps when parsing file
Keep list of include files to pick up  properties later
  • Loading branch information
jonjenssen committed Dec 7, 2023
1 parent 0a2f2da commit 3fb69c4
Show file tree
Hide file tree
Showing 25 changed files with 206 additions and 123 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ cvf::Vec3d RicCreateWellTargetsPickEventHandler::findHexElementIntersection( gsl
RigFemPart* femPart = geoMechView->femParts()->part( femPartIndex );
RigElementType elType = femPart->elementType( elementIndex );

if ( elType == HEX8 || elType == HEX8P )
if ( RigFemTypes::is8NodeElement( elType ) )
{
cellIndex = elementIndex;
const RigFemPartGrid* femGrid = femPart->getOrCreateStructGrid();
Expand Down
4 changes: 2 additions & 2 deletions ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemPart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ float RigFemPart::characteristicElementSize() const
{
if ( m_characteristicElementSize != std::numeric_limits<float>::infinity() ) return m_characteristicElementSize;

std::vector<RigElementType> elementPriority = { HEX8P, HEX8 };
std::vector<RigElementType> elementPriority = { RigElementType::HEX8P, RigElementType::HEX8 };

for ( auto elmType : elementPriority )
{
Expand Down Expand Up @@ -604,7 +604,7 @@ size_t RigFemPart::resultValueIdxFromResultPosType( RigFemResultPosEnum resultPo
bool RigFemPart::isHexahedron( size_t elementIdx ) const
{
RigElementType elType = elementType( elementIdx );
return elType == HEX8 || elType == HEX8P;
return RigFemTypes::is8NodeElement( elType );
}

//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ void RigFemPartGrid::generateStructGridData()
RigElementType elementType = m_femPart->elementType( elmIdx );
size_t i, j, k;
bool validIndex = ijkFromCellIndex( elmIdx, &i, &j, &k );
if ( elementType == HEX8P && validIndex )
if ( ( elementType == RigElementType::HEX8P ) && validIndex )
{
if ( i < min.x() ) min.x() = i;
if ( j < min.y() ) min.y() = j;
Expand Down Expand Up @@ -254,7 +254,7 @@ cvf::Vec3i RigFemPartGrid::findMainIJKFaces( int elementIndex ) const
// Record three independent main direction vectors for the element, and what face they are created from
cvf::Vec3f mainElmDirections[3];
int mainElmDirOriginFaces[3];
if ( eType == HEX8 || eType == HEX8P )
if ( RigFemTypes::is8NodeElement( eType ) )
{
mainElmDirections[0] = normals[0] - normals[1]; // To get a better "average" direction vector
mainElmDirections[1] = normals[2] - normals[3];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorEnIpPorBar::calculate( int p
{
RigElementType elmType = femPart->elementType( elmIdx );

if ( elmType == HEX8P )
if ( elmType == RigElementType::HEX8P )
{
int elmNodeCount = RigFemTypes::elementNodeCount( elmType );
for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ void RigFemPartResultCalculatorGamma::calculateGammaFromFrames( int

int elmNodeCount = RigFemTypes::elementNodeCount( femPart->elementType( elmIdx ) );

if ( elmType == HEX8P )
if ( elmType == RigElementType::HEX8P )
{
for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorInitialPorosity::calculate(

int elmNodeCount = RigFemTypes::elementNodeCount( femPart->elementType( elmIdx ) );

if ( elmType == HEX8P )
if ( elmType == RigElementType::HEX8P )
{
for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorNodalGradients::calculate( i
for ( int elmIdx : elements )
{
RigElementType elmType = femPart->elementType( elmIdx );
if ( elmType == HEX8P )
if ( elmType == RigElementType::HEX8P )
{
// Find the corner coordinates and values for the node
std::array<cvf::Vec3d, 8> hexCorners;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorNormalSE::calculate( int par

int elmNodeCount = RigFemTypes::elementNodeCount( femPart->elementType( elmIdx ) );

if ( elmType == HEX8P )
if ( elmType == RigElementType::HEX8P )
{
for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorNormalST::calculate( int par

int elmNodeCount = RigFemTypes::elementNodeCount( femPart->elementType( elmIdx ) );

if ( elmType == HEX8P )
if ( elmType == RigElementType::HEX8P )
{
for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorNormalized::calculate( int p
for ( int elmIdx = 0; elmIdx < femPart->elementCount(); ++elmIdx )
{
RigElementType elmType = femPart->elementType( elmIdx );
if ( elmType != HEX8 && elmType != HEX8P ) continue;
if ( !RigFemTypes::is8NodeElement( elmType ) ) continue;

bool porRegion = false;
for ( int elmLocalNodeIdx = 0; elmLocalNodeIdx < 8; ++elmLocalNodeIdx )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorPoreCompressibility::calcula

int elmNodeCount = RigFemTypes::elementNodeCount( femPart->elementType( elmIdx ) );

if ( elmType == HEX8P )
if ( elmType == RigElementType::HEX8P )
{
for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorPorosityPermeability::calcul

int elmNodeCount = RigFemTypes::elementNodeCount( femPart->elementType( elmIdx ) );

if ( elmType == HEX8P )
if ( elmType == RigElementType::HEX8P )
{
for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorShearSE::calculate( int part

int elmNodeCount = RigFemTypes::elementNodeCount( femPart->elementType( elmIdx ) );

if ( elmType == HEX8P )
if ( elmType == RigElementType::HEX8P )
{
for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorStressGradients::calculate(
const int* cornerIndices = femPart->connectivities( elmIdx );
RigElementType elmType = femPart->elementType( elmIdx );

if ( elmType != HEX8P && elmType != HEX8 ) continue;
if ( !RigFemTypes::is8NodeElement( elmType ) ) continue;

// Find the corner coordinates for element
std::array<cvf::Vec3d, 8> hexCorners;
Expand Down
76 changes: 59 additions & 17 deletions ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ int RigFemTypes::elementNodeCount( RigElementType elmType )
{
static int elementTypeCounts[3] = { 8, 8, 4 };

return elementTypeCounts[elmType];
return elementTypeCounts[(unsigned int)elmType];
}

//--------------------------------------------------------------------------------------------------
Expand All @@ -40,7 +40,7 @@ int RigFemTypes::elementFaceCount( RigElementType elmType )
{
const static int elementFaceCounts[3] = { 6, 6, 1 };

return elementFaceCounts[elmType];
return elementFaceCounts[(unsigned int)elmType];
}

//--------------------------------------------------------------------------------------------------
Expand All @@ -63,12 +63,12 @@ const int* RigFemTypes::localElmNodeIndicesForFace( RigElementType elmType, int

switch ( elmType )
{
case HEX8:
case HEX8P:
case RigElementType::HEX8:
case RigElementType::HEX8P:
( *faceNodeCount ) = 4;
return HEX8_Faces[faceIdx];
break;
case CAX4:
case RigElementType::CAX4:
( *faceNodeCount ) = 4;
return CAX4_Faces;
break;
Expand All @@ -86,11 +86,11 @@ int RigFemTypes::oppositeFace( RigElementType elmType, int faceIdx )

switch ( elmType )
{
case HEX8:
case HEX8P:
case RigElementType::HEX8:
case RigElementType::HEX8P:
return HEX8_OppositeFaces[faceIdx];
break;
case CAX4:
case RigElementType::CAX4:
return faceIdx;
break;
default:
Expand All @@ -111,11 +111,11 @@ const int* RigFemTypes::localElmNodeToIntegrationPointMapping( RigElementType el

switch ( elmType )
{
case HEX8:
case HEX8P:
case RigElementType::HEX8:
case RigElementType::HEX8P:
return HEX8_Mapping;
break;
case CAX4:
case RigElementType::CAX4:
return HEX8_Mapping; // First four is identical to HEX8
break;
default:
Expand All @@ -129,26 +129,68 @@ const int* RigFemTypes::localElmNodeToIntegrationPointMapping( RigElementType el
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RigFemTypes::elementTypeText( RigElementType elemType )
std::string RigFemTypes::elementTypeText( RigElementType elemType )
{
QString txt = "UNKNOWN_ELM_TYPE";
std::string txt = "UNKNOWN_ELM_TYPE";

switch ( elemType )
{
case HEX8:
case RigElementType::HEX8:
txt = "HEX8";
break;
case HEX8P:
case RigElementType::HEX8P:
txt = "HEX8P";
break;
case CAX4:
case RigElementType::CAX4:
txt = "CAX4";
break;
case UNKNOWN_ELM_TYPE:
case RigElementType::UNKNOWN_ELM_TYPE:
break;
default:
break;
}

return txt;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::map<std::string, RigElementType> RigFemTypes::femTypeMap()
{
std::map<std::string, RigElementType> typeMap;
typeMap["C3D8R"] = RigElementType::HEX8;
typeMap["C3D8"] = RigElementType::HEX8;
typeMap["C3D8P"] = RigElementType::HEX8P;
typeMap["CAX4"] = RigElementType::CAX4;
typeMap["C3D20RT"] = RigElementType::HEX8;
typeMap["C3D8RT"] = RigElementType::HEX8;
typeMap["C3D8T"] = RigElementType::HEX8;

return typeMap;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigElementType RigFemTypes::toRigElementType( const std::string odbTypeName )
{
static std::map<std::string, RigElementType> odbElmTypeToRigElmTypeMap = femTypeMap();

std::map<std::string, RigElementType>::iterator it = odbElmTypeToRigElmTypeMap.find( odbTypeName );

if ( it == odbElmTypeToRigElmTypeMap.end() )
{
return RigElementType::UNKNOWN_ELM_TYPE;
}

return it->second;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigFemTypes::is8NodeElement( RigElementType elmType )
{
return ( elmType == RigElementType::HEX8 ) || ( elmType == RigElementType::HEX8P );
}
22 changes: 14 additions & 8 deletions ApplicationLibCode/GeoMech/GeoMechDataModel/RigFemTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@

#pragma once

class QString;
#include <map>
#include <string>

enum RigElementType
enum class RigElementType
{
HEX8,
HEX8P,
Expand All @@ -32,10 +33,15 @@ enum RigElementType
class RigFemTypes
{
public:
static int elementNodeCount( RigElementType elmType );
static int elementFaceCount( RigElementType elmType );
static const int* localElmNodeIndicesForFace( RigElementType elmType, int faceIdx, int* faceNodeCount );
static int oppositeFace( RigElementType elmType, int faceIdx );
static const int* localElmNodeToIntegrationPointMapping( RigElementType elmType );
static QString elementTypeText( RigElementType elemType );
static int elementNodeCount( RigElementType elmType );
static int elementFaceCount( RigElementType elmType );
static const int* localElmNodeIndicesForFace( RigElementType elmType, int faceIdx, int* faceNodeCount );
static int oppositeFace( RigElementType elmType, int faceIdx );
static const int* localElmNodeToIntegrationPointMapping( RigElementType elmType );
static std::string elementTypeText( RigElementType elemType );
static RigElementType toRigElementType( const std::string odbTypeName );
static bool is8NodeElement( RigElementType elmType );

private:
static std::map<std::string, RigElementType> femTypeMap();
};
Loading

0 comments on commit 3fb69c4

Please sign in to comment.