/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright held by original author \\/ 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 Description Manipulate a cell/face/point set interactively. \*---------------------------------------------------------------------------*/ #include "argList.H" #include "objectRegistry.H" #include "Time.H" #include "polyMesh.H" #include "globalMeshData.H" #include "IStringStream.H" #include "cellSet.H" #include "faceSet.H" #include "pointSet.H" #include "topoSetSource.H" #include "OFstream.H" #include "IFstream.H" #include "demandDrivenData.H" #include "writePatch.H" #include "writePointSet.H" #include "IOobjectList.H" #include #if READLINE != 0 #include #include #endif using namespace Foam; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #if READLINE != 0 static const char* historyFile = ".setSet"; #endif Istream& selectStream(Istream* is0Ptr, Istream* is1Ptr) { if (is0Ptr) { return *is0Ptr; } else if (is1Ptr) { return *is1Ptr; } else { FatalErrorIn("selectStream(Istream*, Istream*)") << "No valid stream opened" << abort(FatalError); return *is0Ptr; } } // Copy set void backup ( const polyMesh& mesh, const word& fromName, const topoSet& fromSet, const word& toName ) { if (fromSet.size()) { Info<< " Backing up " << fromName << " into " << toName << endl; topoSet::New(mesh, toName, fromSet)().write(); } } // Read and copy set void backup ( const word& setType, const polyMesh& mesh, const word& fromName, const word& toName ) { autoPtr fromSet = topoSet::New ( setType, mesh, fromName, IOobject::READ_IF_PRESENT ); backup(mesh, fromName, fromSet(), toName); } // Write set to VTK readable files void writeVTK ( const polyMesh& mesh, const topoSet& currentSet, const fileName& vtkName ) { if (isA(currentSet)) { // Faces of set with OpenFOAM faceID as value faceList setFaces(currentSet.size()); labelList faceValues(currentSet.size()); label setFaceI = 0; forAllConstIter(topoSet, currentSet, iter) { setFaces[setFaceI] = mesh.faces()[iter.key()]; faceValues[setFaceI] = iter.key(); setFaceI++; } primitiveFacePatch fp(setFaces, mesh.points()); writePatch ( true, currentSet.name(), fp, "faceID", faceValues, mesh.time().path()/vtkName ); } else if (isA(currentSet)) { // External faces of cellset with OpenFOAM cellID as value Map