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 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 pairPatchAgglomeration_H
39 #define 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  );
106 
107  //- Agglomerate one level
108  tmp<labelField> agglomerateOneLevel
109  (
110  label& nCoarseCells,
111  const bPatch& patchLevel
112  );
113 
114  //- Combine levels
115  void combineLevels(const label curLevel);
116 
117  //- Shrink the number of levels to that specified
118  void compactLevels(const label fineLevelIndex);
119 
120  //- Check the need for further agglomeration
121  bool continueAgglomerating
122  (
123  const label nLocal,
124  const label nLocalOld
125  );
126 
127  //- Set edge weights
128  void setEdgeWeights(const label indexLevel);
129 
130  //- Set base patch edge weights
131  void setLevel0EdgeWeights();
132 
133  //- Maps current level with base patch
134  void mapBaseToTopAgglom(const label fineLevelIndex);
135 
136  //- No copy construct
138 
139  //- No copy assignment
140  void operator=(const pairPatchAgglomeration&) = delete;
141 
142 
143 public:
144 
145  // Constructors
146 
147  //- Construct given faces, points and control dictionary
149  (
150  const faceList& faces,
151  const pointField& points,
152  const dictionary& controlDict
153  );
154 
155  //- Construct from components
157  (
158  const faceList& faces,
159  const pointField& points,
160  const label mergeLevels,
161  const label maxLevels,
162  const label nFacesInCoarsestLevel,
163  const label nGlobalFacesInCoarsestLevel,
164  const scalar featureAngle = 0
165  );
166 
167 
168  // Destructor
170 
171 
172  // Member Functions
173 
174  //- Agglomerate patch
175  void agglomerate();
176 
177 
178  // Access
179 
180  //- Return size
181  label size() const
182  {
183  return patchLevels_.size();
184  }
185 
186  //- Return restriction from top level to bottom level
188  {
190  }
191 
192  //- Return primitivePatch of given level
193  const bPatch& patchLevel(const label leveli) const;
194 
195  //- Return cell restrict addressing of given level
196  const labelField& restrictAddressing(const label leveli) const
197  {
198  return restrictAddressing_[leveli];
199  }
200 
201 
202  // Restriction and prolongation
203 
204  //- Restrict (integrate by summation) cell field
205  template<class Type>
206  void restrictField
207  (
208  Field<Type>& cf,
209  const Field<Type>& ff,
210  const label fineLevelIndex
211  ) const;
212 
213  //- Prolong (interpolate by injection) cell field
214  template<class Type>
215  void prolongField
216  (
217  Field<Type>& ff,
218  const Field<Type>& cf,
219  const label coarseLevelIndex
220  ) const;
221 };
222 
223 
224 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
225 
226 } // End namespace Foam
227 
228 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
229 
230 #ifdef NoRepository
232 #endif
233 
234 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
235 
236 #endif
237 
238 // ************************************************************************* //
mathematicalConstants.H
List.H
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::pairPatchAgglomeration::mergeLevels_
label mergeLevels_
Number of levels to merge, 1 = don't merge, 2 = merge pairs etc.
Definition: pairPatchAgglomeration.H:63
Foam::pairPatchAgglomeration
Primitive patch pair agglomerate method.
Definition: pairPatchAgglomeration.H:54
Foam::pairPatchAgglomeration::nFaces_
labelList nFaces_
The number of faces in each level.
Definition: pairPatchAgglomeration.H:78
Foam::pairPatchAgglomeration::featureAngle_
scalar featureAngle_
Feature angle.
Definition: pairPatchAgglomeration.H:75
Foam::pairPatchAgglomeration::bPatch
PrimitivePatch< List< face >, const pointField > bPatch
Definition: pairPatchAgglomeration.H:58
Foam::pairPatchAgglomeration::restrictTopBottomAddressing_
labelList restrictTopBottomAddressing_
Maps from finest to coarsest.
Definition: pairPatchAgglomeration.H:85
Foam::pairPatchAgglomeration::restrictTopBottomAddressing
const labelList & restrictTopBottomAddressing() const
Return restriction from top level to bottom level.
Definition: pairPatchAgglomeration.H:186
Foam::Field< vector >
Foam::pairPatchAgglomeration::facePairWeight_
EdgeMap< scalar > facePairWeight_
Edge weights.
Definition: pairPatchAgglomeration.H:91
Foam::pairPatchAgglomeration::size
label size() const
Return size.
Definition: pairPatchAgglomeration.H:180
controlDict
runTime controlDict().readEntry("adjustTimeStep"
Definition: debug.C:143
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:59
indirectPrimitivePatch.H
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::pairPatchAgglomeration::~pairPatchAgglomeration
~pairPatchAgglomeration()
Definition: pairPatchAgglomeration.C:276
Foam::pairPatchAgglomeration::maxLevels_
label maxLevels_
Max number of levels.
Definition: pairPatchAgglomeration.H:66
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::pairPatchAgglomeration::restrictAddressing_
PtrList< labelField > restrictAddressing_
Cell restriction addressing array.
Definition: pairPatchAgglomeration.H:82
Foam::pairPatchAgglomeration::restrictField
void restrictField(Field< Type > &cf, const Field< Type > &ff, const label fineLevelIndex) const
Restrict (integrate by summation) cell field.
Definition: pairPatchAgglomerationTemplates.C:34
Foam::pairPatchAgglomeration::patchLevels_
PtrList< bPatch > patchLevels_
Hierarchy of patch addressing.
Definition: pairPatchAgglomeration.H:88
pairPatchAgglomerationTemplates.C
Foam::fv::ff
const FieldField< fvPatchField, Type > & ff(const FieldField< fvPatchField, Type > &bf)
Definition: CrankNicolsonDdtScheme.C:275
Foam::EdgeMap< scalar >
edgeHashes.H
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::pairPatchAgglomeration::agglomerate
void agglomerate()
Agglomerate patch.
Definition: pairPatchAgglomeration.C:394
Foam::List< label >
Foam::pairPatchAgglomeration::nGlobalFacesInCoarsestLevel_
label nGlobalFacesInCoarsestLevel_
Global number of faces in coarsest level.
Definition: pairPatchAgglomeration.H:72
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::pairPatchAgglomeration::prolongField
void prolongField(Field< Type > &ff, const Field< Type > &cf, const label coarseLevelIndex) const
Prolong (interpolate by injection) cell field.
Definition: pairPatchAgglomerationTemplates.C:62
Foam::pairPatchAgglomeration::patchLevel
const bPatch & patchLevel(const label leveli) const
Return primitivePatch of given level.
Definition: pairPatchAgglomeration.C:284
Foam::pairPatchAgglomeration::nFacesInCoarsestLevel_
label nFacesInCoarsestLevel_
Number of faces in coarsest level.
Definition: pairPatchAgglomeration.H:69
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatch.H:79
Foam::pairPatchAgglomeration::restrictAddressing
const labelField & restrictAddressing(const label leveli) const
Return cell restrict addressing of given level.
Definition: pairPatchAgglomeration.H:195