STARCDsurfaceFormat - read cellTable names from .inp file

This commit is contained in:
Mark Olesen 2009-12-07 15:33:35 +01:00
parent c183d0875d
commit 8227aee6a2
3 changed files with 75 additions and 1 deletions

View File

@ -85,6 +85,18 @@ bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read
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
List<label> pointId;
@ -171,7 +183,22 @@ bool Foam::fileFormats::STARCDsurfaceFormat<Face>::read
{
zoneI = dynSizes.size();
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);
}

View File

@ -26,6 +26,7 @@ License
#include "STARCDsurfaceFormatCore.H"
#include "clock.H"
#include "regExp.H"
#include "IStringStream.H"
// * * * * * * * * * * * * * 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
(
IFstream& is,

View File

@ -62,6 +62,8 @@ protected:
static void writeHeader(Ostream&, const char* filetype);
static Map<word> readInpCellTable(IFstream&);
static bool readPoints(IFstream&, pointField&, labelList& ids);
static void writePoints(Ostream&, const pointField&);