Loading...
Searching...
No Matches
decompositionGAMGAgglomeration.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) 2023 M. Janssens
9 Copyright (C) 2025 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::decompositionGAMGAgglomeration
29
30Description
31 Agglomerate using the decomposition algorithm.
32
33 Can be used to produce quicker coarsening.
34
35 Method coefficients:
36 \table
37 Property | Description | Required | Default
38 method | name of decompositionMethod | yes |
39 numberOfSubdomains | n | yes |
40 forceConnected | (bool) split disconnected region | no | true (GIVE WARNING)
41 renumber | (bool) renumber individual levels | no | false
42 \endtable
43
44
45SourceFiles
46 decompositionGAMGAgglomeration.C
47
48\*---------------------------------------------------------------------------*/
49
50#ifndef decompositionGAMGAgglomeration_H
51#define decompositionGAMGAgglomeration_H
52
53#include "GAMGAgglomeration.H"
54
55// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56
57namespace Foam
58{
59
61
62/*---------------------------------------------------------------------------*\
63 Class decompositionGAMGAgglomeration Declaration
64\*---------------------------------------------------------------------------*/
65
67:
69{
70 // Private Data
71
72 const bool doRenumber_;
73
74 const bool forceConnected_;
75
76 mutable autoPtr<decompositionMethod> decomposerPtr_;
77
78 const label clusterSize_;
79
80 mutable bool hasWarned_;
81
82
83 // Private Member Functions
84
85 template<class Type>
86 static tmp<Field<Type>> avg
87 (
88 const UList<Type>& fld,
89 const label nCoarse,
90 const labelUList& oldToNew
91 );
92
93 //- Agglomerate single level
94 tmp<labelField> agglomerate
95 (
96 const bool partByPart,
97 const label nCoarseCells,
98
99 // Current mesh
100 const lduMesh& mesh,
101 const pointField& cellCentres,
102 const scalarField& cellWeights,
103 const scalarField& faceWeights,
104
105 // Agglomeration of current mesh
106 const labelUList& region
107 ) const;
108
109 static bitSet blockedFaces
110 (
111 const lduAddressing& addr,
112 const labelUList& region // region per cell
113 );
114
115 static bool checkRestriction
116 (
117 labelList& newRestrict,
118 label& nNewCoarse,
119 const lduAddressing& fineAddressing,
120 const labelUList& restriction,
121 const label nCoarse
122 );
123
124 static void coarseCellCells
125 (
126 const lduAddressing& addr,
127 const labelList& regions, // coarse cell
128 CompactListList<label>& cellCells // coarse-to-coarse cells
129 );
130
131
132public:
133
134 //- Runtime type information
135 TypeName("decomposition");
136
137
138 // Constructors
139
140 //- Construct given mesh and controls
142 (
143 const lduMesh& mesh,
145 );
146
147 //- Construct given mesh and controls
149 (
150 const lduMesh& mesh,
151 const scalarField& cellVolumes,
152 const vectorField& faceAreas,
154 );
155
156
157 // Member Functions
158
159 //- Agglomerate from a starting level. Starting level is usually 0
160 //- (initial mesh) but sometimes >0 (restarting after processor
161 //- agglomeration)
162 virtual void agglomerate
163 (
164 const label nCellsInCoarsestLevel,
165 const label startLevel,
166 const scalarField& startFaceWeights,
167 const bool doProcessorAgglomerate = true
168 );
169
170
171 // Helpers
172
173 static void localCellCells
174 (
175 const lduAddressing& addr,
176 const bitSet& isBlockedFace,
177 CompactListList<label>& cellCells
178 );
180 (
181 const lduAddressing& addr,
182 const labelList& regions, // marker
183 const label regioni, // which marker to keep
184 CompactListList<label>& cellCells
185 );
186};
187
188
189// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190
191} // End namespace Foam
192
193// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194
195#ifdef NoRepository
196 #include "decompositionGAMGAgglomerationTemplates.txx"
197#endif
198
199// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
200
201#endif
202
203// ************************************************************************* //
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
A packed storage of objects of type <T> using an offset table for access.
Geometric agglomerated algebraic multigrid agglomeration class.
GAMGAgglomeration(const GAMGAgglomeration &)=delete
No copy construct.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition UList.H:89
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A bitSet stores bits (elements with only two states) in packed internal format and supports a variety...
Definition bitSet.H:61
Agglomerate using the decomposition algorithm.
TypeName("decomposition")
Runtime type information.
decompositionGAMGAgglomeration(const lduMesh &mesh, const dictionary &controlDict)
Construct given mesh and controls.
static void localCellCells(const lduAddressing &addr, const bitSet &isBlockedFace, CompactListList< label > &cellCells)
Abstract base class for domain decomposition.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
The class contains the addressing required by the lduMatrix: upper, lower and losort.
Abstract base class for meshes which provide LDU addressing for the construction of lduMatrix and LDU...
Definition lduMesh.H:54
A class for managing temporary objects.
Definition tmp.H:75
runTime controlDict().readEntry("adjustTimeStep"
const bitSet isBlockedFace(intersectedFaces())
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition List.H:62
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Field< vector > vectorField
Specialisation of Field<T> for vector.
vectorField pointField
pointField is a vectorField.
UList< label > labelUList
A UList of labels.
Definition UList.H:75
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68