Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
11License
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
27Class
28 Foam::pairPatchAgglomeration
29
30Description
31 Primitive patch pair agglomerate method.
32
33SourceFiles
34 pairPatchAgglomeration.C
35
36\*---------------------------------------------------------------------------*/
37
38#ifndef Foam_pairPatchAgglomeration_H
39#define Foam_pairPatchAgglomeration_H
40
43#include "List.H"
44#include "edgeHashes.H"
45
46// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47
48namespace Foam
49{
51/*---------------------------------------------------------------------------*\
52 Class pairPatchAgglomeration Declaration
53\*---------------------------------------------------------------------------*/
55class pairPatchAgglomeration
56{
57protected:
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
72 //- Global number of faces in coarsest level
74
75 //- Feature angle
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
94
95private:
96
97 // Private Member Functions
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
159 pairPatchAgglomeration(const pairPatchAgglomeration&) = delete;
160
161 //- No copy assignment
162 void operator=(const pairPatchAgglomeration&) = delete;
163
164
165public:
166
167 //- Runtime type information
168 TypeName("pairPatch");
169
170
171 // Constructors
172
173 //- Construct given faces, points and control dictionary
174 pairPatchAgglomeration
175 (
176 const faceList& faces,
177 const pointField& points,
179 );
180
181 //- Construct from components
182 pairPatchAgglomeration
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 }
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// ************************************************************************* //
Map from edge (expressed as its endpoints) to value. Hashing (and ==) on an edge is symmetric.
Definition edgeHashes.H:59
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
A list of faces which address into the list of points.
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition PtrList.H:67
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
void prolongField(Field< Type > &ff, const Field< Type > &cf, const label coarseLevelIndex) const
Prolong (interpolate by injection) cell field.
void restrictField(Field< Type > &cf, const Field< Type > &ff, const label fineLevelIndex) const
Restrict (integrate by summation) cell field.
const labelList & restrictTopBottomAddressing() const
Return restriction from top level to bottom level.
TypeName("pairPatch")
Runtime type information.
PtrList< bPatch > patchLevels_
Hierarchy of patch addressing.
labelList nFaces_
The number of faces in each level.
const bPatch & patchLevel(const label leveli) const
Return primitivePatch of given level.
void agglomerate()
Agglomerate patch.
EdgeMap< scalar > facePairWeight_
Edge weights.
label mergeLevels_
Number of levels to merge, 1 = don't merge, 2 = merge pairs etc.
label maxLevels_
Max number of levels.
label nFacesInCoarsestLevel_
Number of faces in coarsest level.
PtrList< labelField > restrictAddressing_
Cell restriction addressing array.
const labelField & restrictAddressing(const label leveli) const
Return cell restrict addressing of given level.
PrimitivePatch< List< face >, const pointField > bPatch
label nGlobalFacesInCoarsestLevel_
Global number of faces in coarsest level.
labelList restrictTopBottomAddressing_
Maps from finest to coarsest.
A class for managing temporary objects.
Definition tmp.H:75
runTime controlDict().readEntry("adjustTimeStep"
const pointField & points
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition List.H:62
List< face > faceList
List of faces.
Definition faceListFwd.H:41
Field< label > labelField
Specialisation of Field<T> for label.
Definition labelField.H:48
PrimitivePatch<::Foam::List< face >, const pointField > bPatch
vectorField pointField
pointField is a vectorField.
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68