Add flex version selection of the yywrap() function to support

the new and more correct version 2.5.34.
This commit is contained in:
henry
2008-05-29 23:29:28 +01:00
parent ff6dd11bc2
commit 8dc018bb53
6 changed files with 81 additions and 56 deletions

View File

@ -70,7 +70,11 @@ PtrList<SLList<label> > slPatchCellFaces;
// Dummy yywrap to keep yylex happy at compile time. // Dummy yywrap to keep yylex happy at compile time.
// It is called by yylex but is not used as the mechanism to change file. // It is called by yylex but is not used as the mechanism to change file.
// See <<EOF>> // See <<EOF>>
#if YY_FLEX_SUBMINOR_VERSION < 34
extern "C" int yywrap() extern "C" int yywrap()
#else
int yyFlexLexer::yywrap()
#endif
{ {
return 1; return 1;
} }
@ -393,7 +397,7 @@ int main(int argc, char *argv[])
} }
// Warning: tet face order has changed between version 1.9.6 and 2.0 // Warning: tet face order has changed between version 1.9.6 and 2.0
// //
label faceIndex[7][6] = label faceIndex[7][6] =
{ {
{-1, -1, -1, -1, -1, -1}, // 0 {-1, -1, -1, -1, -1, -1}, // 0

View File

@ -116,7 +116,11 @@ void uniquify(word& name, HashSet<word>& patchNames)
// Dummy yywrap to keep yylex happy at compile time. // Dummy yywrap to keep yylex happy at compile time.
// It is called by yylex but is not used as the mechanism to change file. // It is called by yylex but is not used as the mechanism to change file.
// See <<EOF>> // See <<EOF>>
#if YY_FLEX_SUBMINOR_VERSION < 34
extern "C" int yywrap() extern "C" int yywrap()
#else
int yyFlexLexer::yywrap()
#endif
{ {
return 1; return 1;
} }

View File

@ -93,7 +93,7 @@ SLList<label> cellGroupEndIndex;
SLList<label> cellGroupType; SLList<label> cellGroupType;
// number of zones adjusted at run-time if necessary // number of zones adjusted at run-time if necessary
label maxZoneID = 100; label maxZoneID = 100;
label zoneIDBuffer = 10; label zoneIDBuffer = 10;
wordList patchTypeIDs(maxZoneID); wordList patchTypeIDs(maxZoneID);
@ -102,7 +102,11 @@ wordList patchNameIDs(maxZoneID);
// Dummy yywrap to keep yylex happy at compile time. // Dummy yywrap to keep yylex happy at compile time.
// It is called by yylex but is not used as the mechanism to change file. // It is called by yylex but is not used as the mechanism to change file.
// See <<EOF>> // See <<EOF>>
#if YY_FLEX_SUBMINOR_VERSION < 34
extern "C" int yywrap() extern "C" int yywrap()
#else
int yyFlexLexer::yywrap()
#endif
{ {
return 1; return 1;
} }
@ -343,7 +347,7 @@ endOfSection {space}")"{space}
// In FOAM, indices start from zero - adjust // In FOAM, indices start from zero - adjust
pointI = pointGroupStartIndex.last() - 1; pointI = pointGroupStartIndex.last() - 1;
// reset number of components to default // reset number of components to default
pointGroupNumberOfComponents = 3; pointGroupNumberOfComponents = 3;
// read number of components in the vector // read number of components in the vector
@ -375,7 +379,7 @@ endOfSection {space}")"{space}
IStringStream vertexXyzStream(YYText()); IStringStream vertexXyzStream(YYText());
// Note: coordinates must be read one at the time. // Note: coordinates must be read one at the time.
scalar x = readScalar(vertexXyzStream); scalar x = readScalar(vertexXyzStream);
scalar y = readScalar(vertexXyzStream); scalar y = readScalar(vertexXyzStream);
@ -387,7 +391,7 @@ endOfSection {space}")"{space}
IStringStream vertexXyzStream(YYText()); IStringStream vertexXyzStream(YYText());
// Note: coordinates must be read one at the time. // Note: coordinates must be read one at the time.
scalar x = readScalar(vertexXyzStream); scalar x = readScalar(vertexXyzStream);
scalar y = readScalar(vertexXyzStream); scalar y = readScalar(vertexXyzStream);
scalar z = readScalar(vertexXyzStream); scalar z = readScalar(vertexXyzStream);
@ -587,7 +591,7 @@ endOfSection {space}")"{space}
// Note. Potentially skip cell set if type is zero. // Note. Potentially skip cell set if type is zero.
// This entry does not exist in Tgrid files. // This entry does not exist in Tgrid files.
if (dimensionOfGrid == 2) if (dimensionOfGrid == 2)
{ {
// Tgrid creating triangles // Tgrid creating triangles
@ -702,7 +706,7 @@ endOfSection {space}")"{space}
IStringStream zoneDataStream(YYText()); IStringStream zoneDataStream(YYText());
// cell zone-ID not in hexadecimal!!! Inconsistency // cell zone-ID not in hexadecimal!!! Inconsistency
label zoneID(readLabel(zoneDataStream)); label zoneID(readLabel(zoneDataStream));
if (zoneID > maxZoneID - 1) if (zoneID > maxZoneID - 1)
@ -727,7 +731,7 @@ endOfSection {space}")"{space}
// Fluent manual inconsistency, version 6.1.22 // Fluent manual inconsistency, version 6.1.22
IStringStream zoneDataStream(YYText()); IStringStream zoneDataStream(YYText());
// cell zone-ID not in hexadecimal!!! Inconsistency // cell zone-ID not in hexadecimal!!! Inconsistency
label zoneID(readLabel(zoneDataStream)); label zoneID(readLabel(zoneDataStream));
if (zoneID > maxZoneID - 1) if (zoneID > maxZoneID - 1)
@ -879,7 +883,7 @@ int main(int argc, char *argv[])
{ {
scaleFactor = atof(args.options()["scale"].c_str()); scaleFactor = atof(args.options()["scale"].c_str());
} }
bool writeSets = args.options().found("writeSets"); bool writeSets = args.options().found("writeSets");
bool writeZones = args.options().found("writeZones"); bool writeZones = args.options().found("writeZones");
@ -901,7 +905,7 @@ int main(int argc, char *argv[])
Info<< "\n\nFINISHED LEXING\n\n\n"; Info<< "\n\nFINISHED LEXING\n\n\n";
// Lookup table giving number of vertices given a fluent cell type ID // Lookup table giving number of vertices given a fluent cell type ID
// Currently not used. // Currently not used.
// label fluentModelNVertices[7] = {-1, 3, 4, 4, 8, 5, 6}; // label fluentModelNVertices[7] = {-1, 3, 4, 4, 8, 5, 6};
// Lookup table giving number of vertices given a fluent cell type ID // Lookup table giving number of vertices given a fluent cell type ID
@ -973,7 +977,7 @@ int main(int argc, char *argv[])
// Note: In order for the owner-neighbour rules to be right, the // Note: In order for the owner-neighbour rules to be right, the
// points given by Fluent need to represent the FRONT plane of the // points given by Fluent need to represent the FRONT plane of the
// geometry. Therefore, the extrusion will be in -z direction // geometry. Therefore, the extrusion will be in -z direction
// //
forAll (oldPoints, pointI) forAll (oldPoints, pointI)
{ {
points[nNewPoints] = oldPoints[pointI]; points[nNewPoints] = oldPoints[pointI];
@ -1131,20 +1135,20 @@ int main(int argc, char *argv[])
//make patchless mesh before analysing boundaries //make patchless mesh before analysing boundaries
faceListList patches(0); faceListList patches(0);
wordList patchNames(0); wordList patchNames(0);
wordList patchTypes(0); wordList patchTypes(0);
word defaultFacesName = "defaultFaces"; word defaultFacesName = "defaultFaces";
word defaultFacesType = emptyPolyPatch::typeName; word defaultFacesType = emptyPolyPatch::typeName;
wordList patchPhysicalTypes(0); wordList patchPhysicalTypes(0);
// Scale the points // Scale the points
points *= scaleFactor; points *= scaleFactor;
Info<< "Building patch-less mesh..." << flush; Info<< "Building patch-less mesh..." << flush;
polyMesh pShapeMesh polyMesh pShapeMesh
( (
IOobject IOobject
@ -1167,13 +1171,13 @@ int main(int argc, char *argv[])
//and zones wont be written //and zones wont be written
//checkmesh done after patch addition as well //checkmesh done after patch addition as well
Info<< "done." << endl; Info<< "done." << endl;
Info<< endl << "Building boundary and internal patches." << endl; Info<< endl << "Building boundary and internal patches." << endl;
//adding patches after mesh construction allows topological checks //adding patches after mesh construction allows topological checks
//on whether a patch is internal or external, something fluent //on whether a patch is internal or external, something fluent
//doesnt seem to mind //doesnt seem to mind
// Make boundary patches // Make boundary patches
SLList<label>::iterator faceGroupZoneIDIter = faceGroupZoneID.begin(); SLList<label>::iterator faceGroupZoneIDIter = faceGroupZoneID.begin();
@ -1183,7 +1187,7 @@ int main(int argc, char *argv[])
// Note. Not all groups of faces will be boundary patches. // Note. Not all groups of faces will be boundary patches.
// Take care on construction // Take care on construction
//2D needs extra space for frontAndBack faces //2D needs extra space for frontAndBack faces
if (dimensionOfGrid == 2) if (dimensionOfGrid == 2)
{ {
@ -1221,7 +1225,7 @@ int main(int argc, char *argv[])
Info<< "Creating patch " << nPatches Info<< "Creating patch " << nPatches
<< " for zone: " << faceGroupZoneIDIter() << " for zone: " << faceGroupZoneIDIter()
<< " start: " << faceGroupStartIndexIter() << " start: " << faceGroupStartIndexIter()
<< " end: " << faceGroupEndIndexIter() << " end: " << faceGroupEndIndexIter()
<< " type: " << curPatchType << " name: " << curPatchName << endl; << " type: " << curPatchType << " name: " << curPatchName << endl;
@ -1251,7 +1255,7 @@ int main(int argc, char *argv[])
} }
//inlets and outlets //inlets and outlets
if if
( (
curPatchType == "pressure" curPatchType == "pressure"
|| curPatchType == "pressure-inlet" || curPatchType == "pressure-inlet"
@ -1317,7 +1321,7 @@ int main(int argc, char *argv[])
Info<< "Patch " << faceGroupZoneIDIter() Info<< "Patch " << faceGroupZoneIDIter()
<< ": Faces are defined but " << ": Faces are defined but "
<< "not created as a zone." << endl << "not created as a zone." << endl
<< "Null specification is only valid for internal faces." << "Null specification is only valid for internal faces."
<< endl; << endl;
patches[nPatches] = patchFaces; patches[nPatches] = patchFaces;
@ -1346,14 +1350,14 @@ int main(int argc, char *argv[])
nPatches++; nPatches++;
} }
//Now have all patch information, //Now have all patch information,
//check whether each patch is internal or external //check whether each patch is internal or external
//and add boundaries to mesh //and add boundaries to mesh
//also write face sets of all patches //also write face sets of all patches
patches.setSize(nPatches); patches.setSize(nPatches);
patchTypes.setSize(nPatches); patchTypes.setSize(nPatches);
patchNames.setSize(nPatches); patchNames.setSize(nPatches);
//old polyBoundary //old polyBoundary
const polyBoundaryMesh& oPatches = pShapeMesh.boundaryMesh(); const polyBoundaryMesh& oPatches = pShapeMesh.boundaryMesh();
@ -1401,12 +1405,12 @@ int main(int argc, char *argv[])
//if a face is defined as internal but is actually external //if a face is defined as internal but is actually external
//it will be put in a default wall boundary //it will be put in a default wall boundary
//internal boundaries are simply ignored //internal boundaries are simply ignored
if(patchTypes[patchI] != "internal" && !pShapeMesh.isInternalFace(meshFaces[0])) if(patchTypes[patchI] != "internal" && !pShapeMesh.isInternalFace(meshFaces[0]))
{ {
//first face is external and has valid non-internal type //first face is external and has valid non-internal type
//check all faces for externalness just to be sure //check all faces for externalness just to be sure
//and mark patch number to global list //and mark patch number to global list
forAll(meshFaces, i) forAll(meshFaces, i)
{ {
@ -1424,7 +1428,7 @@ int main(int argc, char *argv[])
if(facePatchID[faceI - pShapeMesh.nInternalFaces()]!= -1) if(facePatchID[faceI - pShapeMesh.nInternalFaces()]!= -1)
{ {
FatalErrorIn(args.executable()) FatalErrorIn(args.executable())
<< "Face " << faceI << " on new patch " << "Face " << faceI << " on new patch "
<< patchNames[patchI] << patchNames[patchI]
<< " has already been marked for repatching to" << " has already been marked for repatching to"
<< " patch " << " patch "
@ -1435,8 +1439,8 @@ int main(int argc, char *argv[])
} }
//add to boundary patch //add to boundary patch
Info<< "Adding new patch " << patchNames[patchI] Info<< "Adding new patch " << patchNames[patchI]
<< " of type " << patchTypes[patchI] << " of type " << patchTypes[patchI]
<< " as patch " << nBoundaries << endl; << " as patch " << nBoundaries << endl;
@ -1458,15 +1462,15 @@ int main(int argc, char *argv[])
} }
else else
{ {
Info<< "Patch " << patchNames[patchI] Info<< "Patch " << patchNames[patchI]
<< " is internal to the mesh " << " is internal to the mesh "
<< " and is not being added to the boundary." << " and is not being added to the boundary."
<< endl; << endl;
} }
} }
// Check for any remaining boundary faces // Check for any remaining boundary faces
// and add them to a default wall patch // and add them to a default wall patch
// this routine should generally not be invoked // this routine should generally not be invoked
{ {
@ -1480,16 +1484,16 @@ int main(int argc, char *argv[])
} }
} }
defaultBoundaryFaces.shrink(); defaultBoundaryFaces.shrink();
if(defaultBoundaryFaces.size() != 0) if(defaultBoundaryFaces.size() != 0)
{ {
Warning << " fluent mesh has " << defaultBoundaryFaces.size() Warning << " fluent mesh has " << defaultBoundaryFaces.size()
<< " undefined boundary faces." << endl << " undefined boundary faces." << endl
<< " Adding undefined faces to new patch `default_wall`" << " Adding undefined faces to new patch `default_wall`"
<< endl; << endl;
// Add patch to new patch list // Add patch to new patch list
newPatches.append newPatches.append
( (
polyPatch::New polyPatch::New
@ -1506,11 +1510,11 @@ int main(int argc, char *argv[])
cMeshFace += defaultBoundaryFaces.size(); cMeshFace += defaultBoundaryFaces.size();
} }
} }
newPatches.shrink(); newPatches.shrink();
// Use facePatchIDs map to reorder boundary faces into compact regions // Use facePatchIDs map to reorder boundary faces into compact regions
repatchPolyTopoChanger repatcher(pShapeMesh); repatchPolyTopoChanger repatcher(pShapeMesh);
// Add new list of patches // Add new list of patches
@ -1544,11 +1548,11 @@ int main(int argc, char *argv[])
// Zones // Zones
// will write out cell zones and internal faces for those zones // will write out cell zones and internal faces for those zones
// note: zone boundary faces are not added to face zones // note: zone boundary faces are not added to face zones
// the names of boundaries bordering on cell zones are written to // the names of boundaries bordering on cell zones are written to
// a list containing the boundary name and cellzone it borders on // a list containing the boundary name and cellzone it borders on
// interior boundaries are handled via faceSets // interior boundaries are handled via faceSets
// cell zones will only be written if there is more than one // cell zones will only be written if there is more than one
if (writeZones && cellGroupZoneID.size()>1) if (writeZones && cellGroupZoneID.size()>1)
{ {
Info<< "Adding Zones" << endl; Info<< "Adding Zones" << endl;
@ -1559,14 +1563,14 @@ int main(int argc, char *argv[])
// Make face zones for cell zones // Make face zones for cell zones
List<faceZone*> fz(nrCellZones); List<faceZone*> fz(nrCellZones);
// List of patch names and the cellZone(s) they border // List of patch names and the cellZone(s) they border
// this is just an info file to make MRF easier to setup // this is just an info file to make MRF easier to setup
List<DynamicList<word> > boundaryZones List<DynamicList<word> > boundaryZones
( (
pShapeMesh.boundaryMesh().size() pShapeMesh.boundaryMesh().size()
); );
const polyBoundaryMesh& bPatches = pShapeMesh.boundaryMesh(); const polyBoundaryMesh& bPatches = pShapeMesh.boundaryMesh();
forAll(bPatches, pI) forAll(bPatches, pI)
{ {
@ -1591,7 +1595,7 @@ int main(int argc, char *argv[])
// Mark zone cells, used for finding faces // Mark zone cells, used for finding faces
boolList zoneCell(pShapeMesh.nCells(), false); boolList zoneCell(pShapeMesh.nCells(), false);
// shift cell indizes by 1 // shift cell indizes by 1
label nr=0; label nr=0;
for (label celli = (start() - 1); celli < end(); celli++) for (label celli = (start() - 1); celli < end(); celli++)
@ -1645,11 +1649,11 @@ int main(int argc, char *argv[])
break; break;
} }
} }
} }
cnt++; cnt++;
} }
pShapeMesh.addZones(pz, fz, cz); pShapeMesh.addZones(pz, fz, cz);
forAll(bPatches, pI) forAll(bPatches, pI)
@ -1676,10 +1680,10 @@ int main(int argc, char *argv[])
} }
Info<< endl << "Writing mesh..." << flush; Info<< endl << "Writing mesh..." << flush;
Info<< " to " << pShapeMesh.instance()/pShapeMesh.meshDir() Info<< " to " << pShapeMesh.instance()/pShapeMesh.meshDir()
<< " " << flush; << " " << flush;
pShapeMesh.setInstance(pShapeMesh.instance()); pShapeMesh.setInstance(pShapeMesh.instance());
pShapeMesh.write(); pShapeMesh.write();
Info<< "done." << endl << endl; Info<< "done." << endl << endl;

