1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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/>.
28 Class containing mesh-to-mesh mapping information after a patch change
33 \*---------------------------------------------------------------------------*/
35 #ifndef mapPatchChange_H
36 #define mapPatchChange_H
38 #include "labelList.H"
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 /*---------------------------------------------------------------------------*\
46 Class mapPatchChange Declaration
47 \*---------------------------------------------------------------------------*/
54 const label nOldPatches_;
56 //- Patch mapping array
57 const labelList patchMap_;
63 //- Construct from components
64 mapPatchChange(const label nOldPatches, const labelList& patchMap)
66 nOldPatches_(nOldPatches),
75 //- Number of old patches
76 label nOldPatches() const
81 //- Patch map. Size of current patches.
82 // -1 : patch was added
83 // >=0 : old position of patch
84 // any original patch which is not in the list has been deleted
85 const labelList& patchMap() const
93 //- labels of added patches
94 labelList addedPatches() const
96 labelList added(patchMap_.size());
100 forAll(patchMap_, patchI)
102 if (patchMap_[patchI] == -1)
104 added[addedI++] = patchI;
107 added.setSize(addedI);
111 //- labels (on old mesh) of deleted patches
112 labelList deletedPatches() const
114 labelList oldToNew(nOldPatches_, -1);
116 // Mark all preserved patches
117 forAll(patchMap_, patchI)
119 if (patchMap_[patchI] != -1)
121 oldToNew[patchMap_[patchI]] = patchI;
125 // Extract -1 elements from oldToNew. These are the deleted
129 forAll(oldToNew, oldPatchI)
131 if (oldToNew[oldPatchI] == -1)
133 oldToNew[deletedI++] = oldPatchI;
137 oldToNew.setSize(deletedI);
144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
146 } // End namespace Foam
148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152 // ************************************************************************* //