Skip to content

Commit

Permalink
Work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
jonjenssen committed Dec 11, 2023
1 parent 1692598 commit 75afebd
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 9 deletions.
54 changes: 47 additions & 7 deletions ApplicationLibCode/GeoMech/OdbReader/RifInpReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ bool RifInpReader::readFemParts( RigFemPartCollection* femParts )
}

// read element sets
auto elementSetsForPart = elementSets[partId];
auto& elementSetsForPart = elementSets[partId];
for ( auto [setName, elementSet] : elementSetsForPart )
{
femPart->addElementSet( setName, elementSet );
Expand All @@ -187,6 +187,8 @@ bool RifInpReader::readFemParts( RigFemPartCollection* femParts )
femPart->setElementPartId( femParts->partCount() );
femParts->addFemPart( femPart );

readScalarData( parts, m_includeEntries );

modelProgress.incrementProgress();
}

Expand Down Expand Up @@ -581,15 +583,29 @@ std::vector<size_t> RifInpReader::elementSet( int partIndex, std::string partNam
// //--------------------------------------------------------------------------------------------------
std::map<std::string, std::vector<std::string>> RifInpReader::scalarNodeFieldAndComponentNames()
{
return {};
std::map<std::string, std::vector<std::string>> retVal;

for ( auto& entry : m_propertyPartDataNodes )
{
retVal[entry.first] = {};
}

return retVal;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::map<std::string, std::vector<std::string>> RifInpReader::scalarElementNodeFieldAndComponentNames()
{
return {};
std::map<std::string, std::vector<std::string>> retVal;

for ( auto& entry : m_propertyPartDataElements )
{
retVal[entry.first] = {};
}

return retVal;
}

//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -647,15 +663,39 @@ void RifInpReader::readIntegrationPointField( const std::string&
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const std::vector<double> RifInpReader::propertyData( std::string propertyName, int partId ) const
const std::vector<double> RifInpReader::propertyData( RigFemResultPosEnum resultType, std::string propertyName, int partId ) const
{
if ( m_propertyPartData.count( propertyName ) > 0 )
const std::map<std::string, std::map<int, std::vector<double>>>* pData = nullptr;

if ( resultType == RigFemResultPosEnum::RIG_ELEMENT )
pData = &m_propertyPartDataElements;
else if ( resultType == RigFemResultPosEnum::RIG_NODAL )
pData = &m_propertyPartDataNodes;

if ( pData != nullptr )
{
if ( m_propertyPartData.at( propertyName ).count( partId ) > 0 )
if ( pData->count( propertyName ) > 0 )
{
return m_propertyPartData.at( propertyName ).at( partId );
if ( pData->at( propertyName ).count( partId ) > 0 )
{
return pData->at( propertyName ).at( partId );
}
}
}

return {};
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RifInpReader::readScalarData( std::map<int, std::string>& parts, std::vector<RifInpIncludeEntry>& includeEntries )
{
for ( auto& entry : includeEntries )
{
if ( entry.resultType == RigFemResultPosEnum::RIG_ELEMENT )
m_propertyPartDataElements[entry.propertyName] = {};
else if ( entry.resultType == RigFemResultPosEnum::RIG_NODAL )
m_propertyPartDataNodes[entry.propertyName] = {};
}
}
6 changes: 4 additions & 2 deletions ApplicationLibCode/GeoMech/OdbReader/RifInpReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,11 @@ class RifInpReader : public RifGeoMechReaderInterface
int frameIndex,
std::vector<std::vector<float>*>* resultValues ) override;

const std::vector<double> propertyData( std::string propertyName, int partId ) const;
const std::vector<double> propertyData( RigFemResultPosEnum resultType, std::string propertyName, int partId ) const;

private:
void close();
void readScalarData( std::map<int, std::string>& parts, std::vector<RifInpIncludeEntry>& includeEntries );

static void skipComments( std::istream& stream );
static std::string parseLabel( const std::string& line, const std::string& labelName );
Expand All @@ -121,5 +122,6 @@ class RifInpReader : public RifGeoMechReaderInterface
std::vector<RifInpIncludeEntry> m_includeEntries;
std::ifstream m_stream;
std::filesystem::path m_inputPath;
std::map<std::string, std::map<int, std::vector<double>>> m_propertyPartData;
std::map<std::string, std::map<int, std::vector<double>>> m_propertyPartDataNodes;
std::map<std::string, std::map<int, std::vector<double>>> m_propertyPartDataElements;
};

0 comments on commit 75afebd

Please sign in to comment.