00001 /*---------------------------------------------------------------------------*\ 00002 ========= | 00003 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox 00004 \\ / O peration | 00005 \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. 00006 \\/ M anipulation | 00007 ------------------------------------------------------------------------------- 00008 License 00009 This file is part of OpenFOAM. 00010 00011 OpenFOAM is free software: you can redistribute it and/or modify it 00012 under the terms of the GNU General Public License as published by 00013 the Free Software Foundation, either version 3 of the License, or 00014 (at your option) any later version. 00015 00016 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT 00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00018 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 00019 for more details. 00020 00021 You should have received a copy of the GNU General Public License 00022 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. 00023 00024 Application 00025 insideCells 00026 00027 Description 00028 Picks up cells with cell centre 'inside' of surface. 00029 00030 Requires surface to be closed and singly connected. 00031 00032 Usage 00033 00034 - insideCells [OPTIONS] <Foam surface file> <cellSet name> 00035 00036 @param <Foam surface file> \n 00037 @todo Detailed description of argument. 00038 00039 @param <cellSet name> \n 00040 @todo Detailed description of argument. 00041 00042 @param -case <dir>\n 00043 Case directory. 00044 00045 @param -help \n 00046 Display help message. 00047 00048 @param -doc \n 00049 Display Doxygen API documentation page for this application. 00050 00051 @param -srcDoc \n 00052 Display Doxygen source documentation page for this application. 00053 00054 \*---------------------------------------------------------------------------*/ 00055 00056 #include <OpenFOAM/argList.H> 00057 #include <OpenFOAM/Time.H> 00058 #include <OpenFOAM/polyMesh.H> 00059 #include <triSurface/triSurface.H> 00060 #include <meshTools/triSurfaceSearch.H> 00061 #include <meshTools/cellSet.H> 00062 00063 using namespace Foam; 00064 00065 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // 00066 00067 // Main program: 00068 00069 int main(int argc, char *argv[]) 00070 { 00071 Foam::argList::noParallel(); 00072 Foam::argList::validArgs.append("surface file"); 00073 Foam::argList::validArgs.append("destination cellSet"); 00074 00075 # include <OpenFOAM/setRootCase.H> 00076 # include <OpenFOAM/createTime.H> 00077 # include <OpenFOAM/createPolyMesh.H> 00078 00079 fileName surfName(args.additionalArgs()[0]); 00080 00081 fileName setName(args.additionalArgs()[1]); 00082 00083 00084 // Read surface 00085 Info<< "Reading surface from " << surfName << endl; 00086 triSurface surf(surfName); 00087 00088 // Destination cellSet. 00089 cellSet insideCells(mesh, setName, IOobject::NO_READ); 00090 00091 00092 // Construct search engine on surface 00093 triSurfaceSearch querySurf(surf); 00094 00095 boolList inside(querySurf.calcInside(mesh.cellCentres())); 00096 00097 forAll(inside, cellI) 00098 { 00099 if (inside[cellI]) 00100 { 00101 insideCells.insert(cellI); 00102 } 00103 } 00104 00105 00106 Info<< "Selected " << insideCells.size() 00107 << " cells out of " << mesh.nCells() << endl 00108 << endl 00109 << "Writing selected cells to cellSet " << insideCells.name() 00110 << endl << endl 00111 << "Use this cellSet e.g. with subsetMesh : " << endl << endl 00112 << " subsetMesh <root> <case> " << insideCells.name() 00113 << endl << endl; 00114 00115 insideCells.write(); 00116 00117 Info << "End\n" << endl; 00118 00119 return 0; 00120 } 00121 00122 00123 // ************************ vim: set sw=4 sts=4 et: ************************ //