pairPatchAgglomeration.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  Copyright (C) 2016-2020,2023 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::pairPatchAgglomeration
29 
30 Description
31  Primitive patch pair agglomerate method.
32 
33 SourceFiles
34  pairPatchAgglomeration.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef Foam_pairPatchAgglomeration_H
39 #define Foam_pairPatchAgglomeration_H
40 
41 #include "mathematicalConstants.H"
42 #include "indirectPrimitivePatch.H"
43 #include "List.H"
44 #include "edgeHashes.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 
51 /*---------------------------------------------------------------------------*\
52  Class pairPatchAgglomeration Declaration
53 \*---------------------------------------------------------------------------*/
54 
56 {
57 protected:
58 
60 
61  // Protected data
62 
63  //- Number of levels to merge, 1 = don't merge, 2 = merge pairs etc.
64  label mergeLevels_;
65 
66  //- Max number of levels
67  label maxLevels_;
68 
69  //- Number of faces in coarsest level
71 
72  //- Global number of faces in coarsest level
74 
75  //- Feature angle
76  scalar featureAngle_;
77 
78  //- The number of faces in each level
80 
81  //- Cell restriction addressing array.
82  // Maps from the finer to coarse level
84 
85  //- Maps from finest to coarsest
87 
88  //- Hierarchy of patch addressing
90 
91  //- Edge weights
93 
94 
95 private:
96 
97  // Private Member Functions
98 
99  //- Assemble coarse patch
100  bool agglomeratePatch
101  (
102  const bPatch& patch,
103  const labelList& fineToCoarse,
104  const label fineLevelIndex,
105  label& nMarkedEdges
106  );
107 
108  //- Does combining facei with faceIDs produce a single face?
109  bool isSingleEdgeLoop
110  (
111  const bPatch& patch,
112  const labelList& faceIDs,
113  const label facei
114  ) const;
115 
116  //- Select neighbour with highest inbetween edge weight. Either looks
117  //- at already clustered faces (addToCluster=true) or only
118  // unclustered
119  label maxValidNeighbour
120  (
121  const bool addToCluster,
122  const bPatch& patch,
123  const label facei,
124  const labelList& coarseCellMap
125  //const labelListList& coarseToFine
126  ) const;
127 
128  //- Agglomerate one level
129  tmp<labelField> agglomerateOneLevel
130  (
131  label& nCoarseCells,
132  const bPatch& patchLevel
133  );
134 
135  //- Combine levels
136  void combineLevels(const label curLevel);
137 
138  //- Shrink the number of levels to that specified
139  void compactLevels(const label fineLevelIndex);
140 
141  //- Check the need for further agglomeration
142  bool continueAgglomerating
143  (
144  const label nLocal,
145  const label nLocalOld,
146  const label nMarkedEdges
147  );
148 
149  //- Set edge weights
150  void setEdgeWeights(const label indexLevel);
151 
152  //- Set base patch edge weights
153  void setLevel0EdgeWeights();
154 
155  //- Maps current level with base patch
156  void mapBaseToTopAgglom(const label fineLevelIndex);
157 
158  //- No copy construct
160 
161  //- No copy assignment
162  void operator=(const pairPatchAgglomeration&) = delete;
163 
164 
165 public:
166 
167  //- Runtime type information
168  TypeName("pairPatch");
169 
170 
171  // Constructors
172 
173  //- Construct given faces, points and control dictionary
175  (
176  const faceList& faces,
177  const pointField& points,
178  const dictionary& controlDict
179  );
180 
181  //- Construct from components
183  (
184  const faceList& faces,
185  const pointField& points,
186  const label mergeLevels,
187  const label maxLevels,
188  const label nFacesInCoarsestLevel,
189  const label nGlobalFacesInCoarsestLevel,
190  const scalar featureAngle = 0
191  );
192 
193 
194  // Destructor
195  virtual ~pairPatchAgglomeration();
196 
197 
198  // Member Functions
199 
200  //- Agglomerate patch
201  void agglomerate();
202 
203 
204  // Access
205 
206  //- Return size
207  label size() const
208  {
209  return patchLevels_.size();
210  }
211 
212  //- Return restriction from top level to bottom level
214  {
216  }
217 
218  //- Return primitivePatch of given level
219  const bPatch& patchLevel(const label leveli) const;
220 
221  //- Return cell restrict addressing of given level
222  const labelField& restrictAddressing(const label leveli) const
223  {
224  return restrictAddressing_[leveli];
225  }
226 
227 
228  // Restriction and prolongation
229 
230  //- Restrict (integrate by summation) cell field
231  template<class Type>
232  void restrictField
233  (
234  Field<Type>& cf,
235  const Field<Type>& ff,
236  const label fineLevelIndex
237  ) const;
238 
239  //- Prolong (interpolate by injection) cell field
240  template<class Type>
241  void prolongField
242  (
243  Field<Type>& ff,
244  const Field<Type>& cf,
245  const label coarseLevelIndex
246  ) const;
247 };
248 
249 
250 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
251 
252 } // End namespace Foam
253 
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
255 
256 #ifdef NoRepository
258 #endif
259 
260 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
261 
262 #endif
263 
264 // ************************************************************************* //
PrimitivePatch< List< face >, const pointField > bPatch
Field< label > labelField
Specialisation of Field<T> for label.
Definition: labelField.H:48
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:120
PtrList< labelField > restrictAddressing_
Cell restriction addressing array.
PtrList< bPatch > patchLevels_
Hierarchy of patch addressing.
void prolongField(Field< Type > &ff, const Field< Type > &cf, const label coarseLevelIndex) const
Prolong (interpolate by injection) cell field.
const labelField & restrictAddressing(const label leveli) const
Return cell restrict addressing of given level.
A list of faces which address into the list of points.
const labelList & restrictTopBottomAddressing() const
Return restriction from top level to bottom level.
const pointField & points
const bPatch & patchLevel(const label leveli) const
Return primitivePatch of given level.
void agglomerate()
Agglomerate patch.
label nFacesInCoarsestLevel_
Number of faces in coarsest level.
scalar featureAngle_
Feature angle.
label size() const
Return size.
runTime controlDict().readEntry("adjustTimeStep"
The central control dictionary, the contents of which are either taken directly from the FOAM_CONTROL...
Definition: debug.C:142
label nGlobalFacesInCoarsestLevel_
Global number of faces in coarsest level.
labelList restrictTopBottomAddressing_
Maps from finest to coarsest.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Definition: List.H:55
Primitive patch pair agglomerate method.
EdgeMap< scalar > facePairWeight_
Edge weights.
TypeName("pairPatch")
Runtime type information.
const std::string patch
OpenFOAM patch number as a std::string.
labelList nFaces_
The number of faces in each level.
A class for managing temporary objects.
Definition: HashPtrTable.H:50
label maxLevels_
Max number of levels.
label mergeLevels_
Number of levels to merge, 1 = don&#39;t merge, 2 = merge pairs etc.
const FieldField< fvPatchField, Type > & ff(const FieldField< fvPatchField, Type > &bf)
Namespace for OpenFOAM.
void restrictField(Field< Type > &cf, const Field< Type > &ff, const label fineLevelIndex) const
Restrict (integrate by summation) cell field.