View File

@ -78,7 +78,11 @@ label nValuesForPatchFaces = 0;
// Dummy yywrap to keep yylex happy at compile time. // Dummy yywrap to keep yylex happy at compile time.
// It is called by yylex but is not used as the mechanism to change file. // It is called by yylex but is not used as the mechanism to change file.
// See <<EOF>> // See <<EOF>>
#if YY_FLEX_SUBMINOR_VERSION < 34
extern "C" int yywrap() extern "C" int yywrap()
#else
int yyFlexLexer::yywrap()
#endif
{ {
return 1; return 1;
} }
@ -308,7 +312,7 @@ mtype {space}"MTYPE:"{space}
label nodeI(readLabel(nodeStream)); label nodeI(readLabel(nodeStream));
// Note: coordinates must be read one at the time. // Note: coordinates must be read one at the time.
scalar x = readScalar(nodeStream); scalar x = readScalar(nodeStream);
scalar y = readScalar(nodeStream); scalar y = readScalar(nodeStream);
scalar z = readScalar(nodeStream); scalar z = readScalar(nodeStream);
@ -676,7 +680,7 @@ int main(int argc, char *argv[])
} }
} }
labelList pointLookup(maxPointIndex + 1, -1); labelList pointLookup(maxPointIndex + 1, -1);
forAll (pointMap, pointI) forAll (pointMap, pointI)
@ -806,7 +810,7 @@ int main(int argc, char *argv[])
] ]
[curFaces[faceI] - 1] // this gives a fluent face - 1 [curFaces[faceI] - 1] // this gives a fluent face - 1
]; ];
} }
} }

