diff --git a/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C b/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C index 4970d0bcce3c0f4836ab92b0e8c2b1283cee8e84..051f74968be19c6d09eae441f91bb55f696c22bb 100644 --- a/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C +++ b/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C @@ -48,12 +48,164 @@ using namespace Foam; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // +void createBaffles +( + const polyMesh& mesh, + const label faceI, + const label oldPatchI, + const labelList& newPatches, + PackedBoolList& doneFace, + polyTopoChange& meshMod +) +{ + const polyBoundaryMesh& patches = mesh.boundaryMesh(); + const faceZoneMesh& faceZones = mesh.faceZones(); + + const face& f = mesh.faces()[faceI]; + label zoneID = faceZones.whichZone(faceI); + bool zoneFlip = false; + if (zoneID >= 0) + { + const faceZone& fZone = faceZones[zoneID]; + zoneFlip = fZone.flipMap()[fZone.whichFace(faceI)]; + } + label nei = -1; + if (oldPatchI == -1) + { + nei = mesh.faceNeighbour()[faceI]; + } + + + face revFace(f.reverseFace()); + + forAll(newPatches, i) + { + if (oldPatchI == -1) + { + // Internal face + if (doneFace.set(faceI)) + { + // First usage of face. Modify. + meshMod.setAction + ( + polyModifyFace + ( + f, // modified face + faceI, // label of face + mesh.faceOwner()[faceI], // owner + -1, // neighbour + false, // face flip + newPatches[i], // patch for face + false, // remove from zone + zoneID, // zone for face + zoneFlip // face flip in zone + ) + ); + } + else + { + // Second or more usage of face. Add. + meshMod.setAction + ( + polyAddFace + ( + f, // modified face + mesh.faceOwner()[faceI], // owner + -1, // neighbour + -1, // master point + -1, // master edge + faceI, // master face + false, // face flip + newPatches[i], // patch for face + zoneID, // zone for face + zoneFlip // face flip in zone + ) + ); + } + + meshMod.setAction + ( + polyAddFace + ( + revFace, // modified face + nei, // owner + -1, // neighbour + -1, // masterPointID + -1, // masterEdgeID + faceI, // masterFaceID, + true, // face flip + newPatches[i], // patch for face + zoneID, // zone for face + zoneFlip // face flip in zone + ) + ); + } + else if + ( + patches[oldPatchI].coupled() + && patches[newPatches[i]].coupled() + ) + { + // Do not allow coupled patches to be moved to different coupled + // patches. + //WarningIn("createBaffles()") + // << "Not moving face from coupled patch " + // << patches[oldPatchI].name() + // << " to another coupled patch " << patches[newPatches[i]] + // << endl; + } + else + { + if (doneFace.set(faceI)) + { + meshMod.setAction + ( + polyModifyFace + ( + f, // modified face + faceI, // label of face + mesh.faceOwner()[faceI], // owner + -1, // neighbour + false, // face flip + newPatches[i], // patch for face + false, // remove from zone + zoneID, // zone for face + zoneFlip // face flip in zone + ) + ); + } + else + { + meshMod.setAction + ( + polyAddFace + ( + f, // modified face + mesh.faceOwner()[faceI], // owner + -1, // neighbour + -1, // master point + -1, // master edge + faceI, // master face + false, // face flip + newPatches[i], // patch for face + zoneID, // zone for face + zoneFlip // face flip in zone + ) + ); + } + } + } +} + + + // Main program: int main(int argc, char *argv[]) { argList::validArgs.append("set"); argList::validArgs.append("patch"); + argList::validOptions.insert("additionalPatches", "(patch2 .. patchN)"); argList::validOptions.insert("overwrite", ""); # include "setRootCase.H" @@ -63,29 +215,64 @@ int main(int argc, char *argv[]) const word oldInstance = mesh.pointsInstance(); const polyBoundaryMesh& patches = mesh.boundaryMesh(); - const faceZoneMesh& faceZones = mesh.faceZones(); // Faces to baffle word setName(args.additionalArgs()[0]); Pout<< "Reading faceSet from " << setName << nl << endl; faceSet facesToSplit(mesh, setName); + // Make sure set is synchronised across couples + facesToSplit.sync(mesh); Pout<< "Read " << facesToSplit.size() << " faces from " << setName << nl << endl; - // Patch to put them into - word patchName(args.additionalArgs()[1]); - label wantedPatchI = patches.findPatchID(patchName); - Pout<< "Using patch " << patchName << " at index " << wantedPatchI << endl; + // Patches to put baffles into + labelList newPatches(1); - if (wantedPatchI == -1) + word patchName(args.additionalArgs()[1]); + newPatches[0] = patches.findPatchID(patchName); + Pout<< "Using patch " << patchName + << " at index " << newPatches[0] << endl; + + if (newPatches[0] == -1) { FatalErrorIn(args.executable()) - << "Cannot find patch " << patchName << exit(FatalError); + << "Cannot find patch " << patchName << endl + << "Valid patches are " << patches.names() << exit(FatalError); + } + + + // Additional patches + if (args.options().found("additionalPatches")) + { + const wordList patchNames + ( + IStringStream(args.options()["additionalPatches"])() + ); + + forAll(patchNames, i) + { + label patchI = patches.findPatchID(patchNames[i]); + Info<< "Using additional patch " << patchNames[i] + << " at index " << patchI << endl; + + if (patchI == -1) + { + FatalErrorIn(args.executable()) + << "Cannot find patch " << patchNames[i] << endl + << "Valid patches are " << patches.names() + << exit(FatalError); + } + + newPatches.append(patchI); + } } + bool overwrite = args.options().found("overwrite"); + + // Read objects in time directory IOobjectList objects(mesh, runTime.timeName()); @@ -128,107 +315,53 @@ int main(int argc, char *argv[]) polyTopoChange meshMod(mesh); - // Creating baffles: - // - coupled boundary faces : become the patch specified - // - non-coupled ,, : illegal - // - internal faces : converted into boundary faces. + // Do the actual changes - labelList newPatch(mesh.nFaces(), -1); + label nBaffled = 0; + PackedBoolList doneFace(mesh.nFaces()); - forAllConstIter(faceSet, facesToSplit, iter) + for (label faceI = 0; faceI < mesh.nInternalFaces(); faceI++) { - label faceI = iter.key(); - - label patchI = patches.whichPatch(faceI); - - if (patchI == -1) + if (facesToSplit.found(faceI)) { - newPatch[faceI] = wantedPatchI; - } - else - { - if (patches[patchI].coupled()) - { - if (patchI != wantedPatchI) - { - newPatch[faceI] = wantedPatchI; - } - } - else - { - FatalErrorIn(args.executable()) - << "Can only create baffles from internal faces" - << " or coupled boundary faces." << endl - << "Face " << faceI << " is a boundary face on patch " - << patches[patchI].name() << exit(FatalError); - } + createBaffles + ( + mesh, + faceI, + -1, // oldPatchI, + newPatches, + doneFace, + meshMod + ); + nBaffled++; } } - - - // If one side of a coupled boundary is marked for baffling, make sure to - // also do the other side. - - syncTools::syncFaceList(mesh, newPatch, maxEqOp<label>(), false); - - - label nBaffled = 0; - - forAll(newPatch, faceI) + forAll(patches, patchI) { - if (newPatch[faceI] != -1) - { - const face& f = mesh.faces()[faceI]; - label zoneID = faceZones.whichZone(faceI); - bool zoneFlip = false; - if (zoneID >= 0) - { - const faceZone& fZone = faceZones[zoneID]; - zoneFlip = fZone.flipMap()[fZone.whichFace(faceI)]; - } + const polyPatch& pp = patches[patchI]; - meshMod.setAction - ( - polyModifyFace - ( - f, // modified face - faceI, // label of face - mesh.faceOwner()[faceI], // owner - -1, // neighbour - false, // face flip - newPatch[faceI], // patch for face - false, // remove from zone - zoneID, // zone for face - zoneFlip // face flip in zone - ) - ); + forAll(pp, i) + { + label faceI = pp.start()+i; - if (mesh.isInternalFace(faceI)) + if (facesToSplit.found(faceI)) { - meshMod.setAction + createBaffles ( - polyAddFace - ( - f.reverseFace(), // modified face - mesh.faceNeighbour()[faceI],// owner - -1, // neighbour - -1, // masterPointID - -1, // masterEdgeID - faceI, // masterFaceID, - false, // face flip - newPatch[faceI], // patch for face - zoneID, // zone for face - zoneFlip // face flip in zone - ) + mesh, + faceI, + patchI, // oldPatchI, + newPatches, + doneFace, + meshMod ); + nBaffled++; } - - nBaffled++; } } - Pout<< "Converted locally " << nBaffled + Info<< "Converted " << returnReduce(nBaffled, sumOp<label>()) << " faces into boundary faces on patch " << patchName << nl << endl; if (!overwrite) @@ -252,7 +385,7 @@ int main(int argc, char *argv[]) { mesh.setInstance(oldInstance); } - Pout<< "Writing mesh to " << runTime.timeName() << endl; + Info<< "Writing mesh to " << runTime.timeName() << endl; mesh.write(); diff --git a/applications/utilities/parallelProcessing/decomposePar/decomposeParDict b/applications/utilities/parallelProcessing/decomposePar/decomposeParDict index 98ec9b7087f53d7a33edffabac31de7f0b2b7e5e..0c566d50812ffcdbd856d09f12ebac9244177468 100644 --- a/applications/utilities/parallelProcessing/decomposePar/decomposeParDict +++ b/applications/utilities/parallelProcessing/decomposePar/decomposeParDict @@ -22,8 +22,9 @@ numberOfSubdomains 4; //- Keep owner and neighbour on same processor for faces in zones: // preserveFaceZones (heater solid1 solid3); -method simple; +method scotch; // method hierarchical; +// method simple; // method metis; // method manual; @@ -53,6 +54,9 @@ metisCoeffs */ } +scotchCoeffs +{} + manualCoeffs { dataFile "decompositionData"; diff --git a/applications/utilities/parallelProcessing/reconstructPar/processorMeshes.C b/applications/utilities/parallelProcessing/reconstructPar/processorMeshes.C index c7e5838e609ff0aeb96da658974c46f5e3419dd3..8c77b9f85562f15912fc72d340206ab92643834c 100644 --- a/applications/utilities/parallelProcessing/reconstructPar/processorMeshes.C +++ b/applications/utilities/parallelProcessing/reconstructPar/processorMeshes.C @@ -200,12 +200,6 @@ void Foam::processorMeshes::reconstructPoints(fvMesh& mesh) // Read the field for all the processors PtrList<pointIOField> procsPoints(meshes_.size()); - fileName regionPrefix = ""; - if (meshName_ != fvMesh::defaultRegion) - { - regionPrefix = meshName_; - } - forAll (meshes_, procI) { procsPoints.set @@ -217,7 +211,7 @@ void Foam::processorMeshes::reconstructPoints(fvMesh& mesh) ( "points", meshes_[procI].time().timeName(), - regionPrefix/polyMesh::meshSubDir, + polyMesh::meshSubDir, meshes_[procI], IOobject::MUST_READ, IOobject::NO_WRITE diff --git a/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C b/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C index 9311c9b4e9af1dff26b3cec570f56106f4898df8..1e3ed2b9bfb779780f349a3e59d13eab0689aa04 100644 --- a/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C +++ b/applications/utilities/parallelProcessing/reconstructPar/reconstructPar.C @@ -116,6 +116,13 @@ int main(int argc, char *argv[]) { regionPrefix = regionName; } + + // Set all times on processor meshes equal to reconstructed mesh + forAll (databases, procI) + { + databases[procI].setTime(runTime.timeName(), runTime.timeIndex()); + } + // Read all meshes and addressing to reconstructed mesh processorMeshes procMeshes(databases, regionName); diff --git a/src/OpenFOAM/meshes/polyMesh/polyMeshInitMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMeshInitMesh.C index 3fea2c77d9454230648dfaa748443ce7d426b7b9..e364c63f2f1d97aafece5177be7bf6cacf06bb39 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyMeshInitMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyMeshInitMesh.C @@ -82,10 +82,10 @@ void Foam::polyMesh::initMesh() ); string meshInfo = - "nPoints: " + Foam::name(nPoints()) - + " nCells: " + Foam::name(this->nCells()) - + " nFaces: " + Foam::name(nFaces()) - + " nInternalFaces: " + Foam::name(nInternalFaces()); + "nPoints:" + Foam::name(nPoints()) + + " nCells:" + Foam::name(this->nCells()) + + " nFaces:" + Foam::name(nFaces()) + + " nInternalFaces:" + Foam::name(nInternalFaces()); owner_.note() = meshInfo; neighbour_.note() = meshInfo; diff --git a/src/meshTools/directMapped/directMappedPolyPatch/directMappedPolyPatch.H b/src/meshTools/directMapped/directMappedPolyPatch/directMappedPolyPatch.H index e07f78a958cfc3c85c4d361b253f9f068a342433..522564b33775c89f135092dc1b161875c9a78ed0 100644 --- a/src/meshTools/directMapped/directMappedPolyPatch/directMappedPolyPatch.H +++ b/src/meshTools/directMapped/directMappedPolyPatch/directMappedPolyPatch.H @@ -86,7 +86,7 @@ protected: public: //- Runtime type information - TypeName("directMapped"); + TypeName("directMappedPatch"); // Constructors