From 941969a78b48e2391260f0638db73149b0ed5130 Mon Sep 17 00:00:00 2001 From: Henrik Rusche Date: Mon, 9 Jun 2014 11:39:24 +0200 Subject: [PATCH] Revert to latest version of fluentMeshToFoam Add faunctionality in preservePatchTypes to ensure full compatibility --- .../fluentMeshToFoam/fluentMeshToFoam.L | 168 +++++++++--------- .../preservePatchTypes/preservePatchTypes.C | 70 ++++++++ .../preservePatchTypes/preservePatchTypes.H | 13 ++ 3 files changed, 165 insertions(+), 86 deletions(-) diff --git a/applications/utilities/mesh/conversion/fluentMeshToFoam/fluentMeshToFoam.L b/applications/utilities/mesh/conversion/fluentMeshToFoam/fluentMeshToFoam.L index 38fec2d72..4d7abe7fa 100644 --- a/applications/utilities/mesh/conversion/fluentMeshToFoam/fluentMeshToFoam.L +++ b/applications/utilities/mesh/conversion/fluentMeshToFoam/fluentMeshToFoam.L @@ -34,9 +34,9 @@ Description #undef yyFlexLexer - /* ------------------------------------------------------------------------- *\ +/* ------------------------------------------------------------------------- *\ ------ local definitions - \* ------------------------------------------------------------------------- */ +\* ------------------------------------------------------------------------- */ #include "argList.H" #include "objectRegistry.H" @@ -46,6 +46,7 @@ Description #include "emptyPolyPatch.H" #include "wallPolyPatch.H" #include "symmetryPolyPatch.H" +#include "preservePatchTypes.H" #include "cellShape.H" #include "faceSet.H" #include "cellSet.H" @@ -131,7 +132,7 @@ quote \" dash "-" dotColonDash [.:-] -schemeSpecialInitial [!$%&*/:<=>?~_^#.] +schemeSpecialInitial [!$%&*/\\:<=>?~_^#.@'] schemeSpecialSubsequent [.+-] schemeSymbol (({some_space}|{alpha}|{quote}|{schemeSpecialInitial})({alpha}|{quote}|{digit}|{schemeSpecialInitial}|{schemeSpecialSubsequent})*) @@ -141,7 +142,7 @@ integer {decDigit}+ label [1-9]{decDigit}* hexLabel {hexDigit}+ zeroLabel {digit}* - +signedInteger [-+]?{integer} word ({alpha}|{digit}|{dotColonDash})* exponent_part [eE][-+]?{digit}+ @@ -251,11 +252,11 @@ endOfSection {space}")"{space} %} - /* ------------------------------------------------------------------------- *\ + /* ------------------------------------------------------------------------ *\ ------ Start Lexing ------ - \* ------------------------------------------------------------------------- */ + \* ------------------------------------------------------------------------ */ - /* ------ Reading control header ------ */ + /* ------ Reading control header ------ */ {comment} { yy_push_state(readComment); @@ -490,7 +491,7 @@ endOfSection {space}")"{space} // set size of label list curFaceLabels.setSize(readLabel(mixedFaceStream)); - forAll(curFaceLabels, i) + forAll (curFaceLabels, i) { curFaceLabels[i] = readHexLabel(mixedFaceStream) - 1; } @@ -511,7 +512,7 @@ endOfSection {space}")"{space} // for edge is 2, for triangle is 3 and for quad is 4 curFaceLabels.setSize(faceGroupElementType); - forAll(curFaceLabels, i) + forAll (curFaceLabels, i) { curFaceLabels[i] = readHexLabel(mixedFaceStream) - 1; } @@ -765,7 +766,6 @@ endOfSection {space}")"{space} } {lbrac} { - Info<< "Found unknown block in zone:" << YYText() << endl; yy_push_state(unknownBlock); } @@ -785,7 +785,6 @@ endOfSection {space}")"{space} {lbrac}{label} { - Info<< "Found unknown block:" << YYText() << endl; yy_push_state(unknownBlock); } @@ -793,13 +792,11 @@ endOfSection {space}")"{space} } {spaceNl}{lbrac} { - Info<< "Embedded blocks in comment or unknown:" << YYText() << endl; yy_push_state(embeddedUnknownBlock); } {spaceNl}{endOfSection} { - Info<< "Found end of section in unknown:" << YYText() << endl; yy_pop_state(); } @@ -920,14 +917,14 @@ int main(int argc, char *argv[]) labelList nFacesInCell(nCells, 0); - forAll(cellFaces, celli) + forAll (cellFaces, celli) { cellFaces[celli].setSize(fluentModelNFaces[fluentCellModelID[celli] ]); } // fill in owner and neighbour - forAll(owner, faceI) + forAll (owner, faceI) { if (owner[faceI] > -1) { @@ -949,7 +946,7 @@ int main(int argc, char *argv[]) } } - forAll(neighbour, faceI) + forAll (neighbour, faceI) { if (neighbour[faceI] > -1) { @@ -1002,8 +999,8 @@ int main(int argc, char *argv[]) // Note: In order for the owner-neighbour rules to be right, the // points given by Fluent need to represent the FRONT plane of the // geometry. Therefore, the extrusion will be in -z direction - // - forAll(oldPoints, pointI) + + forAll (oldPoints, pointI) { points[nNewPoints] = oldPoints[pointI]; @@ -1012,7 +1009,7 @@ int main(int argc, char *argv[]) nNewPoints++; } - forAll(oldPoints, pointI) + forAll (oldPoints, pointI) { points[nNewPoints] = oldPoints[pointI]; @@ -1027,7 +1024,7 @@ int main(int argc, char *argv[]) // Set the number of empty faces frontAndBackFaces.setSize(2*nCells); - forAll(fluentCellModelID, celli) + forAll (fluentCellModelID, celli) { switch (fluentCellModelID[celli]) { @@ -1071,7 +1068,7 @@ int main(int argc, char *argv[]) default: { - FatalErrorIn("fluentToFoam::main(int argc, char *argv[])") + FatalErrorIn(args.executable()) << "unrecognised 2-D cell shape: " << fluentCellModelID[celli] << abort(FatalError); @@ -1080,12 +1077,12 @@ int main(int argc, char *argv[]) } // Create new faces - forAll(faces, faceI) + forAll (faces, faceI) { if (faces[faceI].size() != 2) { - FatalErrorIn("fluentToFoam::main(int argc, char *argv[])") + FatalErrorIn(args.executable()) << "fluentMeshToFoam: a 2-D face defined with " << faces[faceI].size() << " points." << endl; } @@ -1105,7 +1102,7 @@ int main(int argc, char *argv[]) { // 3-D shape recognition Info<< "Creating shapes for 3-D cells"<< endl; - forAll(fluentCellModelID, celli) + forAll (fluentCellModelID, celli) { if ( @@ -1131,7 +1128,7 @@ int main(int argc, char *argv[]) } else { - FatalErrorIn("fluentToFoam::main(int argc, char *argv[])") + FatalErrorIn(args.executable()) << "unrecognised 3-D cell shape: " << fluentCellModelID[celli] << abort(FatalError); @@ -1143,7 +1140,7 @@ int main(int argc, char *argv[]) // area vector points into the domain. Turn them round before making patches // for Foam compatibility - forAll(faces, faceI) + forAll (faces, faceI) { if (owner[faceI] == -1) { @@ -1231,7 +1228,7 @@ int main(int argc, char *argv[]) label nPatches = 0; - // colate information for all patches (internal and external) + // Colate information for all patches (internal and external) // Create a file listing patch type for each zone @@ -1274,7 +1271,7 @@ int main(int argc, char *argv[]) ++faceGroupEndIndexIter ) { - // get face type and name + // Get face type and name const word& curPatchType = patchTypeIDs[faceGroupZoneIDIter()]; const word& curPatchName = patchNameIDs[faceGroupZoneIDIter()]; @@ -1285,15 +1282,15 @@ int main(int argc, char *argv[]) << " end: " << faceGroupEndIndexIter() << " type: " << curPatchType << " name: " << curPatchName << endl; - // record zone index + // Record zone index zoneToPatchName[faceGroupZoneIDIter()] = curPatchName; - // make patch labels + // Make patch labels label faceLabel = faceGroupStartIndexIter() - 1; faceList patchFaces(faceGroupEndIndexIter() - faceLabel); - forAll(patchFaces, faceI) + forAll (patchFaces, faceI) { if ( @@ -1313,7 +1310,7 @@ int main(int argc, char *argv[]) } } - //inlets and outlets + // Inlets and outlets if ( curPatchType == "pressure" @@ -1378,7 +1375,7 @@ int main(int argc, char *argv[]) else if ( curPatchType == "" - ) //unnamed face regions default to interior patches + ) // Unnamed face regions default to interior patches { Info<< "Patch " << faceGroupZoneIDIter() << ": Faces are defined but " @@ -1394,7 +1391,7 @@ int main(int argc, char *argv[]) } else //unknown face regions are not handled { - FatalErrorIn("fluentToFoam::main(int argc, char *argv[])") + FatalErrorIn(args.executable()) << "fluent patch type " << curPatchType << " not recognised." << abort(FatalError); } @@ -1439,12 +1436,25 @@ int main(int argc, char *argv[]) label sz = bFaces.size(); labelList meshFaces(sz,-1); - // Search faces by point matching - forAll(bFaces, j) + + //make face set and write (seperate from rest for clarity) + //internal and external Fluent boundaries { - const face& f = bFaces[j]; - label cMeshFace = findFace(pShapeMesh, f); - meshFaces[j] = cMeshFace; + faceSet pFaceSet(pShapeMesh, patchNames[patchI], sz); + + forAll (bFaces, j) + { + const face& f = bFaces[j]; + label cMeshFace = findFace(pShapeMesh, f); + meshFaces[j] = cMeshFace; + pFaceSet.insert(cMeshFace); + } + if (writeSets) + { + Info<< "Writing patch " << patchNames[patchI] + << " of size " << sz << " to faceSet." << endl; + pFaceSet.write(); + } } @@ -1461,7 +1471,7 @@ int main(int argc, char *argv[]) && !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 //and mark patch number to global list @@ -1478,7 +1488,7 @@ int main(int argc, char *argv[]) << exit(FatalError); } - if (facePatchID[faceI - pShapeMesh.nInternalFaces()]!= -1) + if(facePatchID[faceI - pShapeMesh.nInternalFaces()]!= -1) { FatalErrorIn(args.executable()) << "Face " << faceI << " on new patch " @@ -1491,7 +1501,7 @@ int main(int argc, char *argv[]) facePatchID[faceI - pShapeMesh.nInternalFaces()] = nBoundaries; } - //add to boundary patch + // Add to boundary patch Info<< "Adding new patch " << patchNames[patchI] << " of type " << patchTypes[patchI] @@ -1528,9 +1538,9 @@ int main(int argc, char *argv[]) // this routine should generally not be invoked { DynamicList