OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

splitCell.C

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-2009 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 \*---------------------------------------------------------------------------*/
00026 
00027 #include "splitCell.H"
00028 #include "error.H"
00029 
00030 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00031 
00032 // Construct from cell number and parent
00033 Foam::splitCell::splitCell(const label cellI, splitCell* parent)
00034 :
00035     cellI_(cellI),
00036     parent_(parent),
00037     master_(NULL),
00038     slave_(NULL)
00039 {}
00040 
00041 
00042 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00043 
00044 Foam::splitCell::~splitCell()
00045 {
00046     splitCell* myParent = parent();
00047 
00048     if (myParent)
00049     {
00050         // Make sure parent does not refer to me anymore.
00051         if (myParent->master() == this)
00052         {
00053             myParent->master() = NULL;
00054         }
00055         else if (myParent->slave() == this)
00056         {
00057             myParent->slave() = NULL;
00058         }
00059         else
00060         {
00061             FatalErrorIn("splitCell::~splitCell()") << "this not equal to"
00062                 << " parent's master or slave pointer" << endl
00063                 << "Cell:" << cellLabel() << abort(FatalError);
00064         }
00065     }
00066 }
00067 
00068 
00069 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00070 
00071 bool Foam::splitCell::isMaster() const
00072 {
00073     splitCell* myParent = parent();
00074 
00075     if (!myParent)
00076     {
00077         FatalErrorIn("splitCell::isMaster()") << "parent not set"
00078             << "Cell:" << cellLabel() << abort(FatalError);
00079 
00080         return false;
00081     }
00082     else if (myParent->master() == this)
00083     {
00084         return true;
00085     }
00086     else if (myParent->slave() == this)
00087     {
00088         return false;
00089     }
00090     else
00091     {
00092         FatalErrorIn("splitCell::isMaster()") << "this not equal to"
00093             << " parent's master or slave pointer" << endl
00094             << "Cell:" << cellLabel() << abort(FatalError);
00095 
00096         return false;
00097     }
00098 }
00099 
00100 
00101 bool Foam::splitCell::isUnrefined() const
00102 {
00103     return !master() && !slave();
00104 }
00105 
00106 
00107 Foam::splitCell* Foam::splitCell::getOther() const
00108 {
00109     splitCell* myParent = parent();
00110 
00111     if (!myParent)
00112     {
00113         FatalErrorIn("splitCell::getOther()") << "parent not set"
00114             << "Cell:" << cellLabel() << abort(FatalError);
00115 
00116         return NULL;
00117     }
00118     else if (myParent->master() == this)
00119     {
00120         return myParent->slave();
00121     }
00122     else if (myParent->slave() == this)
00123     {
00124         return myParent->master();
00125     }
00126     else
00127     {
00128         FatalErrorIn("splitCell::getOther()") << "this not equal to"
00129             << " parent's master or slave pointer" << endl
00130             << "Cell:" << cellLabel() << abort(FatalError);
00131 
00132         return NULL;
00133     }
00134 }
00135 
00136 
00137 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd