mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -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:
@@ -462,6 +462,7 @@ size_t RifOdbReader::resultItemCount(const std::string& fieldName, int stepIndex
|
|||||||
return resultItemCount;
|
return resultItemCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@@ -539,7 +540,7 @@ void RifOdbReader::readScalarNodeField(const std::string& fieldName, const std::
|
|||||||
CVF_ASSERT(compIndex >= 0);
|
CVF_ASSERT(compIndex >= 0);
|
||||||
|
|
||||||
const odb_Frame& frame = stepFrame(stepIndex, frameIndex);
|
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();
|
const odb_SequenceFieldBulkData& seqFieldBulkData = fieldOutput.bulkDataBlocks();
|
||||||
|
|
||||||
size_t dataIndex = 0;
|
size_t dataIndex = 0;
|
||||||
@@ -573,6 +574,38 @@ void RifOdbReader::readScalarElementNodeField(const std::string& fieldName, cons
|
|||||||
// TODO:
|
// TODO:
|
||||||
// Need example files containing element node results for testing
|
// Need example files containing element node results for testing
|
||||||
// Or, consider reporting integration point results as element node results too, and extrapolate when requested
|
// 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);
|
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);
|
reader->readScalarNodeField("U", "U2", 0, 0, 1, &displacementValues);
|
||||||
EXPECT_EQ(5168, displacementValues.size());
|
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;
|
std::vector<cvf::Vec3f> displacements;
|
||||||
reader->readDisplacements(0, 0, 1, &displacements);
|
reader->readDisplacements(0, 0, 1, &displacements);
|
||||||
EXPECT_EQ(5168, displacements.size());
|
EXPECT_EQ(5168, displacements.size());
|
||||||
|
|||||||
Reference in New Issue
Block a user