/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | foam-extend: Open Source CFD \\ / O peration | Version: 4.0 \\ / A nd | Web: http://www.foam-extend.org \\/ M anipulation | For copyright notice see file Copyright ------------------------------------------------------------------------------- License This file is part of foam-extend. foam-extend 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 3 of the License, or (at your option) any later version. foam-extend 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 foam-extend. If not, see . Description Manipulate a cell/face/point set interactively. \*---------------------------------------------------------------------------*/ #include "argList.H" #include "objectRegistry.H" #include "foamTime.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 FOAM 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 foam cellID as value Map