From 72cacc9588df65d7d95aeb399f3c92c36fee3291 Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 24 Sep 2009 18:39:04 +0100 Subject: [PATCH 01/34] added zoneSets --- .../mesh/manipulation/setSet/setSet.C | 67 ++- src/meshTools/Make/files | 15 + .../sets/cellSources/cellToCell/cellToCell.C | 4 +- .../setToCellZone/setToCellZone.C | 168 ++++++++ .../setToCellZone/setToCellZone.H | 115 +++++ .../sets/faceSources/cellToFace/cellToFace.C | 4 +- .../faceZoneToFaceZone/faceZoneToFaceZone.C | 169 ++++++++ .../faceZoneToFaceZone/faceZoneToFaceZone.H | 115 +++++ .../setToFaceZone/setToFaceZone.C | 175 ++++++++ .../setToFaceZone/setToFaceZone.H | 116 +++++ .../setsToFaceZone/setsToFaceZone.C | 222 ++++++++++ .../setsToFaceZone/setsToFaceZone.H | 119 +++++ .../pointSources/cellToPoint/cellToPoint.C | 4 +- .../setToPointZone/setToPointZone.C | 168 ++++++++ .../setToPointZone/setToPointZone.H | 115 +++++ src/meshTools/sets/topoSets/cellSet.C | 13 + src/meshTools/sets/topoSets/cellSet.H | 9 + src/meshTools/sets/topoSets/cellZoneSet.C | 308 +++++++++++++ src/meshTools/sets/topoSets/cellZoneSet.H | 173 ++++++++ src/meshTools/sets/topoSets/faceSet.C | 13 + src/meshTools/sets/topoSets/faceSet.H | 9 + src/meshTools/sets/topoSets/faceZoneSet.C | 406 ++++++++++++++++++ src/meshTools/sets/topoSets/faceZoneSet.H | 187 ++++++++ src/meshTools/sets/topoSets/pointSet.C | 13 + src/meshTools/sets/topoSets/pointSet.H | 9 + src/meshTools/sets/topoSets/pointZoneSet.C | 308 +++++++++++++ src/meshTools/sets/topoSets/pointZoneSet.H | 173 ++++++++ src/meshTools/sets/topoSets/topoSet.C | 74 +++- src/meshTools/sets/topoSets/topoSet.H | 36 +- 29 files changed, 3252 insertions(+), 55 deletions(-) create mode 100644 src/meshTools/sets/cellZoneSources/setToCellZone/setToCellZone.C create mode 100644 src/meshTools/sets/cellZoneSources/setToCellZone/setToCellZone.H create mode 100644 src/meshTools/sets/faceZoneSources/faceZoneToFaceZone/faceZoneToFaceZone.C create mode 100644 src/meshTools/sets/faceZoneSources/faceZoneToFaceZone/faceZoneToFaceZone.H create mode 100644 src/meshTools/sets/faceZoneSources/setToFaceZone/setToFaceZone.C create mode 100644 src/meshTools/sets/faceZoneSources/setToFaceZone/setToFaceZone.H create mode 100644 src/meshTools/sets/faceZoneSources/setsToFaceZone/setsToFaceZone.C create mode 100644 src/meshTools/sets/faceZoneSources/setsToFaceZone/setsToFaceZone.H create mode 100644 src/meshTools/sets/pointZoneSources/setToPointZone/setToPointZone.C create mode 100644 src/meshTools/sets/pointZoneSources/setToPointZone/setToPointZone.H create mode 100644 src/meshTools/sets/topoSets/cellZoneSet.C create mode 100644 src/meshTools/sets/topoSets/cellZoneSet.H create mode 100644 src/meshTools/sets/topoSets/faceZoneSet.C create mode 100644 src/meshTools/sets/topoSets/faceZoneSet.H create mode 100644 src/meshTools/sets/topoSets/pointZoneSet.C create mode 100644 src/meshTools/sets/topoSets/pointZoneSet.H diff --git a/applications/utilities/mesh/manipulation/setSet/setSet.C b/applications/utilities/mesh/manipulation/setSet/setSet.C index a1d7a38912..2172dc24ab 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 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 " - << endl << endl + << endl + << endl << "The 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 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 a61d00246e..272f3e067c 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 222d14965f..bbbcf7785e 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 0000000000..5ff8597a86 --- /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 \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(set)) + { + WarningIn + ( + "setToCellZone::applyToSet(const topoSetSource::setAction" + ", topoSet" + ) << "Operation only allowed on a cellZoneSet." << endl; + } + else + { + cellZoneSet& fzSet = refCast(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