diff --git a/applications/utilities/parallelProcessing/reconstructParMesh/Make/options b/applications/utilities/parallelProcessing/reconstructParMesh/Make/options index f9b5424edd..330bdf7644 100644 --- a/applications/utilities/parallelProcessing/reconstructParMesh/Make/options +++ b/applications/utilities/parallelProcessing/reconstructParMesh/Make/options @@ -1,8 +1,10 @@ EXE_INC = \ -I$(LIB_SRC)/dynamicMesh/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \ - -I$(LIB_SRC)/meshTools/lnInclude + -I$(LIB_SRC)/meshTools/lnInclude \ + -I$(LIB_SRC)/regionModels/regionModel/lnInclude EXE_LIBS = \ -ldynamicMesh \ - -lmeshTools + -lmeshTools \ + -lregionModels diff --git a/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C b/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C index a5bd8637b9..6a91ce3d67 100644 --- a/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C +++ b/applications/utilities/parallelProcessing/reconstructParMesh/reconstructParMesh.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2018 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -50,6 +50,7 @@ Description #include "fvMeshAdder.H" #include "polyTopoChange.H" #include "extrapolatedCalculatedFvPatchFields.H" +#include "regionProperties.H" using namespace Foam; @@ -479,6 +480,7 @@ int main(int argc, char *argv[]) ); #include "addRegionOption.H" + #include "addAllRegionsOption.H" #include "setRootCase.H" #include "createTime.H" @@ -498,18 +500,21 @@ int main(int argc, char *argv[]) << endl; - word regionName = polyMesh::defaultRegion; - word regionDir = word::null; - - if - ( - args.optionReadIfPresent("region", regionName) - && regionName != polyMesh::defaultRegion - ) + const wordList regionNames(selectRegionNames(args, runTime)); + if (regionNames.size() > 1) { - regionDir = regionName; - Info<< "Operating on region " << regionName << nl << endl; + Info<< "Operating on regions " << regionNames[0]; + for (label regioni = 1; regioni < regionNames.size() - 1; ++ regioni) + { + Info<< ", " << regionNames[regioni]; + } + Info<< " and " << regionNames.last() << nl << endl; } + else if (regionNames[0] != polyMesh::defaultRegion) + { + Info<< "Operating on region " << regionNames[0] << nl << endl; + } + scalar mergeTol = defaultMergeTol; args.optionReadIfPresent("mergeTol", mergeTol); @@ -596,77 +601,288 @@ int main(int argc, char *argv[]) databases[proci].setTime(timeDirs[timeI], timeI); } - IOobject facesIO - ( - "faces", - databases[0].timeName(), - regionDir/polyMesh::meshSubDir, - databases[0], - IOobject::NO_READ, - IOobject::NO_WRITE - ); - - - // Problem: faceCompactIOList recognises both 'faceList' and - // 'faceCompactList' so we should be lenient when doing - // typeHeaderOk - if (!facesIO.typeHeaderOk(false)) + forAll(regionNames, regioni) { - Info<< "No mesh." << nl << endl; - continue; - } + const word& regionName = regionNames[regioni]; + const word regionDir = + regionName == polyMesh::defaultRegion + ? word::null + : regionName; + + IOobject facesIO + ( + "faces", + databases[0].timeName(), + regionDir/polyMesh::meshSubDir, + databases[0], + IOobject::NO_READ, + IOobject::NO_WRITE + ); - // Read point on individual processors to determine merge tolerance - // (otherwise single cell domains might give problems) - - const boundBox bb = procBounds(args, databases, regionDir); - const scalar mergeDist = mergeTol*bb.mag(); - - Info<< "Overall mesh bounding box : " << bb << nl - << "Relative tolerance : " << mergeTol << nl - << "Absolute matching distance : " << mergeDist << nl - << endl; - - - // Addressing from processor to reconstructed case - labelListList cellProcAddressing(nProcs); - labelListList faceProcAddressing(nProcs); - labelListList pointProcAddressing(nProcs); - labelListList boundaryProcAddressing(nProcs); - - // Internal faces on the final reconstructed mesh - label masterInternalFaces; - - // Owner addressing on the final reconstructed mesh - labelList masterOwner; - - { - // Construct empty mesh. - // fvMesh** masterMesh = new fvMesh*[nProcs]; - PtrList masterMesh(nProcs); - - for (label proci=0; proci(false)) { - masterMesh.set - ( - proci, - new fvMesh + Info<< "No mesh." << nl << endl; + continue; + } + + + // Read point on individual processors to determine merge tolerance + // (otherwise single cell domains might give problems) + + const boundBox bb = procBounds(args, databases, regionDir); + const scalar mergeDist = mergeTol*bb.mag(); + + Info<< "Overall mesh bounding box : " << bb << nl + << "Relative tolerance : " << mergeTol << nl + << "Absolute matching distance : " << mergeDist << nl + << endl; + + + // Addressing from processor to reconstructed case + labelListList cellProcAddressing(nProcs); + labelListList faceProcAddressing(nProcs); + labelListList pointProcAddressing(nProcs); + labelListList boundaryProcAddressing(nProcs); + + // Internal faces on the final reconstructed mesh + label masterInternalFaces; + + // Owner addressing on the final reconstructed mesh + labelList masterOwner; + + { + // Construct empty mesh. + // fvMesh** masterMesh = new fvMesh*[nProcs]; + PtrList masterMesh(nProcs); + + for (label proci=0; proci couples = determineCoupledFaces + ( + fullMatch, + proci, + proci, + masterMesh[proci], + proci, + proci, + meshToAdd, + mergeDist + ); + + // Add elements to mesh + autoPtr map = fvMeshAdder::add + ( + masterMesh[proci], + meshToAdd, + couples + ); + + // Added processor + renumber(map().addedCellMap(), cellProcAddressing[proci]); + renumber(map().addedFaceMap(), faceProcAddressing[proci]); + renumber(map().addedPointMap(), pointProcAddressing[proci]); + renumber + ( + map().addedPatchMap(), + boundaryProcAddressing[proci] + ); + } + for (label step=2; step= nProcs) + { + continue; + } + + Info<< "Merging mesh " << proci << " with " << next + << endl; + + // Find geometrically shared points/faces. + autoPtr couples = determineCoupledFaces + ( + fullMatch, + proci, + next, + masterMesh[proci], + next, + proci+step, + masterMesh[next], + mergeDist + ); + + // Add elements to mesh + autoPtr map = fvMeshAdder::add + ( + masterMesh[proci], + masterMesh[next], + couples + ); + + // Processors that were already in masterMesh + for (label mergedI=proci; mergedI couples = determineCoupledFaces + // From processor point to reconstructed mesh point + + Info<< "Writing pointProcAddressing to " + << databases[proci].caseName() + /procMesh.facesInstance() + /polyMesh::meshSubDir + << endl; + + labelIOList ( - fullMatch, - proci, - proci, - masterMesh[proci], - proci, - proci, - meshToAdd, - mergeDist + IOobject + ( + "pointProcAddressing", + procMesh.facesInstance(), + polyMesh::meshSubDir, + procMesh, + IOobject::NO_READ, + IOobject::NO_WRITE, + false // Do not register + ), + pointProcAddressing[proci] + ).write(); + + + // From processor face to reconstructed mesh face + + Info<< "Writing faceProcAddressing to " + << databases[proci].caseName() + /procMesh.facesInstance() + /polyMesh::meshSubDir + << endl; + + labelIOList faceProcAddr + ( + IOobject + ( + "faceProcAddressing", + procMesh.facesInstance(), + polyMesh::meshSubDir, + procMesh, + IOobject::NO_READ, + IOobject::NO_WRITE, + false // Do not register + ), + faceProcAddressing[proci] ); - // Add elements to mesh - autoPtr map = fvMeshAdder::add - ( - masterMesh[proci], - meshToAdd, - couples - ); - - // Added processor - renumber(map().addedCellMap(), cellProcAddressing[proci]); - renumber(map().addedFaceMap(), faceProcAddressing[proci]); - renumber(map().addedPointMap(), pointProcAddressing[proci]); - renumber(map().addedPatchMap(), boundaryProcAddressing[proci]); - } - for (label step=2; step= nProcs) - { - continue; - } + const label masterFacei = faceProcAddr[procFacei]; - Info<< "Merging mesh " << proci << " with " << next << endl; - - // Find geometrically shared points/faces. - autoPtr couples = determineCoupledFaces + if ( - fullMatch, - proci, - next, - masterMesh[proci], - next, - proci+step, - masterMesh[next], - mergeDist - ); - - // Add elements to mesh - autoPtr map = fvMeshAdder::add - ( - masterMesh[proci], - masterMesh[next], - couples - ); - - // Processors that were already in masterMesh - for (label mergedI=proci; mergedI