preservePatchesConstraint.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 patches_(coeffDict_.get<wordRes>("patches"))
60{
61 if (decompositionConstraint::debug)
62 {
63 Info<< type()
64 << " : adding constraints to keep owner and (coupled) neighbour"
65 << " of faces in patches " << patches_
66 << " on same processor. This only makes sense for cyclics"
67 << " and cyclicAMI." << endl;
68 }
69}
70
71
73(
75)
76:
78 patches_(patches)
79{
80 if (decompositionConstraint::debug)
81 {
82 Info<< type()
83 << " : adding constraints to keep owner and (coupled) neighbour"
84 << " of faces in patches " << patches_
85 << " on same processor. This only makes sense for cyclics"
86 << " and cyclicAMI." << endl;
87 }
88}
89
90
91// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
92
94(
95 const polyMesh& mesh,
96 boolList& blockedFace,
97 PtrList<labelList>& specifiedProcessorFaces,
98 labelList& specifiedProcessor,
99 List<labelPair>& explicitConnections
100) const
101{
102 const polyBoundaryMesh& pbm = mesh.boundaryMesh();
103
104 blockedFace.resize(mesh.nFaces(), true);
105
106 const labelList patchIDs(pbm.patchSet(patches_).sortedToc());
107
108 label nUnblocked = 0;
109
110 for (const label patchi : patchIDs)
111 {
112 const polyPatch& pp = pbm[patchi];
113
114 forAll(pp, i)
115 {
116 const label meshFacei = pp.start() + i;
117
118 if (blockedFace[meshFacei])
119 {
120 blockedFace[meshFacei] = false;
121 ++nUnblocked;
122 }
123 }
124 }
125
126 if (decompositionConstraint::debug & 2)
127 {
128 reduce(nUnblocked, sumOp<label>());
129 Info<< type() << " : unblocked " << nUnblocked << " faces" << endl;
130 }
131
133}
134
135
137(
138 const polyMesh& mesh,
139 const boolList& blockedFace,
140 const PtrList<labelList>& specifiedProcessorFaces,
141 const labelList& specifiedProcessor,
142 const List<labelPair>& explicitConnections,
143 labelList& decomposition
144) const
145{
146 // If the decomposition has not enforced the constraint, do it over here.
147
148 const polyBoundaryMesh& pbm = mesh.boundaryMesh();
149
150 const labelList patchIDs(pbm.patchSet(patches_).sortedToc());
151
152 // Synchronise decomposition on patchIDs
153 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
154
155 label nChanged;
156
157 do
158 {
159 // Extract min coupled boundary data
160 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
161
162 labelList destProc;
163 getMinBoundaryValue(mesh, decomposition, destProc);
164
165
166 // Override (patchIDs only) if differing
167 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
168
169 nChanged = 0;
170 for (const label patchi : patchIDs)
171 {
172 const polyPatch& pp = pbm[patchi];
173
174 const labelUList& faceCells = pp.faceCells();
175
176 forAll(faceCells, i)
177 {
178 const label bFacei = pp.offset()+i;
179 if (destProc[bFacei] < decomposition[faceCells[i]])
180 {
181 decomposition[faceCells[i]] = destProc[bFacei];
182 ++nChanged;
183 }
184 }
185 }
186
187 reduce(nChanged, sumOp<label>());
188
189 if (decompositionConstraint::debug & 2)
190 {
191 Info<< type() << " : changed decomposition on " << nChanged
192 << " cells" << endl;
193 }
194
195 } while (nChanged > 0);
196}
197
198
199// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
List< Key > sortedToc() const
The table of contents (the keys) in sorted order.
Definition: HashTable.C:137
void resize(const label len)
Adjust allocated size of list.
Definition: ListI.H:139
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
virtual void apply()=0
Apply bins.
Abstract class for handling decomposition constraints.
Constraint to keep owner and neighbour of (cyclic) patch on same processor.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Smooth ATC in cells next to a set of patches supplied by type.
Definition: faceCells.H:59
Sums a given list of (at least two or more) fields and outputs the result into a new field,...
Definition: add.H:161
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
labelHashSet patchSet(const UList< wordRe > &patchNames, const bool warnNotFound=true, const bool useGroups=true) const
Return the set of patch IDs corresponding to the given names.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:75
label offset() const
The offset where this patch starts in the boundary face list.
Definition: polyPatch.C:309
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:364
const labelUList & faceCells() const
Return face-cell addressing.
Definition: polyPatch.C:371
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
const polyBoundaryMesh & patches
dynamicFvMesh & mesh
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
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333