diff --git a/applications/utilities/preProcessing/createExternalCoupledPatchGeometry/addRegionsOption.H b/applications/utilities/preProcessing/createExternalCoupledPatchGeometry/addRegionsOption.H new file mode 100644 index 0000000000..9f57e35a40 --- /dev/null +++ b/applications/utilities/preProcessing/createExternalCoupledPatchGeometry/addRegionsOption.H @@ -0,0 +1,10 @@ +// +// addRegionOption.H +// ~~~~~~~~~~~~~~~~~ + + Foam::argList::addOption + ( + "regions", + "(name1 .. nameN)", + "specify alternative mesh regions" + ); diff --git a/applications/utilities/preProcessing/createExternalCoupledPatchGeometry/createExternalCoupledPatchGeometry.C b/applications/utilities/preProcessing/createExternalCoupledPatchGeometry/createExternalCoupledPatchGeometry.C index 51818b3787..6a8b78c683 100644 --- a/applications/utilities/preProcessing/createExternalCoupledPatchGeometry/createExternalCoupledPatchGeometry.C +++ b/applications/utilities/preProcessing/createExternalCoupledPatchGeometry/createExternalCoupledPatchGeometry.C @@ -38,6 +38,11 @@ Usage \param -region \ \n Specify an alternative mesh region. + \param -regions (\ \ .. \) \n + Specify alternative mesh regions. The region names will be sorted + alphabetically and a single composite name will be created + \_\.._\ + On execution, the combined patch geometry (points and faces) are output to the communications directory. @@ -59,6 +64,7 @@ SeeAlso int main(int argc, char *argv[]) { #include "addRegionOption.H" + #include "addRegionsOption.H" argList::validArgs.append("patchGroup"); argList::addOption ( @@ -68,16 +74,52 @@ int main(int argc, char *argv[]) ); #include "setRootCase.H" #include "createTime.H" - #include "createNamedMesh.H" - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + wordList regionNames(1, fvMesh::defaultRegion); + if (!args.optionReadIfPresent("region", regionNames[0])) + { + args.optionReadIfPresent("regions", regionNames); + } - const wordRe patchGroup(args[1]); + const wordRe patchGroup(args.argRead(1)); fileName commsDir(runTime.path()/"comms"); args.optionReadIfPresent("commsDir", commsDir); - externalCoupledFunctionObject::writeGeometry(mesh, commsDir, patchGroup); + + // Make sure region names are in canonical order + stableSort(regionNames); + + + PtrList meshes(regionNames.size()); + forAll(regionNames, i) + { + Info<< "Create mesh " << regionNames[i] << " for time = " + << runTime.timeName() << nl << endl; + + meshes.set + ( + i, + new fvMesh + ( + Foam::IOobject + ( + regionNames[i], + runTime.timeName(), + runTime, + Foam::IOobject::MUST_READ + ) + ) + ); + } + + + externalCoupledFunctionObject::writeGeometry + ( + UPtrList(meshes), + commsDir, + patchGroup + ); Info<< "\nEnd\n" << endl; diff --git a/src/postProcessing/functionObjects/jobControl/externalCoupled/externalCoupledFunctionObject.C b/src/postProcessing/functionObjects/jobControl/externalCoupled/externalCoupledFunctionObject.C index ca7e2d3951..ca9905c037 100644 --- a/src/postProcessing/functionObjects/jobControl/externalCoupled/externalCoupledFunctionObject.C +++ b/src/postProcessing/functionObjects/jobControl/externalCoupled/externalCoupledFunctionObject.C @@ -31,6 +31,7 @@ License #include "volFields.H" #include "globalIndex.H" #include "fvMesh.H" +#include "DynamicField.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -65,11 +66,16 @@ Foam::fileName Foam::externalCoupledFunctionObject::baseDir() const Foam::fileName Foam::externalCoupledFunctionObject::groupDir ( const fileName& commsDir, - const word& regionName, + const word& regionGroupName, const wordRe& groupName ) { - fileName result(commsDir/regionName/string::validate(groupName)); + fileName result + ( + commsDir + /regionGroupName + /string::validate(groupName) + ); result.clean(); return result; @@ -126,11 +132,11 @@ void Foam::externalCoupledFunctionObject::removeReadFiles() const if (log_) Info<< type() << ": removing all read files" << endl; - forAll(regionNames_, regionI) + forAll(regionGroupNames_, regionI) { - const word& regionName = regionNames_[regionI]; - const fvMesh& mesh = time_.lookupObject(regionName); - const labelList& groups = regionToGroups_[regionName]; + const word& compName = regionGroupNames_[regionI]; + + const labelList& groups = regionToGroups_[compName]; forAll(groups, i) { label groupI = groups[i]; @@ -141,7 +147,7 @@ void Foam::externalCoupledFunctionObject::removeReadFiles() const const word& fieldName = groupReadFields_[groupI][fieldI]; rm ( - groupDir(commsDir_, mesh.dbDir(), groupName) + groupDir(commsDir_, compName, groupName) / fieldName + ".in" ); } @@ -159,22 +165,22 @@ void Foam::externalCoupledFunctionObject::removeWriteFiles() const if (log_) Info<< type() << ": removing all write files" << endl; - forAll(regionNames_, regionI) + forAll(regionGroupNames_, regionI) { - const word& regionName = regionNames_[regionI]; - const fvMesh& mesh = time_.lookupObject(regionName); - const labelList& groups = regionToGroups_[regionName]; + const word& compName = regionGroupNames_[regionI]; + + const labelList& groups = regionToGroups_[compName]; forAll(groups, i) { label groupI = groups[i]; const wordRe& groupName = groupNames_[groupI]; - forAll(groupWriteFields_[groupI], fieldI) + forAll(groupReadFields_[groupI], fieldI) { - const word& fieldName = groupWriteFields_[groupI][fieldI]; + const word& fieldName = groupReadFields_[groupI][fieldI]; rm ( - groupDir(commsDir_, mesh.dbDir(), groupName) + groupDir(commsDir_, compName, groupName) / fieldName + ".out" ); } @@ -376,12 +382,21 @@ void Foam::externalCoupledFunctionObject::readLines void Foam::externalCoupledFunctionObject::writeGeometry ( - const fvMesh& mesh, + const UPtrList& meshes, const fileName& commsDir, const wordRe& groupName ) { - fileName dir(groupDir(commsDir, mesh.dbDir(), groupName)); + wordList regionNames(meshes.size()); + forAll(meshes, i) + { + regionNames[i] = meshes[i].dbDir(); + } + + // Make sure meshes are provided in sorted order + checkOrder(regionNames); + + fileName dir(groupDir(commsDir, compositeName(regionNames), groupName)); //if (log_) { @@ -397,99 +412,210 @@ void Foam::externalCoupledFunctionObject::writeGeometry osFacesPtr.reset(new OFstream(dir/"patchFaces")); } - const labelList patchIDs - ( - mesh.boundaryMesh().patchSet - ( - List(1, groupName) - ).sortedToc() - ); - forAll(patchIDs, i) + DynamicList allMeshesFaces; + DynamicField allMeshesPoints; + + forAll(meshes, meshI) { - label patchI = patchIDs[i]; + const fvMesh& mesh = meshes[meshI]; - const polyPatch& p = mesh.boundaryMesh()[patchI]; + const labelList patchIDs + ( + mesh.boundaryMesh().patchSet + ( + List(1, groupName) + ).sortedToc() + ); + + // Count faces + label nFaces = 0; + forAll(patchIDs, i) + { + nFaces += mesh.boundaryMesh()[patchIDs[i]].size(); + } + + // Collect faces + DynamicList