diff --git a/applications/test/dimensionedType/Test-dimensionedType.C b/applications/test/dimensionedType/Test-dimensionedType.C index 5c826d256f26db4f78c9a69cde68aff5b56c83ec..ccf56fff6bc14d9e8022b67273a65dbd9debd6e8 100644 --- a/applications/test/dimensionedType/Test-dimensionedType.C +++ b/applications/test/dimensionedType/Test-dimensionedType.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -41,6 +41,45 @@ int main(int argc, char *argv[]) Info<< ds*dt << " " << dt*ds << endl; + + // dimensionSet + { + Pout<< "dimensionSet construct from is:" + << dimensionSet(IStringStream("[Pa m^2 s^-2]")()) + << endl; + + IStringStream is("[Pa m^2 s^-2]"); + dimensionSet dset(dimless); + is >> dset; + Pout<< "dimensionSet read:" << dset << endl; + } + // dimensionedType + { + Pout<< "construct from is:" + << dimensionedScalar(IStringStream("bla [Pa mm^2 s^-2] 3.0")()) + << endl; + Pout<< "construct from name,is:" + << dimensionedScalar + ( + "ABC", + IStringStream("[Pa mm^2 s^-2] 3.0")() + ) << endl; + Pout<< "construct from name,dimensionSet,is:" + << dimensionedScalar + ( + "ABC", + dimLength, + IStringStream("bla [mm] 3.0")() + ) << endl; + { + IStringStream is("bla [mm] 3.0"); + dimensionedScalar ds; + is >> ds; + Pout<< "read:" << ds << endl; + } + } + + Info<< "End\n" << endl; return 0; diff --git a/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C b/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C index d129efde6de1af1522691124bf581a64d1a91c16..4abdc6c607c25e0fa85c29d14395dc2a5d8b6c62 100644 --- a/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C +++ b/applications/utilities/mesh/manipulation/splitMeshRegions/splitMeshRegions.C @@ -55,6 +55,8 @@ Description this if you don't mind having disconnected domains in a single region. This option requires all cells to be in one (and one only) cellZone. + - prefixRegion prefixes all normal patches with region name (interface + (patches already have region name prefix) - Should work in parallel. cellZones can differ on either side of processor boundaries in which case @@ -389,6 +391,40 @@ void reorderPatches } +// Prepend prefix to selected patches. +void renamePatches +( + fvMesh& mesh, + const word& prefix, + const labelList& patchesToRename +) +{ + polyBoundaryMesh& polyPatches = + const_cast<polyBoundaryMesh&>(mesh.boundaryMesh()); + forAll(patchesToRename, i) + { + label patchI = patchesToRename[i]; + polyPatch& pp = polyPatches[patchI]; + + if (isA<coupledPolyPatch>(pp)) + { + WarningIn + ( + "renamePatches(fvMesh&, const word&, const labelList&" + ) << "Encountered coupled patch " << pp.name() + << ". Will only rename the patch itself," + << " not any referred patches." + << " This might have to be done by hand." + << endl; + } + + pp.name() = prefix + '_' + pp.name(); + } + // Recalculate any demand driven data (e.g. group to name lookup) + polyPatches.updateMesh(); +} + + template<class GeoField> void subsetVolFields ( @@ -987,6 +1023,7 @@ void createAndWriteRegion const fvMesh& mesh, const labelList& cellRegion, const wordList& regionNames, + const bool prefixRegion, const labelList& faceToInterface, const labelList& interfacePatches, const label regionI, @@ -1017,6 +1054,7 @@ void createAndWriteRegion addedPatches.insert(interfacePatches[interfaceI]+1); } + Info<< "Mapping fields" << endl; // Map existing fields @@ -1109,6 +1147,7 @@ void createAndWriteRegion // Create reordering list to move patches-to-be-deleted to end labelList oldToNew(newPatches.size(), -1); + DynamicList<label> sharedPatches(newPatches.size()); label newI = 0; Info<< "Deleting empty patches" << endl; @@ -1122,7 +1161,12 @@ void createAndWriteRegion { if (returnReduce(pp.size(), sumOp<label>()) > 0) { - oldToNew[patchI] = newI++; + oldToNew[patchI] = newI; + if (!addedPatches.found(patchI)) + { + sharedPatches.append(newI); + } + newI++; } } } @@ -1152,6 +1196,15 @@ void createAndWriteRegion reorderPatches(newMesh(), oldToNew, nNewPatches); + // Rename shared patches with region name + if (prefixRegion) + { + Info<< "Prefixing patches with region name" << endl; + + renamePatches(newMesh(), regionNames[regionI], sharedPatches); + } + + Info<< "Writing new mesh" << endl; newMesh().setInstance(newMeshInstance); @@ -1672,6 +1725,11 @@ int main(int argc, char *argv[]) "useFaceZones", "use faceZones to patch inter-region faces instead of single patch" ); + argList::addBoolOption + ( + "prefixRegion", + "prefix region name to all patches, not just coupling patches" + ); #include "setRootCase.H" #include "createTime.H" @@ -1696,6 +1754,8 @@ int main(int argc, char *argv[]) const bool detectOnly = args.optionFound("detectOnly"); const bool sloppyCellZones = args.optionFound("sloppyCellZones"); const bool useFaceZones = args.optionFound("useFaceZones"); + const bool prefixRegion = args.optionFound("prefixRegion"); + if ( @@ -2226,6 +2286,7 @@ int main(int argc, char *argv[]) mesh, cellRegion, regionNames, + prefixRegion, faceToInterface, interfacePatches, regionI, @@ -2246,6 +2307,7 @@ int main(int argc, char *argv[]) mesh, cellRegion, regionNames, + prefixRegion, faceToInterface, interfacePatches, regionI, @@ -2266,6 +2328,7 @@ int main(int argc, char *argv[]) mesh, cellRegion, regionNames, + prefixRegion, faceToInterface, interfacePatches, regionI,