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-2021 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  static void mergePatchNames
78  (
79  const polyBoundaryMesh& patches0,
80  const polyBoundaryMesh& patches1,
81 
82  DynamicList<word>& allPatchNames,
83  DynamicList<word>& allPatchTypes,
84 
85  labelList& from1ToAllPatches,
86  labelList& fromAllTo1Patches
87  );
88 
89  //- Get starts of patches
90  static labelList getPatchStarts(const polyBoundaryMesh&);
91 
92  //- Get sizes of patches
93  static labelList getPatchSizes(const polyBoundaryMesh&);
94 
95  static List<polyPatch*> combinePatches
96  (
97  const polyMesh& mesh0,
98  const polyMesh& mesh1,
99  const polyBoundaryMesh& allBoundaryMesh,
100  const label nAllPatches,
101  const labelList& fromAllTo1Patches,
102 
103  const label nInternalFaces,
104  const labelList& nFaces,
105 
106  labelList& from0ToAllPatches,
107  labelList& from1ToAllPatches
108  );
109 
110  //- Determine order for internalFaces to be upper-triangular.
111  // Does not change order of external faces.
112  static labelList getFaceOrder
113  (
114  const cellList& cells,
115  const label nInternalFaces,
116  const labelList& owner,
117  const labelList& neighbour
118  );
119 
120  //- Merges primitives of two meshes.
121  static void mergePrimitives
122  (
123  const polyMesh& mesh0,
124  const polyMesh& mesh1,
125  const faceCoupleInfo& coupleInfo,
126 
127  const label nAllPatches,
128  const labelList& fromAllTo1Patches,
129  const labelList& from1ToAllPatches,
130 
132  labelList& from0ToAllPoints,
133  labelList& from1ToAllPoints,
134 
135  faceList& allFaces,
136  labelList& allOwner,
137  labelList& allNeighbour,
138  label& nInternalFaces,
139  labelList& nFacesPerPatch,
140  label& nCells,
141 
142  labelList& from0ToAllFaces,
143  labelList& from1ToAllFaces,
144  labelList& from1ToAllCells
145  );
146 
147  //- Merge point zones
148  static void mergePointZones
149  (
150  const label nAllPoints,
151 
152  const meshPointZones& pz0,
153  const meshPointZones& pz1,
154  const labelList& from0ToAllPoints,
155  const labelList& from1ToAllPoints,
156 
157  DynamicList<word>& zoneNames,
158  labelList& from1ToAll,
159  List<DynamicList<label>>& pzPoints
160  );
161 
162  //- Merge face zones
163  static void mergeFaceZones
164  (
165  const labelList& allOwner,
166 
167  const polyMesh& mesh0,
168  const polyMesh& mesh1,
169  const labelList& from0ToAllFaces,
170  const labelList& from1ToAllFaces,
171  const labelList& from1ToAllCells,
172 
173  DynamicList<word>& zoneNames,
174  labelList& from1ToAll,
175  List<DynamicList<label>>& fzFaces,
176  List<DynamicList<bool>>& fzFlips
177  );
178 
179  //- Merge cell zones
180  static void mergeCellZones
181  (
182  const label nAllCells,
183 
184  const meshCellZones& cz0,
185  const meshCellZones& cz1,
186  const labelList& from1ToAllCells,
187 
188  DynamicList<word>& zoneNames,
189  labelList& from1ToAll,
190  List<DynamicList<label>>& czCells
191  );
192 
193  //- Merge point/face/cell zone information
194  static void mergeZones
195  (
196  const label nAllPoints,
197  const labelList& allOwner,
198  const label nAllCells,
199 
200  const polyMesh& mesh0,
201  const polyMesh& mesh1,
202  const labelList& from0ToAllPoints,
203  const labelList& from0ToAllFaces,
204  const labelList& from1ToAllPoints,
205  const labelList& from1ToAllFaces,
206  const labelList& from1ToAllCells,
207 
208  DynamicList<word>& pointZoneNames,
209  List<DynamicList<label>>& pzPoints,
210 
211  DynamicList<word>& faceZoneNames,
212  List<DynamicList<label>>& fzFaces,
213  List<DynamicList<bool>>& fzFlips,
214 
215  DynamicList<word>& cellZoneNames,
216  List<DynamicList<label>>& czCells
217  );
218 
219  //- Create new zones and add to new mesh.
220  static void addZones
221  (
222  const DynamicList<word>& pointZoneNames,
223  const List<DynamicList<label>>& pzPoints,
224 
225  const DynamicList<word>& faceZoneNames,
226  const List<DynamicList<label>>& fzFaces,
227  const List<DynamicList<bool>>& fzFlips,
228 
229  const DynamicList<word>& cellZoneNames,
230  const List<DynamicList<label>>& czCells,
231 
232  polyMesh& mesh
233  );
234 
235 public:
236 
237 
238  // Member Functions
239 
240  //- Add two polyMeshes. Returns new polyMesh and map construct.
241  static autoPtr<polyMesh> add
242  (
243  const IOobject& io,
244  const polyMesh& mesh0,
245  const polyMesh& mesh1,
246  const faceCoupleInfo& coupleInfo,
248  );
249 
250  //- Inplace add mesh to polyMesh. Returns map construct.
252  (
253  polyMesh& mesh0,
254  const polyMesh& mesh1,
255  const faceCoupleInfo& coupleInfo,
256  const bool validBoundary = true
257  );
258 };
259 
260 
261 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
262 
263 } // End namespace Foam
264 
265 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
266 
267 #endif
268 
269 // ************************************************************************* //
fvMesh & mesh
Adds two meshes without using any polyMesh morphing.
Definition: polyMeshAdder.H:59
Container for information needed to couple to meshes. When constructed from two meshes and a list of ...
const cellShapeList & cells
A class for handling words, derived from string.
Definition: word.H:59
Foam::polyBoundaryMesh.
tmp< pointField > allPoints(const Triangulation &t)
Extract all points in vertex-index order.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:76
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
static autoPtr< polyMesh > add(const IOobject &io, const polyMesh &mesh0, const polyMesh &mesh1, const faceCoupleInfo &coupleInfo, autoPtr< mapAddedPolyMesh > &mapPtr)
Add two polyMeshes. Returns new polyMesh and map construct.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:98
Namespace for OpenFOAM.