diff --git a/applications/utilities/mesh/conversion/fluent3DMeshToFoam/Make/options b/applications/utilities/mesh/conversion/fluent3DMeshToFoam/Make/options index 70c838b774..525acf8e56 100644 --- a/applications/utilities/mesh/conversion/fluent3DMeshToFoam/Make/options +++ b/applications/utilities/mesh/conversion/fluent3DMeshToFoam/Make/options @@ -1,7 +1,9 @@ EXE_INC = \ -I$(LIB_SRC)/meshTools/lnInclude \ - -I$(LIB_SRC)/dynamicMesh/lnInclude + -I$(LIB_SRC)/dynamicMesh/lnInclude \ + -I$(LIB_SRC)/conversion/lnInclude EXE_LIBS = \ -lmeshTools \ - -ldynamicMesh + -ldynamicMesh \ + -lconversion diff --git a/applications/utilities/mesh/conversion/fluent3DMeshToFoam/fluent3DMeshToFoam.L b/applications/utilities/mesh/conversion/fluent3DMeshToFoam/fluent3DMeshToFoam.L index 4f92ff17ad..929947b68f 100644 --- a/applications/utilities/mesh/conversion/fluent3DMeshToFoam/fluent3DMeshToFoam.L +++ b/applications/utilities/mesh/conversion/fluent3DMeshToFoam/fluent3DMeshToFoam.L @@ -38,10 +38,11 @@ License #include "polyMeshZipUpCells.H" #include "wallPolyPatch.H" #include "symmetryPolyPatch.H" -#include "oldCyclicPolyPatch.H" +#include "mergedCyclicPolyPatch.H" #include "Swap.H" #include "IFstream.H" #include "readHexLabel.H" +#include "polyMeshUnMergeCyclics.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -769,6 +770,12 @@ int main(int argc, char *argv[]) "geometry scaling factor - default is 1" ); argList::addOption + ( + "includedAngle", + "angle", + "feature angle with which to split cyclics" + ); + argList::addOption ( "ignoreCellGroups", "names", @@ -901,16 +908,13 @@ int main(int argc, char *argv[]) fluentToFoamType.insert("interface", polyPatch::typeName); fluentToFoamType.insert("internal", polyPatch::typeName); fluentToFoamType.insert("solid", polyPatch::typeName); - fluentToFoamType.insert("fan", oldCyclicPolyPatch::typeName); - fluentToFoamType.insert("radiator", polyPatch::typeName); - fluentToFoamType.insert("porous-jump", polyPatch::typeName); - //- Periodic halves map directly into split cyclics. The problem is the - // initial matching since we require knowledge of the transformation. - // It is ok if the periodics are already ordered. We should read the - // periodic shadow faces section (section 18) to give use the ordering - // For now just disable. - // fluentToFoamType.insert("periodic", cyclicPolyPatch::typeName); + fluentToFoamType.insert("fan", mergedCyclicPolyPatch::typeName); + fluentToFoamType.insert("radiator", mergedCyclicPolyPatch::typeName); + fluentToFoamType.insert("porous-jump", mergedCyclicPolyPatch::typeName); + + fluentToFoamType.insert("periodic", cyclicPolyPatch::typeName); + fluentToFoamType.insert("shadow", cyclicPolyPatch::typeName); // Foam patch type for Fluent zone type @@ -919,6 +923,8 @@ int main(int argc, char *argv[]) HashSet fluentGroupToFoamPatch; fluentGroupToFoamPatch.insert("wall"); fluentGroupToFoamPatch.insert("fan"); + fluentGroupToFoamPatch.insert("radiator"); + fluentGroupToFoamPatch.insert("porous-jump"); // Create initial empty polyMesh @@ -1023,6 +1029,76 @@ int main(int argc, char *argv[]) faceZoneIDs.shrink(); + // Pair up cyclics + // ~~~~~~~~~~~~~~~ + + labelList nbrPatchis(patchIDs.size(), -1); + forAll(patchIDs, patchi) + { + const label zonei = faceGroupZoneID[patchIDs[patchi]]; + const word& name = groupName[zonei]; + const word& type = groupType[zonei]; + + HashTable::const_iterator iter = fluentToFoamType.find(type); + + if (iter != fluentToFoamType.end()) + { + if + ( + iter() == cyclicPolyPatch::typeName + && nbrPatchis[patchi] == -1 + ) + { + // This is one half of a pair of patches defining a cyclic + // interface. Find the neighbouring patch. + + forAll(patchIDs, nbrPatchi) + { + const label nbrZonei = faceGroupZoneID[patchIDs[nbrPatchi]]; + const word& nbrName = groupName[nbrZonei]; + const word& nbrType = groupType[nbrZonei]; + + HashTable::const_iterator nbrIter = + fluentToFoamType.find(nbrType); + + if (nbrIter != fluentToFoamType.end()) + { + if + ( + nbrIter() == cyclicPolyPatch::typeName + && nbrPatchis[nbrPatchi] == -1 + ) + { + // The neighbour must have a different type + // (periodic =/= shadow) and its name must share a + // prefix with the patch. + + if + ( + nbrType != type + && nbrName(min(name.size(), nbrName.size())) + == name(min(name.size(), nbrName.size())) + ) + { + nbrPatchis[nbrPatchi] = patchi; + nbrPatchis[patchi] = nbrPatchi; + break; + } + } + } + } + + if (nbrPatchis[patchi] == -1) + { + FatalErrorInFunction + << "Could not find neighbour patch for " << type + << " patch " << name << exit(FatalError); + } + } + } + } + + // Add empty patches // ~~~~~~~~~~~~~~~~~ @@ -1031,7 +1107,7 @@ int main(int argc, char *argv[]) forAll(patchIDs, patchi) { - label zoneID = faceGroupZoneID[patchIDs[patchi] ]; + const label zoneID = faceGroupZoneID[patchIDs[patchi]]; word name = groupName[zoneID]; const word& type = groupType[zoneID]; @@ -1047,32 +1123,11 @@ int main(int argc, char *argv[]) if (iter != fluentToFoamType.end()) { - // See if we have a periodic and can derive the other side. - word nbrPatchName; if (iter() == cyclicPolyPatch::typeName) { - // Periodic - size_t n = name.rfind("-SIDE-1"); - - if (n != string::npos) - { - nbrPatchName = name.substr(0, n) + "-SIDE-2"; - } - else - { - n = name.rfind("-SIDE-2"); - if (n != string::npos) - { - nbrPatchName = name.substr(0, n) + "-SIDE-1"; - } - } - } - - if (nbrPatchName.size()) - { - Info<< "Adding cyclicPolyPatch for Fluent zone " << name - << " with neighbour patch " << nbrPatchName - << endl; + const label nbrPatchi = nbrPatchis[patchi]; + const label nbrZoneID = faceGroupZoneID[patchIDs[nbrPatchi]]; + const word nbrName = groupName[nbrZoneID]; newPatches[patchi] = new cyclicPolyPatch ( @@ -1082,8 +1137,7 @@ int main(int argc, char *argv[]) patchi, mesh.boundaryMesh(), cyclicPolyPatch::typeName, - nbrPatchName, - cyclicPolyPatch::NOORDERING + nbrName ); } else @@ -1101,9 +1155,6 @@ int main(int argc, char *argv[]) } else { - Info<< "Adding polyPatch for unknown Fluent type " << type - << endl; - newPatches[patchi] = new polyPatch ( name, @@ -1342,6 +1393,7 @@ int main(int argc, char *argv[]) ); } } + // Mark face as being done owner[facei] = -1; } @@ -1411,6 +1463,16 @@ int main(int argc, char *argv[]) polyMeshZipUpCells(mesh); } + // Un-merge any merged cyclics + if (args.optionFound("includedAngle")) + { + polyMeshUnMergeCyclics(mesh, args.optionRead("includedAngle")); + } + else + { + polyMeshUnMergeCyclics(mesh); + } + mesh.setInstance(runTime.constant()); // Set the precision of the points data to 10 diff --git a/applications/utilities/mesh/conversion/kivaToFoam/Make/options b/applications/utilities/mesh/conversion/kivaToFoam/Make/options index e69de29bb2..9cc80f6d26 100644 --- a/applications/utilities/mesh/conversion/kivaToFoam/Make/options +++ b/applications/utilities/mesh/conversion/kivaToFoam/Make/options @@ -0,0 +1,7 @@ +EXE_INC = \ + -I$(LIB_SRC)/dynamicMesh/lnInclude \ + -I$(LIB_SRC)/conversion/lnInclude + +EXE_LIBS = \ + -ldynamicMesh \ + -lconversion diff --git a/applications/utilities/mesh/conversion/kivaToFoam/kivaToFoam.C b/applications/utilities/mesh/conversion/kivaToFoam/kivaToFoam.C index 52316509ec..c47b0e3ff2 100644 --- a/applications/utilities/mesh/conversion/kivaToFoam/kivaToFoam.C +++ b/applications/utilities/mesh/conversion/kivaToFoam/kivaToFoam.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -41,7 +41,8 @@ Description #include "wallPolyPatch.H" #include "symmetryPolyPatch.H" #include "wedgePolyPatch.H" -#include "oldCyclicPolyPatch.H" +#include "mergedCyclicPolyPatch.H" +#include "polyMeshUnMergeCyclics.H" #include "unitConversion.H" using namespace Foam; diff --git a/applications/utilities/mesh/conversion/kivaToFoam/readKivaGrid.H b/applications/utilities/mesh/conversion/kivaToFoam/readKivaGrid.H index 46e1c924a8..0f9eea28c1 100644 --- a/applications/utilities/mesh/conversion/kivaToFoam/readKivaGrid.H +++ b/applications/utilities/mesh/conversion/kivaToFoam/readKivaGrid.H @@ -196,7 +196,7 @@ const word* kivaPatchTypes[nBCs] = &polyPatch::typeName, &polyPatch::typeName, &symmetryPolyPatch::typeName, - &oldCyclicPolyPatch::typeName + &mergedCyclicPolyPatch::typeName }; enum patchTypeNames @@ -574,6 +574,9 @@ polyMesh pShapeMesh defaultFacesType ); +// Un-merge any merged cyclics +polyMeshUnMergeCyclics(pShapeMesh); + Info << "Writing polyMesh" << endl; pShapeMesh.write(); diff --git a/applications/utilities/mesh/conversion/sammToFoam/Make/options b/applications/utilities/mesh/conversion/sammToFoam/Make/options index e69de29bb2..9cc80f6d26 100644 --- a/applications/utilities/mesh/conversion/sammToFoam/Make/options +++ b/applications/utilities/mesh/conversion/sammToFoam/Make/options @@ -0,0 +1,7 @@ +EXE_INC = \ + -I$(LIB_SRC)/dynamicMesh/lnInclude \ + -I$(LIB_SRC)/conversion/lnInclude + +EXE_LIBS = \ + -ldynamicMesh \ + -lconversion diff --git a/applications/utilities/mesh/conversion/sammToFoam/readBoundary.C b/applications/utilities/mesh/conversion/sammToFoam/readBoundary.C index 4f0e6c29f2..5453c942a2 100644 --- a/applications/utilities/mesh/conversion/sammToFoam/readBoundary.C +++ b/applications/utilities/mesh/conversion/sammToFoam/readBoundary.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -29,7 +29,7 @@ Description #include "sammMesh.H" #include "Time.H" #include "wallPolyPatch.H" -#include "oldCyclicPolyPatch.H" +#include "mergedCyclicPolyPatch.H" #include "symmetryPolyPatch.H" #include "preservePatchTypes.H" #include "IFstream.H" @@ -206,9 +206,7 @@ void Foam::sammMesh::readBoundary() } else if (patchType == "CYCL") { - // incorrect. should be cyclicPatch but this - // requires info on connected faces. - patchTypes_[patchLabel] = oldCyclicPolyPatch::typeName; + patchTypes_[patchLabel] = mergedCyclicPolyPatch::typeName; } else { diff --git a/applications/utilities/mesh/conversion/sammToFoam/writeMesh.C b/applications/utilities/mesh/conversion/sammToFoam/writeMesh.C index 0d2e2dddcf..3c8dc00f5f 100644 --- a/applications/utilities/mesh/conversion/sammToFoam/writeMesh.C +++ b/applications/utilities/mesh/conversion/sammToFoam/writeMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -29,6 +29,7 @@ Description #include "sammMesh.H" #include "Time.H" #include "polyMesh.H" +#include "polyMeshUnMergeCyclics.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -56,6 +57,8 @@ void Foam::sammMesh::writeMesh() patchPhysicalTypes_ ); + polyMeshUnMergeCyclics(pShapeMesh); + Info<< "Writing polyMesh" << endl; pShapeMesh.write(); } @@ -82,6 +85,8 @@ void Foam::sammMesh::writeMesh() pMesh.addPatches(polyBoundaryPatches(pMesh)); + polyMeshUnMergeCyclics(pMesh); + Info<< "Writing polyMesh" << endl; pMesh.write(); } diff --git a/applications/utilities/mesh/conversion/star3ToFoam/Make/options b/applications/utilities/mesh/conversion/star3ToFoam/Make/options index 3dbc679a10..b4a6830ff5 100644 --- a/applications/utilities/mesh/conversion/star3ToFoam/Make/options +++ b/applications/utilities/mesh/conversion/star3ToFoam/Make/options @@ -4,4 +4,10 @@ EXE_INC = \ /* -DDEBUG_COUPLE_INTERSECTION */ \ /* -DDEBUG_RIGHT_HAND_WALK */ \ /* -DDEBUG_FACE_ORDERING */ \ - /* -DDEBUG_COUPLE_PROJECTION */ + /* -DDEBUG_COUPLE_PROJECTION */ \ + -I$(LIB_SRC)/dynamicMesh/lnInclude \ + -I$(LIB_SRC)/conversion/lnInclude + +EXE_LIBS = \ + -ldynamicMesh \ + -lconversion diff --git a/applications/utilities/mesh/conversion/star3ToFoam/readBoundary.C b/applications/utilities/mesh/conversion/star3ToFoam/readBoundary.C index ddd9b04b74..2859fc41f4 100644 --- a/applications/utilities/mesh/conversion/star3ToFoam/readBoundary.C +++ b/applications/utilities/mesh/conversion/star3ToFoam/readBoundary.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -29,7 +29,7 @@ Description #include "starMesh.H" #include "Time.H" #include "wallPolyPatch.H" -#include "oldCyclicPolyPatch.H" +#include "mergedCyclicPolyPatch.H" #include "symmetryPolyPatch.H" #include "preservePatchTypes.H" #include "IFstream.H" @@ -204,9 +204,7 @@ void Foam::starMesh::readBoundary() } else if (patchType == "CYCL") { - // incorrect. should be cyclicPatch but this - // requires info on connected faces. - patchTypes_[patchLabel] = oldCyclicPolyPatch::typeName; + patchTypes_[patchLabel] = mergedCyclicPolyPatch::typeName; } else { diff --git a/applications/utilities/mesh/conversion/star3ToFoam/writeMesh.C b/applications/utilities/mesh/conversion/star3ToFoam/writeMesh.C index 3865db5f30..a9bd02818e 100644 --- a/applications/utilities/mesh/conversion/star3ToFoam/writeMesh.C +++ b/applications/utilities/mesh/conversion/star3ToFoam/writeMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -29,6 +29,7 @@ Description #include "starMesh.H" #include "Time.H" #include "polyMesh.H" +#include "polyMeshUnMergeCyclics.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -60,6 +61,8 @@ void Foam::starMesh::writeMesh() patchPhysicalTypes_ ); + polyMeshUnMergeCyclics(pShapeMesh); + Info<< "Writing polyMesh" << endl; pShapeMesh.write(); } @@ -89,6 +92,8 @@ void Foam::starMesh::writeMesh() // adding patches also checks the mesh pMesh.addPatches(polyBoundaryPatches(pMesh)); + polyMeshUnMergeCyclics(pMesh); + Info<< "Writing polyMesh" << endl; pMesh.write(); } diff --git a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C index e5928a6421..49baee1372 100644 --- a/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C +++ b/applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMeshIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2012-2019 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2012-2020 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -437,8 +437,7 @@ Foam::autoPtr Foam::conformalVoronoiMesh::createDummyMesh patchi, mesh.boundaryMesh(), patchDicts[patchi].lookup