From 29b5340b05741fda51b7aa3ff5105f99ae4c0e90 Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 26 Nov 2015 13:04:06 +0000 Subject: [PATCH] ENH: externalCoupled: changed to non-OutputFilter functionObject. - moved control to functionObject (from bc) - this allows multi-region support - see heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater tut - generalisation of streamed reading/writing of specialised bcs --- .../addRegionsOption.H | 10 + .../createExternalCoupledPatchGeometry.C | 50 +- .../externalCoupledFunctionObject.C | 409 ++++++++----- .../externalCoupledFunctionObject.H | 41 +- .../externalCoupledFunctionObjectTemplates.C | 556 ++++++++++-------- .../externalCoupledCavity/0/T | 56 -- .../externalCoupledCavity/0/alphat | 51 -- .../externalCoupledCavity/0/k | 47 -- .../externalCoupledCavity/0/omega | 47 -- .../externalCoupledCavity/Allclean | 14 - .../externalCoupledCavity/Allrun | 14 - .../externalCoupledCavity/Allrun-parallel | 16 - .../externalCoupledCavity/Allrun.pre | 11 - .../externalCoupledCavity/README | 5 - .../externalCoupledMultiRegionHeater/0/T | 30 + .../externalCoupledMultiRegionHeater}/0/U | 28 +- .../0/epsilon | 31 + .../externalCoupledMultiRegionHeater/0/k | 31 + .../externalCoupledMultiRegionHeater}/0/p | 24 +- .../externalCoupledMultiRegionHeater}/0/p_rgh | 24 +- .../externalCoupledMultiRegionHeater/Allclean | 23 + .../externalCoupledMultiRegionHeater/Allrun | 28 + .../Allrun.pre | 33 ++ .../README.txt | 3 + .../constant/bottomWater}/g | 2 - .../constant/bottomWater/radiationProperties | 22 + .../bottomWater/thermophysicalProperties} | 46 +- .../constant/bottomWater/turbulenceProperties | 19 + .../constant/heater/radiationProperties | 23 + .../constant/heater/thermophysicalProperties} | 48 +- .../constant/leftSolid/radiationProperties | 1 + .../leftSolid/thermophysicalProperties | 1 + .../constant/polyMesh}/blockMeshDict | 89 +-- .../constant/polyMesh/boundary | 48 +- .../constant/regionProperties | 24 + .../constant/rightSolid/radiationProperties | 1 + .../rightSolid/thermophysicalProperties | 1 + .../constant/topAir/g | 1 + .../constant/topAir/radiationProperties | 1 + .../constant/topAir}/thermophysicalProperties | 10 +- .../constant/topAir/turbulenceProperties | 1 + .../externalSolver | 47 +- .../system/README | 3 + .../system/bottomWater/changeDictionaryDict | 173 ++++++ .../system/bottomWater/decomposeParDict | 72 +++ .../system/bottomWater}/fvSchemes | 25 +- .../system/bottomWater}/fvSolution | 72 ++- .../system/controlDict | 96 +++ .../system/decomposeParDict | 60 ++ .../system/fvSchemes} | 35 +- .../system/fvSolution} | 13 +- .../system/heater/changeDictionaryDict | 77 +++ .../system/heater/decomposeParDict} | 48 +- .../system/heater/fvSchemes | 53 ++ .../system/heater/fvSolution | 40 ++ .../system/leftSolid/changeDictionaryDict | 65 ++ .../system/leftSolid/decomposeParDict | 44 ++ .../system/leftSolid/fvSchemes | 1 + .../system/leftSolid/fvSolution | 1 + .../system/rightSolid/changeDictionaryDict | 54 ++ .../system/rightSolid/decomposeParDict | 44 ++ .../system/rightSolid/fvSchemes | 1 + .../system/rightSolid/fvSolution | 1 + .../system/topAir/changeDictionaryDict | 179 ++++++ .../system/topAir/decomposeParDict | 72 +++ .../system/topAir/fvSchemes | 1 + .../system/topAir/fvSolution | 1 + .../system/topoSetDict | 178 ++++++ 68 files changed, 2442 insertions(+), 934 deletions(-) create mode 100644 applications/utilities/preProcessing/createExternalCoupledPatchGeometry/addRegionsOption.H delete mode 100644 tutorials/heatTransfer/buoyantSimpleFoam/externalCoupledCavity/0/T delete mode 100644 tutorials/heatTransfer/buoyantSimpleFoam/externalCoupledCavity/0/alphat delete mode 100644 tutorials/heatTransfer/buoyantSimpleFoam/externalCoupledCavity/0/k delete mode 100644 tutorials/heatTransfer/buoyantSimpleFoam/externalCoupledCavity/0/omega delete mode 100755 tutorials/heatTransfer/buoyantSimpleFoam/externalCoupledCavity/Allclean delete mode 100755 tutorials/heatTransfer/buoyantSimpleFoam/externalCoupledCavity/Allrun delete mode 100755 tutorials/heatTransfer/buoyantSimpleFoam/externalCoupledCavity/Allrun-parallel delete mode 100755 tutorials/heatTransfer/buoyantSimpleFoam/externalCoupledCavity/Allrun.pre delete mode 100644 tutorials/heatTransfer/buoyantSimpleFoam/externalCoupledCavity/README create mode 100644 tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/0/T rename tutorials/heatTransfer/{buoyantSimpleFoam/externalCoupledCavity => chtMultiRegionFoam/externalCoupledMultiRegionHeater}/0/U (66%) create mode 100644 tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/0/epsilon create mode 100644 tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/0/k rename tutorials/heatTransfer/{buoyantSimpleFoam/externalCoupledCavity => chtMultiRegionFoam/externalCoupledMultiRegionHeater}/0/p (71%) rename tutorials/heatTransfer/{buoyantSimpleFoam/externalCoupledCavity => chtMultiRegionFoam/externalCoupledMultiRegionHeater}/0/p_rgh (70%) create mode 100755 tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/Allclean create mode 100755 tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/Allrun create mode 100755 tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/Allrun.pre create mode 100644 tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/README.txt rename tutorials/heatTransfer/{buoyantSimpleFoam/externalCoupledCavity/constant => chtMultiRegionFoam/externalCoupledMultiRegionHeater/constant/bottomWater}/g (96%) create mode 100644 tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/constant/bottomWater/radiationProperties rename tutorials/heatTransfer/{buoyantSimpleFoam/externalCoupledCavity/0/epsilon => chtMultiRegionFoam/externalCoupledMultiRegionHeater/constant/bottomWater/thermophysicalProperties} (59%) create mode 100644 tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/constant/bottomWater/turbulenceProperties create mode 100644 tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/constant/heater/radiationProperties rename tutorials/heatTransfer/{buoyantSimpleFoam/externalCoupledCavity/0/nut => chtMultiRegionFoam/externalCoupledMultiRegionHeater/constant/heater/thermophysicalProperties} (62%) create mode 120000 tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/constant/leftSolid/radiationProperties create mode 120000 tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/constant/leftSolid/thermophysicalProperties rename tutorials/heatTransfer/{buoyantSimpleFoam/externalCoupledCavity/system => chtMultiRegionFoam/externalCoupledMultiRegionHeater/constant/polyMesh}/blockMeshDict (63%) rename tutorials/heatTransfer/{buoyantSimpleFoam/externalCoupledCavity => chtMultiRegionFoam/externalCoupledMultiRegionHeater}/constant/polyMesh/boundary (65%) create mode 100644 tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/constant/regionProperties create mode 120000 tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/constant/rightSolid/radiationProperties create mode 120000 tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/constant/rightSolid/thermophysicalProperties create mode 120000 tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/constant/topAir/g create mode 120000 tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/constant/topAir/radiationProperties rename tutorials/heatTransfer/{buoyantSimpleFoam/externalCoupledCavity/constant => chtMultiRegionFoam/externalCoupledMultiRegionHeater/constant/topAir}/thermophysicalProperties (88%) create mode 120000 tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/constant/topAir/turbulenceProperties rename tutorials/heatTransfer/{buoyantSimpleFoam/externalCoupledCavity => chtMultiRegionFoam/externalCoupledMultiRegionHeater}/externalSolver (53%) create mode 100644 tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/system/README create mode 100644 tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/system/bottomWater/changeDictionaryDict create mode 100644 tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/system/bottomWater/decomposeParDict rename tutorials/heatTransfer/{buoyantSimpleFoam/externalCoupledCavity/system => chtMultiRegionFoam/externalCoupledMultiRegionHeater/system/bottomWater}/fvSchemes (70%) rename tutorials/heatTransfer/{buoyantSimpleFoam/externalCoupledCavity/system => chtMultiRegionFoam/externalCoupledMultiRegionHeater/system/bottomWater}/fvSolution (62%) create mode 100644 tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/system/controlDict create mode 100644 tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/system/decomposeParDict rename tutorials/heatTransfer/{buoyantSimpleFoam/externalCoupledCavity/system/decomposeParDict => chtMultiRegionFoam/externalCoupledMultiRegionHeater/system/fvSchemes} (82%) rename tutorials/heatTransfer/{buoyantSimpleFoam/externalCoupledCavity/constant/turbulenceProperties => chtMultiRegionFoam/externalCoupledMultiRegionHeater/system/fvSolution} (84%) create mode 100644 tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/system/heater/changeDictionaryDict rename tutorials/heatTransfer/{buoyantSimpleFoam/externalCoupledCavity/system/controlDict => chtMultiRegionFoam/externalCoupledMultiRegionHeater/system/heater/decomposeParDict} (68%) create mode 100644 tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/system/heater/fvSchemes create mode 100644 tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/system/heater/fvSolution create mode 100644 tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/system/leftSolid/changeDictionaryDict create mode 100644 tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/system/leftSolid/decomposeParDict create mode 120000 tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/system/leftSolid/fvSchemes create mode 120000 tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/system/leftSolid/fvSolution create mode 100644 tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/system/rightSolid/changeDictionaryDict create mode 100644 tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/system/rightSolid/decomposeParDict create mode 120000 tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/system/rightSolid/fvSchemes create mode 120000 tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/system/rightSolid/fvSolution create mode 100644 tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/system/topAir/changeDictionaryDict create mode 100644 tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/system/topAir/decomposeParDict create mode 120000 tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/system/topAir/fvSchemes create mode 120000 tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/system/topAir/fvSolution create mode 100644 tutorials/heatTransfer/chtMultiRegionFoam/externalCoupledMultiRegionHeater/system/topoSetDict 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