Test-findSphereFeatureEdges-octree.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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
19  for more details.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "argList.H"
27 #include "Time.H"
28 #include "fvMesh.H"
29 #include "IStringStream.H"
30 #include "indexedOctree.H"
31 #include "treeDataEdge.H"
32 #include "OFstream.H"
34 
35 using namespace Foam;
36 
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 // Main program:
39 
40 int main(int argc, char *argv[])
41 {
42 
43  #include "setRootCase.H"
44  #include "createTime.H"
45  #include "createMesh.H"
46 
47  fileName sFeatFileName("unit_cube_rotated.extendedFeatureEdgeMesh");
48 
50  (
51  IOobject
52  (
53  sFeatFileName,
54  runTime.time().constant(),
55  "extendedFeatureEdgeMesh",
56  runTime.time(),
59  )
60  );
61 
62  // Slightly extended bb. Slightly off-centred just so on symmetric
63  // geometry there are less face/edge aligned items.
64  treeBoundBox bb
65  (
66  efem.points()
67  );
68 
69  bb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
70  bb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
71 
72  labelList allEdges(identity(efem.edges().size()));
73 
75  (
77  (
78  false, // cachebb
79  efem.edges(), // edges
80  efem.points(), // points
81  allEdges // selected edges
82  ),
83  bb, // bb
84  8, // maxLevel
85  10, // leafsize
86  3.0 // duplicity
87  );
88 
89  Info<< "Points: " << efem.points() << nl << endl;
90  Info<< "Edges: " << efem.edges() << nl << endl;
91 
92  Info<< "Find edge labels within sphere from point (0, 0, 0):" << endl;
93 
94  Info<< " Radius = 0 : "
95  << edgeTree.findSphere(point(0, 0, 0), 0) << endl;
96 
97  Info<< " Radius = 1 : "
98  << edgeTree.findSphere(point(0, 0, 0), 1) << endl;
99 
100  Info<< " Radius = root(1.5) : "
101  << edgeTree.findSphere(point(0, 0, 0), 1.5) << endl;
102 
103  Info<< " Radius = root(2) : "
104  << edgeTree.findSphere(point(0, 0, 0), 2) << endl;
105 
106  Info<< " Radius = root(0.5) : "
107  << edgeTree.findSphere(point(1, 0, 0), 0.5) << endl;
108 
109  Info<< " Radius = root(0.25) : "
110  << edgeTree.findSphere(point(0, 0, 0.5), 0.25) << endl;
111 
112  treeBoundBox tbb(point(0,0,0), point(0.1,0.1,0.1));
113  Info<< " Box = " << tbb << " : "
114  << edgeTree.findBox(tbb) << endl;
115 
116  treeBoundBox tbb1(point(0,0,0), point(1,1,0.1));
117  Info<< " Box = " << tbb1 << " : "
118  << edgeTree.findBox(tbb1) << endl;
119 
120  treeBoundBox tbb2(point(0.3,0,0), point(1,0.3,1));
121  Info<< " Box = " << tbb2 << " : "
122  << edgeTree.findBox(tbb2) << endl;
123 
124  treeBoundBox tbb3(point(-0.2,0.5,0), point(0.3,0.9,1));
125  Info<< " Box = " << tbb3 << " : "
126  << edgeTree.findBox(tbb3) << endl;
127 
128  Info<< "End\n" << endl;
129 
130  return 0;
131 }
132 
133 
134 // ************************************************************************* //
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::boundBox::max
const point & max() const
Maximum describing the bounding box.
Definition: boundBoxI.H:60
Foam::treeBoundBox
Standard boundBox + extra functionality for use in octree.
Definition: treeBoundBox.H:75
indexedOctree.H
Foam::IOobject::MUST_READ
@ MUST_READ
Definition: IOobject.H:108
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
main
int main(int argc, char *argv[])
Definition: Test-findSphereFeatureEdges-octree.C:40
extendedFeatureEdgeMesh.H
Foam::IOobject::NO_WRITE
@ NO_WRITE
Definition: IOobject.H:118
IStringStream.H
OFstream.H
Foam::indexedOctree::findBox
void findBox(const label nodeI, const treeBoundBox &searchBox, labelHashSet &elements) const
Find all elements intersecting box.
Definition: indexedOctree.C:1994
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
argList.H
Foam::edgeMesh::points
const pointField & points() const
Return points.
Definition: edgeMeshI.H:39
Foam::indexedOctree
Non-pointer based hierarchical recursive searching.
Definition: treeDataTriSurface.H:47
Foam::treeDataEdge
Holds data for octree to work on an edges subset.
Definition: treeDataEdge.H:53
Foam::boundBox::min
const point & min() const
Minimum describing the bounding box.
Definition: boundBoxI.H:54
Foam::edgeMesh::edges
const edgeList & edges() const
Return edges.
Definition: edgeMeshI.H:45
Foam::identity
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
Definition: ListOps.C:104
treeDataEdge.H
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
setRootCase.H
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
createMesh.H
createTime.H
Foam::extendedFeatureEdgeMesh
extendedEdgeMesh + IO.
Definition: extendedFeatureEdgeMesh.H:52
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::point
vector point
Point is a vector.
Definition: point.H:41
Foam::indexedOctree::findSphere
void findSphere(const label nodeI, const point &centre, const scalar radiusSqr, labelHashSet &elements) const
Find all elements intersecting sphere.
Definition: indexedOctree.C:2041