polyMeshAdder.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 Class
25  Foam::polyMeshAdder
26 
27 Description
28  Adds two meshes without using any polyMesh morphing.
29 
30  Gets faces to couple as faceCoupleInfo which is list of faces on both
31  meshes. Returns map from last mesh addition.
32 
33 SourceFiles
34  polyMeshAdder.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef polyMeshAdder_H
39 #define polyMeshAdder_H
40 
41 #include "autoPtr.H"
42 #include "polyMesh.H"
43 #include "mapAddedPolyMesh.H"
44 #include "faceCoupleInfo.H"
45 #include "SortableList.H"
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 // Forward declaration of classes
53 class IOobject;
54 class polyTopoChange;
55 
56 /*---------------------------------------------------------------------------*\
57  Class polyMeshAdder Declaration
58 \*---------------------------------------------------------------------------*/
59 
60 class polyMeshAdder
61 {
62 private:
63 
64  // Private Member Functions
65 
66  //- Index of patch in allPatches. Add if nonexisting.
67  static label patchIndex
68  (
69  const polyPatch&,
70  DynamicList<word>& allPatchNames,
71  DynamicList<word>& allPatchTypes
72  );
73 
74  //- Index of zone in all zones
75  static label zoneIndex(const word&, DynamicList<word>&);
76 
77  //- ...
78  static void mergePatchNames
79  (
80  const polyBoundaryMesh& patches0,
81  const polyBoundaryMesh& patches1,
82  DynamicList<word>& allPatchNames,
83  DynamicList<word>& allPatchTypes,
84  labelList& from1ToAllPatches,
85  labelList& fromAllTo1Patches
86  );
87 
88  //- Get starts of patches
89  static labelList getPatchStarts(const polyBoundaryMesh&);
90 
91  //- Get sizes of patches
92  static labelList getPatchSizes(const polyBoundaryMesh&);
93 
94  //- Determine order for internalFaces to be upper-triangular.
95  // Does not change order of external faces.
96  static labelList getFaceOrder
97  (
98  const cellList& cells,
99  const label nInternalFaces,
100  const labelList& owner,
101  const labelList& neighbour
102  );
103 
104  //- Merges primitives of two meshes.
105  static void mergePrimitives
106  (
107  const polyMesh& mesh0,
108  const polyMesh& mesh1,
109  const faceCoupleInfo& coupleInfo,
110 
111  const label nAllPatches,
112  const labelList& fromAllTo1Patches,
113  const labelList& from1ToAllPatches,
114 
115  pointField& allPoints,
116  labelList& from0ToAllPoints,
117  labelList& from1ToAllPoints,
118 
119  faceList& allFaces,
120  labelList& allOwner,
121  labelList& allNeighbour,
122  label& nInternalFaces,
123  labelList& nFacesPerPatch,
124  label& nCells,
125 
126  labelList& from0ToAllFaces,
127  labelList& from1ToAllFaces,
128  labelList& from1ToAllCells
129  );
130 
131  //- Merge point zones
132  static void mergePointZones
133  (
134  const label nAllPoints,
135 
136  const meshPointZones& pz0,
137  const meshPointZones& pz1,
138  const labelList& from0ToAllPoints,
139  const labelList& from1ToAllPoints,
140 
141  DynamicList<word>& zoneNames,
142  labelList& from1ToAll,
143  List<DynamicList<label>>& pzPoints
144  );
145 
146  //- Merge face zones
147  static void mergeFaceZones
148  (
149  const labelList& allOwner,
150 
151  const polyMesh& mesh0,
152  const polyMesh& mesh1,
153  const labelList& from0ToAllFaces,
154  const labelList& from1ToAllFaces,
155  const labelList& from1ToAllCells,
156 
157  DynamicList<word>& zoneNames,
158  labelList& from1ToAll,
159  List<DynamicList<label>>& fzFaces,
160  List<DynamicList<bool>>& fzFlips
161  );
162 
163  //- Merge cell zones
164  static void mergeCellZones
165  (
166  const label nAllCells,
167 
168  const meshCellZones& cz0,
169  const meshCellZones& cz1,
170  const labelList& from1ToAllCells,
171 
172  DynamicList<word>& zoneNames,
173  labelList& from1ToAll,
174  List<DynamicList<label>>& czCells
175  );
176 
177  //- Merge point/face/cell zone information
178  static void mergeZones
179  (
180  const label nAllPoints,
181  const labelList& allOwner,
182  const label nAllCells,
183 
184  const polyMesh& mesh0,
185  const polyMesh& mesh1,
186  const labelList& from0ToAllPoints,
187  const labelList& from0ToAllFaces,
188  const labelList& from1ToAllPoints,
189  const labelList& from1ToAllFaces,
190  const labelList& from1ToAllCells,
191 
192  DynamicList<word>& pointZoneNames,
193  List<DynamicList<label>>& pzPoints,
194 
195  DynamicList<word>& faceZoneNames,
196  List<DynamicList<label>>& fzFaces,
197  List<DynamicList<bool>>& fzFlips,
198 
199  DynamicList<word>& cellZoneNames,
200  List<DynamicList<label>>& czCells
201  );
202 
203  //- Create new zones and add to new mesh.
204  static void addZones
205  (
206  const DynamicList<word>& pointZoneNames,
207  const List<DynamicList<label>>& pzPoints,
208 
209  const DynamicList<word>& faceZoneNames,
210  const List<DynamicList<label>>& fzFaces,
211  const List<DynamicList<bool>>& fzFlips,
212 
213  const DynamicList<word>& cellZoneNames,
214  const List<DynamicList<label>>& czCells,
215 
216  polyMesh& mesh
217  );
218 
219 
220 public:
221 
222  // Member Functions
223 
224  //- Inplace add mesh to polyMesh. Returns map construct.
226  (
227  polyMesh& mesh0,
228  const polyMesh& mesh1,
229  const faceCoupleInfo& coupleInfo,
230  const bool validBoundary = true
231  );
232 };
233 
234 
235 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
236 
237 } // End namespace Foam
238 
239 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
240 
241 #endif
242 
243 // ************************************************************************* //
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
Container for information needed to couple to meshes. When constructed from two meshes and a list of ...
Foam::polyBoundaryMesh.
Adds two meshes without using any polyMesh morphing.
Definition: polyMeshAdder.H:60
static autoPtr< mapAddedPolyMesh > add(polyMesh &mesh0, const polyMesh &mesh1, const faceCoupleInfo &coupleInfo, const bool validBoundary=true)
Inplace add mesh to polyMesh. Returns map construct.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:70
A class for handling words, derived from string.
Definition: word.H:62
const cellShapeList & cells
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59