1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
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/>.
24 \*---------------------------------------------------------------------------*/
29 #include "IStringStream.H"
31 #include "octreeDataCell.H"
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 int main(int argc, char *argv[])
41 argList::validArgs.append("point (x y z)");
43 # include "setRootCase.H"
44 # include "createTime.H"
45 # include "createMesh.H"
47 point sample(IStringStream(args.additionalArgs()[0])());
49 treeBoundBox meshBb(mesh.points());
51 // Calculate typical cell releated size to shift bb by.
52 scalar typDim = meshBb.avgDim()/(2.0*Foam::cbrt(scalar(mesh.nCells())));
54 treeBoundBox shiftedBb
57 meshBb.max() + vector(typDim, typDim, typDim)
61 Info<< "Mesh" << endl;
62 Info<< " bounding box : " << meshBb << endl;
63 Info<< " bounding box (shifted) : " << shiftedBb << endl;
64 Info<< " typical dimension : " << shiftedBb.typDim() << endl;
68 * Now we have allBb and shiftedBb
71 // Wrap indices and mesh information into helper object
72 octreeDataCell shapes(mesh);
74 octree<octreeDataCell> oc
76 shiftedBb, // overall bounding box
77 shapes, // all information needed to do checks on cells
79 10.0, // max. size of leaves
80 10.0 // maximum ratio of cubes v.s. cells
83 Info<< "Point:" << sample << " is in shape "
84 << oc.find(sample) << endl;
85 Info<< "Point:" << sample << " is in cell "
86 << mesh.findCell(sample) << endl;
92 Info<< "End\n" << endl;
98 // ************************************************************************* //