pairPatchAgglomeration.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-2020 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::pairPatchAgglomeration
26 
27 Description
28  Primitive patch pair agglomerate method.
29 
30 SourceFiles
31  pairPatchAgglomeration.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef pairPatchAgglomeration_H
36 #define pairPatchAgglomeration_H
37 
38 #include "mathematicalConstants.H"
39 #include "polyPatch.H"
40 #include "indirectPrimitivePatch.H"
41 #include "List.H"
42 #include "EdgeMap.H"
43 
44 namespace Foam
45 {
47 }
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 /*---------------------------------------------------------------------------*\
55  Class pairPatchAgglomeration Declaration
56 \*---------------------------------------------------------------------------*/
57 
59 {
60 protected:
61 
62  // Protected data
63 
64  //- Number of levels to merge, 1 = don't merge, 2 = merge pairs etc.
66 
67  //- Max number of levels
69 
70  //- Number of faces in coarsest level
72 
73  //- Feature angle
74  scalar featureAngle_;
75 
76  //- The number of faces in each level
78 
79  //- Cell restriction addressing array.
80  // Maps from the finer to coarse level
82 
83  //- Maps from finest to coarsest
85 
86  //- Hierarchy of patch addressing
88 
89  //- Edge weights
91 
92 
93 private:
94 
95  // Private Member Functions
96 
97  //- Assemble coarse patch
98  bool agglomeratePatch
99  (
100  const bPatch& patch,
101  const labelList& fineToCoarse,
102  const label fineLevelIndex
103  );
104 
105  //- Agglomerate one level
106  tmp<labelField> agglomerateOneLevel
107  (
108  label& nCoarseCells,
109  const bPatch& patchLevel
110  );
111 
112  //- Combine leves
113  void combineLevels(const label curLevel);
114 
115  //- Shrink the number of levels to that specified
116  void compactLevels(const label fineLevelIndex);
117 
118  //- Check the need for further agglomeration
119  bool continueAgglomerating(const label fineLevelIndex);
120 
121  //- Set edge weights
122  void setEdgeWeights(const label indexLevel);
123 
124  //- Set base patch edge weights
125  void setBasedEdgeWeights();
126 
127  //- Maps current level with base patch
128  void mapBaseToTopAgglom(const label fineLevelIndex);
129 
130 
131 public:
132 
133  // Constructors
134 
135  //- Construct given mesh and controls
137  (
138  const polyPatch& patch,
139  const dictionary& controlDict,
140  const bool additionalWeights = false
141  );
142 
143  //- Disallow default bitwise copy construction
145 
146 
147  // Destructor
149 
150 
151  // Member Functions
152 
153  //- Agglomerate patch
154  void agglomerate();
155 
156 
157  // Access
158 
159  //- Return size
160  label size() const
161  {
162  return patchLevels_.size();
163  }
164 
165  //- Return restriction from top level to bottom level
167  {
169  }
170 
171  //- Return primitivePatch of given level
172  const bPatch& patchLevel(const label leveli) const;
173 
174  //- Return cell restrict addressing of given level
175  const labelField& restrictAddressing(const label leveli) const
176  {
177  return restrictAddressing_[leveli];
178  }
179 
180 
181  // Restriction and prolongation
182 
183  //- Restrict (integrate by summation) cell field
184  template<class Type>
185  void restrictField
186  (
187  Field<Type>& cf,
188  const Field<Type>& ff,
189  const label fineLevelIndex
190  ) const;
191 
192  //- Prolong (interpolate by injection) cell field
193  template<class Type>
194  void prolongField
195  (
196  Field<Type>& ff,
197  const Field<Type>& cf,
198  const label coarseLevelIndex
199  ) const;
200 
201 
202  // Member Operators
203 
204  //- Disallow default bitwise assignment
205  void operator=(const pairPatchAgglomeration&) = delete;
206 };
207 
208 
209 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
210 
211 } // End namespace Foam
212 
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 
215 #ifdef NoRepository
217 #endif
218 
219 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
220 
221 #endif
222 
223 // ************************************************************************* //
pairPatchAgglomeration(const polyPatch &patch, const dictionary &controlDict, const bool additionalWeights=false)
Construct given mesh and controls.
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
runTime controlDict().lookup("adjustTimeStep") >> adjustTimeStep
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
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.
void agglomerate()
Agglomerate patch.
void operator=(const pairPatchAgglomeration &)=delete
Disallow default bitwise assignment.
label nFacesInCoarsestLevel_
Number of faces in coarsest level.
scalar featureAngle_
Feature angle.
label size() const
Return size.
const bPatch & patchLevel(const label leveli) const
Return primitivePatch of given level.
label size() const
Return the number of elements in the UPtrList.
Definition: UPtrListI.H:29
labelList restrictTopBottomAddressing_
Maps from finest to coarsest.
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:70
Primitive patch pair agglomerate method.
EdgeMap< scalar > facePairWeight_
Edge weights.
labelList nFaces_
The number of faces in each level.
PrimitivePatch< faceList, const pointField > bPatch
A class for managing temporary objects.
Definition: PtrList.H:53
label maxLevels_
Max number of levels.
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
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.