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 | Copyright (C) 2011-2016 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  //- Disallow default bitwise copy construct
132 
133  //- Disallow default bitwise assignment
134  void operator=(const pairPatchAgglomeration&);
135 
136 
137 public:
138 
139  // Constructors
140 
141  //- Construct given mesh and controls
143  (
144  const polyPatch& patch,
145  const dictionary& controlDict,
146  const bool additionalWeights = false
147  );
148 
149 
150  // Destructor
152 
153 
154  // Member Functions
155 
156  //- Agglomerate patch
157  void agglomerate();
158 
159 
160  // Access
161 
162  //- Return size
163  label size() const
164  {
165  return patchLevels_.size();
166  }
167 
168  //- Return restriction from top level to bottom level
170  {
172  }
173 
174  //- Return primitivePatch of given level
175  const bPatch& patchLevel(const label leveli) const;
176 
177  //- Return cell restrict addressing of given level
178  const labelField& restrictAddressing(const label leveli) const
179  {
180  return restrictAddressing_[leveli];
181  }
182 
183 
184  // Restriction and prolongation
185 
186  //- Restrict (integrate by summation) cell field
187  template<class Type>
188  void restrictField
189  (
190  Field<Type>& cf,
191  const Field<Type>& ff,
192  const label fineLevelIndex
193  ) const;
194 
195  //- Prolong (interpolate by injection) cell field
196  template<class Type>
197  void prolongField
198  (
199  Field<Type>& ff,
200  const Field<Type>& cf,
201  const label coarseLevelIndex
202  ) const;
203 };
204 
205 
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
207 
208 } // End namespace Foam
209 
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
211 
212 #ifdef NoRepository
214 #endif
215 
216 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 
218 #endif
219 
220 // ************************************************************************* //
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
void restrictField(Field< Type > &cf, const Field< Type > &ff, const label fineLevelIndex) const
Restrict (integrate by summation) cell field.
runTime controlDict().lookup("adjustTimeStep") >> adjustTimeStep
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
PtrList< labelField > restrictAddressing_
Cell restriction addressing array.
PtrList< bPatch > patchLevels_
Hierarchy of patch addressing.
A list of faces which address into the list of points.
void agglomerate()
Agglomerate patch.
void prolongField(Field< Type > &ff, const Field< Type > &cf, const label coarseLevelIndex) const
Prolong (interpolate by injection) cell field.
label nFacesInCoarsestLevel_
Number of faces in coarsest level.
scalar featureAngle_
Feature angle.
PrimitivePatch< face, List, const pointField > bPatch
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:62
Primitive patch pair agglomerate method.
const labelField & restrictAddressing(const label leveli) const
Return cell restrict addressing of given level.
EdgeMap< scalar > facePairWeight_
Edge weights.
const bPatch & patchLevel(const label leveli) const
Return primitivePatch of given level.
labelList nFaces_
The number of faces in each level.
A class for managing temporary objects.
Definition: PtrList.H:54
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
const labelList & restrictTopBottomAddressing() const
Return restriction from top level to bottom level.
label mergeLevels_
Number of levels to merge, 1 = don&#39;t merge, 2 = merge pairs etc.
label size() const
Return size.
const FieldField< fvPatchField, Type > & ff(const FieldField< fvPatchField, Type > &bf)
Namespace for OpenFOAM.
label size() const
Return the number of elements in the UPtrList.
Definition: UPtrListI.H:29