View File

@ -50,7 +50,11 @@ int yyFlexLexer::yylex()
// Dummy yywrap to keep yylex happy at compile time. // Dummy yywrap to keep yylex happy at compile time.
// It is called by yylex but is not used as the mechanism to change file. // It is called by yylex but is not used as the mechanism to change file.
// See <<EOF>> // See <<EOF>>
#if YY_FLEX_SUBMINOR_VERSION < 34
extern "C" int yywrap() extern "C" int yywrap()
#else
int yyFlexLexer::yywrap()
#endif
{ {
return 1; return 1;
} }

View File

@ -21,7 +21,7 @@ License
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with OpenFOAM; if not, write to the Free Software Foundation, along with OpenFOAM; if not, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
%{ %{
@ -51,7 +51,11 @@ int yyFlexLexer::yylex()
// Dummy yywrap to keep yylex happy at compile time. // Dummy yywrap to keep yylex happy at compile time.
// It is called by yylex but is not used as the mechanism to change file. // It is called by yylex but is not used as the mechanism to change file.
// See <<EOF>> // See <<EOF>>
#if YY_FLEX_SUBMINOR_VERSION < 34
extern "C" int yywrap() extern "C" int yywrap()
#else
int yyFlexLexer::yywrap()
#endif
{ {
return 1; return 1;
} }
@ -391,7 +395,8 @@ bool triSurface::readSTLASCII(const fileName& STLfileName)
// Create the lexer obtaining the approximate number of vertices in the STL // Create the lexer obtaining the approximate number of vertices in the STL
// from the file size // from the file size
STLLexer lexer(&STLstream.stdStream(), Foam::size(STLfileName)/400); STLLexer lexer(&STLstream.stdStream(), Foam::size(STLfileName)/400);
while(lexer.lex() != 0); while(lexer.lex() != 0)
{}
DynamicList<STLpoint>& STLpoints = lexer.STLpoints(); DynamicList<STLpoint>& STLpoints = lexer.STLpoints();