ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / OpenFOAM / meshes / polyMesh / mapPolyMesh / mapPatchChange / mapPatchChange.H
blob529e3f91b6e31ad9805a0ce839674c5115d907ce
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
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 Class
25     Foam::mapPatchChange
27 Description
28     Class containing mesh-to-mesh mapping information after a patch change
29     operation.
31 SourceFiles
33 \*---------------------------------------------------------------------------*/
35 #ifndef mapPatchChange_H
36 #define mapPatchChange_H
38 #include "labelList.H"
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 namespace Foam
45 /*---------------------------------------------------------------------------*\
46                            Class mapPatchChange Declaration
47 \*---------------------------------------------------------------------------*/
49 class mapPatchChange
51     // Private data
53         //- Old patches
54         const label nOldPatches_;
56         //- Patch mapping array
57         const labelList patchMap_;
59 public:
61     // Constructors
63         //- Construct from components
64         mapPatchChange(const label nOldPatches, const labelList& patchMap)
65         :
66             nOldPatches_(nOldPatches),
67             patchMap_(patchMap)
68         {}
71     // Member Functions
73         // Access
75             //- Number of old patches
76             label nOldPatches() const
77             {
78                 return nOldPatches_;
79             }
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
86             {
87                 return patchMap_;
88             }
91         // Utility functions
93             //- labels of added patches
94             labelList addedPatches() const
95             {
96                 labelList added(patchMap_.size());
98                 label addedI = 0;
100                 forAll(patchMap_, patchI)
101                 {
102                     if (patchMap_[patchI] == -1)
103                     {
104                         added[addedI++] = patchI;
105                     }
106                 }
107                 added.setSize(addedI);
108                 return added;
109             }
111             //- labels (on old mesh) of deleted patches
112             labelList deletedPatches() const
113             {
114                 labelList oldToNew(nOldPatches_, -1);
116                 // Mark all preserved patches
117                 forAll(patchMap_, patchI)
118                 {
119                     if (patchMap_[patchI] != -1)
120                     {
121                         oldToNew[patchMap_[patchI]] = patchI;
122                     }
123                 }
125                 // Extract -1 elements from oldToNew. These are the deleted
126                 // patches.
127                 label deletedI = 0;
129                 forAll(oldToNew, oldPatchI)
130                 {
131                     if (oldToNew[oldPatchI] == -1)
132                     {
133                         oldToNew[deletedI++] = oldPatchI;
134                     }
135                 }
137                 oldToNew.setSize(deletedI);
139                 return oldToNew;
140             }
144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
146 } // End namespace Foam
148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
150 #endif
152 // ************************************************************************* //