Revert to latest version of fluentMeshToFoam

Add faunctionality in preservePatchTypes to ensure full compatibility
This commit is contained in:
Henrik Rusche 2014-06-09 11:39:24 +02:00
parent 076f585742
commit 941969a78b
3 changed files with 165 additions and 86 deletions

View file

@ -34,9 +34,9 @@ Description
#undef yyFlexLexer #undef yyFlexLexer
/* ------------------------------------------------------------------------- *\ /* ------------------------------------------------------------------------- *\
------ local definitions ------ local definitions
\* ------------------------------------------------------------------------- */ \* ------------------------------------------------------------------------- */
#include "argList.H" #include "argList.H"
#include "objectRegistry.H" #include "objectRegistry.H"
@ -46,6 +46,7 @@ Description
#include "emptyPolyPatch.H" #include "emptyPolyPatch.H"
#include "wallPolyPatch.H" #include "wallPolyPatch.H"
#include "symmetryPolyPatch.H" #include "symmetryPolyPatch.H"
#include "preservePatchTypes.H"
#include "cellShape.H" #include "cellShape.H"
#include "faceSet.H" #include "faceSet.H"
#include "cellSet.H" #include "cellSet.H"
@ -131,7 +132,7 @@ quote \"
dash "-" dash "-"
dotColonDash [.:-] dotColonDash [.:-]
schemeSpecialInitial [!$%&*/:<=>?~_^#.] schemeSpecialInitial [!$%&*/\\:<=>?~_^#.@']
schemeSpecialSubsequent [.+-] schemeSpecialSubsequent [.+-]
schemeSymbol (({some_space}|{alpha}|{quote}|{schemeSpecialInitial})({alpha}|{quote}|{digit}|{schemeSpecialInitial}|{schemeSpecialSubsequent})*) schemeSymbol (({some_space}|{alpha}|{quote}|{schemeSpecialInitial})({alpha}|{quote}|{digit}|{schemeSpecialInitial}|{schemeSpecialSubsequent})*)
@ -141,7 +142,7 @@ integer {decDigit}+
label [1-9]{decDigit}* label [1-9]{decDigit}*
hexLabel {hexDigit}+ hexLabel {hexDigit}+
zeroLabel {digit}* zeroLabel {digit}*
signedInteger [-+]?{integer}
word ({alpha}|{digit}|{dotColonDash})* word ({alpha}|{digit}|{dotColonDash})*
exponent_part [eE][-+]?{digit}+ exponent_part [eE][-+]?{digit}+
@ -251,11 +252,11 @@ endOfSection {space}")"{space}
%} %}
/* ------------------------------------------------------------------------- *\ /* ------------------------------------------------------------------------ *\
------ Start Lexing ------ ------ Start Lexing ------
\* ------------------------------------------------------------------------- */ \* ------------------------------------------------------------------------ */
/* ------ Reading control header ------ */ /* ------ Reading control header ------ */
{comment} { {comment} {
yy_push_state(readComment); yy_push_state(readComment);
@ -490,7 +491,7 @@ endOfSection {space}")"{space}
// set size of label list // set size of label list
curFaceLabels.setSize(readLabel(mixedFaceStream)); curFaceLabels.setSize(readLabel(mixedFaceStream));
forAll(curFaceLabels, i) forAll (curFaceLabels, i)
{ {
curFaceLabels[i] = readHexLabel(mixedFaceStream) - 1; 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 // for edge is 2, for triangle is 3 and for quad is 4
curFaceLabels.setSize(faceGroupElementType); curFaceLabels.setSize(faceGroupElementType);
forAll(curFaceLabels, i) forAll (curFaceLabels, i)
{ {
curFaceLabels[i] = readHexLabel(mixedFaceStream) - 1; curFaceLabels[i] = readHexLabel(mixedFaceStream) - 1;
} }
@ -765,7 +766,6 @@ endOfSection {space}")"{space}
} }
<readZoneBlock>{lbrac} { <readZoneBlock>{lbrac} {
Info<< "Found unknown block in zone:" << YYText() << endl;
yy_push_state(unknownBlock); yy_push_state(unknownBlock);
} }
@ -785,7 +785,6 @@ endOfSection {space}")"{space}
{lbrac}{label} { {lbrac}{label} {
Info<< "Found unknown block:" << YYText() << endl;
yy_push_state(unknownBlock); yy_push_state(unknownBlock);
} }
@ -793,13 +792,11 @@ endOfSection {space}")"{space}
} }
<readComment,unknownBlock,embeddedUnknownBlock>{spaceNl}{lbrac} { <readComment,unknownBlock,embeddedUnknownBlock>{spaceNl}{lbrac} {
Info<< "Embedded blocks in comment or unknown:" << YYText() << endl;
yy_push_state(embeddedUnknownBlock); yy_push_state(embeddedUnknownBlock);
} }
<readComment,unknownBlock,embeddedUnknownBlock>{spaceNl}{endOfSection} { <readComment,unknownBlock,embeddedUnknownBlock>{spaceNl}{endOfSection} {
Info<< "Found end of section in unknown:" << YYText() << endl;
yy_pop_state(); yy_pop_state();
} }
@ -920,14 +917,14 @@ int main(int argc, char *argv[])
labelList nFacesInCell(nCells, 0); labelList nFacesInCell(nCells, 0);
forAll(cellFaces, celli) forAll (cellFaces, celli)
{ {
cellFaces[celli].setSize(fluentModelNFaces[fluentCellModelID[celli] ]); cellFaces[celli].setSize(fluentModelNFaces[fluentCellModelID[celli] ]);
} }
// fill in owner and neighbour // fill in owner and neighbour
forAll(owner, faceI) forAll (owner, faceI)
{ {
if (owner[faceI] > -1) if (owner[faceI] > -1)
{ {
@ -949,7 +946,7 @@ int main(int argc, char *argv[])
} }
} }
forAll(neighbour, faceI) forAll (neighbour, faceI)
{ {
if (neighbour[faceI] > -1) 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 // 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];
@ -1012,7 +1009,7 @@ int main(int argc, char *argv[])
nNewPoints++; nNewPoints++;
} }
forAll(oldPoints, pointI) forAll (oldPoints, pointI)
{ {
points[nNewPoints] = oldPoints[pointI]; points[nNewPoints] = oldPoints[pointI];
@ -1027,7 +1024,7 @@ int main(int argc, char *argv[])
// Set the number of empty faces // Set the number of empty faces
frontAndBackFaces.setSize(2*nCells); frontAndBackFaces.setSize(2*nCells);
forAll(fluentCellModelID, celli) forAll (fluentCellModelID, celli)
{ {
switch (fluentCellModelID[celli]) switch (fluentCellModelID[celli])
{ {
@ -1071,7 +1068,7 @@ int main(int argc, char *argv[])
default: default:
{ {
FatalErrorIn("fluentToFoam::main(int argc, char *argv[])") FatalErrorIn(args.executable())
<< "unrecognised 2-D cell shape: " << "unrecognised 2-D cell shape: "
<< fluentCellModelID[celli] << fluentCellModelID[celli]
<< abort(FatalError); << abort(FatalError);
@ -1080,12 +1077,12 @@ int main(int argc, char *argv[])
} }
// Create new faces // Create new faces
forAll(faces, faceI) forAll (faces, faceI)
{ {
if (faces[faceI].size() != 2) if (faces[faceI].size() != 2)
{ {
FatalErrorIn("fluentToFoam::main(int argc, char *argv[])") FatalErrorIn(args.executable())
<< "fluentMeshToFoam: a 2-D face defined with " << "fluentMeshToFoam: a 2-D face defined with "
<< faces[faceI].size() << " points." << endl; << faces[faceI].size() << " points." << endl;
} }
@ -1105,7 +1102,7 @@ int main(int argc, char *argv[])
{ {
// 3-D shape recognition // 3-D shape recognition
Info<< "Creating shapes for 3-D cells"<< endl; Info<< "Creating shapes for 3-D cells"<< endl;
forAll(fluentCellModelID, celli) forAll (fluentCellModelID, celli)
{ {
if if
( (
@ -1131,7 +1128,7 @@ int main(int argc, char *argv[])
} }
else else
{ {
FatalErrorIn("fluentToFoam::main(int argc, char *argv[])") FatalErrorIn(args.executable())
<< "unrecognised 3-D cell shape: " << "unrecognised 3-D cell shape: "
<< fluentCellModelID[celli] << fluentCellModelID[celli]
<< abort(FatalError); << abort(FatalError);
@ -1143,7 +1140,7 @@ int main(int argc, char *argv[])
// area vector points into the domain. Turn them round before making patches // area vector points into the domain. Turn them round before making patches
// for Foam compatibility // for Foam compatibility
forAll(faces, faceI) forAll (faces, faceI)
{ {
if (owner[faceI] == -1) if (owner[faceI] == -1)
{ {
@ -1231,7 +1228,7 @@ int main(int argc, char *argv[])
label nPatches = 0; 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 // Create a file listing patch type for each zone
@ -1274,7 +1271,7 @@ int main(int argc, char *argv[])
++faceGroupEndIndexIter ++faceGroupEndIndexIter
) )
{ {
// get face type and name // Get face type and name
const word& curPatchType = patchTypeIDs[faceGroupZoneIDIter()]; const word& curPatchType = patchTypeIDs[faceGroupZoneIDIter()];
const word& curPatchName = patchNameIDs[faceGroupZoneIDIter()]; const word& curPatchName = patchNameIDs[faceGroupZoneIDIter()];
@ -1285,15 +1282,15 @@ int main(int argc, char *argv[])
<< " end: " << faceGroupEndIndexIter() << " end: " << faceGroupEndIndexIter()
<< " type: " << curPatchType << " name: " << curPatchName << endl; << " type: " << curPatchType << " name: " << curPatchName << endl;
// record zone index // Record zone index
zoneToPatchName[faceGroupZoneIDIter()] = curPatchName; zoneToPatchName[faceGroupZoneIDIter()] = curPatchName;
// make patch labels // Make patch labels
label faceLabel = faceGroupStartIndexIter() - 1; label faceLabel = faceGroupStartIndexIter() - 1;
faceList patchFaces(faceGroupEndIndexIter() - faceLabel); faceList patchFaces(faceGroupEndIndexIter() - faceLabel);
forAll(patchFaces, faceI) forAll (patchFaces, faceI)
{ {
if if
( (
@ -1313,7 +1310,7 @@ int main(int argc, char *argv[])
} }
} }
//inlets and outlets // Inlets and outlets
if if
( (
curPatchType == "pressure" curPatchType == "pressure"
@ -1378,7 +1375,7 @@ int main(int argc, char *argv[])
else if else if
( (
curPatchType == "" curPatchType == ""
) //unnamed face regions default to interior patches ) // Unnamed face regions default to interior patches
{ {
Info<< "Patch " << faceGroupZoneIDIter() Info<< "Patch " << faceGroupZoneIDIter()
<< ": Faces are defined but " << ": Faces are defined but "
@ -1394,7 +1391,7 @@ int main(int argc, char *argv[])
} }
else //unknown face regions are not handled else //unknown face regions are not handled
{ {
FatalErrorIn("fluentToFoam::main(int argc, char *argv[])") FatalErrorIn(args.executable())
<< "fluent patch type " << curPatchType << " not recognised." << "fluent patch type " << curPatchType << " not recognised."
<< abort(FatalError); << abort(FatalError);
} }
@ -1439,12 +1436,25 @@ int main(int argc, char *argv[])
label sz = bFaces.size(); label sz = bFaces.size();
labelList meshFaces(sz,-1); 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]; faceSet pFaceSet(pShapeMesh, patchNames[patchI], sz);
label cMeshFace = findFace(pShapeMesh, f);
meshFaces[j] = cMeshFace; 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]) && !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
@ -1478,7 +1488,7 @@ int main(int argc, char *argv[])
<< exit(FatalError); << exit(FatalError);
} }
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 "
@ -1491,7 +1501,7 @@ int main(int argc, char *argv[])
facePatchID[faceI - pShapeMesh.nInternalFaces()] = nBoundaries; facePatchID[faceI - pShapeMesh.nInternalFaces()] = nBoundaries;
} }
//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]
@ -1528,9 +1538,9 @@ int main(int argc, char *argv[])
// this routine should generally not be invoked // this routine should generally not be invoked
{ {
DynamicList<label> defaultBoundaryFaces(facePatchID.size()); DynamicList<label> defaultBoundaryFaces(facePatchID.size());
forAll(facePatchID, idI) forAll (facePatchID, idI)
{ {
if (facePatchID[idI] == -1) if(facePatchID[idI] == -1)
{ {
defaultBoundaryFaces.append(idI); defaultBoundaryFaces.append(idI);
facePatchID[idI] = nBoundaries; facePatchID[idI] = nBoundaries;
@ -1538,7 +1548,7 @@ int main(int argc, char *argv[])
} }
defaultBoundaryFaces.shrink(); defaultBoundaryFaces.shrink();
if (defaultBoundaryFaces.size()) if (defaultBoundaryFaces.size() != 0)
{ {
Warning << " fluent mesh has " << defaultBoundaryFaces.size() Warning << " fluent mesh has " << defaultBoundaryFaces.size()
<< " undefined boundary faces." << endl << " undefined boundary faces." << endl
@ -1582,34 +1592,20 @@ int main(int argc, char *argv[])
} }
repatcher.repatch(); repatcher.repatch();
preservePatchTypes
(
runTime,
runTime.constant(),
polyMesh::defaultRegion,
patchNames,
patchTypes,
defaultFacesName,
defaultFacesType,
patchPhysicalTypes
);
// Set the precision of the points data to 10 // Set the precision of the points data to 10
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision())); IOstream::defaultPrecision(10);
// Re-do face matching to write sets
if (writeSets)
{
forAll(patches, patchI)
{
const faceList& bFaces = patches[patchI];
label sz = bFaces.size();
faceSet pFaceSet(pShapeMesh, patchNames[patchI], sz);
forAll(bFaces, j)
{
const face& f = bFaces[j];
label cMeshFace = findFace(pShapeMesh, f);
pFaceSet.insert(cMeshFace);
}
Info<< "Writing patch " << patchNames[patchI]
<< " of size " << sz << " to faceSet" << endl;
pFaceSet.instance() = pShapeMesh.instance();
pFaceSet.write();
}
}
// Zones // Zones
@ -1620,7 +1616,7 @@ int main(int argc, char *argv[])
// 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;
List<pointZone*> pz(0); List<pointZone*> pz(0);
@ -1644,7 +1640,7 @@ int main(int argc, char *argv[])
boundaryZones[pI].append(bPatches[pI].name()); boundaryZones[pI].append(bPatches[pI].name());
} }
label cnt=0; label cnt = 0;
SLList<label>::iterator cg = cellGroupZoneID.begin(); SLList<label>::iterator cg = cellGroupZoneID.begin();
SLList<label>::iterator start = cellGroupStartIndex.begin(); SLList<label>::iterator start = cellGroupStartIndex.begin();
SLList<label>::iterator end = cellGroupEndIndex.begin(); SLList<label>::iterator end = cellGroupEndIndex.begin();
@ -1663,11 +1659,11 @@ 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 indices by 1 // Shift cell indices by 1
label nr=0; label nr = 0;
for (label celli = (start() - 1); celli < end(); celli++) for (label celli = (start() - 1); celli < end(); celli++)
{ {
cls[nr]=celli; cls[nr] = celli;
zoneCell[celli] = true; zoneCell[celli] = true;
nr++; nr++;
} }
@ -1681,13 +1677,13 @@ int main(int argc, char *argv[])
); );
DynamicList<label> zoneFaces(pShapeMesh.nFaces()); DynamicList<label> zoneFaces(pShapeMesh.nFaces());
forAll(pShapeMesh.faceNeighbour(), faceI) forAll (pShapeMesh.faceNeighbour(), faceI)
{ {
label nei = pShapeMesh.faceNeighbour()[faceI]; label nei = pShapeMesh.faceNeighbour()[faceI];
label own = pShapeMesh.faceOwner()[faceI]; label own = pShapeMesh.faceOwner()[faceI];
if (nei != -1) if(nei != -1)
{ {
if (zoneCell[nei] && zoneCell[own]) if(zoneCell[nei] && zoneCell[own])
{ {
zoneFaces.append(faceI); zoneFaces.append(faceI);
} }
@ -1705,12 +1701,12 @@ int main(int argc, char *argv[])
); );
// Add cell zones to patch zone list // Add cell zones to patch zone list
forAll(bPatches, pI) forAll (bPatches, pI)
{ {
const labelList& faceCells = bPatches[pI].faceCells(); const labelList& faceCells = bPatches[pI].faceCells();
forAll(faceCells, fcI) forAll(faceCells, fcI)
{ {
if (zoneCell[faceCells[fcI] ]) if(zoneCell[faceCells[fcI] ])
{ {
boundaryZones[pI].append(name); boundaryZones[pI].append(name);
break; break;
@ -1735,7 +1731,7 @@ int main(int argc, char *argv[])
); );
OFstream boundaryCellZonesFile(bczf); OFstream boundaryCellZonesFile(bczf);
forAll(boundaryZones, bzI) forAll (boundaryZones, bzI)
{ {
forAll(boundaryZones[bzI], bzII) forAll(boundaryZones[bzI], bzII)
{ {
@ -1777,8 +1773,8 @@ int main(int argc, char *argv[])
for (; cg != cellGroupZoneID.end(); ++cg, ++start, ++end) for (; cg != cellGroupZoneID.end(); ++cg, ++start, ++end)
{ {
const word& name=patchNameIDs[cg()]; const word& name = patchNameIDs[cg()];
const word& type=patchTypeIDs[cg()]; const word& type = patchTypeIDs[cg()];
Info<< "Writing cell set: " << name Info<< "Writing cell set: " << name
<< " of type " << type << " starting at " << start() - 1 << " of type " << type << " starting at " << start() - 1
@ -1806,6 +1802,6 @@ int main(int argc, char *argv[])
} }
/* ------------------------------------------------------------------------- *\ /* --------------------------------------------------------------------------*\
------ End of fluentMeshToFoam.L ------ End of fluentMeshToFoam.L
\* ------------------------------------------------------------------------- */ \* --------------------------------------------------------------------------*/

View file

@ -93,4 +93,74 @@ void Foam::preservePatchTypes
} }
void Foam::preservePatchTypes
(
const objectRegistry& obr,
const word& meshInstance,
const fileName& meshDir,
const wordList& patchNames,
wordList& patchTypes,
const word& defaultFacesName,
word& defaultFacesType,
wordList& patchPhysicalTypes
)
{
dictionary patchDictionary;
{
IOobject patchEntriesHeader
(
"boundary",
meshInstance,
meshDir,
obr,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
);
if (patchEntriesHeader.headerOk())
{
// Create a list of entries from the boundary file.
polyBoundaryMeshEntries patchEntries(patchEntriesHeader);
forAll(patchEntries, patchi)
{
patchDictionary.add(patchEntries[patchi]);
}
}
}
if (patchDictionary.size())
{
forAll(patchNames, patchi)
{
if (patchDictionary.found(patchNames[patchi]))
{
const dictionary& patchDict =
patchDictionary.subDict(patchNames[patchi]);
patchDict.lookup("type") >> patchTypes[patchi];
patchDict.readIfPresent("geometricType", patchTypes[patchi]);
patchDict.readIfPresent
(
"physicalType",
patchPhysicalTypes[patchi]
);
}
}
if (patchDictionary.found(defaultFacesName))
{
const dictionary& patchDict =
patchDictionary.subDict(defaultFacesName);
patchDict.readIfPresent("geometricType", defaultFacesType);
}
}
Info << nl << "Default patch type set to " << defaultFacesType << endl;
}
// ************************************************************************* // // ************************************************************************* //

View file

@ -58,6 +58,19 @@ void preservePatchTypes
word& defaultFacesType word& defaultFacesType
); );
//- preserve patch types
void preservePatchTypes
(
const objectRegistry& obr,
const word& meshInstance,
const fileName& meshDir,
const wordList& patchNames,
wordList& patchTypes,
const word& defaultFacesName,
word& defaultFacesType,
wordList& patchPhysicalTypes
);
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //