initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / dynamicMesh / meshCut / splitCell / splitCell.C
blob39176f238d7bdc728e9d2745ec82f9169f70d240
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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"
28 #include "error.H"
30 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
32 // Construct from cell number and parent
33 Foam::splitCell::splitCell(const label cellI, splitCell* parent)
35     cellI_(cellI),
36     parent_(parent),
37     master_(NULL),
38     slave_(NULL)
42 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
44 Foam::splitCell::~splitCell()
46     splitCell* myParent = parent();
48     if (myParent)
49     {
50         // Make sure parent does not refer to me anymore.
51         if (myParent->master() == this)
52         {
53             myParent->master() = NULL;
54         }
55         else if (myParent->slave() == this)
56         {
57             myParent->slave() = NULL;
58         }
59         else
60         {
61             FatalErrorIn("splitCell::~splitCell()") << "this not equal to"
62                 << " parent's master or slave pointer" << endl
63                 << "Cell:" << cellLabel() << abort(FatalError);
64         }
65     }
69 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
71 bool Foam::splitCell::isMaster() const
73     splitCell* myParent = parent();
75     if (!myParent)
76     {
77         FatalErrorIn("splitCell::isMaster()") << "parent not set"
78             << "Cell:" << cellLabel() << abort(FatalError);
80         return false;
81     }
82     else if (myParent->master() == this)
83     {
84         return true;
85     }
86     else if (myParent->slave() == this)
87     {
88         return false;
89     }
90     else
91     {
92         FatalErrorIn("splitCell::isMaster()") << "this not equal to"
93             << " parent's master or slave pointer" << endl
94             << "Cell:" << cellLabel() << abort(FatalError);
96         return false;
97     }
101 bool Foam::splitCell::isUnrefined() const
103     return !master() && !slave();
107 Foam::splitCell* Foam::splitCell::getOther() const
109     splitCell* myParent = parent();
111     if (!myParent)
112     {
113         FatalErrorIn("splitCell::getOther()") << "parent not set"
114             << "Cell:" << cellLabel() << abort(FatalError);
116         return NULL;
117     }
118     else if (myParent->master() == this)
119     {
120         return myParent->slave();
121     }
122     else if (myParent->slave() == this)
123     {
124         return myParent->master();
125     }
126     else
127     {
128         FatalErrorIn("splitCell::getOther()") << "this not equal to"
129             << " parent's master or slave pointer" << endl
130             << "Cell:" << cellLabel() << abort(FatalError);
132         return NULL;
133     }
137 // ************************************************************************* //