#914 Transformed stress on intersection Box is working

This commit is contained in:
Jacob Støren
2016-10-20 16:09:27 +02:00
parent 159bbbe5e6
commit b4c6277e72
8 changed files with 71 additions and 128 deletions

View File

@@ -113,6 +113,19 @@ const std::vector<RivIntersectionVertexWeights>& RivIntersectionBoxGeometryGener
return m_triVxToCellCornerWeights; return m_triVxToCellCornerWeights;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const cvf::Vec3fArray* RivIntersectionBoxGeometryGenerator::triangleVxes() const
{
CVF_ASSERT(m_triangleVxes->size());
return m_triangleVxes.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class Box class Box
{ {

View File

@@ -55,6 +55,7 @@ public:
// Mapping between cells and geometry // Mapping between cells and geometry
const std::vector<size_t>& triangleToCellIndex() const; const std::vector<size_t>& triangleToCellIndex() const;
const std::vector<RivIntersectionVertexWeights>& triangleVxToCellCornerInterpolationWeights() const; const std::vector<RivIntersectionVertexWeights>& triangleVxToCellCornerInterpolationWeights() const;
const cvf::Vec3fArray* triangleVxes() const;
const RimIntersectionBox* intersectionBox() const; const RimIntersectionBox* intersectionBox() const;

View File

@@ -49,6 +49,7 @@
#include "cvfRenderState_FF.h" #include "cvfRenderState_FF.h"
#include "cvfRenderStateDepth.h" #include "cvfRenderStateDepth.h"
#include "cvfRenderStatePoint.h" #include "cvfRenderStatePoint.h"
#include "RivIntersectionPartMgr.h"
@@ -131,7 +132,7 @@ void RivIntersectionBoxPartMgr::updateCellResultColor(size_t timeStepIndex)
cellResultColors); cellResultColors);
} }
RivIntersectionBoxPartMgr::calculateEclipseTextureCoordinates(m_intersectionBoxFacesTextureCoords.p(), RivIntersectionPartMgr::calculateEclipseTextureCoordinates(m_intersectionBoxFacesTextureCoords.p(),
m_intersectionBoxGenerator->triangleToCellIndex(), m_intersectionBoxGenerator->triangleToCellIndex(),
resultAccessor.p(), resultAccessor.p(),
mapper); mapper);
@@ -159,21 +160,38 @@ void RivIntersectionBoxPartMgr::updateCellResultColor(size_t timeStepIndex)
RigFemResultAddress resVarAddress = cellResultColors->resultAddress(); RigFemResultAddress resVarAddress = cellResultColors->resultAddress();
// Do a "Hack" to show elm nodal and not nodal POR results
if (resVarAddress.resultPosType == RIG_NODAL && resVarAddress.fieldName == "POR-Bar") resVarAddress.resultPosType = RIG_ELEMENT_NODAL;
const std::vector<RivIntersectionVertexWeights> &vertexWeights = m_intersectionBoxGenerator->triangleVxToCellCornerInterpolationWeights(); const std::vector<RivIntersectionVertexWeights> &vertexWeights = m_intersectionBoxGenerator->triangleVxToCellCornerInterpolationWeights();
const std::vector<float>& resultValues = caseData->femPartResults()->resultValues(resVarAddress, 0, (int)timeStepIndex);
bool isElementNodalResult = !(resVarAddress.resultPosType == RIG_NODAL);
RigFemPart* femPart = caseData->femParts()->part(0);
const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper(); const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper();
if (!(resVarAddress.resultPosType == RIG_ELEMENT_NODAL_FACE) )
{
// Do a "Hack" to show elm nodal and not nodal POR results
if ( resVarAddress.resultPosType == RIG_NODAL && resVarAddress.fieldName == "POR-Bar" ) resVarAddress.resultPosType = RIG_ELEMENT_NODAL;
RivIntersectionBoxPartMgr::calculateGeoMechTextureCoords(m_intersectionBoxFacesTextureCoords.p(), const std::vector<float>& resultValues = caseData->femPartResults()->resultValues(resVarAddress, 0, (int)timeStepIndex);
vertexWeights, RigFemPart* femPart = caseData->femParts()->part(0);
resultValues, bool isElementNodalResult = !(resVarAddress.resultPosType == RIG_NODAL);
isElementNodalResult,
femPart, RivIntersectionPartMgr::calculateGeoMechTextureCoords(m_intersectionBoxFacesTextureCoords.p(),
mapper); vertexWeights,
resultValues,
isElementNodalResult,
femPart,
mapper);
}
else
{
// Special direction sensitive result calculation
const cvf::Vec3fArray* triangelVxes = m_intersectionBoxGenerator->triangleVxes();
RivIntersectionPartMgr::calculateGeoMechTensorXfTextureCoords(m_intersectionBoxFacesTextureCoords.p(),
triangelVxes,
vertexWeights,
caseData,
resVarAddress,
(int)timeStepIndex,
mapper);
}
RivScalarMapperUtils::applyTextureResultsToPart(m_intersectionBoxFaces.p(), RivScalarMapperUtils::applyTextureResultsToPart(m_intersectionBoxFaces.p(),
m_intersectionBoxFacesTextureCoords.p(), m_intersectionBoxFacesTextureCoords.p(),
@@ -185,90 +203,6 @@ void RivIntersectionBoxPartMgr::updateCellResultColor(size_t timeStepIndex)
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivIntersectionBoxPartMgr::calculateGeoMechTextureCoords(cvf::Vec2fArray* textureCoords,
const std::vector<RivIntersectionVertexWeights> &vertexWeights,
const std::vector<float> &resultValues,
bool isElementNodalResult,
const RigFemPart* femPart,
const cvf::ScalarMapper* mapper)
{
textureCoords->resize(vertexWeights.size());
if (resultValues.size() == 0)
{
textureCoords->setAll(cvf::Vec2f(0.0, 1.0f));
}
else
{
cvf::Vec2f* rawPtr = textureCoords->ptr();
int vxCount = static_cast<int>(vertexWeights.size());
#pragma omp parallel for schedule(dynamic)
for (int triangleVxIdx = 0; triangleVxIdx < vxCount; ++triangleVxIdx)
{
float resValue = 0;
int weightCount = vertexWeights[triangleVxIdx].size();
for (int wIdx = 0; wIdx < weightCount; ++wIdx)
{
size_t resIdx = isElementNodalResult ? vertexWeights[triangleVxIdx].vxId(wIdx) :
femPart->nodeIdxFromElementNodeResultIdx(vertexWeights[triangleVxIdx].vxId(wIdx));
resValue += resultValues[resIdx] * vertexWeights[triangleVxIdx].weight(wIdx);
}
if (resValue == HUGE_VAL || resValue != resValue) // a != a is true for NAN's
{
rawPtr[triangleVxIdx][1] = 1.0f;
}
else
{
rawPtr[triangleVxIdx] = mapper->mapToTextureCoord(resValue);
}
}
}
}
//--------------------------------------------------------------------------------------------------
/// Calculates the texture coordinates in a "nearly" one dimensional texture.
/// Undefined values are coded with a y-texture coordinate value of 1.0 instead of the normal 0.5
//--------------------------------------------------------------------------------------------------
void RivIntersectionBoxPartMgr::calculateEclipseTextureCoordinates(cvf::Vec2fArray* textureCoords,
const std::vector<size_t>& triangleToCellIdxMap,
const RigResultAccessor* resultAccessor,
const cvf::ScalarMapper* mapper)
{
if (!resultAccessor) return;
size_t numVertices = triangleToCellIdxMap.size()*3;
textureCoords->resize(numVertices);
cvf::Vec2f* rawPtr = textureCoords->ptr();
int triangleCount = static_cast<int>(triangleToCellIdxMap.size());
#pragma omp parallel for
for (int tIdx = 0; tIdx < triangleCount; tIdx++)
{
double cellScalarValue = resultAccessor->cellScalarGlobIdx(triangleToCellIdxMap[tIdx]);
cvf::Vec2f texCoord = mapper->mapToTextureCoord(cellScalarValue);
if (cellScalarValue == HUGE_VAL || cellScalarValue != cellScalarValue) // a != a is true for NAN's
{
texCoord[1] = 1.0f;
}
size_t j;
for (j = 0; j < 3; j++)
{
rawPtr[tIdx*3 + j] = texCoord;
}
}
}
const int priCrossSectionGeo = 1; const int priCrossSectionGeo = 1;
const int priNncGeo = 2; const int priNncGeo = 2;
const int priMesh = 3; const int priMesh = 3;

View File

@@ -57,18 +57,6 @@ private:
void updatePartEffect(); void updatePartEffect();
void generatePartGeometry(); void generatePartGeometry();
static void calculateEclipseTextureCoordinates(cvf::Vec2fArray* textureCoords,
const std::vector<size_t>& triangleToCellIdxMap,
const RigResultAccessor* resultAccessor,
const cvf::ScalarMapper* mapper);
static void calculateGeoMechTextureCoords(cvf::Vec2fArray* textureCoords,
const std::vector<RivIntersectionVertexWeights> &vertexWeights,
const std::vector<float> &resultValues,
bool isElementNodalResult,
const RigFemPart* femPart,
const cvf::ScalarMapper* mapper);
cvf::ref<RivIntersectionHexGridInterface> createHexGridInterface(); cvf::ref<RivIntersectionHexGridInterface> createHexGridInterface();
private: private:

View File

@@ -383,14 +383,10 @@ const std::vector<RivIntersectionVertexWeights>& RivIntersectionGeometryGenerato
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
cvf::Mat3f RivIntersectionGeometryGenerator::calculateTriangleOrientation(int triangleIndex) const cvf::Vec3fArray* RivIntersectionGeometryGenerator::triangleVxes() const
{ {
int triVxStartIdx = triangleIndex*3; CVF_ASSERT(m_triangleVxes->size());
cvf::Vec3f p0 = m_triangleVxes->get(triVxStartIdx); return m_triangleVxes.p();
cvf::Vec3f p1 = m_triangleVxes->get(triVxStartIdx + 1);
cvf::Vec3f p2 = m_triangleVxes->get(triVxStartIdx + 2);
return cvf::GeometryTools::computePlaneHorizontalRotationMx(p1 - p0, p2 - p0);
} }
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------

View File

@@ -66,10 +66,9 @@ public:
// Mapping between cells and geometry // Mapping between cells and geometry
const std::vector<size_t>& triangleToCellIndex() const; const std::vector<size_t>& triangleToCellIndex() const;
const std::vector<RivIntersectionVertexWeights>& triangleVxToCellCornerInterpolationWeights() const; const std::vector<RivIntersectionVertexWeights>& triangleVxToCellCornerInterpolationWeights() const;
const cvf::Vec3fArray* triangleVxes() const;
cvf::Mat3f calculateTriangleOrientation(int triangleIndex);
const RimIntersection* crossSection() const; const RimIntersection* crossSection() const;

View File

@@ -51,6 +51,7 @@
#include "cvfRenderStateDepth.h" #include "cvfRenderStateDepth.h"
#include "cvfRenderStatePoint.h" #include "cvfRenderStatePoint.h"
#include "cafTensor3.h" #include "cafTensor3.h"
#include "cvfGeometryTools.h"
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@@ -184,8 +185,10 @@ void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex)
else else
{ {
// Special direction sensitive result calculation // Special direction sensitive result calculation
// Normal, Horizontal, Semi Vertical, max shear const cvf::Vec3fArray* triangelVxes = m_crossSectionGenerator->triangleVxes();
RivIntersectionPartMgr::calculateGeoMechTensorXfTextureCoords(m_crossSectionFacesTextureCoords.p(), RivIntersectionPartMgr::calculateGeoMechTensorXfTextureCoords(m_crossSectionFacesTextureCoords.p(),
triangelVxes,
vertexWeights, vertexWeights,
caseData, caseData,
resVarAddress, resVarAddress,
@@ -255,6 +258,7 @@ void RivIntersectionPartMgr::calculateGeoMechTextureCoords(cvf::Vec2fArray* text
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
void RivIntersectionPartMgr::calculateGeoMechTensorXfTextureCoords(cvf::Vec2fArray* textureCoords, void RivIntersectionPartMgr::calculateGeoMechTensorXfTextureCoords(cvf::Vec2fArray* textureCoords,
const cvf::Vec3fArray* triangelVertices,
const std::vector<RivIntersectionVertexWeights> &vertexWeights, const std::vector<RivIntersectionVertexWeights> &vertexWeights,
RigGeoMechCaseData* caseData, RigGeoMechCaseData* caseData,
const RigFemResultAddress& resVarAddress, const RigFemResultAddress& resVarAddress,
@@ -296,11 +300,15 @@ void RivIntersectionPartMgr::calculateGeoMechTensorXfTextureCoords(cvf::Vec2fArr
int vxCount = static_cast<int>(vertexWeights.size()); int vxCount = static_cast<int>(vertexWeights.size());
int triCount = vxCount/3; int triCount = vxCount/3;
//#pragma omp parallel for schedule(dynamic) #pragma omp parallel for schedule(dynamic)
for (int triangleIdx = 0; triangleIdx < triCount; ++triangleIdx) for (int triangleIdx = 0; triangleIdx < triCount; ++triangleIdx)
{ {
cvf::Mat3f triangleXf = m_crossSectionGenerator->calculateTriangleOrientation(triangleIdx);
int triangleVxStartIdx = triangleIdx*3; int triangleVxStartIdx = triangleIdx*3;
cvf::Vec3f p0 = triangelVertices->get(triangleVxStartIdx);
cvf::Vec3f p1 = triangelVertices->get(triangleVxStartIdx + 1);
cvf::Vec3f p2 = triangelVertices->get(triangleVxStartIdx + 2);
cvf::Mat3f triangleXf = cvf::GeometryTools::computePlaneHorizontalRotationMx(p1 - p0, p2 - p0);
for(int triangleVxIdx = triangleVxStartIdx; triangleVxIdx < triangleVxStartIdx+3; ++triangleVxIdx) for(int triangleVxIdx = triangleVxStartIdx; triangleVxIdx < triangleVxStartIdx+3; ++triangleVxIdx)
{ {

View File

@@ -68,22 +68,26 @@ private:
void computeData(); void computeData();
public:
static void calculateEclipseTextureCoordinates(cvf::Vec2fArray* textureCoords, static void calculateEclipseTextureCoordinates(cvf::Vec2fArray* textureCoords,
const std::vector<size_t>& triangleToCellIdxMap, const std::vector<size_t>& triangleToCellIdxMap,
const RigResultAccessor* resultAccessor, const RigResultAccessor* resultAccessor,
const cvf::ScalarMapper* mapper); const cvf::ScalarMapper* mapper);
static void calculateGeoMechTextureCoords(cvf::Vec2fArray* textureCoords, static void calculateGeoMechTextureCoords(cvf::Vec2fArray* textureCoords,
const std::vector<RivIntersectionVertexWeights> &vertexWeights, const std::vector<RivIntersectionVertexWeights> &vertexWeights,
const std::vector<float> &resultValues, const std::vector<float> &resultValues,
bool isElementNodalResult, bool isElementNodalResult,
const RigFemPart* femPart, const RigFemPart* femPart,
const cvf::ScalarMapper* mapper); const cvf::ScalarMapper* mapper);
void calculateGeoMechTensorXfTextureCoords(cvf::Vec2fArray* textureCoords,
const std::vector<RivIntersectionVertexWeights> &vertexWeights, static void calculateGeoMechTensorXfTextureCoords(cvf::Vec2fArray* textureCoords,
RigGeoMechCaseData* caseData, const cvf::Vec3fArray* triangelVertices,
const RigFemResultAddress& resVarAddress, const std::vector<RivIntersectionVertexWeights> &vertexWeights,
int timeStepIdx, RigGeoMechCaseData* caseData,
const cvf::ScalarMapper* mapper); const RigFemResultAddress& resVarAddress,
int timeStepIdx,
const cvf::ScalarMapper* mapper);
cvf::ref<RivIntersectionHexGridInterface> createHexGridInterface(); cvf::ref<RivIntersectionHexGridInterface> createHexGridInterface();
private: private: