diff --git a/applications/utilities/mesh/manipulation/setSet/setSet.C b/applications/utilities/mesh/manipulation/setSet/setSet.C index a1d7a38912a97a41878e6aef075c6c0207d729bd..2172dc24abbdb7bf879243a34aa814cfe4a9f6bd 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. \*---------------------------------------------------------------------------*/ @@ -82,6 +82,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 +93,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 +101,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<topoSet> fromSet = topoSet::New + ( + setType, + mesh, + fromName, + IOobject::READ_IF_PRESENT + ); - backup(mesh, fromName, fromSet, toName); + backup(setType, mesh, fromName, fromSet(), toName); } @@ -241,7 +247,8 @@ void printHelp(Ostream& os) << "A set command should be of the following form" << endl << endl << " cellSet|faceSet|pointSet <setName> <action> <source>" - << endl << endl + << endl + << endl << "The <action> is one of" << endl << " list - prints the contents of the set" << endl << " clear - clears the set" << endl @@ -270,6 +277,10 @@ void printHelp(Ostream& os) << " cellSet c0 add pointToCell p0 any" << endl << "List set:" << endl << " cellSet c0 list" << endl + << endl + << "Zones can be set from corresponding sets:" << endl + << " faceZone f0Zone new setToZone f0" << endl + << " cellZone c0Zone new setToZone c0" << endl << endl; } @@ -366,7 +377,7 @@ bool doCommand { r = IOobject::NO_READ; - //backup(mesh, setName, setName + "_old"); + //backup(setType, mesh, setName, setName + "_old"); currentSetPtr = topoSet::New(setType, mesh, setName, typSize); } @@ -401,7 +412,7 @@ bool doCommand //if ((r == IOobject::MUST_READ) && (action != topoSetSource::LIST)) //{ // // currentSet has been read so can make copy. - // backup(mesh, setName, currentSet, setName + "_old"); + // backup(setType, mesh, setName, currentSet, setName + "_old"); //} switch (action) @@ -437,15 +448,18 @@ bool doCommand ); // Backup current set. - topoSet oldSet + autoPtr<topoSet> 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 +561,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 +669,16 @@ commandStatus parseType || setType == "pointSet" ) { - return VALID; + return VALIDSETCMD; + } + else if + ( + setType == "cellZoneSet" + || setType == "faceZoneSet" + || setType == "pointZoneSet" + ) + { + return VALIDZONECMD; } else { @@ -664,7 +688,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 +706,7 @@ commandStatus parseAction(const word& actionName) { (void)topoSetSource::toAction(actionName); - stat = VALID; + stat = VALIDSETCMD; } catch (Foam::IOerror& fIOErr) { @@ -816,12 +840,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 +855,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/src/meshTools/Make/files b/src/meshTools/Make/files index a61d00246e04323e182603105061d72d9150acd6..272f3e067c27f459aaa1cdab2288d7c320fb16a8 100644 --- a/src/meshTools/Make/files +++ b/src/meshTools/Make/files @@ -71,6 +71,9 @@ $(topoSets)/cellSet.C $(topoSets)/topoSet.C $(topoSets)/faceSet.C $(topoSets)/pointSet.C +$(topoSets)/cellZoneSet.C +$(topoSets)/faceZoneSet.C +$(topoSets)/pointZoneSet.C sets/topoSetSource/topoSetSource.C @@ -113,6 +116,18 @@ $(pointSources)/surfaceToPoint/surfaceToPoint.C $(pointSources)/zoneToPoint/zoneToPoint.C $(pointSources)/nearestToPoint/nearestToPoint.C +faceZoneSources = sets/faceZoneSources +$(faceZoneSources)/faceZoneToFaceZone/faceZoneToFaceZone.C +$(faceZoneSources)/setsToFaceZone/setsToFaceZone.C +$(faceZoneSources)/setToFaceZone/setToFaceZone.C + +cellZoneSources = sets/cellZoneSources +$(cellZoneSources)/setToCellZone/setToCellZone.C + +pointZoneSources = sets/pointZoneSources +$(pointZoneSources)/setToPointZone/setToPointZone.C + + surfaceSets/surfaceSets.C triSurface/orientedSurface/orientedSurface.C diff --git a/src/meshTools/sets/cellSources/cellToCell/cellToCell.C b/src/meshTools/sets/cellSources/cellToCell/cellToCell.C index 222d14965f636b8b345401c394139113ce2b354d..bbbcf7785ed85fa91b42ace67e743383db2c8607 100644 --- a/src/meshTools/sets/cellSources/cellToCell/cellToCell.C +++ b/src/meshTools/sets/cellSources/cellToCell/cellToCell.C @@ -106,7 +106,7 @@ void Foam::cellToCell::applyToSet { if ((action == topoSetSource::ADD) || (action == topoSetSource::NEW)) { - Pout<< " Adding all elements of cellSet " << setName_ << " ..." + Info<< " Adding all elements of cellSet " << setName_ << " ..." << endl; // Load the set @@ -116,7 +116,7 @@ void Foam::cellToCell::applyToSet } else if (action == topoSetSource::DELETE) { - Pout<< " Removing all elements of cellSet " << setName_ << " ..." + Info<< " Removing all elements of cellSet " << setName_ << " ..." << endl; // Load the set diff --git a/src/meshTools/sets/cellZoneSources/setToCellZone/setToCellZone.C b/src/meshTools/sets/cellZoneSources/setToCellZone/setToCellZone.C new file mode 100644 index 0000000000000000000000000000000000000000..5ff8597a863cf196a2746b1dd44173fdd4e0ae1e --- /dev/null +++ b/src/meshTools/sets/cellZoneSources/setToCellZone/setToCellZone.C @@ -0,0 +1,168 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "setToCellZone.H" +#include "polyMesh.H" +#include "cellZoneSet.H" + +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + +defineTypeNameAndDebug(setToCellZone, 0); + +addToRunTimeSelectionTable(topoSetSource, setToCellZone, word); + +addToRunTimeSelectionTable(topoSetSource, setToCellZone, istream); + +} + + +Foam::topoSetSource::addToUsageTable Foam::setToCellZone::usage_ +( + setToCellZone::typeName, + "\n Usage: setToCellZone <cellSet>\n\n" + " Select all cells in the cellSet.\n\n" +); + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +// Construct from components +Foam::setToCellZone::setToCellZone +( + const polyMesh& mesh, + const word& setName +) +: + topoSetSource(mesh), + setName_(setName) +{} + + +// Construct from dictionary +Foam::setToCellZone::setToCellZone +( + const polyMesh& mesh, + const dictionary& dict +) +: + topoSetSource(mesh), + setName_(dict.lookup("set")) +{} + + +// Construct from Istream +Foam::setToCellZone::setToCellZone +( + const polyMesh& mesh, + Istream& is +) +: + topoSetSource(mesh), + setName_(checkIs(is)) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::setToCellZone::~setToCellZone() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::setToCellZone::applyToSet +( + const topoSetSource::setAction action, + topoSet& set +) const +{ + if (!isA<cellZoneSet>(set)) + { + WarningIn + ( + "setToCellZone::applyToSet(const topoSetSource::setAction" + ", topoSet" + ) << "Operation only allowed on a cellZoneSet." << endl; + } + else + { + cellZoneSet& fzSet = refCast<cellZoneSet>(set); + + if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + { + Info<< " Adding all cells from cellSet " << setName_ + << " ..." << endl; + + // Load the sets + cellSet fSet(mesh_, setName_); + + // Start off from copy + DynamicList<label> newAddressing(fzSet.addressing()); + + forAllConstIter(cellSet, fSet, iter) + { + label cellI = iter.key(); + + if (!fzSet.found(cellI)) + { + newAddressing.append(cellI); + } + } + + fzSet.addressing().transfer(newAddressing); + fzSet.updateSet(); + } + else if (action == topoSetSource::DELETE) + { + Info<< " Removing all cells from cellSet " << setName_ + << " ..." << endl; + + // Load the set + cellSet loadedSet(mesh_, setName_); + + // Start off empty + DynamicList<label> newAddressing(fzSet.addressing().size()); + + forAll(fzSet.addressing(), i) + { + if (!loadedSet.found(fzSet.addressing()[i])) + { + newAddressing.append(fzSet.addressing()[i]); + } + } + fzSet.addressing().transfer(newAddressing); + fzSet.updateSet(); + } + } +} + + +// ************************************************************************* // diff --git a/src/meshTools/sets/cellZoneSources/setToCellZone/setToCellZone.H b/src/meshTools/sets/cellZoneSources/setToCellZone/setToCellZone.H new file mode 100644 index 0000000000000000000000000000000000000000..cd60837d1ab4fda56009f0f16e4ecbc8e98eceb4 --- /dev/null +++ b/src/meshTools/sets/cellZoneSources/setToCellZone/setToCellZone.H @@ -0,0 +1,115 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::setToCellZone + +Description + A topoSetSource to select cells based on usage in a cellSet. + +SourceFiles + setToCellZone.C + +\*---------------------------------------------------------------------------*/ + +#ifndef setToCellZone_H +#define setToCellZone_H + +#include "topoSetSource.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class setToCellZone Declaration +\*---------------------------------------------------------------------------*/ + +class setToCellZone +: + public topoSetSource +{ + // Private data + + //- Add usage string + static addToUsageTable usage_; + + //- Name of set to use + word setName_; + +public: + + //- Runtime type information + TypeName("setToCellZone"); + + // Constructors + + //- Construct from components + setToCellZone + ( + const polyMesh& mesh, + const word& setName + ); + + //- Construct from dictionary + setToCellZone + ( + const polyMesh& mesh, + const dictionary& dict + ); + + //- Construct from Istream + setToCellZone + ( + const polyMesh& mesh, + Istream& + ); + + + // Destructor + + virtual ~setToCellZone(); + + + // Member Functions + + virtual void applyToSet + ( + const topoSetSource::setAction action, + topoSet& + ) const; + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/sets/faceSources/cellToFace/cellToFace.C b/src/meshTools/sets/faceSources/cellToFace/cellToFace.C index 59d3e2e9ebb95fdf5c7e8fc8c7c5d653fe1d8ad3..5b868c4e8c3b007990786af9668c1e5fac2825e3 100644 --- a/src/meshTools/sets/faceSources/cellToFace/cellToFace.C +++ b/src/meshTools/sets/faceSources/cellToFace/cellToFace.C @@ -217,14 +217,14 @@ void Foam::cellToFace::applyToSet { if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) { - Pout<< " Adding faces according to cellSet " << setName_ + Info<< " Adding faces according to cellSet " << setName_ << " ..." << endl; combine(set, true); } else if (action == topoSetSource::DELETE) { - Pout<< " Removing faces according to cellSet " << setName_ + Info<< " Removing faces according to cellSet " << setName_ << " ..." << endl; combine(set, false); diff --git a/src/meshTools/sets/faceZoneSources/faceZoneToFaceZone/faceZoneToFaceZone.C b/src/meshTools/sets/faceZoneSources/faceZoneToFaceZone/faceZoneToFaceZone.C new file mode 100644 index 0000000000000000000000000000000000000000..49fa39eb09376aefd22d67b1a9f9880249216968 --- /dev/null +++ b/src/meshTools/sets/faceZoneSources/faceZoneToFaceZone/faceZoneToFaceZone.C @@ -0,0 +1,169 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "faceZoneToFaceZone.H" +#include "polyMesh.H" +#include "faceZoneSet.H" + +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + +defineTypeNameAndDebug(faceZoneToFaceZone, 0); + +addToRunTimeSelectionTable(topoSetSource, faceZoneToFaceZone, word); + +addToRunTimeSelectionTable(topoSetSource, faceZoneToFaceZone, istream); + +} + + +Foam::topoSetSource::addToUsageTable Foam::faceZoneToFaceZone::usage_ +( + faceZoneToFaceZone::typeName, + "\n Usage: faceZoneToFaceZone <faceZone>\n\n" + " Select all faces in the faceZone\n\n" +); + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +// Construct from components +Foam::faceZoneToFaceZone::faceZoneToFaceZone +( + const polyMesh& mesh, + const word& setName +) +: + topoSetSource(mesh), + setName_(setName) +{} + + +// Construct from dictionary +Foam::faceZoneToFaceZone::faceZoneToFaceZone +( + const polyMesh& mesh, + const dictionary& dict +) +: + topoSetSource(mesh), + setName_(dict.lookup("zone")) +{} + + +// Construct from Istream +Foam::faceZoneToFaceZone::faceZoneToFaceZone +( + const polyMesh& mesh, + Istream& is +) +: + topoSetSource(mesh), + setName_(checkIs(is)) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::faceZoneToFaceZone::~faceZoneToFaceZone() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::faceZoneToFaceZone::applyToSet +( + const topoSetSource::setAction action, + topoSet& set +) const +{ + if (!isA<faceZoneSet>(set)) + { + WarningIn + ( + "faceZoneToFaceZone::applyToSet(const topoSetSource::setAction" + ", topoSet" + ) << "Operation only allowed on a faceZoneSet." << endl; + } + else + { + faceZoneSet& fSet = refCast<faceZoneSet>(set); + + if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + { + Info<< " Adding all faces from faceZone " << setName_ << " ..." + << endl; + + // Load the set + faceZoneSet loadedSet(mesh_, setName_); + + DynamicList<label> newAddressing(fSet.addressing()); + DynamicList<bool> newFlipMap(fSet.flipMap()); + + forAll(loadedSet.addressing(), i) + { + if (!fSet.found(loadedSet.addressing()[i])) + { + newAddressing.append(loadedSet.addressing()[i]); + newFlipMap.append(loadedSet.flipMap()[i]); + } + } + fSet.addressing().transfer(newAddressing); + fSet.flipMap().transfer(newFlipMap); + fSet.updateSet(); + } + else if (action == topoSetSource::DELETE) + { + Info<< " Removing all faces from faceZone " << setName_ << " ..." + << endl; + + // Load the set + faceZoneSet loadedSet(mesh_, setName_); + + DynamicList<label> newAddressing(fSet.addressing().size()); + DynamicList<bool> newFlipMap(fSet.flipMap().size()); + + forAll(fSet.addressing(), i) + { + if (!loadedSet.found(fSet.addressing()[i])) + { + newAddressing.append(fSet.addressing()[i]); + newFlipMap.append(fSet.flipMap()[i]); + } + } + fSet.addressing().transfer(newAddressing); + fSet.flipMap().transfer(newFlipMap); + fSet.updateSet(); + } + } +} + + +// ************************************************************************* // diff --git a/src/meshTools/sets/faceZoneSources/faceZoneToFaceZone/faceZoneToFaceZone.H b/src/meshTools/sets/faceZoneSources/faceZoneToFaceZone/faceZoneToFaceZone.H new file mode 100644 index 0000000000000000000000000000000000000000..d8a0145d4d8b5a2da2d6bf50790b5ba8f5ca49fb --- /dev/null +++ b/src/meshTools/sets/faceZoneSources/faceZoneToFaceZone/faceZoneToFaceZone.H @@ -0,0 +1,115 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::faceZoneToFaceZone + +Description + A topoSetSource to select faces based on usage in another faceSet. + +SourceFiles + faceZoneToFaceZone.C + +\*---------------------------------------------------------------------------*/ + +#ifndef faceZoneToFaceZone_H +#define faceZoneToFaceZone_H + +#include "topoSetSource.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class faceZoneToFaceZone Declaration +\*---------------------------------------------------------------------------*/ + +class faceZoneToFaceZone +: + public topoSetSource +{ + // Private data + + //- Add usage string + static addToUsageTable usage_; + + //- Name of set to use + word setName_; + +public: + + //- Runtime type information + TypeName("faceZoneToFaceZone"); + + // Constructors + + //- Construct from components + faceZoneToFaceZone + ( + const polyMesh& mesh, + const word& setName + ); + + //- Construct from dictionary + faceZoneToFaceZone + ( + const polyMesh& mesh, + const dictionary& dict + ); + + //- Construct from Istream + faceZoneToFaceZone + ( + const polyMesh& mesh, + Istream& + ); + + + // Destructor + + virtual ~faceZoneToFaceZone(); + + + // Member Functions + + virtual void applyToSet + ( + const topoSetSource::setAction action, + topoSet& + ) const; + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/sets/faceZoneSources/setToFaceZone/setToFaceZone.C b/src/meshTools/sets/faceZoneSources/setToFaceZone/setToFaceZone.C new file mode 100644 index 0000000000000000000000000000000000000000..5562a04dcd7c6ce52815adb2c7050498dcdda399 --- /dev/null +++ b/src/meshTools/sets/faceZoneSources/setToFaceZone/setToFaceZone.C @@ -0,0 +1,175 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "setToFaceZone.H" +#include "polyMesh.H" +#include "faceZoneSet.H" + +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + +defineTypeNameAndDebug(setToFaceZone, 0); + +addToRunTimeSelectionTable(topoSetSource, setToFaceZone, word); + +addToRunTimeSelectionTable(topoSetSource, setToFaceZone, istream); + +} + + +Foam::topoSetSource::addToUsageTable Foam::setToFaceZone::usage_ +( + setToFaceZone::typeName, + "\n Usage: setToFaceZone <faceSet>\n\n" + " Select all faces in the faceSet." + " Sets flipMap.\n\n" +); + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +// Construct from components +Foam::setToFaceZone::setToFaceZone +( + const polyMesh& mesh, + const word& setName +) +: + topoSetSource(mesh), + setName_(setName) +{} + + +// Construct from dictionary +Foam::setToFaceZone::setToFaceZone +( + const polyMesh& mesh, + const dictionary& dict +) +: + topoSetSource(mesh), + setName_(dict.lookup("faceSet")) +{} + + +// Construct from Istream +Foam::setToFaceZone::setToFaceZone +( + const polyMesh& mesh, + Istream& is +) +: + topoSetSource(mesh), + setName_(checkIs(is)) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::setToFaceZone::~setToFaceZone() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::setToFaceZone::applyToSet +( + const topoSetSource::setAction action, + topoSet& set +) const +{ + if (!isA<faceZoneSet>(set)) + { + WarningIn + ( + "setToFaceZone::applyToSet(const topoSetSource::setAction" + ", topoSet" + ) << "Operation only allowed on a faceZoneSet." << endl; + } + else + { + faceZoneSet& fzSet = refCast<faceZoneSet>(set); + + if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + { + Info<< " Adding all faces from faceSet " << setName_ + << " ..." << endl; + + // Load the sets + faceSet fSet(mesh_, setName_); + + // Start off from copy + DynamicList<label> newAddressing(fzSet.addressing()); + DynamicList<bool> newFlipMap(fzSet.flipMap()); + + forAllConstIter(faceSet, fSet, iter) + { + label faceI = iter.key(); + + if (!fzSet.found(faceI)) + { + newAddressing.append(faceI); + newFlipMap.append(true); + } + } + + fzSet.addressing().transfer(newAddressing); + fzSet.flipMap().transfer(newFlipMap); + fzSet.updateSet(); + } + else if (action == topoSetSource::DELETE) + { + Info<< " Removing all faces from faceSet " << setName_ + << " ..." << endl; + + // Load the set + faceSet loadedSet(mesh_, setName_); + + // Start off empty + DynamicList<label> newAddressing(fzSet.addressing().size()); + DynamicList<bool> newFlipMap(fzSet.flipMap().size()); + + forAll(fzSet.addressing(), i) + { + if (!loadedSet.found(fzSet.addressing()[i])) + { + newAddressing.append(fzSet.addressing()[i]); + newFlipMap.append(fzSet.flipMap()[i]); + } + } + fzSet.addressing().transfer(newAddressing); + fzSet.flipMap().transfer(newFlipMap); + fzSet.updateSet(); + } + } +} + + +// ************************************************************************* // diff --git a/src/meshTools/sets/faceZoneSources/setToFaceZone/setToFaceZone.H b/src/meshTools/sets/faceZoneSources/setToFaceZone/setToFaceZone.H new file mode 100644 index 0000000000000000000000000000000000000000..63c6e04efaf823dc6474052f79464d079d586b11 --- /dev/null +++ b/src/meshTools/sets/faceZoneSources/setToFaceZone/setToFaceZone.H @@ -0,0 +1,116 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::setToFaceZone + +Description + A topoSetSource to select faces based on usage in a faceSet. Sets flipMap + to true. + +SourceFiles + setToFaceZone.C + +\*---------------------------------------------------------------------------*/ + +#ifndef setToFaceZone_H +#define setToFaceZone_H + +#include "topoSetSource.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class setToFaceZone Declaration +\*---------------------------------------------------------------------------*/ + +class setToFaceZone +: + public topoSetSource +{ + // Private data + + //- Add usage string + static addToUsageTable usage_; + + //- Name of set to use + word setName_; + +public: + + //- Runtime type information + TypeName("setToFaceZone"); + + // Constructors + + //- Construct from components + setToFaceZone + ( + const polyMesh& mesh, + const word& setName + ); + + //- Construct from dictionary + setToFaceZone + ( + const polyMesh& mesh, + const dictionary& dict + ); + + //- Construct from Istream + setToFaceZone + ( + const polyMesh& mesh, + Istream& + ); + + + // Destructor + + virtual ~setToFaceZone(); + + + // Member Functions + + virtual void applyToSet + ( + const topoSetSource::setAction action, + topoSet& + ) const; + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/sets/faceZoneSources/setsToFaceZone/setsToFaceZone.C b/src/meshTools/sets/faceZoneSources/setsToFaceZone/setsToFaceZone.C new file mode 100644 index 0000000000000000000000000000000000000000..11e2eadd483d9db9bc7c9a6bcc38fd7c32e5c2f9 --- /dev/null +++ b/src/meshTools/sets/faceZoneSources/setsToFaceZone/setsToFaceZone.C @@ -0,0 +1,222 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "setsToFaceZone.H" +#include "polyMesh.H" +#include "faceZoneSet.H" +#include "cellSet.H" + +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + +defineTypeNameAndDebug(setsToFaceZone, 0); + +addToRunTimeSelectionTable(topoSetSource, setsToFaceZone, word); + +addToRunTimeSelectionTable(topoSetSource, setsToFaceZone, istream); + +} + + +Foam::topoSetSource::addToUsageTable Foam::setsToFaceZone::usage_ +( + setsToFaceZone::typeName, + "\n Usage: setsToFaceZone <faceSet> <slaveCellSet>\n\n" + " Select all faces in the faceSet." + " Orientated so slave side is in cellSet.\n\n" +); + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +// Construct from components +Foam::setsToFaceZone::setsToFaceZone +( + const polyMesh& mesh, + const word& faceSetName, + const word& cellSetName +) +: + topoSetSource(mesh), + faceSetName_(faceSetName), + cellSetName_(cellSetName) +{} + + +// Construct from dictionary +Foam::setsToFaceZone::setsToFaceZone +( + const polyMesh& mesh, + const dictionary& dict +) +: + topoSetSource(mesh), + faceSetName_(dict.lookup("faceSet")), + cellSetName_(dict.lookup("cellSet")) +{} + + +// Construct from Istream +Foam::setsToFaceZone::setsToFaceZone +( + const polyMesh& mesh, + Istream& is +) +: + topoSetSource(mesh), + faceSetName_(checkIs(is)), + cellSetName_(checkIs(is)) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::setsToFaceZone::~setsToFaceZone() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::setsToFaceZone::applyToSet +( + const topoSetSource::setAction action, + topoSet& set +) const +{ + if (!isA<faceZoneSet>(set)) + { + WarningIn + ( + "setsToFaceZone::applyToSet(const topoSetSource::setAction" + ", topoSet" + ) << "Operation only allowed on a faceZoneSet." << endl; + } + else + { + faceZoneSet& fzSet = refCast<faceZoneSet>(set); + + if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + { + Info<< " Adding all faces from faceSet " << faceSetName_ + << " ..." << endl; + + // Load the sets + faceSet fSet(mesh_, faceSetName_); + cellSet cSet(mesh_, cellSetName_); + + // Start off from copy + DynamicList<label> newAddressing(fzSet.addressing()); + DynamicList<bool> newFlipMap(fzSet.flipMap()); + + forAllConstIter(faceSet, fSet, iter) + { + label faceI = iter.key(); + + if (!fzSet.found(faceI)) + { + bool flip = false; + + label own = mesh_.faceOwner()[faceI]; + bool ownFound = cSet.found(own); + + if (mesh_.isInternalFace(faceI)) + { + label nei = mesh_.faceNeighbour()[faceI]; + bool neiFound = cSet.found(nei); + + if (ownFound && !neiFound) + { + flip = false; + } + else if(!ownFound && neiFound) + { + flip = true; + } + else + { + WarningIn + ( + "setsToFaceZone::applyToSet" + "(const topoSetSource::setAction, topoSet)" + ) << "One of owner or neighbour of internal face " + << faceI << " should be in cellSet " + << cSet.name() + << " to be able to determine orientation." + << endl + << "Face:" << faceI << " own:" << own + << " OwnInCellSet:" << ownFound + << " nei:" << nei + << " NeiInCellSet:" << neiFound + << endl; + } + } + else + { + flip = !ownFound; + } + + newAddressing.append(faceI); + newFlipMap.append(flip); + } + } + + fzSet.addressing().transfer(newAddressing); + fzSet.flipMap().transfer(newFlipMap); + fzSet.updateSet(); + } + else if (action == topoSetSource::DELETE) + { + Info<< " Removing all faces from faceSet " << faceSetName_ + << " ..." << endl; + + // Load the set + faceZoneSet loadedSet(mesh_, faceSetName_); + + // Start off empty + DynamicList<label> newAddressing(fzSet.addressing().size()); + DynamicList<bool> newFlipMap(fzSet.flipMap().size()); + + forAll(fzSet.addressing(), i) + { + if (!loadedSet.found(fzSet.addressing()[i])) + { + newAddressing.append(fzSet.addressing()[i]); + newFlipMap.append(fzSet.flipMap()[i]); + } + } + fzSet.addressing().transfer(newAddressing); + fzSet.flipMap().transfer(newFlipMap); + fzSet.updateSet(); + } + } +} + + +// ************************************************************************* // diff --git a/src/meshTools/sets/faceZoneSources/setsToFaceZone/setsToFaceZone.H b/src/meshTools/sets/faceZoneSources/setsToFaceZone/setsToFaceZone.H new file mode 100644 index 0000000000000000000000000000000000000000..512c8243d8c210bbcc83cc59a66d30f8dfacf746 --- /dev/null +++ b/src/meshTools/sets/faceZoneSources/setsToFaceZone/setsToFaceZone.H @@ -0,0 +1,119 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::setsToFaceZone + +Description + A topoSetSource to select faces based on usage in a faceSet and cellSet + +SourceFiles + setsToFaceZone.C + +\*---------------------------------------------------------------------------*/ + +#ifndef setsToFaceZone_H +#define setsToFaceZone_H + +#include "topoSetSource.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class setsToFaceZone Declaration +\*---------------------------------------------------------------------------*/ + +class setsToFaceZone +: + public topoSetSource +{ + // Private data + + //- Add usage string + static addToUsageTable usage_; + + //- Name of set to use + word faceSetName_; + + //- Name of set to use + word cellSetName_; + +public: + + //- Runtime type information + TypeName("setsToFaceZone"); + + // Constructors + + //- Construct from components + setsToFaceZone + ( + const polyMesh& mesh, + const word& faceSetName, + const word& cellSetName + ); + + //- Construct from dictionary + setsToFaceZone + ( + const polyMesh& mesh, + const dictionary& dict + ); + + //- Construct from Istream + setsToFaceZone + ( + const polyMesh& mesh, + Istream& + ); + + + // Destructor + + virtual ~setsToFaceZone(); + + + // Member Functions + + virtual void applyToSet + ( + const topoSetSource::setAction action, + topoSet& + ) const; + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/sets/pointSources/cellToPoint/cellToPoint.C b/src/meshTools/sets/pointSources/cellToPoint/cellToPoint.C index 1753f84848f8e90f007a9e2a462fb2837eaa4be1..e96f10945642a1af0f2418bda3ae55350099ec08 100644 --- a/src/meshTools/sets/pointSources/cellToPoint/cellToPoint.C +++ b/src/meshTools/sets/pointSources/cellToPoint/cellToPoint.C @@ -151,13 +151,13 @@ void Foam::cellToPoint::applyToSet { if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) { - Pout<< " Adding from " << setName_ << " ..." << endl; + Info<< " Adding from " << setName_ << " ..." << endl; combine(set, true); } else if (action == topoSetSource::DELETE) { - Pout<< " Removing from " << setName_ << " ..." << endl; + Info<< " Removing from " << setName_ << " ..." << endl; combine(set, false); } diff --git a/src/meshTools/sets/pointZoneSources/setToPointZone/setToPointZone.C b/src/meshTools/sets/pointZoneSources/setToPointZone/setToPointZone.C new file mode 100644 index 0000000000000000000000000000000000000000..80b76f5eed4fd55ca9cc114f17879c5980f89d58 --- /dev/null +++ b/src/meshTools/sets/pointZoneSources/setToPointZone/setToPointZone.C @@ -0,0 +1,168 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "setToPointZone.H" +#include "polyMesh.H" +#include "pointZoneSet.H" + +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + +defineTypeNameAndDebug(setToPointZone, 0); + +addToRunTimeSelectionTable(topoSetSource, setToPointZone, word); + +addToRunTimeSelectionTable(topoSetSource, setToPointZone, istream); + +} + + +Foam::topoSetSource::addToUsageTable Foam::setToPointZone::usage_ +( + setToPointZone::typeName, + "\n Usage: setToPointZone <pointSet>\n\n" + " Select all points in the pointSet.\n\n" +); + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +// Construct from components +Foam::setToPointZone::setToPointZone +( + const polyMesh& mesh, + const word& setName +) +: + topoSetSource(mesh), + setName_(setName) +{} + + +// Construct from dictionary +Foam::setToPointZone::setToPointZone +( + const polyMesh& mesh, + const dictionary& dict +) +: + topoSetSource(mesh), + setName_(dict.lookup("set")) +{} + + +// Construct from Istream +Foam::setToPointZone::setToPointZone +( + const polyMesh& mesh, + Istream& is +) +: + topoSetSource(mesh), + setName_(checkIs(is)) +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::setToPointZone::~setToPointZone() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::setToPointZone::applyToSet +( + const topoSetSource::setAction action, + topoSet& set +) const +{ + if (!isA<pointZoneSet>(set)) + { + WarningIn + ( + "setToPointZone::applyToSet(const topoSetSource::setAction" + ", topoSet" + ) << "Operation only allowed on a pointZoneSet." << endl; + } + else + { + pointZoneSet& fzSet = refCast<pointZoneSet>(set); + + if ((action == topoSetSource::NEW) || (action == topoSetSource::ADD)) + { + Info<< " Adding all points from pointSet " << setName_ + << " ..." << endl; + + // Load the sets + pointSet fSet(mesh_, setName_); + + // Start off from copy + DynamicList<label> newAddressing(fzSet.addressing()); + + forAllConstIter(pointSet, fSet, iter) + { + label pointI = iter.key(); + + if (!fzSet.found(pointI)) + { + newAddressing.append(pointI); + } + } + + fzSet.addressing().transfer(newAddressing); + fzSet.updateSet(); + } + else if (action == topoSetSource::DELETE) + { + Info<< " Removing all points from pointSet " << setName_ + << " ..." << endl; + + // Load the set + pointSet loadedSet(mesh_, setName_); + + // Start off empty + DynamicList<label> newAddressing(fzSet.addressing().size()); + + forAll(fzSet.addressing(), i) + { + if (!loadedSet.found(fzSet.addressing()[i])) + { + newAddressing.append(fzSet.addressing()[i]); + } + } + fzSet.addressing().transfer(newAddressing); + fzSet.updateSet(); + } + } +} + + +// ************************************************************************* // diff --git a/src/meshTools/sets/pointZoneSources/setToPointZone/setToPointZone.H b/src/meshTools/sets/pointZoneSources/setToPointZone/setToPointZone.H new file mode 100644 index 0000000000000000000000000000000000000000..d13a3fe68f58d1f68e645ef0b890c63d0af26253 --- /dev/null +++ b/src/meshTools/sets/pointZoneSources/setToPointZone/setToPointZone.H @@ -0,0 +1,115 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::setToPointZone + +Description + A topoSetSource to select points based on usage in a pointSet. + +SourceFiles + setToPointZone.C + +\*---------------------------------------------------------------------------*/ + +#ifndef setToPointZone_H +#define setToPointZone_H + +#include "topoSetSource.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class setToPointZone Declaration +\*---------------------------------------------------------------------------*/ + +class setToPointZone +: + public topoSetSource +{ + // Private data + + //- Add usage string + static addToUsageTable usage_; + + //- Name of set to use + word setName_; + +public: + + //- Runtime type information + TypeName("setToPointZone"); + + // Constructors + + //- Construct from components + setToPointZone + ( + const polyMesh& mesh, + const word& setName + ); + + //- Construct from dictionary + setToPointZone + ( + const polyMesh& mesh, + const dictionary& dict + ); + + //- Construct from Istream + setToPointZone + ( + const polyMesh& mesh, + Istream& + ); + + + // Destructor + + virtual ~setToPointZone(); + + + // Member Functions + + virtual void applyToSet + ( + const topoSetSource::setAction action, + topoSet& + ) const; + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/sets/topoSets/cellSet.C b/src/meshTools/sets/topoSets/cellSet.C index 4cff9f2908164ccbf8da66ccb31c4013ab22fc66..dabf987a12057f1e5f6cbe11bb62c66d55b97995 100644 --- a/src/meshTools/sets/topoSets/cellSet.C +++ b/src/meshTools/sets/topoSets/cellSet.C @@ -41,6 +41,7 @@ defineTypeNameAndDebug(cellSet, 0); addToRunTimeSelectionTable(topoSet, cellSet, word); addToRunTimeSelectionTable(topoSet, cellSet, size); +addToRunTimeSelectionTable(topoSet, cellSet, set); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -78,6 +79,18 @@ cellSet::cellSet {} +cellSet::cellSet +( + const polyMesh& mesh, + const word& name, + const topoSet& set, + writeOption w +) +: + topoSet(mesh, name, set, w) +{} + + cellSet::cellSet ( const polyMesh& mesh, diff --git a/src/meshTools/sets/topoSets/cellSet.H b/src/meshTools/sets/topoSets/cellSet.H index 627e80e1420bbdcb7d262be4b69a2472a69b8b60..b931ac22f142fa030a4bab64d9b2cc808733d581 100644 --- a/src/meshTools/sets/topoSets/cellSet.H +++ b/src/meshTools/sets/topoSets/cellSet.H @@ -88,6 +88,15 @@ public: writeOption w=NO_WRITE ); + //- Construct from existing set + cellSet + ( + const polyMesh& mesh, + const word& name, + const topoSet&, + writeOption w=NO_WRITE + ); + //- Construct from labelHashSet cellSet ( diff --git a/src/meshTools/sets/topoSets/cellZoneSet.C b/src/meshTools/sets/topoSets/cellZoneSet.C new file mode 100644 index 0000000000000000000000000000000000000000..d2467fe43a4ac8b5c8ad5d655328f8ab123bc845 --- /dev/null +++ b/src/meshTools/sets/topoSets/cellZoneSet.C @@ -0,0 +1,308 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "cellZoneSet.H" +#include "mapPolyMesh.H" +#include "polyMesh.H" +#include "processorPolyPatch.H" +#include "cyclicPolyPatch.H" + +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(cellZoneSet, 0); + +addToRunTimeSelectionTable(topoSet, cellZoneSet, word); +addToRunTimeSelectionTable(topoSet, cellZoneSet, size); +addToRunTimeSelectionTable(topoSet, cellZoneSet, set); + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void cellZoneSet::updateSet() +{ + cellSet::clearStorage(); + cellSet::resize(2*addressing_.size()); + forAll(addressing_, i) + { + cellSet::insert(addressing_[i]); + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +cellZoneSet::cellZoneSet +( + const polyMesh& mesh, + const word& name, + readOption r, + writeOption w +) +: + cellSet(mesh, name, 1000), // do not read cellSet + mesh_(mesh), + addressing_(0) +{ + const cellZoneMesh& cellZones = mesh.cellZones(); + label zoneID = cellZones.findZoneID(name); + + if + ( + (r == IOobject::MUST_READ) + || (r == IOobject::READ_IF_PRESENT && zoneID != -1) + ) + { + const cellZone& fz = cellZones[zoneID]; + addressing_ = fz; + } + + updateSet(); + + check(mesh.nCells()); +} + + +cellZoneSet::cellZoneSet +( + const polyMesh& mesh, + const word& name, + const label size, + writeOption w +) +: + cellSet(mesh, name, size, w), + mesh_(mesh), + addressing_(0) +{ + updateSet(); +} + + +cellZoneSet::cellZoneSet +( + const polyMesh& mesh, + const word& name, + const topoSet& set, + writeOption w +) +: + cellSet(mesh, name, set.size(), w), + mesh_(mesh), + addressing_(refCast<const cellZoneSet>(set).addressing()) +{ + updateSet(); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +cellZoneSet::~cellZoneSet() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void cellZoneSet::invert(const label maxLen) +{ + label n = 0; + + for (label cellI = 0; cellI < maxLen; cellI++) + { + if (!found(cellI)) + { + addressing_[n] = cellI; + n++; + } + } + addressing_.setSize(n); + updateSet(); +} + + +void cellZoneSet::subset(const topoSet& set) +{ + DynamicList<label> newAddressing(addressing_.size()); + + const cellZoneSet& fSet = refCast<const cellZoneSet>(set); + + forAll(fSet.addressing(), i) + { + label cellI = fSet.addressing()[i]; + + if (found(cellI)) + { + newAddressing.append(cellI); + } + } + + addressing_.transfer(newAddressing); + updateSet(); +} + + +void cellZoneSet::addSet(const topoSet& set) +{ + DynamicList<label> newAddressing(addressing_); + + const cellZoneSet& fSet = refCast<const cellZoneSet>(set); + + forAll(fSet.addressing(), i) + { + label cellI = fSet.addressing()[i]; + + if (!found(cellI)) + { + newAddressing.append(cellI); + } + } + + addressing_.transfer(newAddressing); + updateSet(); +} + + +void cellZoneSet::deleteSet(const topoSet& set) +{ + DynamicList<label> newAddressing(addressing_.size()); + + const cellZoneSet& fSet = refCast<const cellZoneSet>(set); + + forAll(addressing_, i) + { + label cellI = addressing_[i]; + + if (!fSet.found(cellI)) + { + // Not found in fSet so add + newAddressing.append(cellI); + } + } + + addressing_.transfer(newAddressing); + updateSet(); +} + + +void cellZoneSet::sync(const polyMesh& mesh) +{} + + +label cellZoneSet::maxSize(const polyMesh& mesh) const +{ + return mesh.nCells(); +} + + +//- Write using given format, version and compression +bool cellZoneSet::writeObject +( + IOstream::streamFormat s, + IOstream::versionNumber v, + IOstream::compressionType c +) const +{ + // Write shadow cellSet + word oldTypeName = typeName; + const_cast<word&>(type()) = cellSet::typeName; + bool ok = cellSet::writeObject(s, v, c); + const_cast<word&>(type()) = oldTypeName; + + // Modify cellZone + cellZoneMesh& cellZones = const_cast<polyMesh&>(mesh_).cellZones(); + label zoneID = cellZones.findZoneID(name()); + + if (zoneID == -1) + { + zoneID = cellZones.size(); + + cellZones.setSize(zoneID+1); + cellZones.set + ( + zoneID, + new cellZone + ( + name(), + addressing_, + zoneID, + cellZones + ) + ); + } + else + { + cellZones[zoneID] = addressing_; + } + return ok && cellZones.write(); +} + + +void cellZoneSet::updateMesh(const mapPolyMesh& morphMap) +{ + // cellZone + labelList newAddressing(addressing_.size()); + + label n = 0; + forAll(addressing_, i) + { + label cellI = addressing_[i]; + label newCellI = morphMap.reverseCellMap()[cellI]; + if (newCellI >= 0) + { + newAddressing[n] = newCellI; + n++; + } + } + newAddressing.setSize(n); + + addressing_.transfer(newAddressing); + + updateSet(); +} + + +void cellZoneSet::writeDebug +( + Ostream& os, + const primitiveMesh& mesh, + const label maxLen +) const +{ + cellSet::writeDebug(os, mesh, maxLen); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/meshTools/sets/topoSets/cellZoneSet.H b/src/meshTools/sets/topoSets/cellZoneSet.H new file mode 100644 index 0000000000000000000000000000000000000000..40f0334f90511bc28035495da3dc0b5e3e10eaaa --- /dev/null +++ b/src/meshTools/sets/topoSets/cellZoneSet.H @@ -0,0 +1,173 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::cellZoneSet + +Description + Like cellSet but updates cellZone when writing. + +SourceFiles + cellZone.C + +\*---------------------------------------------------------------------------*/ + +#ifndef cellZoneSet_H +#define cellZoneSet_H + +#include "cellSet.H" +#include "boolList.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class cellZoneSet Declaration +\*---------------------------------------------------------------------------*/ + +class cellZoneSet +: + public cellSet +{ + // Private data + + const polyMesh& mesh_; + + labelList addressing_; + + // Private Member Functions + + +public: + + //- Runtime type information + TypeName("cellZoneSet"); + + + // Constructors + + //- Construct from objectRegistry and name + cellZoneSet + ( + const polyMesh& mesh, + const word& name, + readOption r=MUST_READ, + writeOption w=NO_WRITE + ); + + //- Construct from additional size of labelHashSet + cellZoneSet + ( + const polyMesh& mesh, + const word& name, + const label, + writeOption w=NO_WRITE + ); + + //- Construct from existing set + cellZoneSet + ( + const polyMesh& mesh, + const word& name, + const topoSet&, + writeOption w=NO_WRITE + ); + + + + // Destructor + + virtual ~cellZoneSet(); + + + // Member functions + + const labelList& addressing() const + { + return addressing_; + } + + labelList& addressing() + { + return addressing_; + } + + //- Make cellSet part consistent with addressing + void updateSet(); + + //- Invert contents. (insert all members 0..maxLen-1 which were not in + // set) + virtual void invert(const label maxLen); + + //- Subset contents. Only elements present in both sets remain. + virtual void subset(const topoSet& set); + + //- Add elements present in set. + virtual void addSet(const topoSet& set); + + //- Delete elements present in set. + virtual void deleteSet(const topoSet& set); + + //- Sync cellZoneSet across coupled patches. + virtual void sync(const polyMesh& mesh); + + //- Write maxLen items with label and coordinates. + virtual void writeDebug + ( + Ostream& os, + const primitiveMesh&, + const label maxLen + ) const; + + //- Write cellZone + virtual bool writeObject + ( + IOstream::streamFormat, + IOstream::versionNumber, + IOstream::compressionType + ) const; + + //- Update any stored data for new labels + virtual void updateMesh(const mapPolyMesh& morphMap); + + //- Return max index+1. + virtual label maxSize(const polyMesh& mesh) const; + + + + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/sets/topoSets/faceSet.C b/src/meshTools/sets/topoSets/faceSet.C index e4a84a14e9b8b57900ee5d3e4d700072a604684e..c5bd79297319bfcd907df167b77d526dd386a05e 100644 --- a/src/meshTools/sets/topoSets/faceSet.C +++ b/src/meshTools/sets/topoSets/faceSet.C @@ -43,6 +43,7 @@ defineTypeNameAndDebug(faceSet, 0); addToRunTimeSelectionTable(topoSet, faceSet, word); addToRunTimeSelectionTable(topoSet, faceSet, size); +addToRunTimeSelectionTable(topoSet, faceSet, set); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -79,6 +80,18 @@ faceSet::faceSet {} +faceSet::faceSet +( + const polyMesh& mesh, + const word& name, + const topoSet& set, + writeOption w +) +: + topoSet(mesh, name, set, w) +{} + + faceSet::faceSet ( const polyMesh& mesh, diff --git a/src/meshTools/sets/topoSets/faceSet.H b/src/meshTools/sets/topoSets/faceSet.H index aefb3380f867cb59876d60bb35e2e26d44f1e731..11e7387b9723b1371f3600c265e601cd15c3727e 100644 --- a/src/meshTools/sets/topoSets/faceSet.H +++ b/src/meshTools/sets/topoSets/faceSet.H @@ -83,6 +83,15 @@ public: writeOption w=NO_WRITE ); + //- Construct from existing set + faceSet + ( + const polyMesh& mesh, + const word& name, + const topoSet&, + writeOption w=NO_WRITE + ); + //- Construct from additional labelHashSet faceSet ( diff --git a/src/meshTools/sets/topoSets/faceZoneSet.C b/src/meshTools/sets/topoSets/faceZoneSet.C new file mode 100644 index 0000000000000000000000000000000000000000..5e980ad783895fb5660ec4e7542fccefa5525cb8 --- /dev/null +++ b/src/meshTools/sets/topoSets/faceZoneSet.C @@ -0,0 +1,406 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "faceZoneSet.H" +#include "mapPolyMesh.H" +#include "polyMesh.H" +#include "processorPolyPatch.H" +#include "cyclicPolyPatch.H" + +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(faceZoneSet, 0); + +addToRunTimeSelectionTable(topoSet, faceZoneSet, word); +addToRunTimeSelectionTable(topoSet, faceZoneSet, size); +addToRunTimeSelectionTable(topoSet, faceZoneSet, set); + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void faceZoneSet::updateSet() +{ + faceSet::clearStorage(); + faceSet::resize(2*addressing_.size()); + forAll(addressing_, i) + { + faceSet::insert(addressing_[i]); + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +faceZoneSet::faceZoneSet +( + const polyMesh& mesh, + const word& name, + readOption r, + writeOption w +) +: + faceSet(mesh, name, 1000), // do not read faceSet + mesh_(mesh), + addressing_(0), + flipMap_(0) +{ + const faceZoneMesh& faceZones = mesh.faceZones(); + label zoneID = faceZones.findZoneID(name); + + if + ( + (r == IOobject::MUST_READ) + || (r == IOobject::READ_IF_PRESENT && zoneID != -1) + ) + { + const faceZone& fz = faceZones[zoneID]; + addressing_ = fz; + flipMap_ = fz.flipMap(); + } + + updateSet(); + + check(mesh.nFaces()); +} + + +faceZoneSet::faceZoneSet +( + const polyMesh& mesh, + const word& name, + const label size, + writeOption w +) +: + faceSet(mesh, name, size, w), + mesh_(mesh), + addressing_(0), + flipMap_(0) +{ + updateSet(); +} + + +faceZoneSet::faceZoneSet +( + const polyMesh& mesh, + const word& name, + const topoSet& set, + writeOption w +) +: + faceSet(mesh, name, set.size(), w), + mesh_(mesh), + addressing_(refCast<const faceZoneSet>(set).addressing()), + flipMap_(refCast<const faceZoneSet>(set).flipMap()) +{ + updateSet(); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +faceZoneSet::~faceZoneSet() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void faceZoneSet::invert(const label maxLen) +{ + label n = 0; + + for (label faceI = 0; faceI < maxLen; faceI++) + { + if (!found(faceI)) + { + addressing_[n] = faceI; + flipMap_[n] = true; //? or false? + n++; + } + } + addressing_.setSize(n); + flipMap_.setSize(n); + updateSet(); +} + + +void faceZoneSet::subset(const topoSet& set) +{ + label nConflict = 0; + + DynamicList<label> newAddressing(addressing_.size()); + DynamicList<bool> newFlipMap(flipMap_.size()); + + Map<label> faceToIndex(addressing_.size()); + forAll(addressing_, i) + { + faceToIndex.insert(addressing_[i], i); + } + + const faceZoneSet& fSet = refCast<const faceZoneSet>(set); + + forAll(fSet.addressing(), i) + { + label faceI = fSet.addressing()[i]; + + Map<label>::const_iterator iter = faceToIndex.find(faceI); + + if (iter != faceToIndex.end()) + { + label index = iter(); + + if (fSet.flipMap()[i] != flipMap_[index]) + { + nConflict++; + } + newAddressing.append(faceI); + newFlipMap.append(flipMap_[index]); + } + } + + if (nConflict > 0) + { + WarningIn(" faceZoneSet::subset(const topoSet&)") + << "subset : there are " << nConflict + << " faces with different orientation in faceZonesSets " + << name() << " and " << set.name() << endl; + } + + addressing_.transfer(newAddressing); + flipMap_.transfer(newFlipMap); + updateSet(); +} + + +void faceZoneSet::addSet(const topoSet& set) +{ + label nConflict = 0; + + DynamicList<label> newAddressing(addressing_); + DynamicList<bool> newFlipMap(flipMap_); + + Map<label> faceToIndex(addressing_.size()); + forAll(addressing_, i) + { + faceToIndex.insert(addressing_[i], i); + } + + const faceZoneSet& fSet = refCast<const faceZoneSet>(set); + + forAll(fSet.addressing(), i) + { + label faceI = fSet.addressing()[i]; + + Map<label>::const_iterator iter = faceToIndex.find(faceI); + + if (iter != faceToIndex.end()) + { + label index = iter(); + + if (fSet.flipMap()[i] != flipMap_[index]) + { + nConflict++; + } + } + else + { + newAddressing.append(faceI); + newFlipMap.append(fSet.flipMap()[i]); + } + } + + if (nConflict > 0) + { + WarningIn("faceZoneSet::addSet(const topoSet&)") + << "addSet : there are " << nConflict + << " faces with different orientation in faceZonesSets " + << name() << " and " << set.name() << endl; + } + + addressing_.transfer(newAddressing); + flipMap_.transfer(newFlipMap); + updateSet(); +} + + +void faceZoneSet::deleteSet(const topoSet& set) +{ + label nConflict = 0; + + DynamicList<label> newAddressing(addressing_.size()); + DynamicList<bool> newFlipMap(flipMap_.size()); + + const faceZoneSet& fSet = refCast<const faceZoneSet>(set); + + Map<label> faceToIndex(fSet.addressing().size()); + forAll(fSet.addressing(), i) + { + faceToIndex.insert(fSet.addressing()[i], i); + } + + forAll(addressing_, i) + { + label faceI = addressing_[i]; + + Map<label>::const_iterator iter = faceToIndex.find(faceI); + + if (iter != faceToIndex.end()) + { + label index = iter(); + + if (fSet.flipMap()[index] != flipMap_[i]) + { + nConflict++; + } + } + else + { + // Not found in fSet so add + newAddressing.append(faceI); + newFlipMap.append(fSet.flipMap()[i]); + } + } + + if (nConflict > 0) + { + WarningIn("faceZoneSet::deleteSet(const topoSet&)") + << "deleteSet : there are " << nConflict + << " faces with different orientation in faceZonesSets " + << name() << " and " << set.name() << endl; + } + + addressing_.transfer(newAddressing); + flipMap_.transfer(newFlipMap); + updateSet(); +} + + +void faceZoneSet::sync(const polyMesh& mesh) +{} + + +label faceZoneSet::maxSize(const polyMesh& mesh) const +{ + return mesh.nFaces(); +} + + +//- Write using given format, version and compression +bool faceZoneSet::writeObject +( + IOstream::streamFormat s, + IOstream::versionNumber v, + IOstream::compressionType c +) const +{ + // Write shadow faceSet + word oldTypeName = typeName; + const_cast<word&>(type()) = faceSet::typeName; + bool ok = faceSet::writeObject(s, v, c); + const_cast<word&>(type()) = oldTypeName; + + // Modify faceZone + faceZoneMesh& faceZones = const_cast<polyMesh&>(mesh_).faceZones(); + label zoneID = faceZones.findZoneID(name()); + + if (zoneID == -1) + { + zoneID = faceZones.size(); + + faceZones.setSize(zoneID+1); + faceZones.set + ( + zoneID, + new faceZone + ( + name(), + addressing_, + flipMap_, + zoneID, + faceZones + ) + ); + } + else + { + faceZones[zoneID].resetAddressing(addressing_, flipMap_); + } + return ok && faceZones.write(); +} + + +void faceZoneSet::updateMesh(const mapPolyMesh& morphMap) +{ + // faceZone + labelList newAddressing(addressing_.size()); + boolList newFlipMap(flipMap_.size()); + + label n = 0; + forAll(addressing_, i) + { + label faceI = addressing_[i]; + label newFaceI = morphMap.reverseFaceMap()[faceI]; + if (newFaceI >= 0) + { + newAddressing[n] = newFaceI; + newFlipMap[n] = flipMap_[i]; + n++; + } + } + newAddressing.setSize(n); + newFlipMap.setSize(n); + + addressing_.transfer(newAddressing); + flipMap_.transfer(newFlipMap); + + updateSet(); +} + + +void faceZoneSet::writeDebug +( + Ostream& os, + const primitiveMesh& mesh, + const label maxLen +) const +{ + faceSet::writeDebug(os, mesh, maxLen); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/meshTools/sets/topoSets/faceZoneSet.H b/src/meshTools/sets/topoSets/faceZoneSet.H new file mode 100644 index 0000000000000000000000000000000000000000..cefe642e44ec5dcfcc01257638dec9034a5ca4f9 --- /dev/null +++ b/src/meshTools/sets/topoSets/faceZoneSet.H @@ -0,0 +1,187 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::faceZoneSet + +Description + Like faceSet but updates faceZone when writing. + +SourceFiles + faceZone.C + +\*---------------------------------------------------------------------------*/ + +#ifndef faceZoneSet_H +#define faceZoneSet_H + +#include "faceSet.H" +#include "boolList.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class faceZoneSet Declaration +\*---------------------------------------------------------------------------*/ + +class faceZoneSet +: + public faceSet +{ + // Private data + + const polyMesh& mesh_; + + labelList addressing_; + + boolList flipMap_; + + // Private Member Functions + + +public: + + //- Runtime type information + TypeName("faceZoneSet"); + + + // Constructors + + //- Construct from objectRegistry and name + faceZoneSet + ( + const polyMesh& mesh, + const word& name, + readOption r=MUST_READ, + writeOption w=NO_WRITE + ); + + //- Construct from additional size of labelHashSet + faceZoneSet + ( + const polyMesh& mesh, + const word& name, + const label, + writeOption w=NO_WRITE + ); + + //- Construct from existing set + faceZoneSet + ( + const polyMesh& mesh, + const word& name, + const topoSet&, + writeOption w=NO_WRITE + ); + + + + // Destructor + + virtual ~faceZoneSet(); + + + // Member functions + + const labelList& addressing() const + { + return addressing_; + } + + labelList& addressing() + { + return addressing_; + } + + + const boolList& flipMap() const + { + return flipMap_; + } + + boolList& flipMap() + { + return flipMap_; + } + + + //- Make faceSet part consistent with addressing + void updateSet(); + + //- Invert contents. (insert all members 0..maxLen-1 which were not in + // set) + virtual void invert(const label maxLen); + + //- Subset contents. Only elements present in both sets remain. + virtual void subset(const topoSet& set); + + //- Add elements present in set. + virtual void addSet(const topoSet& set); + + //- Delete elements present in set. + virtual void deleteSet(const topoSet& set); + + //- Sync faceZoneSet across coupled patches. + virtual void sync(const polyMesh& mesh); + + //- Write maxLen items with label and coordinates. + virtual void writeDebug + ( + Ostream& os, + const primitiveMesh&, + const label maxLen + ) const; + + //- Write faceZone + virtual bool writeObject + ( + IOstream::streamFormat, + IOstream::versionNumber, + IOstream::compressionType + ) const; + + //- Update any stored data for new labels + virtual void updateMesh(const mapPolyMesh& morphMap); + + //- Return max index+1. + virtual label maxSize(const polyMesh& mesh) const; + + + + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/sets/topoSets/pointSet.C b/src/meshTools/sets/topoSets/pointSet.C index 1e4884450cb88b1db2979bcc5c3ed3443cfbeb51..e370299fa1abf061bf475d5c7555042ec15bd24a 100644 --- a/src/meshTools/sets/topoSets/pointSet.C +++ b/src/meshTools/sets/topoSets/pointSet.C @@ -42,6 +42,7 @@ defineTypeNameAndDebug(pointSet, 0); addToRunTimeSelectionTable(topoSet, pointSet, word); addToRunTimeSelectionTable(topoSet, pointSet, size); +addToRunTimeSelectionTable(topoSet, pointSet, set); // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -78,6 +79,18 @@ pointSet::pointSet {} +pointSet::pointSet +( + const polyMesh& mesh, + const word& name, + const topoSet& set, + writeOption w +) +: + topoSet(mesh, name, set, w) +{} + + pointSet::pointSet ( const polyMesh& mesh, diff --git a/src/meshTools/sets/topoSets/pointSet.H b/src/meshTools/sets/topoSets/pointSet.H index b9c8ef93aceb6a2fcd7124f6da1cb2615d1348dc..05f4ef6e36b193ab16b8cbf26f46b0130ab1c1e7 100644 --- a/src/meshTools/sets/topoSets/pointSet.H +++ b/src/meshTools/sets/topoSets/pointSet.H @@ -83,6 +83,15 @@ public: writeOption w=NO_WRITE ); + //- Construct from additional labelHashSet + pointSet + ( + const polyMesh& mesh, + const word& name, + const topoSet&, + writeOption w=NO_WRITE + ); + //- Construct from additional labelHashSet pointSet ( diff --git a/src/meshTools/sets/topoSets/pointZoneSet.C b/src/meshTools/sets/topoSets/pointZoneSet.C new file mode 100644 index 0000000000000000000000000000000000000000..d68956e3b3782ef0e00c75bf7302182076b54f8b --- /dev/null +++ b/src/meshTools/sets/topoSets/pointZoneSet.C @@ -0,0 +1,308 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*---------------------------------------------------------------------------*/ + +#include "pointZoneSet.H" +#include "mapPolyMesh.H" +#include "polyMesh.H" +#include "processorPolyPatch.H" +#include "cyclicPolyPatch.H" + +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(pointZoneSet, 0); + +addToRunTimeSelectionTable(topoSet, pointZoneSet, word); +addToRunTimeSelectionTable(topoSet, pointZoneSet, size); +addToRunTimeSelectionTable(topoSet, pointZoneSet, set); + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void pointZoneSet::updateSet() +{ + pointSet::clearStorage(); + pointSet::resize(2*addressing_.size()); + forAll(addressing_, i) + { + pointSet::insert(addressing_[i]); + } +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +pointZoneSet::pointZoneSet +( + const polyMesh& mesh, + const word& name, + readOption r, + writeOption w +) +: + pointSet(mesh, name, 1000), // do not read pointSet + mesh_(mesh), + addressing_(0) +{ + const pointZoneMesh& pointZones = mesh.pointZones(); + label zoneID = pointZones.findZoneID(name); + + if + ( + (r == IOobject::MUST_READ) + || (r == IOobject::READ_IF_PRESENT && zoneID != -1) + ) + { + const pointZone& fz = pointZones[zoneID]; + addressing_ = fz; + } + + updateSet(); + + check(mesh.nPoints()); +} + + +pointZoneSet::pointZoneSet +( + const polyMesh& mesh, + const word& name, + const label size, + writeOption w +) +: + pointSet(mesh, name, size, w), + mesh_(mesh), + addressing_(0) +{ + updateSet(); +} + + +pointZoneSet::pointZoneSet +( + const polyMesh& mesh, + const word& name, + const topoSet& set, + writeOption w +) +: + pointSet(mesh, name, set.size(), w), + mesh_(mesh), + addressing_(refCast<const pointZoneSet>(set).addressing()) +{ + updateSet(); +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +pointZoneSet::~pointZoneSet() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void pointZoneSet::invert(const label maxLen) +{ + label n = 0; + + for (label pointI = 0; pointI < maxLen; pointI++) + { + if (!found(pointI)) + { + addressing_[n] = pointI; + n++; + } + } + addressing_.setSize(n); + updateSet(); +} + + +void pointZoneSet::subset(const topoSet& set) +{ + DynamicList<label> newAddressing(addressing_.size()); + + const pointZoneSet& fSet = refCast<const pointZoneSet>(set); + + forAll(fSet.addressing(), i) + { + label pointI = fSet.addressing()[i]; + + if (found(pointI)) + { + newAddressing.append(pointI); + } + } + + addressing_.transfer(newAddressing); + updateSet(); +} + + +void pointZoneSet::addSet(const topoSet& set) +{ + DynamicList<label> newAddressing(addressing_); + + const pointZoneSet& fSet = refCast<const pointZoneSet>(set); + + forAll(fSet.addressing(), i) + { + label pointI = fSet.addressing()[i]; + + if (!found(pointI)) + { + newAddressing.append(pointI); + } + } + + addressing_.transfer(newAddressing); + updateSet(); +} + + +void pointZoneSet::deleteSet(const topoSet& set) +{ + DynamicList<label> newAddressing(addressing_.size()); + + const pointZoneSet& fSet = refCast<const pointZoneSet>(set); + + forAll(addressing_, i) + { + label pointI = addressing_[i]; + + if (!fSet.found(pointI)) + { + // Not found in fSet so add + newAddressing.append(pointI); + } + } + + addressing_.transfer(newAddressing); + updateSet(); +} + + +void pointZoneSet::sync(const polyMesh& mesh) +{} + + +label pointZoneSet::maxSize(const polyMesh& mesh) const +{ + return mesh.nPoints(); +} + + +//- Write using given format, version and compression +bool pointZoneSet::writeObject +( + IOstream::streamFormat s, + IOstream::versionNumber v, + IOstream::compressionType c +) const +{ + // Write shadow pointSet + word oldTypeName = typeName; + const_cast<word&>(type()) = pointSet::typeName; + bool ok = pointSet::writeObject(s, v, c); + const_cast<word&>(type()) = oldTypeName; + + // Modify pointZone + pointZoneMesh& pointZones = const_cast<polyMesh&>(mesh_).pointZones(); + label zoneID = pointZones.findZoneID(name()); + + if (zoneID == -1) + { + zoneID = pointZones.size(); + + pointZones.setSize(zoneID+1); + pointZones.set + ( + zoneID, + new pointZone + ( + name(), + addressing_, + zoneID, + pointZones + ) + ); + } + else + { + pointZones[zoneID] = addressing_; + } + return ok && pointZones.write(); +} + + +void pointZoneSet::updateMesh(const mapPolyMesh& morphMap) +{ + // pointZone + labelList newAddressing(addressing_.size()); + + label n = 0; + forAll(addressing_, i) + { + label pointI = addressing_[i]; + label newPointI = morphMap.reversePointMap()[pointI]; + if (newPointI >= 0) + { + newAddressing[n] = newPointI; + n++; + } + } + newAddressing.setSize(n); + + addressing_.transfer(newAddressing); + + updateSet(); +} + + +void pointZoneSet::writeDebug +( + Ostream& os, + const primitiveMesh& mesh, + const label maxLen +) const +{ + pointSet::writeDebug(os, mesh, maxLen); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/meshTools/sets/topoSets/pointZoneSet.H b/src/meshTools/sets/topoSets/pointZoneSet.H new file mode 100644 index 0000000000000000000000000000000000000000..9518c5e71d51d374031755e8b7b9e1330f5cfe53 --- /dev/null +++ b/src/meshTools/sets/topoSets/pointZoneSet.H @@ -0,0 +1,173 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by the + Free Software Foundation; either version 2 of the License, or (at your + option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM; if not, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::pointZoneSet + +Description + Like pointSet but updates pointZone when writing. + +SourceFiles + pointZone.C + +\*---------------------------------------------------------------------------*/ + +#ifndef pointZoneSet_H +#define pointZoneSet_H + +#include "pointSet.H" +#include "boolList.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class pointZoneSet Declaration +\*---------------------------------------------------------------------------*/ + +class pointZoneSet +: + public pointSet +{ + // Private data + + const polyMesh& mesh_; + + labelList addressing_; + + // Private Member Functions + + +public: + + //- Runtime type information + TypeName("pointZoneSet"); + + + // Constructors + + //- Construct from objectRegistry and name + pointZoneSet + ( + const polyMesh& mesh, + const word& name, + readOption r=MUST_READ, + writeOption w=NO_WRITE + ); + + //- Construct from additional size of labelHashSet + pointZoneSet + ( + const polyMesh& mesh, + const word& name, + const label, + writeOption w=NO_WRITE + ); + + //- Construct from existing set + pointZoneSet + ( + const polyMesh& mesh, + const word& name, + const topoSet&, + writeOption w=NO_WRITE + ); + + + + // Destructor + + virtual ~pointZoneSet(); + + + // Member functions + + const labelList& addressing() const + { + return addressing_; + } + + labelList& addressing() + { + return addressing_; + } + + //- Make pointSet part consistent with addressing + void updateSet(); + + //- Invert contents. (insert all members 0..maxLen-1 which were not in + // set) + virtual void invert(const label maxLen); + + //- Subset contents. Only elements present in both sets remain. + virtual void subset(const topoSet& set); + + //- Add elements present in set. + virtual void addSet(const topoSet& set); + + //- Delete elements present in set. + virtual void deleteSet(const topoSet& set); + + //- Sync pointZoneSet across coupled patches. + virtual void sync(const polyMesh& mesh); + + //- Write maxLen items with label and coordinates. + virtual void writeDebug + ( + Ostream& os, + const primitiveMesh&, + const label maxLen + ) const; + + //- Write pointZone + virtual bool writeObject + ( + IOstream::streamFormat, + IOstream::versionNumber, + IOstream::compressionType + ) const; + + //- Update any stored data for new labels + virtual void updateMesh(const mapPolyMesh& morphMap); + + //- Return max index+1. + virtual label maxSize(const polyMesh& mesh) const; + + + + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/meshTools/sets/topoSets/topoSet.C b/src/meshTools/sets/topoSets/topoSet.C index 32f8d1ff989c6981b216fa5e83bb6fe23f269661..28bc14f469fe1c0facf4ec6b48aae8b6ee0d7eb5 100644 --- a/src/meshTools/sets/topoSets/topoSet.C +++ b/src/meshTools/sets/topoSets/topoSet.C @@ -39,6 +39,7 @@ namespace Foam defineTypeNameAndDebug(topoSet, 0); defineRunTimeSelectionTable(topoSet, word); defineRunTimeSelectionTable(topoSet, size); +defineRunTimeSelectionTable(topoSet, set); // Construct named object from existing set. @@ -103,6 +104,37 @@ autoPtr<topoSet> topoSet::New } +// Construct named object from existing set. +autoPtr<topoSet> topoSet::New +( + const word& setType, + const polyMesh& mesh, + const word& name, + const topoSet& set, + writeOption w +) +{ + setConstructorTable::iterator cstrIter = + setConstructorTablePtr_ + ->find(setType); + + if (cstrIter == setConstructorTablePtr_->end()) + { + FatalErrorIn + ( + "topoSet::New(const word&, " + "const polyMesh&, const word&, const topoSet&, writeOption)" + ) << "Unknown set type " << setType + << endl << endl + << "Valid set types : " << endl + << setConstructorTablePtr_->sortedToc() + << exit(FatalError); + } + + return autoPtr<topoSet>(cstrIter()(mesh, name, set, w)); +} + + Foam::fileName topoSet::topoSet::localPath ( const polyMesh& mesh, @@ -255,9 +287,9 @@ void topoSet::writeDebug ) const { // Bounding box of contents. - boundBox bb(pointField(coords, toc())); + boundBox bb(pointField(coords, toc()), true); - Pout<< "Set bounding box: min = " + os << "Set bounding box: min = " << bb.min() << " max = " << bb.max() << " meters. " << endl << endl; label n = 0; @@ -538,18 +570,18 @@ void topoSet::writeDebug(Ostream& os, const label maxLen) const } -void topoSet::writeDebug -( - Ostream&, - const primitiveMesh&, - const label -) const -{ - notImplemented - ( - "topoSet::writeDebug(Ostream&, const primitiveMesh&, const label)" - ); -} +//void topoSet::writeDebug +//( +// Ostream&, +// const primitiveMesh&, +// const label +//) const +//{ +// notImplemented +// ( +// "topoSet::writeDebug(Ostream&, const primitiveMesh&, const label)" +// ); +//} bool topoSet::writeData(Ostream& os) const @@ -564,13 +596,13 @@ void topoSet::updateMesh(const mapPolyMesh&) } -//- Return max index+1. -label topoSet::maxSize(const polyMesh&) const -{ - notImplemented("topoSet::maxSize(const polyMesh&)"); - - return -1; -} +////- Return max index+1. +//label topoSet::maxSize(const polyMesh&) const +//{ +// notImplemented("topoSet::maxSize(const polyMesh&)"); +// +// return -1; +//} // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // diff --git a/src/meshTools/sets/topoSets/topoSet.H b/src/meshTools/sets/topoSets/topoSet.H index 51049ab9e25a3309dcfcaeb555355c59e39f1daa..124681305a6c93abf1fb25471738dce47ae061f0 100644 --- a/src/meshTools/sets/topoSets/topoSet.H +++ b/src/meshTools/sets/topoSets/topoSet.H @@ -55,7 +55,6 @@ namespace Foam class mapPolyMesh; class polyMesh; class primitiveMesh; -//class directPolyTopoChange; /*---------------------------------------------------------------------------*\ Class topoSet Declaration @@ -154,6 +153,21 @@ public: (mesh, name, size, w) ); + // For the constructor as copy + declareRunTimeSelectionTable + ( + autoPtr, + topoSet, + set, + ( + const polyMesh& mesh, + const word& name, + const topoSet& set, + writeOption w + ), + (mesh, name, set, w) + ); + // Constructors @@ -208,7 +222,7 @@ public: // Selectors - //- Return a reference to the selected source + //- Return a pointer to a toposet read from file static autoPtr<topoSet> New ( const word& setType, @@ -218,7 +232,7 @@ public: writeOption w=NO_WRITE ); - //- Return a reference to the selected source + //- Return a pointer to a new toposet of given size static autoPtr<topoSet> New ( const word& setType, @@ -228,6 +242,16 @@ public: writeOption w=NO_WRITE ); + //- Return a pointer to a new toposet as copy of another toposet + static autoPtr<topoSet> New + ( + const word& setType, + const polyMesh& mesh, + const word& name, + const topoSet& set, + writeOption w=NO_WRITE + ); + // Destructor @@ -256,13 +280,13 @@ public: virtual void writeDebug(Ostream& os, const label maxLen) const; //- Like above but also writes mesh related quantity - // (usually coordinate). Not implemented. + // (usually coordinate). virtual void writeDebug ( Ostream& os, const primitiveMesh&, const label maxLen - ) const; + ) const = 0; //- Write contents. virtual bool writeData(Ostream&) const; @@ -271,7 +295,7 @@ public: virtual void updateMesh(const mapPolyMesh& morphMap); //- Return max allowable index (+1). Not implemented. - virtual label maxSize(const polyMesh& mesh) const; + virtual label maxSize(const polyMesh& mesh) const = 0;