Got elements and nodes from odb in the unit test

This commit is contained in:
Jacob Støren
2015-04-23 15:43:11 +02:00
parent 4737807b7b
commit 6dad519f30
5 changed files with 108 additions and 12 deletions

View File

@@ -35,3 +35,31 @@ RigFemPart::~RigFemPart()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFemPart::preAllocateElementStorage(int elementCount)
{
m_elementId.reserve(elementCount);
m_elementTypes.reserve(elementCount);
m_elementConnectivityStartIndices.reserve(elementCount);
m_allAlementConnectivities.reserve(elementCount*8);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigFemPart::appendElement(RigElementType elmType, int id, const int* connectivities)
{
m_elementId.push_back(id);
m_elementTypes.push_back(elmType);
m_elementConnectivityStartIndices.push_back(m_allAlementConnectivities.size());
int nodeCount = elmentNodeCount(elmType);
for (int lnIdx = 0; lnIdx < nodeCount; ++lnIdx)
{
m_allAlementConnectivities.push_back(connectivities[lnIdx]);
}
}

View File

@@ -38,13 +38,13 @@ class RigFemPart : public cvf::Object
public:
RigFemPart();
virtual ~RigFemPart();
int appendElement(RigElementType elmType, int id, const int* connectivities);
void preAllocateElementStorage(int elementCount);
void appendElement(RigElementType elmType, int id, const int* connectivities);
size_t elementCount() const { return m_elementId.size(); }
int elmId(size_t index) const { return m_elementId[index]; }
RigElementType elmentType(size_t index) const { return m_elementTypes[index]; }
RigElementType elementType(size_t index) const { return m_elementTypes[index]; }
const int* connectivities(size_t index) const { return &m_allAlementConnectivities[m_elementConnectivityStartIndices[index]];}
RigFemPartNodes& nodes() {return m_nodes;}

View File

@@ -18,22 +18,24 @@
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <assert.h>
enum RigElementType
{
HEX8
HEX8,
CAX4
};
static const int elmentNodeCount(RigElementType elmType)
{
static int elementTypeCounts[1] = {8};
static int elementTypeCounts[2] = {8,4};
return elementTypeCounts[elmType];
}
static const int elmentFaceCount(RigElementType elmType)
{
const static int elementFaceCounts[1] = {6};
const static int elementFaceCounts[2] = {6, 1};
return elementFaceCounts[elmType];
}
@@ -51,7 +53,22 @@ static const int elmentFaceCount(RigElementType elmType)
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 };
(*faceNodeCount) = 4;
return HEX8_Faces[faceIdx];
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;
}