Loading...
Searching...
No Matches
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-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 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 Info<< type() << " : unblocked "
123 << returnReduce(nUnblocked, sumOp<label>()) << " 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 = 0;
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 if (decompositionConstraint::debug & 2)
192 {
193 Info<< type() << " : changed decomposition on "
194 << returnReduce(nChanged, sumOp<label>()) << " cells" << endl;
195 }
196
197 } while (returnReduceOr(nChanged));
198}
199
200
201// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
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 setSize(label n)
Alias for resize().
Definition List.H:536
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
wordList names() const
A list of the zone names.
Definition ZoneMesh.C:463
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/move owner and neighbour of faceZone onto 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.
preserveFaceZones(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
A subset of mesh faces organised as a primitive patch.
Definition faceZone.H:63
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
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
dynamicFvMesh & mesh
const labelIOList & zoneIDs
Definition correctPhi.H:59
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).
ZoneMesh< faceZone, polyMesh > faceZoneMesh
A ZoneMesh with faceZone content on a polyMesh.
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
dictionary dict