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 -------------------------------------------------------------------------------
11 License
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 
35 namespace Foam
36 {
37 namespace decompositionConstraints
38 {
39  defineTypeName(preserveFaceZones);
40 
42  (
43  decompositionConstraint,
44  preserveFaceZones,
45  dictionary
46  );
47 }
48 }
49 
50 
51 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
52 
54 (
55  const dictionary& dict
56 )
57 :
58  decompositionConstraint(dict, typeName),
59  zones_(coeffDict_.get<wordRes>("zones"))
60 {
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 {
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 
121  {
122  reduce(nUnblocked, sumOp<label>());
123  Info<< type() << " : unblocked " << nUnblocked << " faces" << endl;
124  }
125 
126  syncTools::syncFaceList(mesh, blockedFace, andEqOp<bool>());
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 
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 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
preserveFaceZonesConstraint.H
Foam::decompositionConstraints::preserveFaceZones::apply
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.
Definition: preserveFaceZonesConstraint.C:131
Foam::decompositionConstraint
Abstract class for handling decomposition constraints.
Definition: decompositionConstraint.H:58
Foam::decompositionConstraints::defineTypeName
defineTypeName(geometric)
Foam::andEqOp
Definition: ops.H:85
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
syncTools.H
zoneIDs
const labelIOList & zoneIDs
Definition: correctPhi.H:59
Foam::decompositionConstraints::preserveFaceZones::preserveFaceZones
preserveFaceZones(const dictionary &dict)
Construct with constraint dictionary.
Definition: preserveFaceZonesConstraint.C:54
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::sumOp
Definition: ops.H:213
Foam::decompositionConstraints::preserveFaceZones::add
virtual void add(const polyMesh &mesh, boolList &blockedFace, PtrList< labelList > &specifiedProcessorFaces, labelList &specifiedProcessor, List< labelPair > &explicitConnections) const
Add my constraints to list of constraints.
Definition: preserveFaceZonesConstraint.C:90
Foam::faceZone
A subset of mesh faces organised as a primitive patch.
Definition: faceZone.H:64
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::List::setSize
void setSize(const label n)
Alias for resize()
Definition: List.H:222
Foam::ZoneMesh< faceZone, polyMesh >
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:59
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
reduce
reduce(hasMovingMesh, orOp< bool >())
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::ZoneMesh::names
wordList names() const
A list of the zone names.
Definition: ZoneMesh.C:305
Foam::decompositionConstraints::addToRunTimeSelectionTable
addToRunTimeSelectionTable(decompositionConstraint, geometric, dictionary)
Foam::List< bool >
Foam::UList
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:103
Foam::wordRes
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:51
Foam::roots::type
type
Types of root.
Definition: Roots.H:54