mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-09 23:16:00 -06:00
Renaming of geo mech interface, separated results reporting for different result positions
Reporting nodal, element nodal, and integration point result names separately. Some functions in the geo mech interface were renamed. Renamed "result" to "field" in function and parameter names in the interface. TODO: Consider if we should report integration point results as element node results too, and extrapolate when requested, if needed. Fixed map handling in RifOdbReader::componentIndex().
This commit is contained in:
parent
ebfad85b5b
commit
5a9f22bfd2
@ -42,10 +42,14 @@ public:
|
||||
virtual ~RifGeoMechReaderInterface();
|
||||
|
||||
virtual bool readFemParts(const std::string& fileName, RigFemPartCollection* geoMechCase) = 0;
|
||||
virtual std::vector<std::string> steps() = 0;
|
||||
virtual std::vector<double> frameTimeValues(int stepIndex) = 0;
|
||||
virtual std::map<std::string, std::vector<std::string> > scalarNodeResultNames() const = 0;
|
||||
virtual void readScalarNodeResult(const std::string& resultName, const std::string& componmentName, int partIndex, int stepIndex, int frameIndex, std::vector<float>* resultValues) = 0;
|
||||
virtual std::vector<std::string> stepNames() = 0;
|
||||
virtual std::vector<double> frameTimes(int stepIndex) = 0;
|
||||
|
||||
virtual std::map<std::string, std::vector<std::string> > scalarNodeFieldAndComponentNames() const = 0;
|
||||
virtual std::map<std::string, std::vector<std::string> > scalarElementNodeFieldAndComponentNames() const = 0;
|
||||
virtual std::map<std::string, std::vector<std::string> > scalarIntegrationPointFieldAndComponentNames() const = 0;
|
||||
|
||||
virtual void readScalarNodeField(const std::string& fieldName, const std::string& componmentName, int partIndex, int stepIndex, int frameIndex, std::vector<float>* resultValues) = 0;
|
||||
virtual void readDisplacements(int partIndex, int stepIndex, int frameIndex, std::vector<cvf::Vec3f>* displacements) = 0;
|
||||
|
||||
private:
|
||||
|
@ -178,6 +178,62 @@ void readOdbFile(const std::string& fileName, RigFemPartCollection* femParts)
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::map<std::string, std::vector<std::string> > scalarFieldAndComponentNames(odb_Odb* odb, odb_Enum::odb_ResultPositionEnum resultPosition)
|
||||
{
|
||||
CVF_ASSERT(odb != NULL);
|
||||
|
||||
std::map<std::string, std::vector<std::string> > resultNamesMap;
|
||||
|
||||
odb_StepRepository stepRepository = odb->steps();
|
||||
odb_StepRepositoryIT sIter(stepRepository);
|
||||
for (sIter.first(); !sIter.isDone(); sIter.next())
|
||||
{
|
||||
odb_SequenceFrame& stepFrames = stepRepository[sIter.currentKey()].frames();
|
||||
|
||||
int numFrames = stepFrames.size();
|
||||
for (int f = 0; f < numFrames; f++)
|
||||
{
|
||||
odb_Frame frame = stepFrames.constGet(f);
|
||||
|
||||
odb_FieldOutputRepository& fieldCon = frame.fieldOutputs();
|
||||
odb_FieldOutputRepositoryIT fieldConIT(fieldCon);
|
||||
for (fieldConIT.first(); !fieldConIT.isDone(); fieldConIT.next())
|
||||
{
|
||||
odb_FieldOutput& field = fieldCon[fieldConIT.currentKey()];
|
||||
|
||||
odb_SequenceFieldLocation fieldLocations = field.locations();
|
||||
for (int loc = 0; loc < fieldLocations.size(); loc++)
|
||||
{
|
||||
const odb_FieldLocation& fieldLocation = fieldLocations.constGet(loc);
|
||||
if (fieldLocation.position() == resultPosition || resultPosition == odb_Enum::odb_ResultPositionEnum::UNDEFINED_POSITION)
|
||||
{
|
||||
std::string fieldName = field.name().CStr();
|
||||
odb_SequenceString components = field.componentLabels();
|
||||
|
||||
std::vector<std::string> compVec;
|
||||
|
||||
int numComp = components.size();
|
||||
for (int comp = 0; comp < numComp; comp++)
|
||||
{
|
||||
compVec.push_back(components[comp].CStr());
|
||||
}
|
||||
|
||||
resultNamesMap.insert(std::make_pair(fieldName, compVec));
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return resultNamesMap;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -209,7 +265,7 @@ bool RifOdbReader::readFemParts(const std::string& fileName, RigFemPartCollectio
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<std::string> RifOdbReader::steps()
|
||||
std::vector<std::string> RifOdbReader::stepNames()
|
||||
{
|
||||
CVF_ASSERT(m_odb != NULL);
|
||||
|
||||
@ -229,7 +285,7 @@ std::vector<std::string> RifOdbReader::steps()
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<double> RifOdbReader::frameTimeValues(int stepIndex)
|
||||
std::vector<double> RifOdbReader::frameTimes(int stepIndex)
|
||||
{
|
||||
CVF_ASSERT(m_odb != NULL);
|
||||
|
||||
@ -256,48 +312,30 @@ std::vector<double> RifOdbReader::frameTimeValues(int stepIndex)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::map<std::string, std::vector<std::string> > RifOdbReader::scalarNodeResultNames() const
|
||||
std::map<std::string, std::vector<std::string> > RifOdbReader::scalarNodeFieldAndComponentNames() const
|
||||
{
|
||||
CVF_ASSERT(m_odb != NULL);
|
||||
|
||||
std::map<std::string, std::vector<std::string> > resultNamesMap;
|
||||
|
||||
odb_StepRepository stepRepository = m_odb->steps();
|
||||
odb_StepRepositoryIT sIter(stepRepository);
|
||||
for (sIter.first(); !sIter.isDone(); sIter.next())
|
||||
{
|
||||
odb_SequenceFrame& stepFrames = stepRepository[sIter.currentKey()].frames();
|
||||
|
||||
int numFrames = stepFrames.size();
|
||||
for (int f = 0; f < numFrames; f++)
|
||||
{
|
||||
odb_Frame frame = stepFrames.constGet(f);
|
||||
|
||||
odb_FieldOutputRepository& fieldCon = frame.fieldOutputs();
|
||||
odb_FieldOutputRepositoryIT fieldConIT(fieldCon);
|
||||
for (fieldConIT.first(); !fieldConIT.isDone(); fieldConIT.next())
|
||||
{
|
||||
odb_FieldOutput& field = fieldCon[fieldConIT.currentKey()];
|
||||
|
||||
std::string fieldName = field.name().CStr();
|
||||
odb_SequenceString components = field.componentLabels();
|
||||
|
||||
std::vector<std::string> compVec;
|
||||
|
||||
int numComp = components.size();
|
||||
for (int comp = 0; comp < numComp; comp++)
|
||||
{
|
||||
compVec.push_back(components[comp].CStr());
|
||||
}
|
||||
|
||||
resultNamesMap.insert(std::make_pair(fieldName, compVec));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return resultNamesMap;
|
||||
return scalarFieldAndComponentNames(m_odb, odb_Enum::odb_ResultPositionEnum::NODAL);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::map<std::string, std::vector<std::string> > RifOdbReader::scalarElementNodeFieldAndComponentNames() const
|
||||
{
|
||||
return scalarFieldAndComponentNames(m_odb, odb_Enum::odb_ResultPositionEnum::ELEMENT_NODAL);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::map<std::string, std::vector<std::string> > RifOdbReader::scalarIntegrationPointFieldAndComponentNames() const
|
||||
{
|
||||
return scalarFieldAndComponentNames(m_odb, odb_Enum::odb_ResultPositionEnum::INTEGRATION_POINT);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -317,15 +355,15 @@ odb_Frame RifOdbReader::stepFrame(int stepIndex, int frameIndex) const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Get the number of result items (== #nodes or #elements)
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
size_t RifOdbReader::resultItemCount(const std::string& resultName, int stepIndex, int frameIndex) const
|
||||
size_t RifOdbReader::resultItemCount(const std::string& fieldName, int stepIndex, int frameIndex) const
|
||||
{
|
||||
const odb_Frame& frame = stepFrame(stepIndex, frameIndex);
|
||||
const odb_FieldOutputRepository& fieldOutputRepo = frame.fieldOutputs();
|
||||
|
||||
odb_String fieldName = resultName.c_str();
|
||||
CVF_ASSERT(fieldOutputRepo.isMember(fieldName));
|
||||
odb_String fieldNameStr = fieldName.c_str();
|
||||
CVF_ASSERT(fieldOutputRepo.isMember(fieldNameStr));
|
||||
|
||||
const odb_FieldOutput& fieldOutput = fieldOutputRepo[fieldName];
|
||||
const odb_FieldOutput& fieldOutput = fieldOutputRepo[fieldNameStr];
|
||||
const odb_SequenceFieldBulkData& seqFieldBulkData = fieldOutput.bulkDataBlocks();
|
||||
|
||||
size_t resultItemCount = 0;
|
||||
@ -343,11 +381,17 @@ size_t RifOdbReader::resultItemCount(const std::string& resultName, int stepInde
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
int RifOdbReader::componentIndex(const std::string& resultName, const std::string& componentName) const
|
||||
int RifOdbReader::componentIndex(const std::string& fieldName, const std::string& componentName) const
|
||||
{
|
||||
std::map<std::string, std::vector<std::string> > resultCompMap = scalarNodeResultNames();
|
||||
std::map<std::string, std::vector<std::string> > resultCompMap = scalarFieldAndComponentNames(m_odb, odb_Enum::odb_ResultPositionEnum::UNDEFINED_POSITION);
|
||||
|
||||
std::vector<std::string> comps = resultCompMap.at(resultName);
|
||||
std::vector<std::string> comps;
|
||||
|
||||
auto mapIt = resultCompMap.find(fieldName);
|
||||
if (mapIt != resultCompMap.end())
|
||||
{
|
||||
comps = mapIt->second;
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < comps.size(); i++)
|
||||
{
|
||||
@ -364,21 +408,21 @@ int RifOdbReader::componentIndex(const std::string& resultName, const std::strin
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifOdbReader::readScalarNodeResult(const std::string& resultName, const std::string& componentName, int partIndex, int stepIndex, int frameIndex, std::vector<float>* resultValues)
|
||||
void RifOdbReader::readScalarNodeField(const std::string& fieldName, const std::string& componentName, int partIndex, int stepIndex, int frameIndex, std::vector<float>* resultValues)
|
||||
{
|
||||
CVF_ASSERT(resultValues);
|
||||
|
||||
size_t dataSize = resultItemCount(resultName, stepIndex, frameIndex);
|
||||
size_t dataSize = resultItemCount(fieldName, stepIndex, frameIndex);
|
||||
if (dataSize > 0)
|
||||
{
|
||||
resultValues->resize(dataSize);
|
||||
}
|
||||
|
||||
int compIndex = componentIndex(resultName, componentName);
|
||||
int compIndex = componentIndex(fieldName, componentName);
|
||||
CVF_ASSERT(compIndex >= 0);
|
||||
|
||||
const odb_Frame& frame = stepFrame(stepIndex, frameIndex);
|
||||
const odb_FieldOutput& fieldOutput = frame.fieldOutputs()[resultName.c_str()];
|
||||
const odb_FieldOutput& fieldOutput = frame.fieldOutputs()[fieldName.c_str()];
|
||||
const odb_SequenceFieldBulkData& seqFieldBulkData = fieldOutput.bulkDataBlocks();
|
||||
|
||||
size_t dataIndex = 0;
|
||||
@ -401,6 +445,31 @@ void RifOdbReader::readScalarNodeResult(const std::string& resultName, const std
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifOdbReader::readScalarElementNodeField(const std::string& fieldName, const std::string& componentName, int partIndex, int stepIndex, int frameIndex, std::vector<float>* resultValues)
|
||||
{
|
||||
CVF_ASSERT(resultValues);
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifOdbReader::readScalarIntegrationPointField(const std::string& fieldName, const std::string& componentName, int partIndex, int stepIndex, int frameIndex, std::vector<float>* resultValues)
|
||||
{
|
||||
CVF_ASSERT(resultValues);
|
||||
|
||||
// TODO
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@ -408,7 +477,6 @@ void RifOdbReader::readDisplacements(int partIndex, int stepIndex, int frameInde
|
||||
{
|
||||
CVF_ASSERT(displacements);
|
||||
|
||||
//
|
||||
size_t dataSize = resultItemCount("U", stepIndex, frameIndex);
|
||||
if (dataSize > 0)
|
||||
{
|
||||
|
@ -40,23 +40,30 @@ public:
|
||||
RifOdbReader();
|
||||
virtual ~RifOdbReader();
|
||||
|
||||
virtual bool readFemParts(const std::string& fileName, RigFemPartCollection* geoMechCase);
|
||||
virtual std::vector<std::string> stepNames();
|
||||
virtual std::vector<double> frameTimes(int stepIndex);
|
||||
|
||||
virtual std::map<std::string, std::vector<std::string> > scalarNodeFieldAndComponentNames() const;
|
||||
virtual std::map<std::string, std::vector<std::string> > scalarElementNodeFieldAndComponentNames() const;
|
||||
virtual std::map<std::string, std::vector<std::string> > scalarIntegrationPointFieldAndComponentNames() const;
|
||||
|
||||
virtual void readScalarNodeField(const std::string& fieldName, const std::string& componmentName, int partIndex, int stepIndex, int frameIndex, std::vector<float>* resultValues);
|
||||
virtual void readScalarElementNodeField(const std::string& fieldName, const std::string& componmentName, int partIndex, int stepIndex, int frameIndex, std::vector<float>* resultValues);
|
||||
virtual void readScalarIntegrationPointField(const std::string& fieldName, const std::string& componmentName, int partIndex, int stepIndex, int frameIndex, std::vector<float>* resultValues);
|
||||
virtual void readDisplacements(int partIndex, int stepIndex, int frameIndex, std::vector<cvf::Vec3f>* displacements);
|
||||
|
||||
bool openFile(const std::string& fileName);
|
||||
|
||||
static void initializeOdbAPI();
|
||||
static void finalizeOdbAPI();
|
||||
|
||||
virtual bool readFemParts(const std::string& fileName, RigFemPartCollection* geoMechCase);
|
||||
virtual std::vector<std::string> steps();
|
||||
virtual std::vector<double> frameTimeValues(int stepIndex);
|
||||
virtual std::map<std::string, std::vector<std::string> > scalarNodeResultNames() const;
|
||||
virtual void readScalarNodeResult(const std::string& resultName, const std::string& componmentName, int partIndex, int stepIndex, int frameIndex, std::vector<float>* resultValues);
|
||||
virtual void readDisplacements(int partIndex, int stepIndex, int frameIndex, std::vector<cvf::Vec3f>* displacements);
|
||||
|
||||
bool openFile(const std::string& fileName);
|
||||
|
||||
private:
|
||||
void close();
|
||||
size_t resultItemCount(const std::string& resultName, int stepIndex, int frameIndex) const;
|
||||
odb_Frame stepFrame(int stepIndex, int frameIndex) const;
|
||||
int componentIndex(const std::string& resultName, const std::string& componentName) const;
|
||||
|
||||
void close();
|
||||
size_t resultItemCount(const std::string& fieldName, int stepIndex, int frameIndex) const;
|
||||
odb_Frame stepFrame(int stepIndex, int frameIndex) const;
|
||||
int componentIndex(const std::string& fieldName, const std::string& componentName) const;
|
||||
|
||||
private:
|
||||
odb_Odb* m_odb;
|
||||
|
@ -41,18 +41,24 @@ TEST(OdbReaderTest, BasicTests)
|
||||
|
||||
cvf::ref<RifOdbReader> reader2 = new RifOdbReader;
|
||||
EXPECT_EQ(true, reader2->openFile(TEST_FILE));
|
||||
EXPECT_EQ(true, reader2->steps().size() == 1);
|
||||
EXPECT_EQ(true, reader2->stepNames().size() == 1);
|
||||
|
||||
std::vector<std::string> steps = reader2->steps();
|
||||
std::vector<std::string> steps = reader2->stepNames();
|
||||
EXPECT_EQ(true, steps.at(0).find("Date_20100930") >= 0);
|
||||
EXPECT_EQ(2, reader2->frameTimeValues(0).size());
|
||||
EXPECT_EQ(1.0, reader2->frameTimeValues(0)[1]);
|
||||
EXPECT_EQ(2, reader2->frameTimes(0).size());
|
||||
EXPECT_EQ(1.0, reader2->frameTimes(0)[1]);
|
||||
|
||||
std::map<std::string, std::vector<std::string> > resultNamesMap = reader2->scalarNodeResultNames();
|
||||
EXPECT_EQ(8, resultNamesMap.size());
|
||||
std::map<std::string, std::vector<std::string> > scalarNodeFieldsMap = reader2->scalarNodeFieldAndComponentNames();
|
||||
EXPECT_EQ(3, scalarNodeFieldsMap.size());
|
||||
|
||||
std::map<std::string, std::vector<std::string> > scalarElementNodeFieldsMap = reader2->scalarElementNodeFieldAndComponentNames();
|
||||
EXPECT_EQ(0, scalarElementNodeFieldsMap.size());
|
||||
|
||||
std::map<std::string, std::vector<std::string> > scalarIntegrationPointFieldsMap = reader2->scalarIntegrationPointFieldAndComponentNames();
|
||||
EXPECT_EQ(6, scalarIntegrationPointFieldsMap.size());
|
||||
|
||||
std::vector<float> displacementValues;
|
||||
reader2->readScalarNodeResult("U", "U2", 0, 0, 1, &displacementValues);
|
||||
reader2->readScalarNodeField("U", "U2", 0, 0, 1, &displacementValues);
|
||||
EXPECT_EQ(5168, displacementValues.size());
|
||||
|
||||
std::vector<cvf::Vec3f> displacements;
|
||||
|
Loading…
Reference in New Issue
Block a user