1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 Converts a Fluent mesh to OpenFOAM format.
31 \*---------------------------------------------------------------------------*/
36 /* ------------------------------------------------------------------------ *\
37 ------ local definitions
38 \* ------------------------------------------------------------------------ */
43 #include "polyTopoChange.H"
44 #include "polyMeshZipUpCells.H"
45 #include "wallPolyPatch.H"
46 #include "symmetryPolyPatch.H"
47 #include "cyclicPolyPatch.H"
51 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
60 // Scale factor used to scale points (optional command line argument)
61 scalar scaleFactor = 1.0;
63 label dimensionOfGrid = 0;
68 bool hangingNodes = false;
73 labelList neighbour(0);
75 // Group type and name
76 Map<word> groupType(100);
77 Map<word> groupName(100);
80 DynamicList<label> pointGroupZoneID;
81 DynamicList<label> pointGroupStartIndex;
82 DynamicList<label> pointGroupEndIndex;
85 DynamicList<label> faceGroupZoneID;
86 DynamicList<label> faceGroupStartIndex;
87 DynamicList<label> faceGroupEndIndex;
90 DynamicList<label> cellGroupZoneID;
91 DynamicList<label> cellGroupStartIndex;
92 DynamicList<label> cellGroupEndIndex;
93 DynamicList<label> cellGroupType;
96 void uniquify(word& name, HashSet<word>& patchNames)
98 if (!patchNames.found(name))
100 patchNames.insert(name);
104 Info<< " name " << name << " already used";
107 word baseName = name;
111 name = baseName + "_" + Foam::name(i++);
112 } while (patchNames.found(name));
114 Info<< ", changing to " << name << endl;
119 // Dummy yywrap to keep yylex happy at compile time.
120 // It is called by yylex but is not used as the mechanism to change file.
122 #if YY_FLEX_SUBMINOR_VERSION < 34
123 extern "C" int yywrap()
125 int yyFlexLexer::yywrap()
135 some_space {one_space}+
142 hexDigit [[:xdigit:]]
150 schemeSpecialInitial [!$%&*/\\:<=>?~_^#.@']
151 schemeSpecialSubsequent [.+-]
152 schemeSymbol (({some_space}|{alpha}|{quote}|{schemeSpecialInitial})({alpha}|{quote}|{digit}|{schemeSpecialInitial}|{schemeSpecialSubsequent})*)
155 identifier {alpha}({alpha}|{digit})*
157 label [1-9]{decDigit}*
160 signedInteger [-+]?{integer}
161 word ({alpha}|{digit}|{dotColonDash})*
163 exponent_part [eE][-+]?{digit}+
164 fractional_constant [-+]?(({digit}*"."{digit}+)|({digit}+".")|({digit}))
166 double ((({fractional_constant}{exponent_part}?)|({digit}+{exponent_part}))|0)
172 labelListElement {space}{zeroLabel}
173 hexLabelListElement {space}{hexLabel}
174 scalarListElement {space}{double}
175 schemeSymbolListElement {space}{schemeSymbol}
176 labelList ({labelListElement}+{space})
177 hexLabelList ({hexLabelListElement}+{space})
178 scalarList ({scalarListElement}+{space})
179 schemeSymbolList ({schemeSymbolListElement}+{space})
182 text ({space}({word}*{space})*)
183 anythingInBlock ([^)]*)
185 dateDDMMYYYY ({digit}{digit}"/"{digit}{digit}"/"{digit}{digit}{digit}{digit})
186 dateDDMonYYYY ((({digit}{digit}{space})|({digit}{space})){alpha}*{space}{digit}{digit}{digit}{digit})
187 time ({digit}{digit}":"{digit}{digit}":"{digit}{digit})
189 versionNumber ({digit}|".")*
191 header {space}"(1"{space}
192 dimension {space}"(2"{space}
193 points {space}"(10"{space}
194 faces {space}"(13"{space}
195 cells {space}"(12"{space}
196 zoneVariant1 {space}"(39"{space}
197 zoneVariant2 {space}"(45"{space}
198 faceTree {space}"(59"{space}
201 unknownPeriodicFace "17"{space}
202 periodicFace "18"{space}
204 faceParents "61"{space}
205 ignoreBlocks ("4"|"37"|"38"|"40"|"41"|"60"|"64"){space}
207 redundantBlock {space}({comment}|{unknownPeriodicFace}|{periodicFace}|{cellTree}|{faceParents}|{ignoreBlocks}){space}
209 endOfSection {space}")"{space}
213 /* ------------------------------------------------------------------------ *\
214 ----- Exclusive start states -----
215 \* ------------------------------------------------------------------------ */
223 %x readNumberOfPoints
224 %x readPointGroupData
247 %x ignoreEmbeddedBlock
251 // End of read character pointer returned by strtol and strtod
255 label pointGroupNumberOfComponents = 3;
256 label pointi = 0; // index used for reading points
257 label cmpt = 0; // component index used for reading points
260 label faceGroupElementType = -1;
261 label facei = 0; // index used for reading faces
265 /* ------------------------------------------------------------------------ *\
266 ------ Start Lexing ------
267 \* ------------------------------------------------------------------------ */
269 /* ------ Reading control header ------ */
275 <readHeader>{anythingInBlock} {
276 Info<< "Header: " << YYText() << endl;
281 BEGIN(readDimension);
284 <readDimension>{space}{label}{space} {
285 dimensionOfGrid = atoi(YYText());
286 Info<< "Dimension of grid: " << dimensionOfGrid << endl;
291 BEGIN(readPointHeader);
294 <readPointHeader>{space}{lbrac}{space}"0"{space}"1"{space} {
295 BEGIN(readNumberOfPoints);
298 <readNumberOfPoints>{hexLabel}{space}{labelList} {
299 nPoints = strtol(YYText(), &endPtr, 16);
300 Info<< "Number of points: " << nPoints << endl;
301 points.setSize(nPoints);
303 // Ignore rest of stream
306 <readPointHeader>{space}{lbrac} {
307 BEGIN(readPointGroupData);
310 <readPointGroupData>{space}{hexLabel}{space}{hexLabel}{space}{hexLabel}{labelList} {
311 // Read point zone-ID, start and end-label
312 // the indices will be used for checking later.
313 pointGroupZoneID.append(strtol(YYText(), &endPtr, 16));
315 // In FOAM, indices start from zero - adjust
316 pointGroupStartIndex.append(strtol(endPtr, &endPtr, 16) - 1);
318 pointGroupEndIndex.append(strtol(endPtr, &endPtr, 16) - 1);
320 // point group type skipped
321 strtol(endPtr, &endPtr, 16);
323 pointi = pointGroupStartIndex[pointGroupStartIndex.size()-1];
325 // reset number of components to default
326 pointGroupNumberOfComponents = 3;
328 // read number of components in the vector
329 if (endPtr < &(YYText()[YYLeng()-1]))
331 pointGroupNumberOfComponents = strtol(endPtr, &endPtr, 16);
334 Info<< "PointGroup: "
335 << pointGroupZoneID[pointGroupZoneID.size()-1]
337 << pointGroupStartIndex[pointGroupStartIndex.size()-1]
339 << pointGroupEndIndex[pointGroupEndIndex.size()-1] << flush;
342 <readNumberOfPoints,readPointGroupData>{endOfSection} {
343 BEGIN(readPointData);
346 <readPointData>{space}{lbrac}{space} {
347 Info<< ". Reading points..." << flush;
349 yy_push_state(readScalarList);
352 <readScalarList>{signedInteger}{space} {
353 points[pointi][cmpt++] = scaleFactor*atol(YYText());
355 if (cmpt == pointGroupNumberOfComponents)
357 if (pointGroupNumberOfComponents == 2)
359 points[pointi].z() = 0.0;
367 <readScalarList>{scalar}{space} {
368 points[pointi][cmpt++] = scaleFactor*atof(YYText());
370 if (cmpt == pointGroupNumberOfComponents)
372 if (pointGroupNumberOfComponents == 2)
374 points[pointi].z() = 0.0;
382 <readScalarList>{endOfSection} {
383 Info<< "done." << endl;
385 // check read of points
386 if (pointi != pointGroupEndIndex[pointGroupEndIndex.size()-1]+1)
389 << "Problem with reading points: " << nl
391 << pointGroupStartIndex[pointGroupStartIndex.size()-1]
393 << pointGroupEndIndex[pointGroupEndIndex.size()-1]
394 << " last points read: " << pointi << nl
395 << " on line " << lineNo << endl;
402 BEGIN(readFaceHeader);
405 <readFaceHeader>{space}{lbrac}{space}"0"{space}"1"{space} {
406 BEGIN(readNumberOfFaces);
409 <readNumberOfFaces>{space}{hexLabel}{space}{labelListElement}+ {
410 nFaces = strtol(YYText(), &endPtr, 16);
412 Info<< "Number of faces: " << nFaces << endl;
414 faces.setSize(nFaces);
415 owner.setSize(nFaces);
416 neighbour.setSize(nFaces);
418 // Type and element type not read
421 <readFaceHeader>{space}{lbrac} {
422 BEGIN(readFaceGroupData);
425 <readFaceGroupData>{space}{hexLabel}{space}{hexLabel}{space}{hexLabel}{hexLabelListElement}+ {
426 // read fluentFace zone-ID, start and end-label
427 faceGroupZoneID.append(strtol(YYText(), &endPtr, 16));
429 // In FOAM, indices start from zero - adjust
430 faceGroupStartIndex.append(strtol(endPtr, &endPtr, 16) - 1);
432 faceGroupEndIndex.append(strtol(endPtr, &endPtr, 16) - 1);
435 strtol(endPtr, &endPtr, 16);
437 faceGroupElementType = strtol(endPtr, &endPtr, 16);
439 facei = faceGroupStartIndex[faceGroupStartIndex.size()-1];
442 << faceGroupZoneID[faceGroupZoneID.size()-1]
444 << faceGroupStartIndex[faceGroupStartIndex.size()-1]
446 << faceGroupEndIndex[faceGroupEndIndex.size()-1] << flush;
449 <readNumberOfFaces,readFaceGroupData>{space}{endOfSection} {
453 <readFaceData>{space}{lbrac} {
454 if (faceGroupElementType == 0 || faceGroupElementType > 4)
456 Info<< ". Reading mixed faces..." << flush;
457 yy_push_state(readFacesMixed);
461 Info<< ". Reading uniform faces..." << flush;
462 yy_push_state(readFacesUniform);
466 <readFacesMixed>{space}{hexLabelList} {
467 face& curFaceLabels = faces[facei];
469 // set size of label list
470 curFaceLabels.setSize(strtol(YYText(), &endPtr, 16));
472 forAll (curFaceLabels, i)
474 curFaceLabels[i] = strtol(endPtr, &endPtr, 16) - 1;
477 // read neighbour and owner. Neighbour comes first
478 neighbour[facei] = strtol(endPtr, &endPtr, 16) - 1;
479 owner[facei] = strtol(endPtr, &endPtr, 16) - 1;
483 <readFacesUniform>{space}{hexLabelList} {
484 face& curFaceLabels = faces[facei];
486 // Set size of label list.
487 curFaceLabels.setSize(faceGroupElementType);
489 curFaceLabels[0] = strtol(YYText(), &endPtr, 16) - 1;
491 for (int i=1; i<faceGroupElementType; i++)
493 curFaceLabels[i] = strtol(endPtr, &endPtr, 16) - 1;
496 // read neighbour and owner. Neighbour comes first
497 neighbour[facei] = strtol(endPtr, &endPtr, 16) - 1;
498 owner[facei] = strtol(endPtr, &endPtr, 16) - 1;
502 <readFacesMixed,readFacesUniform>{space}{endOfSection} {
503 Info<< "done." << endl;
505 // check read of fluentFaces
506 if (facei != faceGroupEndIndex[faceGroupEndIndex.size()-1]+1)
509 << "Problem with reading fluentFaces: " << nl
511 << faceGroupStartIndex[faceGroupStartIndex.size()-1]
513 << faceGroupEndIndex[faceGroupEndIndex.size()-1]
514 << " last fluentFaces read: " << facei << nl
515 << " on line " << lineNo << endl;
523 BEGIN(readCellHeader);
526 <readCellHeader>{space}{lbrac}{space}"0"{space}"1"{space} {
527 BEGIN(readNumberOfCells);
530 <readNumberOfCells>{space}{hexLabel}{space}{labelListElement}+ {
531 nCells = strtol(YYText(), &endPtr, 16);
532 Info<< "Number of cells: " << nCells << endl;
535 <readCellHeader>{space}{lbrac} {
536 BEGIN(readCellGroupData);
539 <readCellGroupData>{space}{hexLabel}{space}{hexLabel}{space}{hexLabel}{space}{hexLabel} {
540 // Warning. This entry must be above the next one because of the lexing
541 // rules. It is introduced to deal with the problem of reading
542 // non-standard cell definition from Tgrid, which misses the type label.
545 << "Tgrid syntax problem: " << YYText() << nl
546 << " on line " << lineNo << endl;
548 // read cell zone-ID, start and end-label
549 cellGroupZoneID.append(strtol(YYText(), &endPtr, 16));
551 // the indices will be used for checking later.
552 cellGroupStartIndex.append(strtol(endPtr, &endPtr, 16) - 1);
554 cellGroupEndIndex.append(strtol(endPtr, &endPtr, 16) - 1);
556 cellGroupType.append(strtol(endPtr, &endPtr, 16));
559 << cellGroupZoneID[cellGroupZoneID.size()-1]
561 << cellGroupStartIndex[cellGroupStartIndex.size()-1]
563 << cellGroupEndIndex[cellGroupEndIndex.size()-1]
565 << cellGroupType[cellGroupType.size()-1]
569 <readCellGroupData>{space}{hexLabel}{space}{hexLabel}{space}{hexLabel}{space}{hexLabel}{space}{hexLabel} {
570 // Warning. See above
572 // read cell zone-ID, start and end-label
573 cellGroupZoneID.append(strtol(YYText(), &endPtr, 16));
575 // the indices will be used for checking later.
576 cellGroupStartIndex.append(strtol(endPtr, &endPtr, 16) - 1);
578 cellGroupEndIndex.append(strtol(endPtr, &endPtr, 16) - 1);
580 cellGroupType.append(strtol(endPtr, &endPtr, 16));
582 // Note. Potentially skip cell set if type is zero.
583 strtol(endPtr, &endPtr, 16);
586 << cellGroupZoneID[cellGroupZoneID.size()-1]
588 << cellGroupStartIndex[cellGroupStartIndex.size()-1]
590 << cellGroupEndIndex[cellGroupEndIndex.size()-1]
592 << cellGroupType[cellGroupType.size()-1]
596 <readNumberOfCells,readCellGroupData>{endOfSection} {
600 <readCellData>{space}{lbrac} {
601 // Quickly scan to the end of the cell data block and discard
603 while ((c = yyinput()) != 0 && c != ')')
608 // There are hanging nodes in the mesh so make sure it gets zipped-up
610 yy_push_state(ignoreBlock);
614 BEGIN(readZoneHeader);
618 BEGIN(readZoneHeader);
621 <readZoneHeader>{space}{lbrac} {
622 BEGIN(readZoneGroupData);
625 <readZoneGroupData>{space}{label}{space}{word}{space}{word}{space}{label}? {
626 IStringStream zoneDataStream(YYText());
628 // cell zone-ID not in hexadecimal!!! Inconsistency
629 label zoneID(readLabel(zoneDataStream));
631 groupType.insert(zoneID, word(zoneDataStream));
632 groupName.insert(zoneID, word(zoneDataStream));
634 Info<< "Zone: " << zoneID
635 << " name: " << groupName[zoneID]
636 << " type: " << groupType[zoneID] << flush;
639 <readZoneGroupData>{endOfSection} {
643 <readZoneData>{space}{lbrac} {
644 Info<< ". Reading zone data..." << flush;
645 yy_push_state(readZoneBlock);
648 <readZoneBlock>{space}{schemeSymbolList} {
651 <readZoneBlock>{lbrac} {
653 // << "Found unknown block in zone: " << YYText() << nl
654 // << " on line " << lineNo << endl;
655 yy_push_state(ignoreBlock);
658 <readZoneBlock>{endOfSection} {
659 Info<< "done." << endl;
665 /* ------ Reading end of section and others ------ */
667 <readHeader,readDimension,readPointData,readFaceData,readCellData,readZoneData>{space}{endOfSection} {
671 /* ------ Reading unknown type or non-standard comment ------ */
675 << "Found unknown block of type: "
676 << Foam::string(YYText())(1, YYLeng()-1) << nl
677 << " on line " << lineNo << endl;
679 yy_push_state(ignoreBlock);
682 {lbrac}{redundantBlock} {
683 yy_push_state(ignoreBlock);
686 <ignoreBlock,ignoreEmbeddedBlock>{space}{quote}{text}{quote} {
689 <ignoreBlock,ignoreEmbeddedBlock>{space}{schemeSymbol} {
692 <ignoreBlock,ignoreEmbeddedBlock>{space}{lbrac} {
693 yy_push_state(ignoreEmbeddedBlock);
697 <ignoreBlock,ignoreEmbeddedBlock>{space}{endOfSection} {
701 <ignoreBlock,ignoreEmbeddedBlock>{space}{labelList} {
704 <ignoreBlock,ignoreEmbeddedBlock>{space}{hexLabelList} {
707 <ignoreBlock,ignoreEmbeddedBlock>{space}{scalarList} {
710 <ignoreBlock,ignoreEmbeddedBlock>{space}{schemeSymbolList} {
713 <ignoreBlock,ignoreEmbeddedBlock>{space}{text} {
717 /* ------ Count newlines. ------ */
724 /* ------ Ignore remaining space. ------ */
730 /* ------ Any other characters are errors. ------ */
733 // This is a catch all.
734 FatalErrorIn("fluentMeshToFoam::lexer")
735 << "Do not understand characters: " << YYText() << nl
736 << " on line " << lineNo
741 /* ------ On EOF return to previous file, if none exists terminate. ------ */
748 int main(int argc, char *argv[])
750 argList::noParallel();
751 argList::validArgs.append("Fluent mesh file");
752 argList::validOptions.insert("scale", "scale factor");
753 argList::validOptions.insert("ignoreCellGroups", "cell group names");
754 argList::validOptions.insert("ignoreFaceGroups", "face group names");
756 argList args(argc, argv);
763 if (args.options().found("scale"))
765 scaleFactor = atof(args.options()["scale"].c_str());
768 HashSet<word> ignoreCellGroups;
769 if (args.options().found("ignoreCellGroups"))
771 IStringStream(args.options()["ignoreCellGroups"])() >> ignoreCellGroups;
774 HashSet<word> ignoreFaceGroups;
775 if (args.options().found("ignoreFaceGroups"))
777 IStringStream(args.options()["ignoreFaceGroups"])() >> ignoreFaceGroups;
780 # include "createTime.H"
782 fileName fluentFile(args.additionalArgs()[0]);
783 IFstream fluentStream(fluentFile);
787 FatalErrorIn(args.executable())
788 << ": file " << fluentFile << " not found"
792 yyFlexLexer lexer(&fluentStream.stdStream());
794 while(lexer.yylex() != 0)
797 Info<< "\nFINISHED LEXING\n\n";
799 if (dimensionOfGrid != 3)
801 FatalErrorIn(args.executable())
802 << "Mesh is not 3D, dimension of grid: " << dimensionOfGrid
806 pointGroupZoneID.shrink();
807 pointGroupStartIndex.shrink();
808 pointGroupEndIndex.shrink();
810 faceGroupZoneID.shrink();
811 faceGroupStartIndex.shrink();
812 faceGroupEndIndex.shrink();
814 cellGroupZoneID.shrink();
815 cellGroupStartIndex.shrink();
816 cellGroupEndIndex.shrink();
817 cellGroupType.shrink();
820 // Pre-filtering: flip "owner" boundary or wrong oriented internal
821 // faces and move to neighbour
822 forAll (faces, facei)
827 || (neighbour[facei] != -1 && owner[facei] > neighbour[facei])
830 faces[facei] = faces[facei].reverseFace();
831 Swap(owner[facei], neighbour[facei]);
836 // Foam type for Fluent type
837 // ~~~~~~~~~~~~~~~~~~~~~~~~~
839 HashTable<word> fluentToFoamType;
841 fluentToFoamType.insert("pressure", polyPatch::typeName);
842 fluentToFoamType.insert("pressure-inlet", polyPatch::typeName);
843 fluentToFoamType.insert("inlet-vent", polyPatch::typeName);
844 fluentToFoamType.insert("intake-fan", polyPatch::typeName);
845 fluentToFoamType.insert("pressure-outlet", polyPatch::typeName);
846 fluentToFoamType.insert("exhaust-fan", polyPatch::typeName);
847 fluentToFoamType.insert("outlet-vent", polyPatch::typeName);
848 fluentToFoamType.insert("pressure-far-field", polyPatch::typeName);
849 fluentToFoamType.insert("velocity-inlet", polyPatch::typeName);
850 fluentToFoamType.insert("mass-flow-inlet", polyPatch::typeName);
851 fluentToFoamType.insert("outflow", polyPatch::typeName);
853 fluentToFoamType.insert("wall" , wallPolyPatch::typeName);
855 fluentToFoamType.insert("symmetry", symmetryPolyPatch::typeName);
856 fluentToFoamType.insert("axis", symmetryPolyPatch::typeName);
858 fluentToFoamType.insert("interior", polyPatch::typeName);
859 fluentToFoamType.insert("interface", polyPatch::typeName);
860 fluentToFoamType.insert("internal", polyPatch::typeName);
861 fluentToFoamType.insert("solid", polyPatch::typeName);
862 fluentToFoamType.insert("fan", cyclicPolyPatch::typeName);
863 fluentToFoamType.insert("radiator", polyPatch::typeName);
864 fluentToFoamType.insert("porous-jump", polyPatch::typeName);
867 // Foam patch type for Fluent zone type
868 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
870 HashSet<word> fluentGroupToFoamPatch;
871 fluentGroupToFoamPatch.insert("wall");
872 fluentGroupToFoamPatch.insert("fan");
875 // Create intial empty polyMesh
876 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
882 polyMesh::defaultRegion,
893 // Check the cell groups for zones ignoring those in ignoreCellGroups
894 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
895 label nCellZones = 0;
896 labelList cellZoneIDs(cellGroupZoneID.size());
898 forAll(cellGroupZoneID, cgi)
900 if (!ignoreCellGroups.found(groupName[cellGroupZoneID[cgi] ]))
902 cellZoneIDs[nCellZones++] = cgi;
906 cellZoneIDs.setSize(nCellZones);
909 // Check the face groups for boundary patches, baffles and faceZones
910 // ignoring the interior zones in ignoreCellGroups
911 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
912 DynamicList<label> patchIDs(faceGroupZoneID.size());
913 DynamicList<label> faceZoneIDs(faceGroupZoneID.size());
915 forAll(faceGroupZoneID, fgi)
917 label zoneID = faceGroupZoneID[fgi];
918 label start = faceGroupStartIndex[fgi];
920 if (groupType.found(zoneID))
922 const word& type = groupType[zoneID];
924 // Check the first element of neighbour for boundary group
925 if (neighbour[start] == -1 || fluentGroupToFoamPatch.found(type))
927 patchIDs.append(fgi);
931 if (!ignoreFaceGroups.found(groupName[faceGroupZoneID[fgi] ]))
933 faceZoneIDs.append(fgi);
937 else if (hangingNodes)
939 label end = faceGroupEndIndex[fgi];
941 Info<< "Unknown FaceGroup " << zoneID
942 << " assumed to be parent faces of refinement "
943 "patterns and ignored."
946 // Set the owner of these faces to -1 so that they do not get
948 for(label facei = start; facei <= end; facei++)
955 if (neighbour[start] == -1)
957 // Boundary face in unknown group. Create a patch for it.
958 groupType.insert(zoneID, "unknown");
959 groupName.insert(zoneID, "FaceGroup" + Foam::name(zoneID));
960 patchIDs.append(fgi);
961 Info<< "Created patch " << fgi << " for unknown FaceGroup "
962 << zoneID << '.' << endl;
966 WarningIn(args.executable())
967 << "Unknown FaceGroup " << zoneID << " not in a zone"
974 faceZoneIDs.shrink();
980 List<polyPatch*> newPatches(patchIDs.size());
981 HashSet<word> patchNames;
983 forAll(patchIDs, patchi)
985 label zoneID = faceGroupZoneID[patchIDs[patchi] ];
986 word name = groupName[zoneID];
987 const word& type = groupType[zoneID];
989 Info<< "Creating patch " << patchi
990 << " for zone: " << zoneID
995 uniquify(name, patchNames);
997 HashTable<word>::const_iterator iter = fluentToFoamType.find(type);
999 if (iter != fluentToFoamType.end())
1001 newPatches[patchi] = polyPatch::New
1013 Info<< "Adding polyPatch for unknown Fluent type " << type
1016 newPatches[patchi] = new polyPatch
1026 mesh.addPatches(newPatches);
1033 mesh.cellZones().setSize(cellZoneIDs.size());
1034 HashSet<word> cellZoneNames;
1036 forAll(cellZoneIDs, cellZonei)
1038 label zoneID = cellGroupZoneID[cellZoneIDs[cellZonei] ];
1039 word name = groupName[zoneID];
1040 const word& type = groupType[zoneID];
1042 Info<< "Creating cellZone " << cellZonei
1043 << " name: " << name
1044 << " type: " << type
1047 uniquify(name, cellZoneNames);
1049 mesh.cellZones().set
1063 mesh.faceZones().setSize(faceZoneIDs.size());
1064 HashSet<word> faceZoneNames;
1066 forAll(faceZoneIDs, faceZonei)
1068 label zoneID = faceGroupZoneID[faceZoneIDs[faceZonei] ];
1069 word name = groupName[zoneID];
1070 const word& type = groupType[zoneID];
1072 Info<< "Creating faceZone " << faceZonei
1073 << " name: " << name
1074 << " type: " << type
1077 uniquify(name, faceZoneNames);
1079 mesh.faceZones().set
1094 // Modify mesh for points/cells/faces
1095 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1097 // Mesh-change container
1098 polyTopoChange meshMod(mesh, false);
1101 forAll(points, pointi)
1103 meshMod.addPoint(points[pointi], pointi, -1, true);
1108 for (label celli = 0; celli < nCells; celli++)
1112 -1, // masterPointID
1115 celli, // masterCellID
1120 // Modify cells to be in zones as required
1121 forAll(cellZoneIDs, cellZonei)
1123 label cgi = cellZoneIDs[cellZonei];
1127 label celli = cellGroupStartIndex[cgi];
1128 celli <= cellGroupEndIndex[cgi];
1132 meshMod.modifyCell(celli, cellZonei);
1137 bool doneWarning = false;
1139 // Add faceZone faces
1140 forAll(faceZoneIDs, faceZonei)
1142 label fgi = faceZoneIDs[faceZonei];
1143 label start = faceGroupStartIndex[fgi];
1144 label end = faceGroupEndIndex[fgi];
1145 label zoneID = faceGroupZoneID[fgi];
1147 Info<< "faceZone from Fluent indices: " << start
1149 << " type: " << groupType[zoneID]
1152 for (label facei = start; facei <= end; facei++)
1154 if (owner[facei] >= nCells || neighbour[facei] >= nCells)
1158 WarningIn(args.executable())
1159 << "Ignoring internal face " << facei
1160 << " on FaceZone " << zoneID
1161 << " since owner " << owner[facei] << " or neighbour "
1162 << neighbour[facei] << " outside range of cells 0.."
1164 << " Suppressing future warnings." << endl;
1175 -1, // masterPointID
1177 facei, // masterFace
1178 false, // flipFaceFlux
1180 faceZonei, // zoneID
1185 // Mark face as being done
1191 forAll(patchIDs, patchi)
1193 label fgi = patchIDs[patchi];
1194 label start = faceGroupStartIndex[fgi];
1195 label end = faceGroupEndIndex[fgi];
1196 label zoneID = faceGroupZoneID[fgi];
1198 Info<< "patch " << patchi << " from Fluent indices: " << start
1200 << " type: " << groupType[zoneID]
1203 for (label facei = start; facei <= end; facei++)
1205 if (owner[facei] >= nCells || neighbour[facei] >= nCells)
1209 WarningIn(args.executable())
1210 << "Ignoring patch face " << facei
1211 << " on FaceZone " << zoneID
1212 << " since owner " << owner[facei] << " or neighbour "
1213 << neighbour[facei] << " outside range of cells 0.."
1215 << " Suppressing future warnings." << endl;
1226 -1, // masterPointID
1228 facei, // masterFace
1229 false, // flipFaceFlux
1235 // For baffles create the opposite face
1236 if (neighbour[start] != -1)
1240 faces[facei].reverseFace(),
1243 -1, // masterPointID
1245 facei, // masterFace
1246 false, // flipFaceFlux
1253 // Mark face as being done
1258 // Add remaining internal faces
1259 forAll(owner, facei)
1261 if (owner[facei] != -1)
1263 // Check the face being added as an internal face actually is one
1264 if (neighbour[facei] == -1)
1266 FatalErrorIn(args.executable())
1267 << "Attempt of add internal face " << facei
1268 << " which is a boundary face"
1269 << exit(FatalError);
1272 if (owner[facei] >= nCells || neighbour[facei] >= nCells)
1276 WarningIn(args.executable())
1277 << "Ignoring internal face " << facei
1278 << " since owner " << owner[facei] << " or neighbour "
1279 << neighbour[facei] << " outside range of cells 0.."
1281 << " Suppressing future warnings." << endl;
1295 false, //flipFaceFlux
1307 neighbour.setSize(0);
1313 autoPtr<mapPolyMesh> map = meshMod.changeMesh(mesh, false);
1315 // Zip-up the mesh if it contained hanging nodes
1318 Info<< "Zipping mesh to remove hanging nodes" << endl;
1319 polyMeshZipUpCells(mesh);
1322 mesh.setInstance(runTime.constant());
1324 // Set the precision of the points data to 10
1325 IOstream::defaultPrecision(10);
1327 Info<< nl << "Writing mesh to " << mesh.objectPath() << endl;
1331 Info<< nl << "End" << endl;
1336 /* ------------------------------------------------------------------------ *\
1337 ------ End of fluentMeshToFoam.L
1338 \* ------------------------------------------------------------------------ */