diff --git a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidFields.H b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidFields.H index 1826a77217..7c82fec144 100644 --- a/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidFields.H +++ b/applications/solvers/heatTransfer/chtMultiRegionFoam/fluid/createFluidFields.H @@ -41,24 +41,6 @@ ) ); - Info<< " Adding to KFluid\n" << endl; - KFluid.set - ( - i, - new volScalarField - ( - IOobject - ( - "K", - runTime.timeName(), - fluidRegions[i], - IOobject::NO_READ, - IOobject::NO_WRITE - ), - thermoFluid[i].Cp()*thermoFluid[i].alpha() - ) - ); - Info<< " Adding to UFluid\n" << endl; UFluid.set ( @@ -129,6 +111,24 @@ ).ptr() ); + Info<< " Adding to KFluid\n" << endl; + KFluid.set + ( + i, + new volScalarField + ( + IOobject + ( + "K", + runTime.timeName(), + fluidRegions[i], + IOobject::NO_READ, + IOobject::NO_WRITE + ), + thermoFluid[i].Cp()*turbulence[i].alphaEff() + ) + ); + Info<< " Adding to DpDtFluid\n" << endl; DpDtFluid.set ( diff --git a/applications/utilities/mesh/manipulation/cellSet/cellSet.C b/applications/utilities/mesh/manipulation/cellSet/cellSet.C index ca8225d3f2..e803627426 100644 --- a/applications/utilities/mesh/manipulation/cellSet/cellSet.C +++ b/applications/utilities/mesh/manipulation/cellSet/cellSet.C @@ -37,37 +37,6 @@ using namespace Foam; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// Copy set -void backup -( - const polyMesh& mesh, - const word& fromName, - const topoSet& fromSet, - const word& toName -) -{ - Info<< "Backing up " << fromName << " into " << toName << endl; - - topoSet backupSet(mesh, toName, fromSet); - - backupSet.write(); -} - - -// Read and copy set -void backup -( - const polyMesh& mesh, - const word& fromName, - const word& toName -) -{ - topoSet fromSet(mesh, fromName, IOobject::READ_IF_PRESENT); - - backup(mesh, fromName, fromSet, toName); -} - - // Main program: int main(int argc, char *argv[]) @@ -114,8 +83,6 @@ int main(int argc, char *argv[]) { r = IOobject::NO_READ; - backup(mesh, setName, setName + "_old"); - currentSetPtr.reset ( new cellSet @@ -151,7 +118,7 @@ int main(int argc, char *argv[]) if ((r == IOobject::MUST_READ) && (action != topoSetSource::LIST)) { // currentSet has been read so can make copy. - backup(mesh, setName, currentSet, setName + "_old"); + //backup(mesh, setName, currentSet, setName + "_old"); } if (action == topoSetSource::CLEAR) @@ -173,7 +140,16 @@ int main(int argc, char *argv[]) forAll(topoSetSources, topoSetSourceI) { // Backup current set. - topoSet oldSet(mesh, currentSet.name() + "_old2", currentSet); + autoPtr oldSet + ( + topoSet::New + ( + currentSet.type(), + mesh, + currentSet.name() + "_old2", + currentSet + ) + ); currentSet.clear(); diff --git a/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C b/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C index 2a589c1643..96fb76ffe2 100644 --- a/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C +++ b/applications/utilities/mesh/manipulation/checkMesh/checkMesh.C @@ -47,7 +47,7 @@ using namespace Foam; int main(int argc, char *argv[]) { - timeSelector::addOptions(false); // no constant + timeSelector::addOptions(); # include "addRegionOption.H" argList::validOptions.insert("noTopology", ""); argList::validOptions.insert("allGeometry", ""); diff --git a/applications/utilities/mesh/manipulation/faceSet/faceSet.C b/applications/utilities/mesh/manipulation/faceSet/faceSet.C index d1700cc2f9..8441a1cdbe 100644 --- a/applications/utilities/mesh/manipulation/faceSet/faceSet.C +++ b/applications/utilities/mesh/manipulation/faceSet/faceSet.C @@ -37,37 +37,6 @@ using namespace Foam; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// Copy set -void backup -( - const polyMesh& mesh, - const word& fromName, - const topoSet& fromSet, - const word& toName -) -{ - Info<< "Backing up " << fromName << " into " << toName << endl; - - topoSet backupSet(mesh, toName, fromSet); - - backupSet.write(); -} - - -// Read and copy set -void backup -( - const polyMesh& mesh, - const word& fromName, - const word& toName -) -{ - topoSet fromSet(mesh, fromName, IOobject::READ_IF_PRESENT); - - backup(mesh, fromName, fromSet, toName); -} - - // Main program: int main(int argc, char *argv[]) @@ -114,8 +83,6 @@ int main(int argc, char *argv[]) { r = IOobject::NO_READ; - backup(mesh, setName, setName + "_old"); - currentSetPtr.reset ( new faceSet @@ -151,7 +118,7 @@ int main(int argc, char *argv[]) if ((r == IOobject::MUST_READ) && (action != topoSetSource::LIST)) { // currentSet has been read so can make copy. - backup(mesh, setName, currentSet, setName + "_old"); + //backup(mesh, setName, currentSet, setName + "_old"); } if (action == topoSetSource::CLEAR) @@ -173,7 +140,16 @@ int main(int argc, char *argv[]) forAll(topoSetSources, topoSetSourceI) { // Backup current set. - topoSet oldSet(mesh, currentSet.name() + "_old2", currentSet); + autoPtr oldSet + ( + topoSet::New + ( + currentSet.type(), + mesh, + currentSet.name() + "_old2", + currentSet + ) + ); currentSet.clear(); diff --git a/applications/utilities/mesh/manipulation/pointSet/pointSet.C b/applications/utilities/mesh/manipulation/pointSet/pointSet.C index ef57d08d07..1aa70191f8 100644 --- a/applications/utilities/mesh/manipulation/pointSet/pointSet.C +++ b/applications/utilities/mesh/manipulation/pointSet/pointSet.C @@ -37,37 +37,6 @@ using namespace Foam; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// Copy set -void backup -( - const polyMesh& mesh, - const word& fromName, - const topoSet& fromSet, - const word& toName -) -{ - Info<< "Backing up " << fromName << " into " << toName << endl; - - topoSet backupSet(mesh, toName, fromSet); - - backupSet.write(); -} - - -// Read and copy set -void backup -( - const polyMesh& mesh, - const word& fromName, - const word& toName -) -{ - topoSet fromSet(mesh, fromName, IOobject::READ_IF_PRESENT); - - backup(mesh, fromName, fromSet, toName); -} - - // Main program: int main(int argc, char *argv[]) @@ -114,8 +83,6 @@ int main(int argc, char *argv[]) { r = IOobject::NO_READ; - backup(mesh, setName, setName + "_old"); - currentSetPtr.reset ( new pointSet @@ -151,7 +118,7 @@ int main(int argc, char *argv[]) if ((r == IOobject::MUST_READ) && (action != topoSetSource::LIST)) { // currentSet has been read so can make copy. - backup(mesh, setName, currentSet, setName + "_old"); + //backup(mesh, setName, currentSet, setName + "_old"); } if (action == topoSetSource::CLEAR) @@ -173,7 +140,16 @@ int main(int argc, char *argv[]) forAll(topoSetSources, topoSetSourceI) { // Backup current set. - topoSet oldSet(mesh, currentSet.name() + "_old2", currentSet); + autoPtr oldSet + ( + topoSet::New + ( + currentSet.type(), + mesh, + currentSet.name() + "_old2", + currentSet + ) + ); currentSet.clear(); diff --git a/applications/utilities/mesh/manipulation/setSet/setSet.C b/applications/utilities/mesh/manipulation/setSet/setSet.C index a1d7a38912..3732c7e4ec 100644 --- a/applications/utilities/mesh/manipulation/setSet/setSet.C +++ b/applications/utilities/mesh/manipulation/setSet/setSet.C @@ -23,7 +23,7 @@ License Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Description - Manipulate a cell/face/point set interactively. + Manipulate a cell/face/point/ set or zone interactively. \*---------------------------------------------------------------------------*/ @@ -42,6 +42,9 @@ Description #include "writePatch.H" #include "writePointSet.H" #include "IOobjectList.H" +#include "cellZoneSet.H" +#include "faceZoneSet.H" +#include "pointZoneSet.H" #include @@ -82,6 +85,7 @@ Istream& selectStream(Istream* is0Ptr, Istream* is1Ptr) // Copy set void backup ( + const word& setType, const polyMesh& mesh, const word& fromName, const topoSet& fromSet, @@ -92,9 +96,7 @@ void backup { Pout<< " Backing up " << fromName << " into " << toName << endl; - topoSet backupSet(mesh, toName, fromSet); - - backupSet.write(); + topoSet::New(setType, mesh, toName, fromSet)().write(); } } @@ -102,14 +104,21 @@ void backup // Read and copy set void backup ( + const word& setType, const polyMesh& mesh, const word& fromName, const word& toName ) { - topoSet fromSet(mesh, fromName, IOobject::READ_IF_PRESENT); + autoPtr fromSet = topoSet::New + ( + setType, + mesh, + fromName, + IOobject::READ_IF_PRESENT + ); - backup(mesh, fromName, fromSet, toName); + backup(setType, mesh, fromName, fromSet(), toName); } @@ -241,11 +250,13 @@ void printHelp(Ostream& os) << "A set command should be of the following form" << endl << endl << " cellSet|faceSet|pointSet " - << endl << endl + << endl + << endl << "The is one of" << endl << " list - prints the contents of the set" << endl << " clear - clears the set" << endl << " invert - inverts the set" << endl + << " remove - remove the set" << endl << " new - sets to set to the source set" << endl << " add - adds all elements from the source set" << endl << " delete - deletes ,," << endl @@ -270,6 +281,20 @@ void printHelp(Ostream& os) << " cellSet c0 add pointToCell p0 any" << endl << "List set:" << endl << " cellSet c0 list" << endl + << endl + << "Zones can be set using zoneSets from corresponding sets:" << endl + << " cellZoneSet c0Zone new setToZone c0" << endl + << " faceZoneSet f0Zone new setToZone f0" << endl + << endl + << "or if orientation is important:" << endl + << " faceZoneSet f0Zone new setsToZone f0 c0" << endl + << endl + << "ZoneSets can be manipulated using the general actions:" << endl + << " list - prints the contents of the set" << endl + << " clear - clears the set" << endl + << " invert - inverts the set (undefined orientation)" + << endl + << " remove - remove the set" << endl << endl; } @@ -312,10 +337,126 @@ void printAllSets(const polyMesh& mesh, Ostream& os) os << '\t' << set.name() << "\tsize:" << set.size() << endl; } } + + const cellZoneMesh& cellZones = mesh.cellZones(); + if (cellZones.size()) + { + os << "cellZones:" << endl; + forAll(cellZones, i) + { + const cellZone& zone = cellZones[i]; + os << '\t' << zone.name() << "\tsize:" << zone.size() << endl; + } + } + const faceZoneMesh& faceZones = mesh.faceZones(); + if (faceZones.size()) + { + os << "faceZones:" << endl; + forAll(faceZones, i) + { + const faceZone& zone = faceZones[i]; + os << '\t' << zone.name() << "\tsize:" << zone.size() << endl; + } + } + const pointZoneMesh& pointZones = mesh.pointZones(); + if (pointZones.size()) + { + os << "pointZones:" << endl; + forAll(pointZones, i) + { + const pointZone& zone = pointZones[i]; + os << '\t' << zone.name() << "\tsize:" << zone.size() << endl; + } + } + os << endl; } +template +void removeZone +( + ZoneMesh& zones, + const word& setName +) +{ + label zoneID = zones.findZoneID(setName); + + if (zoneID != -1) + { + Info<< "Removing zone " << setName << " at index " << zoneID << endl; + // Shuffle to last position + labelList oldToNew(zones.size()); + label newI = 0; + forAll(oldToNew, i) + { + if (i != zoneID) + { + oldToNew[i] = newI++; + } + } + oldToNew[zoneID] = newI; + zones.reorder(oldToNew); + // Remove last element + zones.setSize(zones.size()-1); + zones.clearAddressing(); + zones.write(); + } +} + + +// Physically remove a set +void removeSet +( + const polyMesh& mesh, + const word& setType, + const word& setName +) +{ + // Remove the file + IOobjectList objects + ( + mesh, + mesh.pointsInstance(), + polyMesh::meshSubDir/"sets" + ); + + if (objects.found(setName)) + { + // Remove file + fileName object = objects[setName]->objectPath(); + Info<< "Removing file " << object << endl; + rm(object); + } + + // See if zone + if (setType == cellZoneSet::typeName) + { + removeZone + ( + const_cast(mesh.cellZones()), + setName + ); + } + else if (setType == faceZoneSet::typeName) + { + removeZone + ( + const_cast(mesh.faceZones()), + setName + ); + } + else if (setType == pointZoneSet::typeName) + { + removeZone + ( + const_cast(mesh.pointZones()), + setName + ); + } +} + + // Read command and execute. Return true if ok, false otherwise. bool doCommand ( @@ -358,38 +499,29 @@ bool doCommand IOobject::readOption r; - if + if (action == topoSetSource::REMOVE) + { + removeSet(mesh, setType, setName); + } + else if ( (action == topoSetSource::NEW) || (action == topoSetSource::CLEAR) ) { r = IOobject::NO_READ; - - //backup(mesh, setName, setName + "_old"); - currentSetPtr = topoSet::New(setType, mesh, setName, typSize); } else { r = IOobject::MUST_READ; - currentSetPtr = topoSet::New(setType, mesh, setName, r); - topoSet& currentSet = currentSetPtr(); - // Presize it according to current mesh data. currentSet.resize(max(currentSet.size(), typSize)); } - if (currentSetPtr.empty()) - { - Pout<< " Cannot construct/load set " - << topoSet::localPath(mesh, setName) << endl; - - ok = false; - } - else + if (currentSetPtr.valid()) { topoSet& currentSet = currentSetPtr(); @@ -398,12 +530,6 @@ bool doCommand << " Action:" << actionName << endl; - //if ((r == IOobject::MUST_READ) && (action != topoSetSource::LIST)) - //{ - // // currentSet has been read so can make copy. - // backup(mesh, setName, currentSet, setName + "_old"); - //} - switch (action) { case topoSetSource::CLEAR: @@ -437,15 +563,18 @@ bool doCommand ); // Backup current set. - topoSet oldSet + autoPtr oldSet ( - mesh, - currentSet.name() + "_old2", - currentSet + topoSet::New + ( + setType, + mesh, + currentSet.name() + "_old2", + currentSet + ) ); currentSet.clear(); - currentSet.resize(oldSet.size()); setSource().applyToSet(topoSetSource::NEW, currentSet); // Combine new value of currentSet with old one. @@ -547,7 +676,8 @@ enum commandStatus { QUIT, // quit program INVALID, // token is not a valid set manipulation command - VALID // ,, is a valid ,, + VALIDSETCMD, // ,, is a valid ,, + VALIDZONECMD // ,, is a valid zone ,, }; @@ -654,7 +784,16 @@ commandStatus parseType || setType == "pointSet" ) { - return VALID; + return VALIDSETCMD; + } + else if + ( + setType == "cellZoneSet" + || setType == "faceZoneSet" + || setType == "pointZoneSet" + ) + { + return VALIDZONECMD; } else { @@ -664,7 +803,7 @@ commandStatus parseType ", IStringStream&)" ) << "Illegal command " << setType << endl << "Should be one of 'help', 'list', 'time' or a set type :" - << " 'cellSet', 'faceSet', 'pointSet'" + << " 'cellSet', 'faceSet', 'pointSet', 'faceZoneSet'" << endl; return INVALID; @@ -682,7 +821,7 @@ commandStatus parseAction(const word& actionName) { (void)topoSetSource::toAction(actionName); - stat = VALID; + stat = VALIDSETCMD; } catch (Foam::IOerror& fIOErr) { @@ -724,6 +863,10 @@ int main(int argc, char *argv[]) // Print some mesh info printMesh(runTime, mesh); + // Print current sets + printAllSets(mesh, Pout); + + std::ifstream* fileStreamPtr(NULL); @@ -745,11 +888,10 @@ int main(int argc, char *argv[]) #if READLINE != 0 else if (!read_history(historyFile)) { - Info<< "Successfully read history from " << historyFile << endl; + Pout<< "Successfully read history from " << historyFile << endl; } #endif - Pout<< "Please type 'help', 'quit' or a set command after prompt." << endl; bool ok = true; @@ -816,12 +958,12 @@ int main(int argc, char *argv[]) IStringStream is(rawLine + ' '); - // Type: cellSet, faceSet, pointSet + // Type: cellSet, faceSet, pointSet, faceZoneSet is >> setType; stat = parseType(runTime, mesh, setType, is); - if (stat == VALID) + if (stat == VALIDSETCMD || stat == VALIDZONECMD) { if (is >> setName) { @@ -831,14 +973,13 @@ int main(int argc, char *argv[]) } } } - ok = true; if (stat == QUIT) { break; } - else if (stat == VALID) + else if (stat == VALIDSETCMD || stat == VALIDZONECMD) { ok = doCommand(mesh, setType, setName, actionName, writeVTK, is); } diff --git a/applications/utilities/mesh/manipulation/splitMesh/splitMesh.C b/applications/utilities/mesh/manipulation/splitMesh/splitMesh.C index 65e4d33237..bc193810bd 100644 --- a/applications/utilities/mesh/manipulation/splitMesh/splitMesh.C +++ b/applications/utilities/mesh/manipulation/splitMesh/splitMesh.C @@ -270,6 +270,10 @@ int main(int argc, char *argv[]) { mesh.setInstance(oldInstance); } + else + { + mesh.setInstance(runTime.timeName()); + } Info<< "Writing mesh to " << runTime.timeName() << endl; if (!mesh.write()) diff --git a/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C b/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C index 338c8dbcb1..f00cc8716f 100644 --- a/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C +++ b/applications/utilities/mesh/manipulation/subsetMesh/subsetMesh.C @@ -334,7 +334,7 @@ int main(int argc, char *argv[]) } else { - mesh.setInstance(oldInstance); + subsetter.subMesh().setInstance(oldInstance); } Info<< "Writing subsetted mesh and fields to time " << runTime.timeName() diff --git a/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C b/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C index e310cc758f..d3b9bd0492 100644 --- a/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C +++ b/applications/utilities/parallelProcessing/decomposePar/domainDecomposition.C @@ -34,6 +34,7 @@ License #include "Map.H" #include "globalMeshData.H" #include "DynamicList.H" +#include "fvFieldDecomposer.H" // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -306,12 +307,29 @@ bool domainDecomposition::writeDecomposition() forAll (curPatchSizes, patchi) { + // Get the face labels consistent with the field mapping + // (reuse the patch field mappers) + const polyPatch& meshPatch = + meshPatches[curBoundaryAddressing[patchi]]; + + fvFieldDecomposer::patchFieldDecomposer patchMapper + ( + SubList