preserveFaceZonesConstraint.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) 2015-2016 OpenFOAM Foundation
9 Copyright (C) 2018,2021 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
27\*---------------------------------------------------------------------------*/
28
31#include "syncTools.H"
32
33// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34
35namespace Foam
36{
37namespace decompositionConstraints
38{
40
42 (
46 );
47}
48}
49
50
51// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
52
54(
55 const dictionary& dict
56)
57:
59 zones_(coeffDict_.get<wordRes>("zones"))
60{
61 if (decompositionConstraint::debug)
62 {
63 Info<< type() << " : adding constraints to keep owner and neighbour"
64 << " of faces in zones " << zones_
65 << " on same processor" << endl;
66 }
67}
68
69
71(
72 const UList<wordRe>& zones
73)
74:
76 zones_(zones)
77{
78 if (decompositionConstraint::debug)
79 {
80 Info<< type() << " : adding constraints to keep owner and neighbour"
81 << " of faces in zones " << zones_
82 << " on same processor" << endl;
83 }
84}
85
86
87// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
88
90(
91 const polyMesh& mesh,
92 boolList& blockedFace,
93 PtrList<labelList>& specifiedProcessorFaces,
94 labelList& specifiedProcessor,
95 List<labelPair>& explicitConnections
96) const
97{
98 blockedFace.setSize(mesh.nFaces(), true);
99
100 const faceZoneMesh& fZones = mesh.faceZones();
101
102 const labelList zoneIDs(zones_.matching(fZones.names()));
103
104 label nUnblocked = 0;
105
106 for (const label zonei : zoneIDs)
107 {
108 const faceZone& fz = fZones[zonei];
109
110 for (const label meshFacei : fz)
111 {
112 if (blockedFace[meshFacei])
113 {
114 blockedFace[meshFacei] = false;
115 ++nUnblocked;
116 }
117 }
118 }
119
120 if (decompositionConstraint::debug & 2)
121 {
122 reduce(nUnblocked, sumOp<label>());
123 Info<< type() << " : unblocked " << nUnblocked << " faces" << endl;
124 }
125
127}
128
129
131(
132 const polyMesh& mesh,
133 const boolList& blockedFace,
134 const PtrList<labelList>& specifiedProcessorFaces,
135 const labelList& specifiedProcessor,
136 const List<labelPair>& explicitConnections,
137 labelList& decomposition
138) const
139{
140 // If the decomposition has not enforced the constraint do it over
141 // here.
142
143 label nChanged;
144
145 do
146 {
147 // Extract min coupled boundary data
148 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
149
150 labelList destProc;
151 getMinBoundaryValue(mesh, decomposition, destProc);
152
153
154 // Override if differing
155 // ~~~~~~~~~~~~~~~~~~~~~
156
157 const faceZoneMesh& fZones = mesh.faceZones();
158
159 const labelList zoneIDs(zones_.matching(fZones.names()));
160
161 nChanged = 0;
162 for (const label zonei : zoneIDs)
163 {
164 const faceZone& fz = fZones[zonei];
165
166 for (const label facei : fz)
167 {
168 const label own = mesh.faceOwner()[facei];
169
170 if (mesh.isInternalFace(facei))
171 {
172 const label nei = mesh.faceNeighbour()[facei];
173 if (decomposition[nei] < decomposition[own])
174 {
175 decomposition[own] = decomposition[nei];
176 ++nChanged;
177 }
178 }
179 else
180 {
181 const label bFaceI = facei-mesh.nInternalFaces();
182 if (destProc[bFaceI] < decomposition[own])
183 {
184 decomposition[own] = destProc[bFaceI];
185 ++nChanged;
186 }
187 }
188 }
189 }
190
191 reduce(nChanged, sumOp<label>());
192
193 if (decompositionConstraint::debug & 2)
194 {
195 reduce(nChanged, sumOp<label>());
196 Info<< type() << " : changed decomposition on " << nChanged
197 << " cells" << endl;
198 }
199
200 } while (nChanged > 0);
201}
202
203
204// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
void setSize(const label n)
Alias for resize()
Definition: List.H:218
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: PtrList.H:73
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:94
wordList names() const
A list of the zone names.
Definition: ZoneMesh.C:304
virtual void apply()=0
Apply bins.
Abstract class for handling decomposition constraints.
Constraint to keep/move owner and neighbour of faceZone onto same processor.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A subset of mesh faces organised as a primitive patch.
Definition: faceZone.H:67
Sums a given list of (at least two or more) fields and outputs the result into a new field,...
Definition: add.H:161
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
static void syncFaceList(const polyMesh &mesh, UList< T > &faceValues, const CombineOp &cop)
Synchronize values on all mesh faces.
Definition: syncTools.H:396
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:54
#define defineTypeName(Type)
Define the typeName.
Definition: className.H:96
dynamicFvMesh & mesh
const labelIOList & zoneIDs
Definition: correctPhi.H:59
Namespace for OpenFOAM.
messageStream Info
Information stream (stdout output on master, null elsewhere)
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:598
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
dictionary dict