masterCoarsestGAMGProcAgglomeration.C
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) 2013-2014 OpenFOAM Foundation
9-------------------------------------------------------------------------------
10License
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
14 under the terms of the GNU General Public License as published by
15 the Free Software Foundation, either version 3 of the License, or
16 (at your option) any later version.
17
18 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25
26\*---------------------------------------------------------------------------*/
27
30#include "GAMGAgglomeration.H"
31
32// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33
34namespace Foam
35{
37
39 (
43 );
44}
45
46
47// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48
50(
51 GAMGAgglomeration& agglom,
53)
54:
56{}
57
58
59// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
60
63{
64 forAllReverse(comms_, i)
65 {
66 if (comms_[i] != -1)
67 {
69 }
70 }
71}
72
73
74// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
75
77{
78 if (debug)
79 {
80 Pout<< nl << "Starting mesh overview" << endl;
81 printStats(Pout, agglom_);
82 }
83
84 if (agglom_.size() >= 1)
85 {
86 // Agglomerate one but last level (since also agglomerating
87 // restrictAddressing)
88 label fineLevelIndex = agglom_.size()-1;
89
90 if (agglom_.hasMeshLevel(fineLevelIndex))
91 {
92 // Get the fine mesh
93 const lduMesh& levelMesh = agglom_.meshLevel(fineLevelIndex);
94 label levelComm = levelMesh.comm();
95 label nProcs = UPstream::nProcs(levelComm);
96
97 if (nProcs > 1)
98 {
99 // Processor restriction map: per processor the coarse processor
100 labelList procAgglomMap(nProcs, Zero);
101
102 // Master processor
103 labelList masterProcs;
104 // Local processors that agglomerate. agglomProcIDs[0] is in
105 // masterProc.
106 List<label> agglomProcIDs;
108 (
109 levelComm,
110 procAgglomMap,
111 masterProcs,
112 agglomProcIDs
113 );
114
115 // Allocate a communicator for the processor-agglomerated matrix
116 comms_.append
117 (
119 (
120 levelComm,
121 masterProcs
122 )
123 );
124
125 // Use processor agglomeration maps to do the actual collecting.
126 if (Pstream::myProcNo(levelComm) != -1)
127 {
129 (
130 fineLevelIndex,
131 procAgglomMap,
132 masterProcs,
133 agglomProcIDs,
134 comms_.last()
135 );
136 }
137 }
138 }
139 }
140
141 // Print a bit
142 if (debug)
143 {
144 Pout<< nl << "Agglomerated mesh overview" << endl;
145 printStats(Pout, agglom_);
146 }
147
148 return true;
149}
150
151
152// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
Geometric agglomerated algebraic multigrid agglomeration class.
static void calculateRegionMaster(const label comm, const labelList &procAgglomMap, labelList &masterProcs, List< label > &agglomProcIDs)
Given fine to coarse processor map determine:
Processor agglomeration of GAMGAgglomerations.
virtual bool agglomerate()=0
Modify agglomeration. Return true if modified.
label nProcs() const noexcept
Number of ranks associated with PstreamBuffers.
T & last()
Return the last element of the list.
Definition: UListI.H:216
static void freeCommunicator(const label communicator, const bool doPstream=true)
Free a previously allocated communicator.
Definition: UPstream.C:174
static label allocateCommunicator(const label parent, const labelList &subRanks, const bool doPstream=true)
Allocate a new communicator.
Definition: UPstream.C:108
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Abstract base class for meshes which provide LDU addressing for the construction of lduMatrix and LDU...
Definition: lduMesh.H:63
virtual label comm() const =0
Return communicator used for parallel communication.
Processor agglomeration of GAMGAgglomerations.
virtual bool agglomerate()
Modify agglomeration. Return true if modified.
int myProcNo() const noexcept
Return processor number.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
runTime controlDict().readEntry("adjustTimeStep"
Namespace for OpenFOAM.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
#define forAllReverse(list, i)
Reverse loop across all elements in list.
Definition: stdFoam.H:346