mergePatchPairs.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) 2023 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::mergePatchPairs
26 
27 Description
28  Class to stitch mesh by merging patch-pairs
29 
30 SourceFiles
31  mergePatchPairs.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef mergePatchPairs_H
36 #define mergePatchPairs_H
37 
38 #include "polyMesh.H"
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 namespace Foam
43 {
44 
45 class fvMesh;
46 class polyTopoChange;
47 class polyPatchIntersection;
48 
49 /*---------------------------------------------------------------------------*\
50  Class mergePatchPairs Declaration
51 \*---------------------------------------------------------------------------*/
52 
53 class mergePatchPairs
54 {
55  // Private data
56 
57  polyMesh& mesh_;
58 
59  const scalar snapTol_;
60 
61  mutable labelList newPoints_;
62 
63 
64  // Private member functions
65 
66  //- Return patch index of given patch name
67  // Throw a fatal error if the patch name is not found
68  label findPatchIndex(const word& patchName) const;
69 
70  //- Return the patch index pairs
71  // corresponding to the give patch name pairs
72  Pair<label> findPatchIndices
73  (
74  const Pair<word>& patchNamePair
75  ) const;
76 
77  //- Set the patchPairs_ patch index pair list
78  // from the patchNamePairs_ patch name pair list
79  List<Pair<label>> patchPairs
80  (
81  const List<Pair<word>>& patchNamePairs
82  ) const;
83 
84  //- Remove all the points corresponding to the patch pairs to be merged
85  void removePoints
86  (
87  polyTopoChange& meshMod,
88  const List<Pair<label>>& patchPairs
89  ) const;
90 
91  //- Add the points generated by the patch intersection
92  void addPoints
93  (
94  polyTopoChange& meshMod,
96  ) const;
97 
98  //- Remove all the faces of the source and target patches to me merged
99  void removeFaces
100  (
101  polyTopoChange& meshMod,
103  ) const;
104 
105  //- Map face from patch-local point indices to global mesh point indices
106  face mapFace(const face& f) const;
107 
108  //- Add a new internal and patch face to the mesh
109  void addFaces
110  (
111  polyTopoChange& meshMod,
113  ) const;
114 
115  void addEdgeAddedPoints
116  (
117  HashTable<labelList, edge, Hash<edge>>& edgeAddedPoints,
118  const primitivePatch& patch,
119  const List<DynamicList<label>>& patchEdgeAddedPoints
120  ) const;
121 
122  //- Update the point indices of the changed points in the pointMap
123  void updatePoints
124  (
125  labelList& pointMap,
126  const primitivePatch& patch,
127  const labelList& pointPoints
128  ) const;
129 
130  //- Modify the edges of existing edge-connected faces
131  // by changing the end-point and adding any additional points
132  // and point-connected faces by updating the point indices
133  void modifyFaces
134  (
135  polyTopoChange& meshMod,
137  ) const;
138 
139  //- Intersect the given pair of patches and insert all face changes
140  // into meshMod
141  void intersectPatchPair
142  (
143  polyTopoChange& meshMod,
144  const polyPatch& srcPatch,
145  const polyPatch& tgtPatch
146  ) const;
147 
148  //- Merge all the given patch pairs
149  // returning the polyTopoChangeMap for subsequent field mapping
151  (
152  const List<Pair<label>>& patchPairIndices
153  ) const;
154 
155  //- Return true if the points of patchi are connected to any
156  // of the patches already tested
157  bool connected
158  (
159  boolList& patchPoints,
160  const label patchi
161  ) const;
162 
163  //- Merge all the given patch pairs
164  // and update all the fields cached in the given mesh
165  template<class Mesh>
166  inline void merge
167  (
168  Mesh& mesh,
169  const List<Pair<word>>& patchPairNames
170  ) const;
171 
172 
173 public:
174 
175  // Static Data Members
176 
177  ClassName("mergePatchPairs");
178 
179 
180  // Constructors
181 
183  (
184  polyMesh& mesh,
185  const List<Pair<word>>& patchPairNames,
186  const scalar snapTol
187  );
188 
190  (
191  fvMesh& mesh,
192  const List<Pair<word>>& patchPairNames,
193  const scalar snapTol
194  );
195 };
196 
197 
198 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
199 
200 } // End namespace Foam
201 
202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203 
204 #endif
205 
206 // ************************************************************************* //
An STL-conforming hash table.
Definition: HashTable.H:127
Hash function class for primitives. All non-primitives used to hash entries on hash tables likely nee...
Definition: Hash.H:53
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:61
A face is a list of labels corresponding to mesh vertices.
Definition: face.H:76
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:99
Foam::intersection.
Definition: intersection.H:50
Class to stitch mesh by merging patch-pairs.
ClassName("mergePatchPairs")
mergePatchPairs(polyMesh &mesh, const List< Pair< word >> &patchPairNames, const scalar snapTol)
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
Intersection between two polyPatches.
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:70
Direct mesh changes based on v1.3 polyTopoChange syntax.
Given list of faces to remove insert all the topology changes. Contains helper function to get consis...
Definition: removeFaces.H:63
Removes selected points from mesh and updates faces using these points.
Definition: removePoints.H:59
A class for handling words, derived from string.
Definition: word.H:62
label patchi
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
labelList f(nPoints)