Loading...
Searching...
No Matches
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-2022 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"
33// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35namespace Foam
36{
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 Info<< type() << " : unblocked "
129 << returnReduce(nUnblocked, sumOp<label>()) << " 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 = 0;
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 if (decompositionConstraint::debug & 2)
188 {
189 Info<< type() << " : changed decomposition on "
190 << returnReduce(nChanged, sumOp<label>()) << " cells" << endl;
191 }
192
193 } while (returnReduceOr(nChanged));
194}
195
196
197// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
labelList patchIDs
const polyBoundaryMesh & pbm
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition List.H:72
void resize(const label len)
Adjust allocated size of list.
Definition ListI.H:153
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition PtrList.H:67
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
Abstract class for handling decomposition constraints.
dictionary coeffDict_
Constraint coefficients dictionary.
void getMinBoundaryValue(const polyMesh &mesh, const labelList &decomposition, labelList &destProc) const
Get minimum label across coupled boundary faces.
decompositionConstraint(const decompositionConstraint &)=delete
No copy construct.
Constraint to keep owner and neighbour of (cyclic) patch on same processor.
virtual void apply(const polyMesh &mesh, const boolList &blockedFace, const PtrList< labelList > &specifiedProcessorFaces, const labelList &specifiedProcessor, const List< labelPair > &explicitConnections, labelList &decomposition) const
Apply any additional post-decomposition constraints.
virtual void add(const polyMesh &mesh, boolList &blockedFace, PtrList< labelList > &specifiedProcessorFaces, labelList &specifiedProcessor, List< labelPair > &explicitConnections) const
Add my constraints to list of constraints.
preservePatches(const dictionary &dict)
Construct with constraint dictionary.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
Smooth ATC in cells next to a set of patches supplied by type.
Definition faceCells.H:55
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh,...
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
A patch is a list of labels that address the faces in the global face list.
Definition polyPatch.H:73
static void syncFaceList(const polyMesh &mesh, UList< T > &faceValues, const CombineOp &cop, const bool parRun=UPstream::parRun())
Synchronize values on all mesh faces.
Definition syncTools.H:465
A List of wordRe with additional matching capabilities.
Definition wordRes.H:56
#define defineTypeName(Type)
Define the typeName.
Definition className.H:113
const polyBoundaryMesh & patches
dynamicFvMesh & mesh
Namespace for OpenFOAM.
bool returnReduceOr(const bool value, const int communicator=UPstream::worldComm)
Perform logical (or) MPI Allreduce on a copy. Uses UPstream::reduceOr.
List< label > labelList
A List of labels.
Definition List.H:62
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 POSIX.C:801
T returnReduce(const T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Perform reduction on a copy, using specified binary operation.
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
List< bool > boolList
A List of bools.
Definition List.H:60
UList< label > labelUList
A UList of labels.
Definition UList.H:75
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299