1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
30 #include "IStringStream.H"
32 #include "octreeDataCell.H"
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 int main(int argc, char *argv[])
42 argList::validArgs.append("point (x y z)");
44 # include "setRootCase.H"
45 # include "createTime.H"
46 # include "createMesh.H"
48 point sample(IStringStream(args.additionalArgs()[0])());
50 treeBoundBox meshBb(mesh.points());
52 // Calculate typical cell releated size to shift bb by.
53 scalar typDim = meshBb.avgDim()/(2.0*Foam::cbrt(scalar(mesh.nCells())));
55 treeBoundBox shiftedBb
58 meshBb.max() + vector(typDim, typDim, typDim)
62 Info<< "Mesh" << endl;
63 Info<< " bounding box : " << meshBb << endl;
64 Info<< " bounding box (shifted) : " << shiftedBb << endl;
65 Info<< " typical dimension : " << shiftedBb.typDim() << endl;
69 * Now we have allBb and shiftedBb
72 // Wrap indices and mesh information into helper object
73 octreeDataCell shapes(mesh);
75 octree<octreeDataCell> oc
77 shiftedBb, // overall bounding box
78 shapes, // all information needed to do checks on cells
80 10.0, // max. size of leaves
81 10.0 // maximum ratio of cubes v.s. cells
84 Info<< "Point:" << sample << " is in shape "
85 << oc.find(sample) << endl;
86 Info<< "Point:" << sample << " is in cell "
87 << mesh.findCell(sample) << endl;
93 Info<< "End\n" << endl;
99 // ************************************************************************* //