mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Results are now loaded pr field, and not pr component
To increase speed, and to pave way for derived results. New methods in OdbReader fixed, and is now operational. Must delete obsolete stuff now.
This commit is contained in:
parent
bd67047f57
commit
406379e544
@ -89,7 +89,7 @@ std::map<std::string, std::vector<std::string> > RigFemPartResultsCollection::sc
|
|||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
/// Will always return a valid object, but it can be empty
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
RigFemScalarResultFrames* RigFemPartResultsCollection::findOrLoadScalarResult(int partIndex,
|
RigFemScalarResultFrames* RigFemPartResultsCollection::findOrLoadScalarResult(int partIndex,
|
||||||
const RigFemResultAddress& resVarAddr)
|
const RigFemResultAddress& resVarAddr)
|
||||||
@ -104,11 +104,19 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::findOrLoadScalarResult(in
|
|||||||
|
|
||||||
// Check whether a derived result is requested
|
// Check whether a derived result is requested
|
||||||
|
|
||||||
|
frames = calculateDerivedResult(partIndex, resVarAddr);
|
||||||
|
if (frames) return frames;
|
||||||
|
|
||||||
// We need to read the data as bulk fields, and populate the correct scalar caches
|
// We need to read the data as bulk fields, and populate the correct scalar caches
|
||||||
|
|
||||||
frames = m_femPartResults[partIndex]->createScalarResult(resVarAddr);
|
std::vector< RigFemResultAddress> resultAddressOfComponents = this->getResAddrToComponentsToRead(resVarAddr);
|
||||||
|
//
|
||||||
|
std::vector<RigFemScalarResultFrames*> resultsForEachComponent;
|
||||||
|
for (size_t cIdx = 0; cIdx < resultAddressOfComponents.size(); ++cIdx)
|
||||||
|
{
|
||||||
|
resultsForEachComponent.push_back(m_femPartResults[partIndex]->createScalarResult(resultAddressOfComponents[cIdx]));
|
||||||
|
}
|
||||||
|
|
||||||
int frameCount = this->frameCount();
|
int frameCount = this->frameCount();
|
||||||
|
|
||||||
for (int stepIndex = 0; stepIndex < frameCount; ++stepIndex)
|
for (int stepIndex = 0; stepIndex < frameCount; ++stepIndex)
|
||||||
@ -117,24 +125,97 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::findOrLoadScalarResult(in
|
|||||||
|
|
||||||
for (int fIdx = 1; (size_t)fIdx < frameTimes.size() && fIdx < 2 ; ++fIdx) // Read only the second frame
|
for (int fIdx = 1; (size_t)fIdx < frameTimes.size() && fIdx < 2 ; ++fIdx) // Read only the second frame
|
||||||
{
|
{
|
||||||
std::vector<float>* frameData = &(frames->frameData(stepIndex));
|
std::vector<std::vector<float>*> componentDataVectors;
|
||||||
|
for (size_t cIdx = 0; cIdx < resultsForEachComponent.size(); ++cIdx)
|
||||||
|
{
|
||||||
|
componentDataVectors.push_back(&(resultsForEachComponent[cIdx]->frameData(stepIndex)));
|
||||||
|
}
|
||||||
|
|
||||||
switch (resVarAddr.resultPosType)
|
switch (resVarAddr.resultPosType)
|
||||||
{
|
{
|
||||||
case RIG_NODAL:
|
case RIG_NODAL:
|
||||||
m_readerInterface->readScalarNodeField(resVarAddr.fieldName, resVarAddr.componentName, partIndex, stepIndex, fIdx, frameData);
|
m_readerInterface->readNodeField(resVarAddr.fieldName, partIndex, stepIndex, fIdx, &componentDataVectors);
|
||||||
break;
|
break;
|
||||||
case RIG_ELEMENT_NODAL:
|
case RIG_ELEMENT_NODAL:
|
||||||
m_readerInterface->readScalarElementNodeField(resVarAddr.fieldName, resVarAddr.componentName, partIndex, stepIndex, fIdx, frameData);
|
m_readerInterface->readElementNodeField(resVarAddr.fieldName, partIndex, stepIndex, fIdx, &componentDataVectors);
|
||||||
break;
|
break;
|
||||||
case RIG_INTEGRATION_POINT:
|
case RIG_INTEGRATION_POINT:
|
||||||
m_readerInterface->readScalarIntegrationPointField(resVarAddr.fieldName, resVarAddr.componentName, partIndex, stepIndex, fIdx, frameData);
|
m_readerInterface->readIntegrationPointField(resVarAddr.fieldName, partIndex, stepIndex, fIdx, &componentDataVectors);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Now fetch the particular component requested, which should now exist and be read.
|
||||||
|
frames = m_femPartResults[partIndex]->findScalarResult(resVarAddr);
|
||||||
|
|
||||||
|
if (!frames)
|
||||||
|
{
|
||||||
|
frames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); // Create a dummy empty result, if the request did not specify the component.
|
||||||
|
}
|
||||||
|
|
||||||
return frames;
|
return frames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
RigFemScalarResultFrames* RigFemPartResultsCollection::calculateDerivedResult(int partIndex, const RigFemResultAddress& resVarAddr)
|
||||||
|
{
|
||||||
|
// ST[11, 22, 33, 12, 13, 23, 1, 2, 3], Gamma[1,2,3], NS[11,22,33,12,13,23, 1, 2, 3]
|
||||||
|
|
||||||
|
if (resVarAddr.fieldName == "NS")
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
std::vector< RigFemResultAddress> RigFemPartResultsCollection::getResAddrToComponentsToRead(const RigFemResultAddress& resVarAddr)
|
||||||
|
{
|
||||||
|
std::map<std::string, std::vector<std::string> > fieldAndComponentNames;
|
||||||
|
switch (resVarAddr.resultPosType)
|
||||||
|
{
|
||||||
|
case RIG_NODAL:
|
||||||
|
fieldAndComponentNames = m_readerInterface->scalarNodeFieldAndComponentNames();
|
||||||
|
break;
|
||||||
|
case RIG_ELEMENT_NODAL:
|
||||||
|
fieldAndComponentNames = m_readerInterface->scalarElementNodeFieldAndComponentNames();
|
||||||
|
break;
|
||||||
|
case RIG_INTEGRATION_POINT:
|
||||||
|
fieldAndComponentNames = m_readerInterface->scalarIntegrationPointFieldAndComponentNames();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector< RigFemResultAddress> resAddressToComponents;
|
||||||
|
|
||||||
|
std::map<std::string, std::vector<std::string> >::iterator fcIt = fieldAndComponentNames.find(resVarAddr.fieldName);
|
||||||
|
|
||||||
|
if (fcIt != fieldAndComponentNames.end())
|
||||||
|
{
|
||||||
|
std::vector<std::string> compNames = fcIt->second;
|
||||||
|
for (size_t cIdx = 0; cIdx < compNames.size(); ++cIdx)
|
||||||
|
{
|
||||||
|
resAddressToComponents.push_back(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, compNames[cIdx]));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (compNames.size() == 0) // This is a scalar field. Add one component named ""
|
||||||
|
{
|
||||||
|
CVF_ASSERT(resVarAddr.componentName == "");
|
||||||
|
resAddressToComponents.push_back(resVarAddr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return resAddressToComponents;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -263,4 +344,3 @@ const std::vector<size_t>& RigFemPartResultsCollection::scalarValuesHistogram(co
|
|||||||
return this->statistics(resVarAddr)->cellScalarValuesHistogram();
|
return this->statistics(resVarAddr)->cellScalarValuesHistogram();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -58,12 +58,14 @@ private:
|
|||||||
RigFemScalarResultFrames* findOrLoadScalarResult(int partIndex,
|
RigFemScalarResultFrames* findOrLoadScalarResult(int partIndex,
|
||||||
const RigFemResultAddress& resVarAddr);
|
const RigFemResultAddress& resVarAddr);
|
||||||
|
|
||||||
|
RigFemScalarResultFrames* calculateDerivedResult(int partIndex, const RigFemResultAddress& resVarAddr);
|
||||||
|
|
||||||
friend class RigFemNativeStatCalc;
|
friend class RigFemNativeStatCalc;
|
||||||
cvf::Collection<RigFemPartResults> m_femPartResults;
|
cvf::Collection<RigFemPartResults> m_femPartResults;
|
||||||
cvf::ref<RifGeoMechReaderInterface> m_readerInterface;
|
cvf::ref<RifGeoMechReaderInterface> m_readerInterface;
|
||||||
|
|
||||||
RigStatisticsDataCache* statistics(const RigFemResultAddress& resVarAddr);
|
RigStatisticsDataCache* statistics(const RigFemResultAddress& resVarAddr);
|
||||||
|
std::vector< RigFemResultAddress> getResAddrToComponentsToRead(const RigFemResultAddress& resVarAddr);
|
||||||
std::map<RigFemResultAddress, cvf::ref<RigStatisticsDataCache> > m_resultStatistics;
|
std::map<RigFemResultAddress, cvf::ref<RigStatisticsDataCache> > m_resultStatistics;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -612,25 +612,40 @@ odb_Instance* RifOdbReader::instance(int instanceIndex)
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
const odb_SequenceFieldBulkData& RifOdbReader::fieldBulkData(const std::string& fieldName, ResultPosition position, odb_Instance* instance, const odb_Frame& frame)
|
const odb_SequenceFieldBulkData& RifOdbReader::fieldBulkData(const std::string& fieldName, ResultPosition position, odb_Instance* instance, const odb_Frame& frame)
|
||||||
{
|
{
|
||||||
|
<<<<<<< HEAD
|
||||||
|
|
||||||
const odb_FieldOutput& fieldOutput = frame.fieldOutputs()[fieldName.c_str()].getSubset(*instance);
|
const odb_FieldOutput& fieldOutput = frame.fieldOutputs()[fieldName.c_str()].getSubset(*instance);
|
||||||
CVF_ASSERT(false); // This stuff must be fixed for linux
|
CVF_ASSERT(false); // This stuff must be fixed for linux
|
||||||
#if 0
|
#if 0
|
||||||
|
=======
|
||||||
|
const odb_FieldOutput& mainFieldOutput = frame.fieldOutputs()[fieldName.c_str()].getSubset(*instance);
|
||||||
|
|
||||||
|
>>>>>>> Results are now loaded pr field, and not pr component
|
||||||
switch (position)
|
switch (position)
|
||||||
{
|
{
|
||||||
|
case NODAL:
|
||||||
|
return mainFieldOutput.getSubset(odb_Enum::NODAL).bulkDataBlocks();
|
||||||
|
break;
|
||||||
|
|
||||||
case ELEMENT_NODAL:
|
case ELEMENT_NODAL:
|
||||||
fieldOutput = fieldOutput.getSubset(odb_Enum::ELEMENT_NODAL);
|
return mainFieldOutput.getSubset(odb_Enum::ELEMENT_NODAL).bulkDataBlocks();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case INTEGRATION_POINT:
|
case INTEGRATION_POINT:
|
||||||
fieldOutput = fieldOutput.getSubset(odb_Enum::INTEGRATION_POINT);
|
return mainFieldOutput.getSubset(odb_Enum::INTEGRATION_POINT).bulkDataBlocks();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
CVF_ASSERT(false);
|
||||||
|
return mainFieldOutput.getSubset(odb_Enum::NODAL).bulkDataBlocks();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
<<<<<<< HEAD
|
||||||
#endif
|
#endif
|
||||||
return fieldOutput.bulkDataBlocks();
|
return fieldOutput.bulkDataBlocks();
|
||||||
|
=======
|
||||||
|
|
||||||
|
>>>>>>> Results are now loaded pr field, and not pr component
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -968,19 +983,21 @@ void RifOdbReader::readNodeField(const std::string& fieldName, int partIndex, in
|
|||||||
std::map<int, int>& nodeIdToIdxMap = m_nodeIdToIdxMaps[partIndex];
|
std::map<int, int>& nodeIdToIdxMap = m_nodeIdToIdxMaps[partIndex];
|
||||||
|
|
||||||
size_t dataSize = nodeIdToIdxMap.size();
|
size_t dataSize = nodeIdToIdxMap.size();
|
||||||
|
|
||||||
if (dataSize > 0)
|
if (dataSize > 0)
|
||||||
{
|
{
|
||||||
for (int comp = 0; comp < compCount; comp++)
|
for (int comp = 0; comp < compCount; comp++)
|
||||||
{
|
{
|
||||||
CVF_ASSERT((*resultValues)[comp]);
|
CVF_ASSERT((*resultValues)[comp]);
|
||||||
|
|
||||||
(*resultValues)[comp]->resize(dataSize);
|
(*resultValues)[comp]->resize(dataSize, std::numeric_limits<float>::infinity());
|
||||||
(*resultValues)[comp]->assign(dataSize, std::numeric_limits<float>::infinity());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const odb_Frame& frame = stepFrame(stepIndex, frameIndex);
|
const odb_Frame& frame = stepFrame(stepIndex, frameIndex);
|
||||||
const odb_SequenceFieldBulkData& seqFieldBulkData = fieldBulkData(fieldName, NODAL, partInstance, frame);
|
const odb_FieldOutput& instanceFieldOutput = frame.fieldOutputs()[fieldName.c_str()].getSubset(*partInstance);
|
||||||
|
const odb_FieldOutput& fieldOutput = instanceFieldOutput.getSubset(odb_Enum::NODAL);
|
||||||
|
const odb_SequenceFieldBulkData& seqFieldBulkData = fieldOutput.bulkDataBlocks();
|
||||||
|
|
||||||
size_t dataIndex = 0;
|
size_t dataIndex = 0;
|
||||||
int numBlocks = seqFieldBulkData.size();
|
int numBlocks = seqFieldBulkData.size();
|
||||||
@ -994,11 +1011,12 @@ void RifOdbReader::readNodeField(const std::string& fieldName, int partIndex, in
|
|||||||
int* nodeLabels = bulkData.nodeLabels();
|
int* nodeLabels = bulkData.nodeLabels();
|
||||||
float* data = bulkDataGetter.data();
|
float* data = bulkDataGetter.data();
|
||||||
|
|
||||||
for (int i = 0; i < numNodes; i++)
|
for (int nIdx = 0; nIdx < numNodes; nIdx++)
|
||||||
{
|
{
|
||||||
for (int comp = 0; comp < numComp; comp++)
|
for (int comp = 0; comp < numComp; comp++)
|
||||||
{
|
{
|
||||||
(*(*resultValues)[comp])[nodeIdToIdxMap[nodeLabels[i]]] = data[i*numComp + comp];
|
std::vector<float>* singleComponentValues = (*resultValues)[comp];
|
||||||
|
(*singleComponentValues)[nodeIdToIdxMap[nodeLabels[nIdx]]] = data[nIdx*numComp + comp];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1008,7 +1026,9 @@ void RifOdbReader::readNodeField(const std::string& fieldName, int partIndex, in
|
|||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
void RifOdbReader::readElementNodeField(const std::string& fieldName, int partIndex, int stepIndex, int frameIndex, std::vector<std::vector<float>*>* resultValues)
|
void RifOdbReader::readElementNodeField(const std::string& fieldName,
|
||||||
|
int partIndex, int stepIndex, int frameIndex,
|
||||||
|
std::vector<std::vector<float>*>* resultValues)
|
||||||
{
|
{
|
||||||
CVF_ASSERT(resultValues);
|
CVF_ASSERT(resultValues);
|
||||||
|
|
||||||
@ -1025,13 +1045,14 @@ void RifOdbReader::readElementNodeField(const std::string& fieldName, int partIn
|
|||||||
{
|
{
|
||||||
CVF_ASSERT((*resultValues)[comp]);
|
CVF_ASSERT((*resultValues)[comp]);
|
||||||
|
|
||||||
(*resultValues)[comp]->resize(dataSize);
|
(*resultValues)[comp]->resize(dataSize, std::numeric_limits<float>::infinity());
|
||||||
(*resultValues)[comp]->assign(dataSize, std::numeric_limits<float>::infinity());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const odb_Frame& frame = stepFrame(stepIndex, frameIndex);
|
const odb_Frame& frame = stepFrame(stepIndex, frameIndex);
|
||||||
const odb_SequenceFieldBulkData& seqFieldBulkData = fieldBulkData(fieldName, ELEMENT_NODAL, partInstance, frame);
|
const odb_FieldOutput& instanceFieldOutput = frame.fieldOutputs()[fieldName.c_str()].getSubset(*partInstance);
|
||||||
|
const odb_FieldOutput& fieldOutput = instanceFieldOutput.getSubset(odb_Enum::ELEMENT_NODAL);
|
||||||
|
const odb_SequenceFieldBulkData& seqFieldBulkData = fieldOutput.bulkDataBlocks();
|
||||||
|
|
||||||
std::map<int, int>& elementIdToIdxMap = m_elementIdToIdxMaps[partIndex];
|
std::map<int, int>& elementIdToIdxMap = m_elementIdToIdxMaps[partIndex];
|
||||||
CVF_ASSERT(elementIdToIdxMap.size() > 0);
|
CVF_ASSERT(elementIdToIdxMap.size() > 0);
|
||||||
@ -1046,25 +1067,20 @@ void RifOdbReader::readElementNodeField(const std::string& fieldName, int partIn
|
|||||||
int numValues = bulkData.length();
|
int numValues = bulkData.length();
|
||||||
int numComp = bulkData.width();
|
int numComp = bulkData.width();
|
||||||
int elemCount = bulkData.numberOfElements();
|
int elemCount = bulkData.numberOfElements();
|
||||||
int ipCount = numValues/elemCount;
|
int elemNodeCount = numValues/elemCount;
|
||||||
int* elementLabels = bulkData.elementLabels();
|
int* elementLabels = bulkData.elementLabels();
|
||||||
float* data = bulkDataGetter.data();
|
float* data = bulkDataGetter.data();
|
||||||
|
|
||||||
RigElementType eType = toRigElementType(bulkData.baseElementType());
|
|
||||||
const int* elmNodeToIpResultMapping = localElmNodeToIntegrationPointMapping(eType);
|
|
||||||
if (!elmNodeToIpResultMapping) continue;
|
|
||||||
|
|
||||||
for (int elem = 0; elem < elemCount; elem++)
|
for (int elem = 0; elem < elemCount; elem++)
|
||||||
{
|
{
|
||||||
int elementIdx = elementIdToIdxMap[elementLabels[elem*ipCount]];
|
int elementIdx = elementIdToIdxMap[elementLabels[elem*elemNodeCount]];
|
||||||
int elementResultStartDestIdx = elementIdx*ipCount; // Ikke generellt riktig !
|
int elementResultStartDestIdx = elementIdx*elemNodeCount; // Ikke generellt riktig !
|
||||||
int elementResultStartSourceIdx = elem*ipCount*numComp;
|
int elementResultStartSourceIdx = elem*elemNodeCount*numComp;
|
||||||
|
|
||||||
for (int ipIdx = 0; ipIdx < ipCount; ipIdx++)
|
for (int elemNode = 0; elemNode < elemNodeCount; elemNode++)
|
||||||
{
|
{
|
||||||
int resultIpIdx = elmNodeToIpResultMapping[ipIdx];
|
int destIdx = elementResultStartDestIdx + elemNode;
|
||||||
int destIdx = elementResultStartDestIdx + ipIdx;
|
int srcIdx = elementResultStartSourceIdx + elemNode*numComp;
|
||||||
int srcIdx = elementResultStartSourceIdx + resultIpIdx*numComp;
|
|
||||||
|
|
||||||
for (int comp = 0; comp < numComp; comp++)
|
for (int comp = 0; comp < numComp; comp++)
|
||||||
{
|
{
|
||||||
@ -1096,13 +1112,14 @@ void RifOdbReader::readIntegrationPointField(const std::string& fieldName, int p
|
|||||||
{
|
{
|
||||||
CVF_ASSERT((*resultValues)[comp]);
|
CVF_ASSERT((*resultValues)[comp]);
|
||||||
|
|
||||||
(*resultValues)[comp]->resize(dataSize);
|
(*resultValues)[comp]->resize(dataSize, std::numeric_limits<float>::infinity());
|
||||||
(*resultValues)[comp]->assign(dataSize, std::numeric_limits<float>::infinity());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const odb_Frame& frame = stepFrame(stepIndex, frameIndex);
|
const odb_Frame& frame = stepFrame(stepIndex, frameIndex);
|
||||||
const odb_SequenceFieldBulkData& seqFieldBulkData = fieldBulkData(fieldName, INTEGRATION_POINT, partInstance, frame);
|
const odb_FieldOutput& instanceFieldOutput = frame.fieldOutputs()[fieldName.c_str()].getSubset(*partInstance);
|
||||||
|
const odb_FieldOutput& fieldOutput = instanceFieldOutput.getSubset(odb_Enum::INTEGRATION_POINT);
|
||||||
|
const odb_SequenceFieldBulkData& seqFieldBulkData = fieldOutput.bulkDataBlocks();
|
||||||
|
|
||||||
std::map<int, int>& elementIdToIdxMap = m_elementIdToIdxMaps[partIndex];
|
std::map<int, int>& elementIdToIdxMap = m_elementIdToIdxMaps[partIndex];
|
||||||
CVF_ASSERT(elementIdToIdxMap.size() > 0);
|
CVF_ASSERT(elementIdToIdxMap.size() > 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user