mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#933 Fixed closest result for pr element face-node result when picking on elements. Also fixed the result plot in the same respect.
This commit is contained in:
@@ -1368,3 +1368,91 @@ int RigFemPartResultsCollection::partCount() const
|
||||
return m_femParts->partCount();
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigFemClosestResultIndexCalculator::RigFemClosestResultIndexCalculator(RigFemPart* femPart,
|
||||
RigFemResultPosEnum resultPosition,
|
||||
int elementIndex,
|
||||
int m_face,
|
||||
const cvf::Vec3d& m_intersectionPoint)
|
||||
{
|
||||
m_resultIndexToClosestResult = -1;
|
||||
m_closestNodeId = -1;
|
||||
|
||||
if ( resultPosition != RIG_ELEMENT_NODAL_FACE )
|
||||
{
|
||||
RigElementType elmType = femPart->elementType(elementIndex);
|
||||
const int* elmentConn = femPart->connectivities(elementIndex);
|
||||
int elmNodeCount = RigFemTypes::elmentNodeCount(elmType);
|
||||
|
||||
// Find the closest node
|
||||
int closestLocalNode = -1;
|
||||
float minDist = std::numeric_limits<float>::infinity();
|
||||
for ( int lNodeIdx = 0; lNodeIdx < elmNodeCount; ++lNodeIdx )
|
||||
{
|
||||
int nodeIdx = elmentConn[lNodeIdx];
|
||||
cvf::Vec3f nodePos = femPart->nodes().coordinates[nodeIdx];
|
||||
float dist = (nodePos - cvf::Vec3f(m_intersectionPoint)).lengthSquared();
|
||||
if ( dist < minDist )
|
||||
{
|
||||
closestLocalNode = lNodeIdx;
|
||||
minDist = dist;
|
||||
}
|
||||
}
|
||||
|
||||
if ( closestLocalNode >= 0 )
|
||||
{
|
||||
float scalarValue = std::numeric_limits<float>::infinity();
|
||||
int nodeIdx = elmentConn[closestLocalNode];
|
||||
if ( resultPosition == RIG_NODAL )
|
||||
{
|
||||
m_resultIndexToClosestResult = nodeIdx;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_resultIndexToClosestResult = static_cast<int>(femPart->elementNodeResultIdx(elementIndex, closestLocalNode));
|
||||
}
|
||||
|
||||
m_closestNodeId = femPart->nodes().nodeIds[nodeIdx];
|
||||
}
|
||||
}
|
||||
else if ( m_face != -1 )
|
||||
{
|
||||
int elmNodFaceResIdx = -1;
|
||||
int closestNodeIdx = -1;
|
||||
{
|
||||
int closestLocFaceNode = -1;
|
||||
{
|
||||
RigElementType elmType = femPart->elementType(elementIndex);
|
||||
int faceCount = RigFemTypes::elmentFaceCount(elmType);
|
||||
const int* elmNodeIndices = femPart->connectivities(elementIndex);
|
||||
int faceNodeCount = 0;
|
||||
const int* localElmNodeIndicesForFace = RigFemTypes::localElmNodeIndicesForFace(elmType, m_face, &faceNodeCount);
|
||||
|
||||
float minDist = std::numeric_limits<float>::infinity();
|
||||
for ( int faceNodIdx = 0; faceNodIdx < faceNodeCount; ++faceNodIdx )
|
||||
{
|
||||
int nodeIdx = elmNodeIndices[localElmNodeIndicesForFace[faceNodIdx]];
|
||||
cvf::Vec3f nodePos = femPart->nodes().coordinates[nodeIdx];
|
||||
float dist = (nodePos - cvf::Vec3f(m_intersectionPoint)).lengthSquared();
|
||||
if ( dist < minDist )
|
||||
{
|
||||
closestLocFaceNode = faceNodIdx;
|
||||
closestNodeIdx = nodeIdx;
|
||||
minDist = dist;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int elmNodFaceResIdxElmStart = elementIndex * 24; // HACK should get from part
|
||||
int elmNodFaceResIdxFaceStart = elmNodFaceResIdxElmStart + 4*m_face;
|
||||
|
||||
if ( closestLocFaceNode >= 0 ) elmNodFaceResIdx = elmNodFaceResIdxFaceStart + closestLocFaceNode;
|
||||
}
|
||||
|
||||
m_resultIndexToClosestResult = elmNodFaceResIdx;
|
||||
m_closestNodeId = femPart->nodes().nodeIds[closestNodeIdx];
|
||||
}
|
||||
}
|
||||
@@ -124,3 +124,22 @@ public:
|
||||
private:
|
||||
std::array<float, 3> incAziR;
|
||||
};
|
||||
|
||||
class RigFemPart;
|
||||
|
||||
class RigFemClosestResultIndexCalculator
|
||||
{
|
||||
public:
|
||||
RigFemClosestResultIndexCalculator(RigFemPart* femPart,
|
||||
RigFemResultPosEnum resultPosition,
|
||||
int elementIndex,
|
||||
int m_face,
|
||||
const cvf::Vec3d& m_intersectionPoint);
|
||||
|
||||
int resultIndexToClosestResult() { return m_resultIndexToClosestResult; }
|
||||
int closestNodeId() { return m_closestNodeId; }
|
||||
|
||||
private:
|
||||
int m_resultIndexToClosestResult;
|
||||
int m_closestNodeId;
|
||||
};
|
||||
|
||||
@@ -31,12 +31,17 @@
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RigFemTimeHistoryResultAccessor::RigFemTimeHistoryResultAccessor(RigGeoMechCaseData* geomData, RigFemResultAddress femResultAddress,
|
||||
size_t gridIndex, size_t cellIndex, const cvf::Vec3d& intersectionPoint)
|
||||
RigFemTimeHistoryResultAccessor::RigFemTimeHistoryResultAccessor(RigGeoMechCaseData* geomData,
|
||||
RigFemResultAddress femResultAddress,
|
||||
size_t gridIndex,
|
||||
size_t cellIndex,
|
||||
int face,
|
||||
const cvf::Vec3d& intersectionPoint)
|
||||
: m_geoMechCaseData(geomData),
|
||||
m_femResultAddress(femResultAddress),
|
||||
m_gridIndex(gridIndex),
|
||||
m_cellIndex(cellIndex),
|
||||
m_face(face),
|
||||
m_intersectionPoint(intersectionPoint)
|
||||
{
|
||||
computeTimeHistoryData();
|
||||
@@ -66,7 +71,7 @@ QString RigFemTimeHistoryResultAccessor::topologyText() const
|
||||
k++;
|
||||
|
||||
cvf::Vec3d domainCoord = m_intersectionPoint;
|
||||
text += QString(", ijk[%1, %2, %3]").arg(i).arg(j).arg(k);
|
||||
text += QString(", ijk[%1, %2, %3] ").arg(i).arg(j).arg(k);
|
||||
|
||||
QString formattedText;
|
||||
formattedText.sprintf("Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", domainCoord.x(), domainCoord.y(), -domainCoord.z());
|
||||
@@ -93,46 +98,15 @@ void RigFemTimeHistoryResultAccessor::computeTimeHistoryData()
|
||||
{
|
||||
m_timeHistoryValues.clear();
|
||||
|
||||
size_t scalarResultIndex = cvf::UNDEFINED_SIZE_T;
|
||||
RigFemClosestResultIndexCalculator closestCalc(m_geoMechCaseData->femParts()->part(m_gridIndex),
|
||||
m_femResultAddress.resultPosType,
|
||||
m_cellIndex,
|
||||
m_face,
|
||||
m_intersectionPoint );
|
||||
|
||||
int scalarResultIndex = closestCalc.resultIndexToClosestResult();
|
||||
|
||||
// Compute scalar result index from geometry
|
||||
{
|
||||
RigFemPart* femPart = m_geoMechCaseData->femParts()->part(m_gridIndex);
|
||||
RigElementType elmType = femPart->elementType(m_cellIndex);
|
||||
const int* elmentConn = femPart->connectivities(m_cellIndex);
|
||||
int elmNodeCount = RigFemTypes::elmentNodeCount(elmType);
|
||||
|
||||
// Find the closest node
|
||||
int closestLocalNode = -1;
|
||||
float minDist = std::numeric_limits<float>::infinity();
|
||||
for (int lNodeIdx = 0; lNodeIdx < elmNodeCount; ++lNodeIdx)
|
||||
{
|
||||
int nodeIdx = elmentConn[lNodeIdx];
|
||||
cvf::Vec3f nodePos = femPart->nodes().coordinates[nodeIdx];
|
||||
float dist = (nodePos - cvf::Vec3f(m_intersectionPoint)).lengthSquared();
|
||||
if (dist < minDist)
|
||||
{
|
||||
closestLocalNode = lNodeIdx;
|
||||
minDist = dist;
|
||||
}
|
||||
}
|
||||
|
||||
// Create a text showing the results from the closest node
|
||||
if (closestLocalNode >= 0)
|
||||
{
|
||||
int nodeIdx = elmentConn[closestLocalNode];
|
||||
if (m_femResultAddress.resultPosType == RIG_NODAL)
|
||||
{
|
||||
scalarResultIndex = static_cast<size_t>(nodeIdx);
|
||||
}
|
||||
else
|
||||
{
|
||||
scalarResultIndex = femPart->elementNodeResultIdx(static_cast<int>(m_cellIndex), closestLocalNode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (scalarResultIndex == cvf::UNDEFINED_SIZE_T) return;
|
||||
if (scalarResultIndex < 0) return;
|
||||
|
||||
RigFemPartResultsCollection* femPartResultsColl = m_geoMechCaseData->femPartResults();
|
||||
for (int frameIdx = 0; frameIdx < femPartResultsColl->frameCount(); frameIdx++)
|
||||
|
||||
@@ -30,8 +30,12 @@ class RigGeoMechCaseData;
|
||||
class RigFemTimeHistoryResultAccessor
|
||||
{
|
||||
public:
|
||||
RigFemTimeHistoryResultAccessor(RigGeoMechCaseData* geomData, RigFemResultAddress femResultAddress,
|
||||
size_t gridIndex, size_t cellIndex, const cvf::Vec3d& intersectionPoint);
|
||||
RigFemTimeHistoryResultAccessor(RigGeoMechCaseData* geomData,
|
||||
RigFemResultAddress femResultAddress,
|
||||
size_t gridIndex,
|
||||
size_t cellIndex,
|
||||
int face,
|
||||
const cvf::Vec3d& intersectionPoint);
|
||||
|
||||
QString topologyText() const;
|
||||
std::vector<double> timeHistoryValues() const;
|
||||
@@ -46,6 +50,7 @@ private:
|
||||
size_t m_gridIndex;
|
||||
size_t m_cellIndex;
|
||||
size_t m_scalarResultIndex;
|
||||
int m_face;
|
||||
|
||||
cvf::Vec3d m_intersectionPoint;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user