mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Added functions for element sets
The geomech interface and the ODB reader now have functions that return element set names for a given part, and that return a vector of element indexes for a given element set.
This commit is contained in:
parent
e5e36f43b9
commit
ac700e0c54
@ -46,6 +46,9 @@ public:
|
||||
virtual bool readFemParts(RigFemPartCollection* geoMechCase) = 0;
|
||||
virtual std::vector<std::string> stepNames() = 0;
|
||||
virtual std::vector<double> frameTimes(int stepIndex) = 0;
|
||||
|
||||
virtual std::vector<std::string> elementSetNames(int partIndex) = 0;
|
||||
virtual std::vector<size_t> elementSet(int partIndex, int setIndex) = 0;
|
||||
|
||||
virtual std::map<std::string, std::vector<std::string> > scalarNodeFieldAndComponentNames() = 0;
|
||||
virtual std::map<std::string, std::vector<std::string> > scalarElementNodeFieldAndComponentNames() = 0;
|
||||
|
@ -464,6 +464,77 @@ std::vector<double> RifOdbReader::frameTimes(int stepIndex)
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<std::string> RifOdbReader::elementSetNames(int partIndex)
|
||||
{
|
||||
CVF_ASSERT(m_odb != NULL);
|
||||
|
||||
std::map< int, std::vector<std::string> >::const_iterator mapIt = m_partElementSetNames.find(partIndex);
|
||||
if (mapIt == m_partElementSetNames.end())
|
||||
{
|
||||
std::vector<std::string> setNames;
|
||||
|
||||
const odb_Assembly& rootAssembly = m_odb->constRootAssembly();
|
||||
const odb_InstanceRepository& instances = rootAssembly.instances();
|
||||
|
||||
int currentInstance = 0;
|
||||
odb_InstanceRepositoryIT instIt(instances);
|
||||
for (instIt.first(); !instIt.isDone(); instIt.next(), currentInstance++)
|
||||
{
|
||||
const odb_Instance& instance = instIt.currentValue();
|
||||
|
||||
if (currentInstance == partIndex)
|
||||
{
|
||||
const odb_SetRepository& sets = rootAssembly.elementSets();
|
||||
|
||||
odb_SetRepositoryIT setIt(sets);
|
||||
for (setIt.first(); !setIt.isDone(); setIt.next())
|
||||
{
|
||||
const odb_Set& set = setIt.currentValue();
|
||||
setNames.push_back(set.name().CStr());
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
m_partElementSetNames[partIndex] = setNames;
|
||||
}
|
||||
|
||||
return m_partElementSetNames.at(partIndex);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<size_t> RifOdbReader::elementSet(int partIndex, int setIndex)
|
||||
{
|
||||
CVF_ASSERT(m_odb != NULL);
|
||||
|
||||
std::vector<std::string> setNames = elementSetNames(partIndex);
|
||||
const odb_Assembly& rootAssembly = m_odb->constRootAssembly();
|
||||
|
||||
const odb_Set& set = rootAssembly.elementSets()[odb_String(setNames[setIndex].c_str())];
|
||||
odb_SequenceString instanceNames = set.instanceNames();
|
||||
|
||||
const odb_SequenceElement& setElements = set.elements(instanceNames[partIndex]);
|
||||
int elementCount = setElements.size();
|
||||
|
||||
std::vector<size_t> elementIndexes;
|
||||
elementIndexes.resize(elementCount);
|
||||
|
||||
for (int i = 0; i < elementCount; i++)
|
||||
{
|
||||
elementIndexes[i] = setElements.element(i).index();
|
||||
}
|
||||
|
||||
return elementIndexes;
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
@ -45,6 +45,9 @@ public:
|
||||
virtual bool readFemParts(RigFemPartCollection* geoMechCase);
|
||||
virtual std::vector<std::string> stepNames();
|
||||
virtual std::vector<double> frameTimes(int stepIndex);
|
||||
|
||||
virtual std::vector<std::string> elementSetNames(int partIndex);
|
||||
virtual std::vector<size_t> elementSet(int partIndex, int setIndex);
|
||||
|
||||
virtual std::map<std::string, std::vector<std::string> > scalarNodeFieldAndComponentNames();
|
||||
virtual std::map<std::string, std::vector<std::string> > scalarElementNodeFieldAndComponentNames();
|
||||
@ -96,6 +99,7 @@ private:
|
||||
private:
|
||||
odb_Odb* m_odb;
|
||||
std::map< RifOdbResultKey, std::vector<std::string> > m_resultsMetaData;
|
||||
std::map< int, std::vector<std::string> > m_partElementSetNames;
|
||||
std::vector< std::map<int, int> > m_nodeIdToIdxMaps;
|
||||
std::vector< std::map<int, int> > m_elementIdToIdxMaps;
|
||||
static size_t sm_instanceCount;
|
||||
|
Loading…
Reference in New Issue
Block a user