1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "splitCell.H"
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 // Construct from cell number and parent
33 Foam::splitCell::splitCell(const label cellI, splitCell* parent)
42 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
44 Foam::splitCell::~splitCell()
46 splitCell* myParent = parent();
50 // Make sure parent does not refer to me anymore.
51 if (myParent->master() == this)
53 myParent->master() = NULL;
55 else if (myParent->slave() == this)
57 myParent->slave() = NULL;
61 FatalErrorIn("splitCell::~splitCell()") << "this not equal to"
62 << " parent's master or slave pointer" << endl
63 << "Cell:" << cellLabel() << abort(FatalError);
69 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
71 bool Foam::splitCell::isMaster() const
73 splitCell* myParent = parent();
77 FatalErrorIn("splitCell::isMaster()") << "parent not set"
78 << "Cell:" << cellLabel() << abort(FatalError);
82 else if (myParent->master() == this)
86 else if (myParent->slave() == this)
92 FatalErrorIn("splitCell::isMaster()") << "this not equal to"
93 << " parent's master or slave pointer" << endl
94 << "Cell:" << cellLabel() << abort(FatalError);
101 bool Foam::splitCell::isUnrefined() const
103 return !master() && !slave();
107 Foam::splitCell* Foam::splitCell::getOther() const
109 splitCell* myParent = parent();
113 FatalErrorIn("splitCell::getOther()") << "parent not set"
114 << "Cell:" << cellLabel() << abort(FatalError);
118 else if (myParent->master() == this)
120 return myParent->slave();
122 else if (myParent->slave() == this)
124 return myParent->master();
128 FatalErrorIn("splitCell::getOther()") << "this not equal to"
129 << " parent's master or slave pointer" << endl
130 << "Cell:" << cellLabel() << abort(FatalError);
137 // ************************************************************************* //