mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-09 23:16:00 -06:00
Reading element node and integration point fields
Implemented RifOdbReader::readScalarElementNodeField() and RifOdbReader::readScalarIntegrationPointField(). Needs verification. Test files with element nodal fields needed.
This commit is contained in:
parent
d5eb383abd
commit
64bbcc04f8
@ -462,6 +462,7 @@ size_t RifOdbReader::resultItemCount(const std::string& fieldName, int stepIndex
|
||||
return resultItemCount;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -539,7 +540,7 @@ void RifOdbReader::readScalarNodeField(const std::string& fieldName, const std::
|
||||
CVF_ASSERT(compIndex >= 0);
|
||||
|
||||
const odb_Frame& frame = stepFrame(stepIndex, frameIndex);
|
||||
const odb_FieldOutput& fieldOutput = frame.fieldOutputs()[fieldName.c_str()];
|
||||
const odb_FieldOutput& fieldOutput = frame.fieldOutputs()[fieldName.c_str()].getSubset(odb_Enum::NODAL);
|
||||
const odb_SequenceFieldBulkData& seqFieldBulkData = fieldOutput.bulkDataBlocks();
|
||||
|
||||
size_t dataIndex = 0;
|
||||
@ -573,6 +574,38 @@ void RifOdbReader::readScalarElementNodeField(const std::string& fieldName, cons
|
||||
// TODO:
|
||||
// Need example files containing element node results for testing
|
||||
// Or, consider reporting integration point results as element node results too, and extrapolate when requested
|
||||
|
||||
size_t dataSize = resultItemCount(fieldName, stepIndex, frameIndex);
|
||||
if (dataSize > 0)
|
||||
{
|
||||
resultValues->resize(dataSize);
|
||||
}
|
||||
|
||||
int compIndex = componentIndex(RifOdbResultPosition::ELEMENT_NODAL, fieldName, componentName);
|
||||
CVF_ASSERT(compIndex >= 0);
|
||||
|
||||
const odb_Frame& frame = stepFrame(stepIndex, frameIndex);
|
||||
const odb_FieldOutput& fieldOutput = frame.fieldOutputs()[fieldName.c_str()].getSubset(odb_Enum::ELEMENT_NODAL);
|
||||
const odb_SequenceFieldBulkData& seqFieldBulkData = fieldOutput.bulkDataBlocks();
|
||||
|
||||
size_t dataIndex = 0;
|
||||
int numBlocks = seqFieldBulkData.size();
|
||||
for (int block = 0; block < numBlocks; block++)
|
||||
{
|
||||
const odb_FieldBulkData& bulkData = seqFieldBulkData[block];
|
||||
|
||||
if (bulkData.numberOfNodes() > 0)
|
||||
{
|
||||
int numNodes = bulkData.length();
|
||||
int numComp = bulkData.width();
|
||||
float* data = bulkData.data();
|
||||
|
||||
for (int i = 0; i < numNodes; i++)
|
||||
{
|
||||
(*resultValues)[dataIndex++] = data[i*numComp + compIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -583,7 +616,34 @@ void RifOdbReader::readScalarIntegrationPointField(const std::string& fieldName,
|
||||
{
|
||||
CVF_ASSERT(resultValues);
|
||||
|
||||
// TODO
|
||||
size_t dataSize = resultItemCount(fieldName, stepIndex, frameIndex);
|
||||
if (dataSize > 0)
|
||||
{
|
||||
resultValues->resize(dataSize);
|
||||
}
|
||||
|
||||
int compIndex = componentIndex(RifOdbResultPosition::INTEGRATION_POINT, fieldName, componentName);
|
||||
CVF_ASSERT(compIndex >= 0);
|
||||
|
||||
const odb_Frame& frame = stepFrame(stepIndex, frameIndex);
|
||||
const odb_FieldOutput& fieldOutput = frame.fieldOutputs()[fieldName.c_str()].getSubset(odb_Enum::INTEGRATION_POINT);
|
||||
const odb_SequenceFieldBulkData& seqFieldBulkData = fieldOutput.bulkDataBlocks();
|
||||
|
||||
size_t dataIndex = 0;
|
||||
int numBlocks = seqFieldBulkData.size();
|
||||
for (int block = 0; block < numBlocks; block++)
|
||||
{
|
||||
const odb_FieldBulkData& bulkData = seqFieldBulkData[block];
|
||||
|
||||
int numNodes = bulkData.length();
|
||||
int numComp = bulkData.width();
|
||||
float* data = bulkData.data();
|
||||
|
||||
for (int i = 0; i < numNodes; i++)
|
||||
{
|
||||
(*resultValues)[dataIndex++] = data[i*numComp + compIndex];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -62,6 +62,18 @@ TEST(OdbReaderTest, BasicTests)
|
||||
reader->readScalarNodeField("U", "U2", 0, 0, 1, &displacementValues);
|
||||
EXPECT_EQ(5168, displacementValues.size());
|
||||
|
||||
std::vector<float> integrationPointS22;
|
||||
reader->readScalarIntegrationPointField("S", "22", 0, 0, 1, &integrationPointS22);
|
||||
EXPECT_EQ(34560, integrationPointS22.size());
|
||||
|
||||
std::vector<float> integrationPointE33;
|
||||
reader->readScalarIntegrationPointField("E", "33", 0, 0, 1, &integrationPointE33);
|
||||
EXPECT_EQ(34560, integrationPointE33.size());
|
||||
|
||||
std::vector<float> integrationPointTEMP;
|
||||
reader->readScalarIntegrationPointField("TEMP", "", 0, 0, 1, &integrationPointTEMP);
|
||||
EXPECT_EQ(34560, integrationPointTEMP.size());
|
||||
|
||||
std::vector<cvf::Vec3f> displacements;
|
||||
reader->readDisplacements(0, 0, 1, &displacements);
|
||||
EXPECT_EQ(5168, displacements.size());
|
||||
|
Loading…
Reference in New Issue
Block a user