FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 Description
00025 
00026 \*---------------------------------------------------------------------------*/
00027 
00028 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00029 
00030 // Get type of octant
00031 template <class Type>
00032 inline Foam::label Foam::treeNode<Type>::getVolType(const label octant) const
00033 {
00034     return (volType_ >> 2*octant) & 0x3;
00035 }
00036 
00037 
00038 template <class Type>
00039 inline const Foam::point& Foam::treeNode<Type>::midpoint() const
00040 {
00041     return mid_;
00042 }
00043 
00044 
00045 template <class Type>
00046 inline Foam::treeElem<Type>* const* Foam::treeNode<Type>::subNodes() const
00047 {
00048     return subNodes_;
00049 }
00050 
00051 
00052 // octant contains pointer to treeNode(1) or treeLeaf(0)
00053 template <class Type>
00054 inline Foam::label Foam::treeNode<Type>::isNode(const label octant) const
00055 {
00056     return subNodeTypes_ & (0x1 << octant);
00057 }
00058 
00059 
00060 // Get pointer to sub node
00061 template <class Type>
00062 inline Foam::treeNode<Type>* Foam::treeNode<Type>::getNodePtr
00063 (
00064     const label octant
00065 ) const
00066 {
00067 #   ifdef FULLDEBUG
00068     if (!isNode(octant))
00069     {
00070         FatalErrorIn("treeNode::getNodePtr(const label)")
00071             << "not a treeNode"
00072             << abort(FatalError);
00073     }
00074 #   endif
00075 
00076     return static_cast<treeNode<Type>*>(subNodes_[octant]);
00077 }
00078 
00079 
00080 // Get pointer to sub leaf
00081 template <class Type>
00082 inline Foam::treeLeaf<Type>* Foam::treeNode<Type>::getLeafPtr
00083 (
00084     const label octant
00085 ) const
00086 {
00087 #   ifdef FULLDEBUG
00088     if (isNode(octant))
00089     {
00090         FatalErrorIn("treeNode::getLeafPtr(const label)")
00091             << "not a treeLeaf"
00092             << abort(FatalError);
00093     }
00094 #   endif
00095 
00096     return static_cast<treeLeaf<Type>*>(subNodes_[octant]);
00097 }
00098 
00099 
00100 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines