The open source CFD toolbox
mapPatchChange.H
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2016 OpenFOAM Foundation
9-------------------------------------------------------------------------------
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26Class
27 Foam::mapPatchChange
28
29Description
30 Class containing mesh-to-mesh mapping information after a patch change
31 operation.
32
33SourceFiles
34
35\*---------------------------------------------------------------------------*/
36
37#ifndef mapPatchChange_H
38#define mapPatchChange_H
39
40#include "labelList.H"
41
42// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43
44namespace Foam
45{
46
47/*---------------------------------------------------------------------------*\
48 Class mapPatchChange Declaration
49\*---------------------------------------------------------------------------*/
52{
53 // Private data
54
55 //- Old patches
56 const label nOldPatches_;
57
58 //- Patch mapping array
59 const labelList patchMap_;
60
61public:
62
63 // Constructors
64
65 //- Construct from components
66 mapPatchChange(const label nOldPatches, const labelList& patchMap)
67 :
68 nOldPatches_(nOldPatches),
69 patchMap_(patchMap)
70 {}
71
72
73 // Member Functions
74
75 // Access
76
77 //- Number of old patches
78 label nOldPatches() const
79 {
80 return nOldPatches_;
81 }
82
83 //- Patch map. Size of current patches.
84 // -1 : patch was added
85 // >=0 : old position of patch
86 // any original patch which is not in the list has been deleted
87 const labelList& patchMap() const
88 {
89 return patchMap_;
90 }
91
92
93 // Utility functions
94
95 //- Labels of added patches
97 {
99
101
102 forAll(patchMap_, patchi)
103 {
104 if (patchMap_[patchi] == -1)
105 {
107 }
108 }
111 }
112
113 //- Labels (on old mesh) of deleted patches
115 {
116 labelList oldToNew(nOldPatches_, -1);
117
118 // Mark all preserved patches
119 forAll(patchMap_, patchi)
120 {
121 if (patchMap_[patchi] != -1)
122 {
123 oldToNew[patchMap_[patchi]] = patchi;
124 }
125 }
126
127 // Extract -1 elements from oldToNew. These are the deleted
128 // patches.
129 label deletedI = 0;
130
131 forAll(oldToNew, oldPatchi)
132 {
133 if (oldToNew[oldPatchi] == -1)
134 {
135 oldToNew[deletedI++] = oldPatchi;
136 }
137 }
138
139 oldToNew.setSize(deletedI);
140
141 return oldToNew;
142 }
143};
144
145
146// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
147
148} // End namespace Foam
149
150// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151
152#endif
153
154// ************************************************************************* //
void setSize(const label n)
Alias for resize()
Definition: List.H:218
void size(const label n)
Definition: UList.H:114
Class containing mesh-to-mesh mapping information after a patch change operation.
labelList deletedPatches() const
Labels (on old mesh) of deleted patches.
label nOldPatches() const
Number of old patches.
const labelList & patchMap() const
Patch map. Size of current patches.
mapPatchChange(const label nOldPatches, const labelList &patchMap)
Construct from components.