1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 Picks up cells with cell centre 'inside' of surface.
26 Requires surface to be closed and singly connected.
28 \*---------------------------------------------------------------------------*/
33 #include "triSurface.H"
34 #include "triSurfaceSearch.H"
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 int main(int argc, char *argv[])
47 "Create a cellSet for cells with their centres inside the defined "
49 "Surface must be closed and singly connected."
52 argList::noParallel();
53 argList::validArgs.append("surfaceFile");
54 argList::validArgs.append("cellSet");
56 # include "setRootCase.H"
57 # include "createTime.H"
58 # include "createPolyMesh.H"
60 const fileName surfName = args[1];
61 const fileName setName = args[2];
64 Info<< "Reading surface from " << surfName << endl;
65 triSurface surf(surfName);
67 // Destination cellSet.
68 cellSet insideCells(mesh, setName, IOobject::NO_READ);
71 // Construct search engine on surface
72 triSurfaceSearch querySurf(surf);
74 boolList inside(querySurf.calcInside(mesh.cellCentres()));
80 insideCells.insert(cellI);
85 Info<< "Selected " << insideCells.size() << " of " << mesh.nCells()
86 << " cells" << nl << nl
87 << "Writing selected cells to cellSet " << insideCells.name()
89 << "Use this cellSet e.g. with subsetMesh : " << nl << nl
90 << " subsetMesh " << insideCells.name()
95 Info<< "End\n" << endl;
101 // ************************************************************************* //