mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STARCDsurfaceFormat - read cellTable names from .inp file
This commit is contained in:
@ -85,6 +85,18 @@ bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read
|
|||||||
|
|
||||||
fileName baseName = filename.lessExt();
|
fileName baseName = filename.lessExt();
|
||||||
|
|
||||||
|
// read cellTable names (if possible)
|
||||||
|
Map<word> cellTableLookup;
|
||||||
|
|
||||||
|
{
|
||||||
|
IFstream is(baseName + ".inp");
|
||||||
|
if (is.good())
|
||||||
|
{
|
||||||
|
cellTableLookup = readInpCellTable(is);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// STAR-CD index of points
|
// STAR-CD index of points
|
||||||
List<label> pointId;
|
List<label> pointId;
|
||||||
|
|
||||||
@ -171,7 +183,22 @@ bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read
|
|||||||
{
|
{
|
||||||
zoneI = dynSizes.size();
|
zoneI = dynSizes.size();
|
||||||
lookup.insert(cellTableId, zoneI);
|
lookup.insert(cellTableId, zoneI);
|
||||||
dynNames.append(word("cellTable_") + ::Foam::name(zoneI));
|
|
||||||
|
Map<word>::const_iterator tableNameIter =
|
||||||
|
cellTableLookup.find(cellTableId);
|
||||||
|
|
||||||
|
if (tableNameIter == cellTableLookup.end())
|
||||||
|
{
|
||||||
|
dynNames.append
|
||||||
|
(
|
||||||
|
word("cellTable_") + ::Foam::name(cellTableId)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dynNames.append(tableNameIter());
|
||||||
|
}
|
||||||
|
|
||||||
dynSizes.append(0);
|
dynSizes.append(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -26,6 +26,7 @@ License
|
|||||||
|
|
||||||
#include "STARCDsurfaceFormatCore.H"
|
#include "STARCDsurfaceFormatCore.H"
|
||||||
#include "clock.H"
|
#include "clock.H"
|
||||||
|
#include "regExp.H"
|
||||||
#include "IStringStream.H"
|
#include "IStringStream.H"
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||||
@ -87,6 +88,50 @@ void Foam::fileFormats::STARCDsurfaceFormatCore::writeHeader
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// parse things like this:
|
||||||
|
// CTNAME 1 someName
|
||||||
|
// don't bother with the older comma-delimited format
|
||||||
|
|
||||||
|
Foam::Map<Foam::word>
|
||||||
|
Foam::fileFormats::STARCDsurfaceFormatCore::readInpCellTable
|
||||||
|
(
|
||||||
|
IFstream& is
|
||||||
|
)
|
||||||
|
{
|
||||||
|
Map<word> lookup;
|
||||||
|
|
||||||
|
regExp ctnameRE
|
||||||
|
(
|
||||||
|
" *CTNA[^ ]*" // keyword - min 4 chars
|
||||||
|
"[[:space:]]+" // space delimited
|
||||||
|
"([0-9]+)" // 1: <digits>
|
||||||
|
"[[:space:]]+" // space delimited
|
||||||
|
"([^,[:space:]].*)", // 2: <name>
|
||||||
|
true // ignore case
|
||||||
|
);
|
||||||
|
|
||||||
|
string line;
|
||||||
|
List<string> groups;
|
||||||
|
while (is.good() && is.getLine(line).good())
|
||||||
|
{
|
||||||
|
if (ctnameRE.match(line, groups))
|
||||||
|
{
|
||||||
|
const label tableId = atoi(groups[0].c_str());
|
||||||
|
|
||||||
|
// strip bad chars
|
||||||
|
string::stripInvalid<word>(groups[1]);
|
||||||
|
|
||||||
|
if (!groups[1].empty())
|
||||||
|
{
|
||||||
|
lookup.insert(tableId, groups[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return lookup;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Foam::fileFormats::STARCDsurfaceFormatCore::readPoints
|
bool Foam::fileFormats::STARCDsurfaceFormatCore::readPoints
|
||||||
(
|
(
|
||||||
IFstream& is,
|
IFstream& is,
|
||||||
|
|||||||
@ -62,6 +62,8 @@ protected:
|
|||||||
|
|
||||||
static void writeHeader(Ostream&, const char* filetype);
|
static void writeHeader(Ostream&, const char* filetype);
|
||||||
|
|
||||||
|
static Map<word> readInpCellTable(IFstream&);
|
||||||
|
|
||||||
static bool readPoints(IFstream&, pointField&, labelList& ids);
|
static bool readPoints(IFstream&, pointField&, labelList& ids);
|
||||||
|
|
||||||
static void writePoints(Ostream&, const pointField&);
|
static void writePoints(Ostream&, const pointField&);
|
||||||
|
|||||||
Reference in New Issue
Block a user