Moved the element type functions into a static class

This commit is contained in:
Jacob Støren 2015-04-27 15:04:05 +02:00
parent c0217a68a4
commit 8be93ae448
6 changed files with 90 additions and 48 deletions

View File

@ -11,6 +11,7 @@ add_library( ${PROJECT_NAME}
RigFemPart.h RigFemPart.h
RigFemPart.cpp RigFemPart.cpp
RigFemTypes.h RigFemTypes.h
RigFemTypes.cpp
RigGeoMechCaseData.cpp RigGeoMechCaseData.cpp
RigGeoMechCaseData.h RigGeoMechCaseData.h
RigFemPartCollection.cpp RigFemPartCollection.cpp

View File

@ -58,7 +58,7 @@ void RigFemPart::appendElement(RigElementType elmType, int id, const int* connec
m_elementTypes.push_back(elmType); m_elementTypes.push_back(elmType);
m_elementConnectivityStartIndices.push_back(m_allAlementConnectivities.size()); m_elementConnectivityStartIndices.push_back(m_allAlementConnectivities.size());
int nodeCount = elmentNodeCount(elmType); int nodeCount = RigFemTypes::elmentNodeCount(elmType);
for (int lnIdx = 0; lnIdx < nodeCount; ++lnIdx) for (int lnIdx = 0; lnIdx < nodeCount; ++lnIdx)
{ {
m_allAlementConnectivities.push_back(connectivities[lnIdx]); m_allAlementConnectivities.push_back(connectivities[lnIdx]);

View File

@ -0,0 +1,79 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2015- Statoil ASA
// Copyright (C) 2015- Ceetron Solutions AS
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RigFemTypes.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const int RigFemTypes::elmentNodeCount(RigElementType elmType)
{
static int elementTypeCounts[2] ={ 8, 4 };
return elementTypeCounts[elmType];
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const int RigFemTypes::elmentFaceCount(RigElementType elmType)
{
const static int elementFaceCounts[2] ={ 6, 1 };
return elementFaceCounts[elmType];
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
// HEX8
// 7---------6
// /| /| |k
// / | / | | /j
// 4---------5 | |/
// | 3------|--2 *---i
// | / | /
// |/ |/
// 0---------1
const int* RigFemTypes::elementLocalFaceIndices(RigElementType elmType, int faceIdx, int* faceNodeCount)
{
static const int HEX8_Faces[6][4] ={ { 1, 2, 6, 5 }, { 0, 4, 7, 3 }, { 3, 7, 6, 2 }, { 0, 1, 5, 4 }, { 4, 5, 6, 7 }, { 0, 3, 2, 1 } };
static const int CAX4_Faces[4] ={ 0, 1, 2, 3 };
switch (elmType)
{
case HEX8:
(*faceNodeCount) = 4;
return HEX8_Faces[faceIdx];
break;
case CAX4:
(*faceNodeCount) = 4;
return CAX4_Faces;
break;
default:
assert(false); // Element type not supported
break;
}
return CAX4_Faces;
}

View File

@ -26,49 +26,11 @@ enum RigElementType
CAX4 CAX4
}; };
static const int elmentNodeCount(RigElementType elmType) class RigFemTypes
{ {
static int elementTypeCounts[2] = {8,4}; public:
static const int elmentNodeCount(RigElementType elmType);
static const int elmentFaceCount(RigElementType elmType);
static const int* elementLocalFaceIndices(RigElementType elmType, int faceIdx, int* faceNodeCount);
return elementTypeCounts[elmType]; };
}
static const int elmentFaceCount(RigElementType elmType)
{
const static int elementFaceCounts[2] = {6, 1};
return elementFaceCounts[elmType];
}
// HEX8
// 7---------6
// /| /| |k
// / | / | | /j
// 4---------5 | |/
// | 3------|--2 *---i
// | / | /
// |/ |/
// 0---------1
static const int* elementLocalFaceIndices(RigElementType elmType, int faceIdx, int* faceNodeCount)
{
static const int HEX8_Faces[6][4] = { {1, 2, 6, 5 }, {0,4,7,3}, {3,7,6,2}, {0,1,5,4}, {4,5,6,7} ,{0,3,2,1} };
static const int CAX4_Faces[4] = {0, 1, 2, 3 };
switch (elmType)
{
case HEX8:
(*faceNodeCount) = 4;
return HEX8_Faces[faceIdx];
break;
case CAX4:
(*faceNodeCount) = 4;
return CAX4_Faces;
break;
default:
assert(false); // Element type not supported
break;
}
return CAX4_Faces;
}

View File

@ -162,7 +162,7 @@ void RivFemPartGeometryGenerator::computeArrays()
if (m_elmVisibility.isNull() || (*m_elmVisibility)[elmIdx]) if (m_elmVisibility.isNull() || (*m_elmVisibility)[elmIdx])
{ {
RigElementType eType = m_part->elementType(elmIdx); RigElementType eType = m_part->elementType(elmIdx);
int faceCount = elmentFaceCount(eType); int faceCount = RigFemTypes::elmentFaceCount(eType);
int elmQuadCount = 0; int elmQuadCount = 0;
const int* elmNodeIndices = m_part->connectivities(elmIdx); const int* elmNodeIndices = m_part->connectivities(elmIdx);
@ -170,7 +170,7 @@ void RivFemPartGeometryGenerator::computeArrays()
for (int lfIdx = 0; lfIdx < faceCount; ++lfIdx) for (int lfIdx = 0; lfIdx < faceCount; ++lfIdx)
{ {
int faceNodeCount = 0; int faceNodeCount = 0;
const int* elmLocalFaceIndices = elementLocalFaceIndices(eType, lfIdx, &faceNodeCount); const int* elmLocalFaceIndices = RigFemTypes::elementLocalFaceIndices(eType, lfIdx, &faceNodeCount);
if (faceNodeCount == 4) if (faceNodeCount == 4)
{ {
#if 0 #if 0

View File

@ -111,7 +111,7 @@ void readOdbFile(const std::string& fileName, RigFemPartCollection* femParts)
int nodeCount = 0; int nodeCount = 0;
const int* idBasedConnectivities = odbElm.connectivity(nodeCount); const int* idBasedConnectivities = odbElm.connectivity(nodeCount);
CVF_TIGHT_ASSERT(nodeCount == elmentNodeCount(elmType)); CVF_TIGHT_ASSERT(nodeCount == RigFemTypes::elmentNodeCount(elmType));
indexBasedConnectivities.resize(nodeCount); indexBasedConnectivities.resize(nodeCount);
for (int lnIdx = 0; lnIdx < nodeCount; ++lnIdx) for (int lnIdx = 0; lnIdx < nodeCount; ++lnIdx)