mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#10842 INP grid importer: create sets for GENERATE keyword.
Fixes #10842.
This commit is contained in:
parent
2beb830102
commit
a2919d4b0e
@ -213,9 +213,10 @@ void RifInpReader::read( std::istream&
|
|||||||
}
|
}
|
||||||
else if ( uppercasedLine.starts_with( "*ELSET," ) )
|
else if ( uppercasedLine.starts_with( "*ELSET," ) )
|
||||||
{
|
{
|
||||||
|
bool isGenerateSet = uppercasedLine.find( "GENERATE" ) != std::string::npos;
|
||||||
skipComments( stream );
|
skipComments( stream );
|
||||||
std::string setName = parseLabel( line, "elset" );
|
std::string setName = parseLabel( line, "elset" );
|
||||||
auto elementSet = readElementSet( stream );
|
auto elementSet = isGenerateSet ? readElementSetGenerate( stream ) : readElementSet( stream );
|
||||||
elementSets[partId].push_back( { setName, elementSet } );
|
elementSets[partId].push_back( { setName, elementSet } );
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,6 +332,44 @@ std::vector<size_t> RifInpReader::readElementSet( std::istream& stream )
|
|||||||
return elementSet;
|
return elementSet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
std::vector<size_t> RifInpReader::readElementSetGenerate( std::istream& stream )
|
||||||
|
{
|
||||||
|
std::vector<size_t> elementSet;
|
||||||
|
|
||||||
|
// Read until we find a new section (which should start with a '*').
|
||||||
|
while ( stream.peek() != '*' && stream.peek() != EOF )
|
||||||
|
{
|
||||||
|
// Read entire line of comma-separated values
|
||||||
|
std::string line;
|
||||||
|
std::getline( stream, line );
|
||||||
|
|
||||||
|
// Process the comma-separated values
|
||||||
|
auto parts = RiaStdStringTools::splitString( line, ',' );
|
||||||
|
if ( parts.size() >= 3 )
|
||||||
|
{
|
||||||
|
int firstElement = RiaStdStringTools::toInt( parts[0] );
|
||||||
|
int lastElement = RiaStdStringTools::toInt( parts[1] );
|
||||||
|
int increment = RiaStdStringTools::toInt( parts[2] );
|
||||||
|
if ( lastElement < firstElement || increment <= 0 )
|
||||||
|
{
|
||||||
|
RiaLogging::error( "Encountered illegal set definition (using GENERATE keyword)." );
|
||||||
|
return elementSet;
|
||||||
|
}
|
||||||
|
|
||||||
|
for ( int i = firstElement; i < lastElement; i += increment )
|
||||||
|
{
|
||||||
|
int elementId = i - 1;
|
||||||
|
elementSet.push_back( elementId );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return elementSet;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@ -78,6 +78,7 @@ private:
|
|||||||
static std::vector<std::pair<int, cvf::Vec3d>> readNodes( std::istream& stream );
|
static std::vector<std::pair<int, cvf::Vec3d>> readNodes( std::istream& stream );
|
||||||
static std::vector<std::pair<int, std::vector<int>>> readElements( std::istream& stream );
|
static std::vector<std::pair<int, std::vector<int>>> readElements( std::istream& stream );
|
||||||
static std::vector<size_t> readElementSet( std::istream& stream );
|
static std::vector<size_t> readElementSet( std::istream& stream );
|
||||||
|
static std::vector<size_t> readElementSetGenerate( std::istream& stream );
|
||||||
|
|
||||||
static void read( std::istream& stream,
|
static void read( std::istream& stream,
|
||||||
std::map<int, std::string>& parts,
|
std::map<int, std::string>& parts,
|
||||||
|
Loading…
Reference in New Issue
Block a user