Commit e3c70a83 authored by Mark Olesen's avatar Mark Olesen
Browse files

Merge commit 'OpenCFD/master' into olesenm

parents 110e9989 7c0048e8
......@@ -54,7 +54,10 @@ using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Scalae factor used to scale points (optional command line argument)
// Line number
label lineNo = 1;
// Scale factor used to scale points (optional command line argument)
scalar scaleFactor = 1.0;
label dimensionOfGrid = 0;
......@@ -131,8 +134,6 @@ one_space [ \t\f]
space {one_space}*
some_space {one_space}+
cspace ","{space}
nl (\n|\r)
spaceNl ({space}|{nl})*
alpha [_[:alpha:]]
digit [[:digit:]]
......@@ -146,7 +147,7 @@ quote \"
dash "-"
dotColonDash [.:-]
schemeSpecialInitial [!$%&*/\\:<=>?~_^#.@]
schemeSpecialInitial [!$%&*/\\:<=>?~_^#.@']
schemeSpecialSubsequent [.+-]
schemeSymbol (({some_space}|{alpha}|{quote}|{schemeSpecialInitial})({alpha}|{quote}|{digit}|{schemeSpecialInitial}|{schemeSpecialSubsequent})*)
......@@ -187,23 +188,23 @@ time ({digit}{digit}":"{digit}{digit}":"{digit}{digit})
versionNumber ({digit}|".")*
header {spaceNl}"(1"{space}
dimension {spaceNl}"(2"{space}
points {spaceNl}"(10"{space}
faces {spaceNl}"(13"{space}
cells {spaceNl}"(12"{space}
zoneVariant1 {spaceNl}"(39"{space}
zoneVariant2 {spaceNl}"(45"{space}
faceTree {spaceNl}"(59"{space}
header {space}"(1"{space}
dimension {space}"(2"{space}
points {space}"(10"{space}
faces {space}"(13"{space}
cells {space}"(12"{space}
zoneVariant1 {space}"(39"{space}
zoneVariant2 {space}"(45"{space}
faceTree {space}"(59"{space}
comment "0"{space}
unknownPeriodicFace "17"{space}
periodicFace "18"{space}
cellTree "58"{space}
faceParents "61"{space}
ignoreBlocks ("4"|"37"|"38"|"41"|"60"|"64"){space}
ignoreBlocks ("4"|"37"|"38"|"40"|"41"|"60"|"64"){space}
redundantBlock {spaceNl}({comment}|{unknownPeriodicFace}|{periodicFace}|{cellTree}|{faceParents}|{ignoreBlocks}){space}
redundantBlock {space}({comment}|{unknownPeriodicFace}|{periodicFace}|{cellTree}|{faceParents}|{ignoreBlocks}){space}
endOfSection {space}")"{space}
......@@ -290,7 +291,7 @@ endOfSection {space}")"{space}
BEGIN(readPointHeader);
}
<readPointHeader>{spaceNl}{lbrac}{space}"0"{space}"1"{space} {
<readPointHeader>{space}{lbrac}{space}"0"{space}"1"{space} {
BEGIN(readNumberOfPoints);
}
......@@ -302,7 +303,7 @@ endOfSection {space}")"{space}
// Ignore rest of stream
}
<readPointHeader>{spaceNl}{lbrac} {
<readPointHeader>{space}{lbrac} {
BEGIN(readPointGroupData);
}
......@@ -342,7 +343,7 @@ endOfSection {space}")"{space}
BEGIN(readPointData);
}
<readPointData>{spaceNl}{lbrac}{spaceNl} {
<readPointData>{space}{lbrac}{space} {
Info<< ". Reading points..." << flush;
cmpt = 0;
yy_push_state(readScalarList);
......@@ -350,20 +351,33 @@ endOfSection {space}")"{space}
<readScalarList>{signedInteger}{space} {
points[pointi][cmpt++] = scaleFactor*atol(YYText());
if (cmpt == pointGroupNumberOfComponents)
{
if (pointGroupNumberOfComponents == 2)
{
points[pointi].z() = 0.0;
}
cmpt = 0;
pointi++;
}
}
<readScalarList>{scalar}{space} {
points[pointi][cmpt++] = scaleFactor*atof(YYText());
}
<readScalarList>{spaceNl} {
if (cmpt == pointGroupNumberOfComponents)
{
if (pointGroupNumberOfComponents == 2)
{
points[pointi].z() = 0.0;
}
cmpt = 0;
pointi++;
}
}
<readScalarList>{endOfSection} {
Info<< "done." << endl;
......@@ -372,12 +386,13 @@ endOfSection {space}")"{space}
if (pointi != pointGroupEndIndex[pointGroupEndIndex.size()-1]+1)
{
Warning
<< "Problem with reading points: "
<< "start index: "
<< "Problem with reading points: " << nl
<< " start index: "
<< pointGroupStartIndex[pointGroupStartIndex.size()-1]
<< " end index: "
<< pointGroupEndIndex[pointGroupEndIndex.size()-1]
<< " last points read: " << pointi << endl;
<< " last points read: " << pointi << nl
<< " on line " << lineNo << endl;
}
yy_pop_state();
......@@ -387,7 +402,7 @@ endOfSection {space}")"{space}
BEGIN(readFaceHeader);
}
<readFaceHeader>{spaceNl}{lbrac}{space}"0"{space}"1"{space} {
<readFaceHeader>{space}{lbrac}{space}"0"{space}"1"{space} {
BEGIN(readNumberOfFaces);
}
......@@ -403,7 +418,7 @@ endOfSection {space}")"{space}
// Type and element type not read
}
<readFaceHeader>{spaceNl}{lbrac} {
<readFaceHeader>{space}{lbrac} {
BEGIN(readFaceGroupData);
}
......@@ -431,12 +446,12 @@ endOfSection {space}")"{space}
<< faceGroupEndIndex[faceGroupEndIndex.size()-1] << flush;
}
<readNumberOfFaces,readFaceGroupData>{spaceNl}{endOfSection} {
<readNumberOfFaces,readFaceGroupData>{space}{endOfSection} {
BEGIN(readFaceData);
}
<readFaceData>{spaceNl}{lbrac} {
if (faceGroupElementType == 0)
<readFaceData>{space}{lbrac} {
if (faceGroupElementType == 0 || faceGroupElementType > 4)
{
Info<< ". Reading mixed faces..." << flush;
yy_push_state(readFacesMixed);
......@@ -448,7 +463,7 @@ endOfSection {space}")"{space}
}
}
<readFacesMixed>{spaceNl}{hexLabelList} {
<readFacesMixed>{space}{hexLabelList} {
face& curFaceLabels = faces[facei];
// set size of label list
......@@ -465,7 +480,7 @@ endOfSection {space}")"{space}
facei++;
}
<readFacesUniform>{spaceNl}{hexLabelList} {
<readFacesUniform>{space}{hexLabelList} {
face& curFaceLabels = faces[facei];
// Set size of label list.
......@@ -484,19 +499,20 @@ endOfSection {space}")"{space}
facei++;
}
<readFacesMixed,readFacesUniform>{spaceNl}{endOfSection} {
<readFacesMixed,readFacesUniform>{space}{endOfSection} {
Info<< "done." << endl;
// check read of fluentFaces
if (facei != faceGroupEndIndex[faceGroupEndIndex.size()-1]+1)
{
Warning
<< "Problem with reading fluentFaces: "
<< "start index: "
<< "Problem with reading fluentFaces: " << nl
<< " start index: "
<< faceGroupStartIndex[faceGroupStartIndex.size()-1]
<< " end index: "
<< faceGroupEndIndex[faceGroupEndIndex.size()-1]
<< " last fluentFaces read: " << facei << endl;
<< " last fluentFaces read: " << facei << nl
<< " on line " << lineNo << endl;
}
yy_pop_state();
......@@ -507,7 +523,7 @@ endOfSection {space}")"{space}
BEGIN(readCellHeader);
}
<readCellHeader>{spaceNl}{lbrac}{space}"0"{space}"1"{space} {
<readCellHeader>{space}{lbrac}{space}"0"{space}"1"{space} {
BEGIN(readNumberOfCells);
}
......@@ -516,7 +532,7 @@ endOfSection {space}")"{space}
Info<< "Number of cells: " << nCells << endl;
}
<readCellHeader>{spaceNl}{lbrac} {
<readCellHeader>{space}{lbrac} {
BEGIN(readCellGroupData);
}
......@@ -526,7 +542,8 @@ endOfSection {space}")"{space}
// non-standard cell definition from Tgrid, which misses the type label.
Warning
<< "Tgrid syntax problem: " << YYText() << endl;
<< "Tgrid syntax problem: " << YYText() << nl
<< " on line " << lineNo << endl;
// read cell zone-ID, start and end-label
cellGroupZoneID.append(strtol(YYText(), &endPtr, 16));
......@@ -580,7 +597,7 @@ endOfSection {space}")"{space}
BEGIN(readCellData);
}
<readCellData>{spaceNl}{lbrac} {
<readCellData>{space}{lbrac} {
// Quickly scan to the end of the cell data block and discard
register int c;
while ((c = yyinput()) != 0 && c != ')')
......@@ -601,7 +618,7 @@ endOfSection {space}")"{space}
BEGIN(readZoneHeader);
}
<readZoneHeader>{spaceNl}{lbrac} {
<readZoneHeader>{space}{lbrac} {
BEGIN(readZoneGroupData);
}
......@@ -623,17 +640,18 @@ endOfSection {space}")"{space}
BEGIN(readZoneData);
}
<readZoneData>{spaceNl}{lbrac} {
<readZoneData>{space}{lbrac} {
Info<< ". Reading zone data..." << flush;
yy_push_state(readZoneBlock);
}
<readZoneBlock>{spaceNl}{schemeSymbolList} {
<readZoneBlock>{space}{schemeSymbolList} {
}
<readZoneBlock>{lbrac} {
Warning
<< "Found unknown block in zone: " << YYText() << endl;
//Warning
// << "Found unknown block in zone: " << YYText() << nl
// << " on line " << lineNo << endl;
yy_push_state(ignoreBlock);
}
......@@ -646,7 +664,7 @@ endOfSection {space}")"{space}
/* ------ Reading end of section and others ------ */
<readHeader,readDimension,readPointData,readFaceData,readCellData,readZoneData>{spaceNl}{endOfSection} {
<readHeader,readDimension,readPointData,readFaceData,readCellData,readZoneData>{space}{endOfSection} {
BEGIN(INITIAL);
}
......@@ -655,7 +673,8 @@ endOfSection {space}")"{space}
{lbrac}{label} {
Warning
<< "Found unknown block of type: "
<< Foam::string(YYText())(1, YYLeng()-1) << endl;
<< Foam::string(YYText())(1, YYLeng()-1) << nl
<< " on line " << lineNo << endl;
yy_push_state(ignoreBlock);
}
......@@ -664,40 +683,47 @@ endOfSection {space}")"{space}
yy_push_state(ignoreBlock);
}
<ignoreBlock,ignoreEmbeddedBlock>{spaceNl}{quote}{text}{quote} {
<ignoreBlock,ignoreEmbeddedBlock>{space}{quote}{text}{quote} {
}
<ignoreBlock,ignoreEmbeddedBlock>{spaceNl}{schemeSymbol} {
<ignoreBlock,ignoreEmbeddedBlock>{space}{schemeSymbol} {
}
<ignoreBlock,ignoreEmbeddedBlock>{spaceNl}{lbrac} {
<ignoreBlock,ignoreEmbeddedBlock>{space}{lbrac} {
yy_push_state(ignoreEmbeddedBlock);
}
<ignoreBlock,ignoreEmbeddedBlock>{spaceNl}{endOfSection} {
<ignoreBlock,ignoreEmbeddedBlock>{space}{endOfSection} {
yy_pop_state();
}
<ignoreBlock,ignoreEmbeddedBlock>{spaceNl}{labelList} {
<ignoreBlock,ignoreEmbeddedBlock>{space}{labelList} {
}
<ignoreBlock,ignoreEmbeddedBlock>{spaceNl}{hexLabelList} {
<ignoreBlock,ignoreEmbeddedBlock>{space}{hexLabelList} {
}
<ignoreBlock,ignoreEmbeddedBlock>{spaceNl}{scalarList} {
<ignoreBlock,ignoreEmbeddedBlock>{space}{scalarList} {
}
<ignoreBlock,ignoreEmbeddedBlock>{spaceNl}{schemeSymbolList} {
<ignoreBlock,ignoreEmbeddedBlock>{space}{schemeSymbolList} {
}
<ignoreBlock,ignoreEmbeddedBlock>{spaceNl}{text} {
<ignoreBlock,ignoreEmbeddedBlock>{space}{text} {
}
/* ------ Count newlines. ------ */
<*>\n {
lineNo++;
}
/* ------ Ignore remaining space and \n s. ------ */
/* ------ Ignore remaining space. ------ */
<*>{some_space}|\n|\r {
<*>{some_space}|\r {
}
......@@ -706,7 +732,8 @@ endOfSection {space}")"{space}
<*>. {
// This is a catch all.
FatalErrorIn("fluentMeshToFoam::lexer")
<< "Do not understand characters: " << YYText()
<< "Do not understand characters: " << YYText() << nl
<< " on line " << lineNo
<< exit(FatalError);
}
......@@ -882,11 +909,8 @@ int main(int argc, char *argv[])
// Check the face groups for boundary patches, baffles and faceZones
// ignoring the interior zones in ignoreCellGroups
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
label nPatches = 0;
labelList patchIDs(faceGroupZoneID.size());
label nFaceZones = 0;
labelList faceZoneIDs(faceGroupZoneID.size());
DynamicList<label> patchIDs(faceGroupZoneID.size());
DynamicList<label> faceZoneIDs(faceGroupZoneID.size());
forAll(faceGroupZoneID, fgi)
{
......@@ -900,13 +924,13 @@ int main(int argc, char *argv[])
// Check the first element of neighbour for boundary group
if (neighbour[start] == -1 || fluentGroupToFoamPatch.found(type))
{
patchIDs[nPatches++] = fgi;
patchIDs.append(fgi);
}
else
{
if (!ignoreFaceGroups.found(groupName[faceGroupZoneID[fgi] ]))
if (!ignoreFaceGroups.found(groupName[faceGroupZoneID[fgi]]))
{
faceZoneIDs[nFaceZones++] = fgi;
faceZoneIDs.append(fgi);
}
}
}
......@@ -928,20 +952,32 @@ int main(int argc, char *argv[])
}
else
{
FatalErrorIn(args.executable())
if (neighbour[start] == -1)
{
// Boundary face in unknown group. Create a patch for it.
groupType.insert(zoneID, "unknown");
groupName.insert(zoneID, "FaceGroup" + Foam::name(zoneID));
patchIDs.append(fgi);
Info<< "Created patch " << fgi << " for unknown FaceGroup "
<< zoneID << '.' << endl;
}
else
{
WarningIn(args.executable())
<< "Unknown FaceGroup " << zoneID << " not in a zone"
<< exit(FatalError);
<< endl;
}
}
}
patchIDs.setSize(nPatches);
faceZoneIDs.setSize(nFaceZones);
patchIDs.shrink();
faceZoneIDs.shrink();
// Add empty patches
// ~~~~~~~~~~~~~~~~~
List<polyPatch*> newPatches(nPatches);
List<polyPatch*> newPatches(patchIDs.size());
HashSet<word> patchNames;
forAll(patchIDs, patchi)
......@@ -1024,7 +1060,7 @@ int main(int argc, char *argv[])
}
// Face zones
mesh.faceZones().setSize(nFaceZones);
mesh.faceZones().setSize(faceZoneIDs.size());
HashSet<word> faceZoneNames;
forAll(faceZoneIDs, faceZonei)
......@@ -1098,6 +1134,8 @@ int main(int argc, char *argv[])
}
bool doneWarning = false;
// Add faceZone faces
forAll(faceZoneIDs, faceZonei)
{
......@@ -1112,6 +1150,22 @@ int main(int argc, char *argv[])
<< endl;
for (label facei = start; facei <= end; facei++)
{
if (owner[facei] >= nCells || neighbour[facei] >= nCells)
{
if (!doneWarning)
{
WarningIn(args.executable())
<< "Ignoring internal face " << facei
<< " on FaceZone " << zoneID
<< " since owner " << owner[facei] << " or neighbour "
<< neighbour[facei] << " outside range of cells 0.."
<< nCells-1 << endl
<< " Suppressing future warnings." << endl;
doneWarning = true;
}
}
else
{
meshMod.addFace
(
......@@ -1126,6 +1180,7 @@ int main(int argc, char *argv[])
faceZonei, // zoneID
false // zoneFlip
);
}
// Mark face as being done
owner[facei] = -1;
......@@ -1146,6 +1201,22 @@ int main(int argc, char *argv[])
<< endl;
for (label facei = start; facei <= end; facei++)
{
if (owner[facei] >= nCells || neighbour[facei] >= nCells)
{
if (!doneWarning)
{
WarningIn(args.executable())
<< "Ignoring patch face " << facei
<< " on FaceZone " << zoneID
<< " since owner " << owner[facei] << " or neighbour "
<< neighbour[facei] << " outside range of cells 0.."
<< nCells-1 << endl
<< " Suppressing future warnings." << endl;
doneWarning = true;
}
}
else
{
meshMod.addFace
(
......@@ -1178,7 +1249,7 @@ int main(int argc, char *argv[])
false // zoneFlip
);
}
}
// Mark face as being done
owner[facei] = -1;
}
......@@ -1198,6 +1269,21 @@ int main(int argc, char *argv[])
<< exit(FatalError);
}
if (owner[facei] >= nCells || neighbour[facei] >= nCells)
{
if (!doneWarning)
{
WarningIn(args.executable())
<< "Ignoring internal face " << facei
<< " since owner " << owner[facei] << " or neighbour "
<< neighbour[facei] << " outside range of cells 0.."
<< nCells-1 << endl
<< " Suppressing future warnings." << endl;
doneWarning = true;
}
}
else
{
meshMod.addFace
(
faces[facei],
......@@ -1213,6 +1299,7 @@ int main(int argc, char *argv[])
);
}
}
}
// Reclaim storage
faces.setSize(0);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment