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-2025 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 pointZoneList& pz0,
137  const pointZoneList& 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  boolList& fzOrientations,
161  List<DynamicList<bool>>& fzFlips
162  );
163 
164  //- Merge cell zones
165  static void mergeCellZones
166  (
167  const label nAllCells,
168 
169  const cellZoneList& cz0,
170  const cellZoneList& cz1,
171  const labelList& from1ToAllCells,
172 
173  DynamicList<word>& zoneNames,
174  labelList& from1ToAll,
175  List<DynamicList<label>>& czCells
176  );
177 
178  //- Merge point/face/cell zone information
179  static void mergeZones
180  (
181  const label nAllPoints,
182  const labelList& allOwner,
183  const label nAllCells,
184 
185  const polyMesh& mesh0,
186  const polyMesh& mesh1,
187  const labelList& from0ToAllPoints,
188  const labelList& from0ToAllFaces,
189  const labelList& from1ToAllPoints,
190  const labelList& from1ToAllFaces,
191  const labelList& from1ToAllCells,
192 
193  DynamicList<word>& pointZoneNames,
194  List<DynamicList<label>>& pzPoints,
195 
196  DynamicList<word>& faceZoneNames,
197  List<DynamicList<label>>& fzFaces,
198  boolList& fzOrientations,
199  List<DynamicList<bool>>& fzFlips,
200 
201  DynamicList<word>& cellZoneNames,
202  List<DynamicList<label>>& czCells
203  );
204 
205  //- Create new zones and add to new mesh.
206  static void addZones
207  (
208  const DynamicList<word>& pointZoneNames,
209  const List<DynamicList<label>>& pzPoints,
210 
211  const DynamicList<word>& faceZoneNames,
212  const List<DynamicList<label>>& fzFaces,
213  const boolList& fzOrientations,
214  const List<DynamicList<bool>>& fzFlips,
215 
216  const DynamicList<word>& cellZoneNames,
217  const List<DynamicList<label>>& czCells,
218 
219  polyMesh& mesh
220  );
221 
222 
223 public:
224 
225  // Member Functions
226 
227  //- Inplace add mesh to polyMesh. Returns map construct.
229  (
230  polyMesh& mesh0,
231  const polyMesh& mesh1,
232  const faceCoupleInfo& coupleInfo,
233  const bool validBoundary = true
234  );
235 };
236 
237 
238 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
239 
240 } // End namespace Foam
241 
242 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
243 
244 #endif
245 
246 // ************************************************************************* //
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
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
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