OpenFOAM logo
Open Source CFD Toolkit

treeNodeI.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2005 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Description
00026 
00027 \*---------------------------------------------------------------------------*/
00028 
00029 
00030 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00031 
00032 namespace Foam
00033 {
00034 
00035 
00036 // Get type of octant
00037 template <class Type>
00038 inline label treeNode<Type>::getVolType(const label octant) const
00039 {
00040     return (volType_ >> 2*octant) & 0x3;
00041 }
00042 
00043 
00044 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00045 
00046 template <class Type>
00047 inline const point& treeNode<Type>::mid() const
00048 {
00049     return mid_;
00050 }
00051 
00052 template <class Type>
00053 inline treeElem<Type>* const* treeNode<Type>::subNodes() const
00054 {
00055     return subNodes_;
00056 }
00057 
00058 // octant contains pointer to treeNode(1) or treeLeaf(0)
00059 template <class Type>
00060 inline label treeNode<Type>::isNode(const label octant) const
00061 {
00062     return subNodeTypes_ & (0x1 << octant);
00063 }
00064 
00065 // Get pointer to sub node
00066 template <class Type>
00067 inline treeNode<Type>* treeNode<Type>::getNodePtr(const label octant) const
00068 {
00069 #   ifdef FULLDEBUG
00070     if (!isNode(octant))
00071     {
00072         FatalErrorIn("treeNode::getNodePtr(const label)")
00073             << "not a treeNode"
00074             << abort(FatalError);
00075     }
00076 #   endif
00077 
00078     return static_cast<treeNode<Type>*>(subNodes_[octant]);
00079 }
00080 
00081 
00082 // Get pointer to sub leaf
00083 template <class Type>
00084 inline treeLeaf<Type>* treeNode<Type>::getLeafPtr(const label octant) const
00085 {
00086 #   ifdef FULLDEBUG
00087     if (isNode(octant))
00088     {
00089         FatalErrorIn("treeNode::getLeafPtr(const label)")
00090             << "not a treeLeaf"
00091             << abort(FatalError);
00092     }
00093 #   endif
00094 
00095     return static_cast<treeLeaf<Type>*>(subNodes_[octant]);
00096 }
00097 
00098 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00099 
00100 } // End namespace Foam
00101 
00102 // ************************************************************************* //
For further information go to www.openfoam.org