1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 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
29 Class containing mesh-to-mesh mapping information after a patch change
34 \*---------------------------------------------------------------------------*/
36 #ifndef mapPatchChange_H
37 #define mapPatchChange_H
39 #include "labelList.H"
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 /*---------------------------------------------------------------------------*\
47 Class mapPatchChange Declaration
48 \*---------------------------------------------------------------------------*/
55 const label nOldPatches_;
57 //- Patch mapping array
58 const labelList patchMap_;
64 //- Construct from components
65 mapPatchChange(const label nOldPatches, const labelList& patchMap)
67 nOldPatches_(nOldPatches),
76 //- Number of old patches
77 label nOldPatches() const
82 //- Patch map. Size of current patches.
83 // -1 : patch was added
84 // >=0 : old position of patch
85 // any original patch which is not in the list has been deleted
86 const labelList& patchMap() const
94 //- labels of added patches
95 labelList addedPatches() const
97 labelList added(patchMap_.size());
101 forAll(patchMap_, patchI)
103 if (patchMap_[patchI] == -1)
105 added[addedI++] = patchI;
108 added.setSize(addedI);
112 //- labels (on old mesh) of deleted patches
113 labelList deletedPatches() const
115 labelList oldToNew(nOldPatches_, -1);
117 // Mark all preserved patches
118 forAll(patchMap_, patchI)
120 if (patchMap_[patchI] != -1)
122 oldToNew[patchMap_[patchI]] = patchI;
126 // Extract -1 elements from oldToNew. These are the deleted
130 forAll(oldToNew, oldPatchI)
132 if (oldToNew[oldPatchI] == -1)
134 oldToNew[deletedI++] = oldPatchI;
138 oldToNew.setSize(deletedI);
145 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
147 } // End namespace Foam
149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 // ************************************************************************* //