#914 Added calculation of element face aligned stress

This commit is contained in:
Jacob Støren
2016-10-19 12:22:13 +02:00
parent d82eb6a774
commit d8247c2ac6
14 changed files with 286 additions and 71 deletions

View File

@@ -166,40 +166,75 @@ void RivFemElmVisibilityCalculator::computePropertyVisibility(cvf::UByteArray* c
// Do a "Hack" to use elm nodal and not nodal POR results
if (resVarAddress.resultPosType == RIG_NODAL && resVarAddress.fieldName == "POR-Bar") resVarAddress.resultPosType = RIG_ELEMENT_NODAL;
#pragma omp parallel for schedule(dynamic)
for (int cellIndex = 0; cellIndex < elementCount; cellIndex++)
if (resVarAddress.resultPosType != RIG_ELEMENT_NODAL_FACE)
{
if ( (*cellVisibility)[cellIndex] )
#pragma omp parallel for schedule(dynamic)
for (int cellIndex = 0; cellIndex < elementCount; cellIndex++)
{
RigElementType eType = grid->elementType(cellIndex);
int elmNodeCount = RigFemTypes::elmentNodeCount(eType);
const int* elmNodeIndices = grid->connectivities(cellIndex);
for(int enIdx = 0; enIdx < elmNodeCount; ++enIdx)
if ( (*cellVisibility)[cellIndex] )
{
size_t resultValueIndex = cvf::UNDEFINED_SIZE_T;
if (resVarAddress.resultPosType == RIG_NODAL)
{
resultValueIndex = elmNodeIndices[enIdx];
}
else
{
resultValueIndex = grid->elementNodeResultIdx(cellIndex, enIdx);
}
RigElementType eType = grid->elementType(cellIndex);
int elmNodeCount = RigFemTypes::elmentNodeCount(eType);
double scalarValue = resVals[resultValueIndex];
if (lowerBound <= scalarValue && scalarValue <= upperBound)
const int* elmNodeIndices = grid->connectivities(cellIndex);
for(int enIdx = 0; enIdx < elmNodeCount; ++enIdx)
{
if (filterType == RimCellFilter::EXCLUDE)
size_t resultValueIndex = cvf::UNDEFINED_SIZE_T;
if (resVarAddress.resultPosType == RIG_NODAL)
{
(*cellVisibility)[cellIndex] = false;
resultValueIndex = elmNodeIndices[enIdx];
}
else
{
resultValueIndex = grid->elementNodeResultIdx(cellIndex, enIdx);
}
double scalarValue = resVals[resultValueIndex];
if (lowerBound <= scalarValue && scalarValue <= upperBound)
{
if (filterType == RimCellFilter::EXCLUDE)
{
(*cellVisibility)[cellIndex] = false;
}
}
else
{
if (filterType == RimCellFilter::INCLUDE)
{
(*cellVisibility)[cellIndex] = false;
}
}
}
else
}
}
}
else
{
#pragma omp parallel for schedule(dynamic)
for(int cellIndex = 0; cellIndex < elementCount; cellIndex++)
{
if((*cellVisibility)[cellIndex])
{
RigElementType eType = grid->elementType(cellIndex);
int elmNodeCount = RigFemTypes::elmentNodeCount(eType);
const int* elmNodeIndices = grid->connectivities(cellIndex);
for(int fpIdx = 0; fpIdx < 24; ++fpIdx)
{
if (filterType == RimCellFilter::INCLUDE)
double scalarValue = resVals[cellIndex*24 + fpIdx];
if(lowerBound <= scalarValue && scalarValue <= upperBound)
{
(*cellVisibility)[cellIndex] = false;
if(filterType == RimCellFilter::EXCLUDE)
{
(*cellVisibility)[cellIndex] = false;
}
}
else
{
if(filterType == RimCellFilter::INCLUDE)
{
(*cellVisibility)[cellIndex] = false;
}
}
}
}

View File

@@ -156,6 +156,7 @@ void RivFemPartGeometryGenerator::computeArrays()
m_quadVerticesToNodeIdx.clear();
m_quadVerticesToGlobalElmNodeIdx.clear();
m_quadVerticesToGlobalElmFaceNodeIdx.clear();
trianglesToElements.clear();
trianglesToElementFaces.clear();
@@ -179,6 +180,8 @@ void RivFemPartGeometryGenerator::computeArrays()
int faceCount = RigFemTypes::elmentFaceCount(eType);
const int* elmNodeIndices = m_part->connectivities(elmIdx);
int elmNodFaceResIdxElmStart = elmIdx * 24; // HACK should get from part
for (int lfIdx = 0; lfIdx < faceCount; ++lfIdx)
{
@@ -194,8 +197,6 @@ void RivFemPartGeometryGenerator::computeArrays()
if (faceNodeCount == 4)
{
// Todo: Needs to get rid of opposite faces
const cvf::Vec3f* quadVxs[4];
quadVxs[0] = &(nodeCoordinates[ elmNodeIndices[localElmNodeIndicesForFace[0]] ]);
@@ -232,6 +233,13 @@ void RivFemPartGeometryGenerator::computeArrays()
m_quadVerticesToGlobalElmNodeIdx.push_back(qElmNodeResIdx[2]);
m_quadVerticesToGlobalElmNodeIdx.push_back(qElmNodeResIdx[3]);
int elmNodFaceResIdxFaceStart = elmNodFaceResIdxElmStart + lfIdx*4; // HACK
m_quadVerticesToGlobalElmFaceNodeIdx.push_back(elmNodFaceResIdxFaceStart + 0);
m_quadVerticesToGlobalElmFaceNodeIdx.push_back(elmNodFaceResIdxFaceStart + 1);
m_quadVerticesToGlobalElmFaceNodeIdx.push_back(elmNodFaceResIdxFaceStart + 2);
m_quadVerticesToGlobalElmFaceNodeIdx.push_back(elmNodFaceResIdxFaceStart + 3);
trianglesToElements.push_back(elmIdx);
trianglesToElements.push_back(elmIdx);
trianglesToElementFaces.push_back(lfIdx);

View File

@@ -62,6 +62,7 @@ public:
const std::vector<size_t>& quadVerticesToNodeIdxMapping() const { return m_quadVerticesToNodeIdx;}
const std::vector<size_t>& quadVerticesToGlobalElmNodeIdx() const { return m_quadVerticesToGlobalElmNodeIdx;}
const std::vector<size_t>& quadVerticesToGlobalElmFaceNodeIdx() const { return m_quadVerticesToGlobalElmFaceNodeIdx; }
RivFemPartTriangleToElmMapper* triangleToElementMapper() { return m_triangleMapper.p();}
@@ -82,6 +83,7 @@ private:
//cvf::ref<cvf::Vec3fArray> m_triangleVertices; // If needed, we will do it like this, I think
std::vector<size_t> m_quadVerticesToNodeIdx;
std::vector<size_t> m_quadVerticesToGlobalElmNodeIdx;
std::vector<size_t> m_quadVerticesToGlobalElmFaceNodeIdx;
// Mappings
cvf::ref<RivFemPartTriangleToElmMapper> m_triangleMapper;

View File

@@ -241,6 +241,7 @@ void RivFemPartPartMgr::updateCellResultColor(size_t timeStepIndex, RimGeoMechCe
const std::vector<float>& resultValues = caseData->femPartResults()->resultValues(resVarAddress, m_gridIdx, (int)timeStepIndex);
const std::vector<size_t>* vxToResultMapping = NULL;
int vxCount = 0;
if (resVarAddress.resultPosType == RIG_NODAL)
{
@@ -252,8 +253,13 @@ void RivFemPartPartMgr::updateCellResultColor(size_t timeStepIndex, RimGeoMechCe
{
vxToResultMapping = &(m_surfaceGenerator.quadVerticesToGlobalElmNodeIdx());
}
else if(resVarAddress.resultPosType == RIG_ELEMENT_NODAL_FACE)
{
vxToResultMapping = &(m_surfaceGenerator.quadVerticesToGlobalElmFaceNodeIdx());
}
m_surfaceFacesTextureCoords->resize(vxToResultMapping->size());
vxCount = static_cast<int>(vxToResultMapping->size());
m_surfaceFacesTextureCoords->resize(vxCount);
if (resultValues.size() == 0)
{
@@ -263,12 +269,10 @@ void RivFemPartPartMgr::updateCellResultColor(size_t timeStepIndex, RimGeoMechCe
{
cvf::Vec2f* rawPtr = m_surfaceFacesTextureCoords->ptr();
int vxCount = static_cast<int>(vxToResultMapping->size());
#pragma omp parallel for schedule(dynamic)
for (int quadStartIdx = 0; quadStartIdx < vxCount; quadStartIdx += 4)
{
float resultValue1 = resultValues[(*vxToResultMapping)[quadStartIdx]];
float resultValue1 = resultValues[(*vxToResultMapping)[quadStartIdx + 0]];
float resultValue2 = resultValues[(*vxToResultMapping)[quadStartIdx + 1]];
float resultValue3 = resultValues[(*vxToResultMapping)[quadStartIdx + 2]];
float resultValue4 = resultValues[(*vxToResultMapping)[quadStartIdx + 3]];