FIX: Update foamPackSource for new SF upload scheme
[freefoam.git] / src / dynamicMesh / meshCut / splitCell / splitCell.C
blob23410f65e356e661c3fff0f634c251608bc79c47
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2010 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
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
19     for more details.
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"
27 #include <OpenFOAM/error.H>
29 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
31 // Construct from cell number and parent
32 Foam::splitCell::splitCell(const label cellI, splitCell* parent)
34     cellI_(cellI),
35     parent_(parent),
36     master_(NULL),
37     slave_(NULL)
41 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
43 Foam::splitCell::~splitCell()
45     splitCell* myParent = parent();
47     if (myParent)
48     {
49         // Make sure parent does not refer to me anymore.
50         if (myParent->master() == this)
51         {
52             myParent->master() = NULL;
53         }
54         else if (myParent->slave() == this)
55         {
56             myParent->slave() = NULL;
57         }
58         else
59         {
60             FatalErrorIn("splitCell::~splitCell()") << "this not equal to"
61                 << " parent's master or slave pointer" << endl
62                 << "Cell:" << cellLabel() << abort(FatalError);
63         }
64     }
68 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
70 bool Foam::splitCell::isMaster() const
72     splitCell* myParent = parent();
74     if (!myParent)
75     {
76         FatalErrorIn("splitCell::isMaster()") << "parent not set"
77             << "Cell:" << cellLabel() << abort(FatalError);
79         return false;
80     }
81     else if (myParent->master() == this)
82     {
83         return true;
84     }
85     else if (myParent->slave() == this)
86     {
87         return false;
88     }
89     else
90     {
91         FatalErrorIn("splitCell::isMaster()") << "this not equal to"
92             << " parent's master or slave pointer" << endl
93             << "Cell:" << cellLabel() << abort(FatalError);
95         return false;
96     }
100 bool Foam::splitCell::isUnrefined() const
102     return !master() && !slave();
106 Foam::splitCell* Foam::splitCell::getOther() const
108     splitCell* myParent = parent();
110     if (!myParent)
111     {
112         FatalErrorIn("splitCell::getOther()") << "parent not set"
113             << "Cell:" << cellLabel() << abort(FatalError);
115         return NULL;
116     }
117     else if (myParent->master() == this)
118     {
119         return myParent->slave();
120     }
121     else if (myParent->slave() == this)
122     {
123         return myParent->master();
124     }
125     else
126     {
127         FatalErrorIn("splitCell::getOther()") << "this not equal to"
128             << " parent's master or slave pointer" << endl
129             << "Cell:" << cellLabel() << abort(FatalError);
131         return NULL;
132     }
136 // ************************ vim: set sw=4 sts=4 et: ************************ //