FreeFOAM The Cross-Platform CFD Toolkit
treeNodeI.H
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) 1991-2010 OpenCFD Ltd.
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 Description
25 
26 \*---------------------------------------------------------------------------*/
27 
28 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
29 
30 // Get type of octant
31 template <class Type>
32 inline Foam::label Foam::treeNode<Type>::getVolType(const label octant) const
33 {
34  return (volType_ >> 2*octant) & 0x3;
35 }
36 
37 
38 template <class Type>
40 {
41  return mid_;
42 }
43 
44 
45 template <class Type>
47 {
48  return subNodes_;
49 }
50 
51 
52 // octant contains pointer to treeNode(1) or treeLeaf(0)
53 template <class Type>
54 inline Foam::label Foam::treeNode<Type>::isNode(const label octant) const
55 {
56  return subNodeTypes_ & (0x1 << octant);
57 }
58 
59 
60 // Get pointer to sub node
61 template <class Type>
63 (
64  const label octant
65 ) const
66 {
67 # ifdef FULLDEBUG
68  if (!isNode(octant))
69  {
70  FatalErrorIn("treeNode::getNodePtr(const label)")
71  << "not a treeNode"
72  << abort(FatalError);
73  }
74 # endif
75 
76  return static_cast<treeNode<Type>*>(subNodes_[octant]);
77 }
78 
79 
80 // Get pointer to sub leaf
81 template <class Type>
83 (
84  const label octant
85 ) const
86 {
87 # ifdef FULLDEBUG
88  if (isNode(octant))
89  {
90  FatalErrorIn("treeNode::getLeafPtr(const label)")
91  << "not a treeLeaf"
92  << abort(FatalError);
93  }
94 # endif
95 
96  return static_cast<treeLeaf<Type>*>(subNodes_[octant]);
97 }
98 
99 
100 // ************************ vim: set sw=4 sts=4 et: ************************ //