1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2010 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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "splitCell.H"
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 // Construct from cell number and parent
32 Foam::splitCell::splitCell(const label cellI, splitCell* parent)
41 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
43 Foam::splitCell::~splitCell()
45 splitCell* myParent = parent();
49 // Make sure parent does not refer to me anymore.
50 if (myParent->master() == this)
52 myParent->master() = NULL;
54 else if (myParent->slave() == this)
56 myParent->slave() = NULL;
60 FatalErrorIn("splitCell::~splitCell()") << "this not equal to"
61 << " parent's master or slave pointer" << endl
62 << "Cell:" << cellLabel() << abort(FatalError);
68 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
70 bool Foam::splitCell::isMaster() const
72 splitCell* myParent = parent();
76 FatalErrorIn("splitCell::isMaster()") << "parent not set"
77 << "Cell:" << cellLabel() << abort(FatalError);
81 else if (myParent->master() == this)
85 else if (myParent->slave() == this)
91 FatalErrorIn("splitCell::isMaster()") << "this not equal to"
92 << " parent's master or slave pointer" << endl
93 << "Cell:" << cellLabel() << abort(FatalError);
100 bool Foam::splitCell::isUnrefined() const
102 return !master() && !slave();
106 Foam::splitCell* Foam::splitCell::getOther() const
108 splitCell* myParent = parent();
112 FatalErrorIn("splitCell::getOther()") << "parent not set"
113 << "Cell:" << cellLabel() << abort(FatalError);
117 else if (myParent->master() == this)
119 return myParent->slave();
121 else if (myParent->slave() == this)
123 return myParent->master();
127 FatalErrorIn("splitCell::getOther()") << "this not equal to"
128 << " parent's master or slave pointer" << endl
129 << "Cell:" << cellLabel() << abort(FatalError);
136 // ************************************************************************* //