mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#933 Moved and renamed TimeHistory calculator to the user interface module
This commit is contained in:
@@ -37,6 +37,7 @@ ${CEE_CURRENT_LIST_DIR}RiuViewerCommands.h
|
||||
${CEE_CURRENT_LIST_DIR}RiuWellLogPlot.h
|
||||
${CEE_CURRENT_LIST_DIR}RiuWellLogTrack.h
|
||||
${CEE_CURRENT_LIST_DIR}RiuGeoMechXfTensorResultAccessor.h
|
||||
${CEE_CURRENT_LIST_DIR}RiuFemTimeHistoryResultAccessor.h
|
||||
)
|
||||
|
||||
set (SOURCE_GROUP_SOURCE_FILES
|
||||
@@ -72,7 +73,7 @@ ${CEE_CURRENT_LIST_DIR}RiuViewerCommands.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RiuWellLogPlot.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RiuWellLogTrack.cpp
|
||||
${CEE_CURRENT_LIST_DIR}RiuGeoMechXfTensorResultAccessor.cpp
|
||||
|
||||
${CEE_CURRENT_LIST_DIR}RiuFemTimeHistoryResultAccessor.cpp
|
||||
)
|
||||
|
||||
list(APPEND CODE_HEADER_FILES
|
||||
|
||||
@@ -0,0 +1,163 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) Statoil ASA
|
||||
// Copyright (C) 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 "RiuFemTimeHistoryResultAccessor.h"
|
||||
|
||||
#include "RigFemPart.h"
|
||||
#include "RigFemPartCollection.h"
|
||||
#include "RigFemPartGrid.h"
|
||||
#include "RigFemPartResultsCollection.h"
|
||||
#include "RigFemTypes.h"
|
||||
#include "RigGeoMechCaseData.h"
|
||||
#include "RiuGeoMechXfTensorResultAccessor.h"
|
||||
|
||||
#include <cmath> // Needed for HUGE_VAL on Linux
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuFemTimeHistoryResultAccessor::RiuFemTimeHistoryResultAccessor(RigGeoMechCaseData* geomData,
|
||||
RigFemResultAddress femResultAddress,
|
||||
size_t gridIndex,
|
||||
int elementIndex,
|
||||
int face,
|
||||
const cvf::Vec3d& intersectionPoint)
|
||||
: m_geoMechCaseData(geomData),
|
||||
m_femResultAddress(femResultAddress),
|
||||
m_gridIndex(gridIndex),
|
||||
m_elementIndex(elementIndex),
|
||||
m_face(face),
|
||||
m_intersectionPoint(intersectionPoint),
|
||||
m_hasIntersectionTriangle(false)
|
||||
{
|
||||
computeTimeHistoryData();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
RiuFemTimeHistoryResultAccessor::RiuFemTimeHistoryResultAccessor(RigGeoMechCaseData* geomData,
|
||||
RigFemResultAddress femResultAddress,
|
||||
size_t gridIndex,
|
||||
int elementIndex,
|
||||
int face,
|
||||
const cvf::Vec3d& intersectionPoint,
|
||||
const std::array<cvf::Vec3f, 3>& intersectionTriangle)
|
||||
: m_geoMechCaseData(geomData),
|
||||
m_femResultAddress(femResultAddress),
|
||||
m_gridIndex(gridIndex),
|
||||
m_elementIndex(elementIndex),
|
||||
m_face(face),
|
||||
m_intersectionPoint(intersectionPoint),
|
||||
m_hasIntersectionTriangle(true),
|
||||
m_intersectionTriangle(intersectionTriangle)
|
||||
{
|
||||
computeTimeHistoryData();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QString RiuFemTimeHistoryResultAccessor::topologyText() const
|
||||
{
|
||||
QString text;
|
||||
|
||||
if (m_geoMechCaseData)
|
||||
{
|
||||
RigFemPart* femPart = m_geoMechCaseData->femParts()->part(m_gridIndex);
|
||||
int elementId = femPart->elmId(m_elementIndex);
|
||||
text += QString("Element : Id[%1]").arg(elementId);
|
||||
|
||||
size_t i = 0;
|
||||
size_t j = 0;
|
||||
size_t k = 0;
|
||||
if (m_geoMechCaseData->femParts()->part(m_gridIndex)->structGrid()->ijkFromCellIndex(m_elementIndex, &i, &j, &k))
|
||||
{
|
||||
// Adjust to 1-based Eclipse indexing
|
||||
i++;
|
||||
j++;
|
||||
k++;
|
||||
|
||||
cvf::Vec3d domainCoord = m_intersectionPoint;
|
||||
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());
|
||||
|
||||
text += formattedText;
|
||||
}
|
||||
}
|
||||
|
||||
return text;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<double> RiuFemTimeHistoryResultAccessor::timeHistoryValues() const
|
||||
{
|
||||
return m_timeHistoryValues;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RiuFemTimeHistoryResultAccessor::computeTimeHistoryData()
|
||||
{
|
||||
m_timeHistoryValues.clear();
|
||||
|
||||
RigFemClosestResultIndexCalculator closestCalc(m_geoMechCaseData->femParts()->part(m_gridIndex),
|
||||
m_femResultAddress.resultPosType,
|
||||
m_elementIndex,
|
||||
m_face,
|
||||
m_intersectionPoint );
|
||||
|
||||
int scalarResultIndex = closestCalc.resultIndexToClosestResult();
|
||||
m_closestNodeId = closestCalc.closestNodeId();
|
||||
|
||||
RigFemPartResultsCollection* femPartResultsColl = m_geoMechCaseData->femPartResults();
|
||||
|
||||
if (m_femResultAddress.resultPosType == RIG_ELEMENT_NODAL_FACE && m_hasIntersectionTriangle)
|
||||
{
|
||||
int closestElmNodeResIndex = closestCalc.closestElementNodeResIdx();
|
||||
|
||||
for ( int frameIdx = 0; frameIdx < femPartResultsColl->frameCount(); frameIdx++ )
|
||||
{
|
||||
RiuGeoMechXfTensorResultAccessor stressXfAccessor(femPartResultsColl, m_femResultAddress, frameIdx);
|
||||
float scalarValue = stressXfAccessor.calculateElmNodeValue(m_intersectionTriangle, closestElmNodeResIndex);
|
||||
m_timeHistoryValues.push_back(scalarValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( scalarResultIndex < 0 ) return;
|
||||
|
||||
for ( int frameIdx = 0; frameIdx < femPartResultsColl->frameCount(); frameIdx++ )
|
||||
{
|
||||
const std::vector<float>& scalarResults = m_geoMechCaseData->femPartResults()->resultValues(m_femResultAddress, static_cast<int>(m_gridIndex), frameIdx);
|
||||
if ( scalarResults.size() )
|
||||
{
|
||||
float scalarValue = scalarResults[scalarResultIndex];
|
||||
|
||||
m_timeHistoryValues.push_back(scalarValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (C) Statoil ASA
|
||||
// Copyright (C) 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.
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "RigFemResultAddress.h"
|
||||
|
||||
#include "cvfStructGrid.h"
|
||||
#include "cvfVector3.h"
|
||||
#include <array>
|
||||
|
||||
class RigGeoMechCaseData;
|
||||
|
||||
|
||||
class RiuFemTimeHistoryResultAccessor
|
||||
{
|
||||
public:
|
||||
RiuFemTimeHistoryResultAccessor(RigGeoMechCaseData* geomData,
|
||||
RigFemResultAddress femResultAddress,
|
||||
size_t gridIndex,
|
||||
int elementIndex,
|
||||
int face,
|
||||
const cvf::Vec3d& intersectionPoint);
|
||||
|
||||
RiuFemTimeHistoryResultAccessor(RigGeoMechCaseData* geomData,
|
||||
RigFemResultAddress femResultAddress,
|
||||
size_t gridIndex,
|
||||
int elementIndex,
|
||||
int face,
|
||||
const cvf::Vec3d& intersectionPoint,
|
||||
const std::array<cvf::Vec3f, 3>& m_intersectionTriangle);
|
||||
|
||||
QString topologyText() const;
|
||||
std::vector<double> timeHistoryValues() const;
|
||||
int closestNodeId() const { return m_closestNodeId; }
|
||||
|
||||
private:
|
||||
void computeTimeHistoryData();
|
||||
|
||||
private:
|
||||
RigGeoMechCaseData* m_geoMechCaseData;
|
||||
RigFemResultAddress m_femResultAddress;
|
||||
|
||||
size_t m_gridIndex;
|
||||
int m_elementIndex;
|
||||
size_t m_scalarResultIndex;
|
||||
int m_face;
|
||||
int m_closestNodeId;
|
||||
|
||||
cvf::Vec3d m_intersectionPoint;
|
||||
|
||||
bool m_hasIntersectionTriangle;
|
||||
std::array<cvf::Vec3f, 3> m_intersectionTriangle;
|
||||
|
||||
std::vector<double> m_timeHistoryValues;
|
||||
};
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
|
||||
#include "RigCaseCellResultsData.h"
|
||||
#include "RigCaseData.h"
|
||||
#include "RigFemTimeHistoryResultAccessor.h"
|
||||
#include "RiuFemTimeHistoryResultAccessor.h"
|
||||
#include "RigGeoMechCaseData.h"
|
||||
#include "RigTimeHistoryResultAccessor.h"
|
||||
|
||||
@@ -145,12 +145,12 @@ void RiuSelectionChangedHandler::addCurveFromSelectionItem(const RiuGeoMechSelec
|
||||
geoMechView->geoMechCase() &&
|
||||
geoMechView->geoMechCase()->geoMechData())
|
||||
{
|
||||
std::unique_ptr<RigFemTimeHistoryResultAccessor> timeHistResultAccessor;
|
||||
std::unique_ptr<RiuFemTimeHistoryResultAccessor> timeHistResultAccessor;
|
||||
|
||||
if ( geomSelectionItem->m_hasIntersectionTriangle )
|
||||
{
|
||||
timeHistResultAccessor = std::unique_ptr<RigFemTimeHistoryResultAccessor>(
|
||||
new RigFemTimeHistoryResultAccessor(geoMechView->geoMechCase()->geoMechData(),
|
||||
timeHistResultAccessor = std::unique_ptr<RiuFemTimeHistoryResultAccessor>(
|
||||
new RiuFemTimeHistoryResultAccessor(geoMechView->geoMechCase()->geoMechData(),
|
||||
geoMechView->cellResultResultDefinition()->resultAddress(),
|
||||
geomSelectionItem->m_gridIndex,
|
||||
static_cast<int>(geomSelectionItem->m_cellIndex),
|
||||
@@ -160,8 +160,8 @@ void RiuSelectionChangedHandler::addCurveFromSelectionItem(const RiuGeoMechSelec
|
||||
}
|
||||
else
|
||||
{
|
||||
timeHistResultAccessor = std::unique_ptr<RigFemTimeHistoryResultAccessor>(
|
||||
new RigFemTimeHistoryResultAccessor(geoMechView->geoMechCase()->geoMechData(),
|
||||
timeHistResultAccessor = std::unique_ptr<RiuFemTimeHistoryResultAccessor>(
|
||||
new RiuFemTimeHistoryResultAccessor(geoMechView->geoMechCase()->geoMechData(),
|
||||
geoMechView->cellResultResultDefinition()->resultAddress(),
|
||||
geomSelectionItem->m_gridIndex,
|
||||
static_cast<int>(geomSelectionItem->m_cellIndex),
|
||||
|
||||
Reference in New Issue
Block a user