processorCyclicPolyPatch.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) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2019-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 "SubField.H"
32#include "cyclicPolyPatch.H"
33
34// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35
36namespace Foam
37{
40}
41
42
43// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
44
46(
47 const label size,
48 const label start,
49 const label index,
50 const polyBoundaryMesh& bm,
51 const int myProcNo,
52 const int neighbProcNo,
53 const word& referPatchName,
54 const transformType transform,
55 const word& patchType
56)
57:
59 (
60 newName(referPatchName, myProcNo, neighbProcNo),
61 size,
62 start,
63 index,
64 bm,
65 myProcNo,
66 neighbProcNo,
68 patchType
69 ),
70 referPatchName_(referPatchName),
71 tag_(-1),
72 referPatchID_(-1)
73{}
74
75
77(
78 const word& name,
79 const dictionary& dict,
80 const label index,
81 const polyBoundaryMesh& bm,
82 const word& patchType
83)
84:
85 processorPolyPatch(name, dict, index, bm, patchType),
86 referPatchName_(dict.lookup("referPatch")),
87 tag_(dict.getOrDefault<int>("tag", -1)),
88 referPatchID_(-1)
89{}
90
91
93(
95 const polyBoundaryMesh& bm
96)
97:
98 processorPolyPatch(pp, bm),
99 referPatchName_(pp.referPatchName()),
100 tag_(pp.tag()),
101 referPatchID_(-1)
102{}
103
104
106(
107 const processorCyclicPolyPatch& pp,
108 const polyBoundaryMesh& bm,
109 const label index,
110 const label newSize,
111 const label newStart
112)
113:
114 processorPolyPatch(pp, bm, index, newSize, newStart),
115 referPatchName_(pp.referPatchName_),
116 tag_(pp.tag()),
117 referPatchID_(-1)
118{}
119
120
122(
123 const processorCyclicPolyPatch& pp,
124 const polyBoundaryMesh& bm,
125 const label index,
126 const label newSize,
127 const label newStart,
128 const word& referPatchName
129)
130:
131 processorPolyPatch(pp, bm, index, newSize, newStart),
132 referPatchName_(referPatchName),
133 tag_(-1),
134 referPatchID_(-1)
135{}
136
137
139(
140 const processorCyclicPolyPatch& pp,
141 const polyBoundaryMesh& bm,
142 const label index,
143 const labelUList& mapAddressing,
144 const label newStart
145)
146:
147 processorPolyPatch(pp, bm, index, mapAddressing, newStart),
148 referPatchName_(pp.referPatchName()),
149 tag_(-1),
150 referPatchID_(-1)
151{}
152
153
154// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
155
157{}
158
159
160// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
161
163(
164 const word& cyclicPolyPatchName,
165 const label myProcNo,
166 const label neighbProcNo
167)
168{
169 return
170 processorPolyPatch::newName(myProcNo, neighbProcNo)
171 + "through"
172 + cyclicPolyPatchName;
173}
174
175
177(
178 const word& cyclicPolyPatchName,
179 const polyBoundaryMesh& bm
180)
181{
182 return bm.indices
183 (
184 wordRe
185 (
186 "procBoundary.*to.*through" + cyclicPolyPatchName,
188 )
189 );
190}
191
192
194{
195 if (tag_ == -1)
196 {
197 // Get unique tag to use for all comms. Make sure that both sides
198 // use the same tag
199 const cyclicPolyPatch& cycPatch = refCast<const cyclicPolyPatch>
200 (
201 referPatch()
202 );
203
204 if (owner())
205 {
206 tag_ = string::hasher()(cycPatch.name()) % 32768u;
207 }
208 else
209 {
210 tag_ = string::hasher()(cycPatch.neighbPatch().name()) % 32768u;
211 }
212
213 if (tag_ == Pstream::msgType() || tag_ == -1)
214 {
216 << "Tag calculated from cyclic patch name " << tag_
217 << " is the same as the current message type "
218 << Pstream::msgType() << " or -1" << nl
219 << "Please set a non-conflicting, unique, tag by hand"
220 << " using the 'tag' entry"
221 << exit(FatalError);
222 }
223 if (debug)
224 {
225 Pout<< "processorCyclicPolyPatch " << name() << " uses tag " << tag_
226 << endl;
227 }
228 }
229 return tag_;
230}
231
232
234{
235 // Send over processorPolyPatch data
237}
238
239
241{
242 // Receive and initialise processorPolyPatch data
244
245 if (Pstream::parRun())
246 {
247
248 // Where do we store the calculated transformation?
249 // - on the processor patch?
250 // - on the underlying cyclic patch?
251 // - or do we not auto-calculate the transformation but
252 // have option of reading it.
253
254 // Update underlying cyclic halves. Need to do both since only one
255 // half might be present as a processorCyclic.
256 coupledPolyPatch& pp = const_cast<coupledPolyPatch&>(referPatch());
257 pp.calcGeometry
258 (
259 *this,
260 faceCentres(),
261 faceAreas(),
262 faceCellCentres(),
263 neighbFaceCentres(),
264 neighbFaceAreas(),
265 neighbFaceCellCentres()
266 );
267
268 if (isA<cyclicPolyPatch>(pp))
269 {
270 const cyclicPolyPatch& cpp = refCast<const cyclicPolyPatch>(pp);
271 const_cast<cyclicPolyPatch&>(cpp.neighbPatch()).calcGeometry
272 (
273 *this,
274 neighbFaceCentres(),
275 neighbFaceAreas(),
276 neighbFaceCellCentres(),
277 faceCentres(),
278 faceAreas(),
279 faceCellCentres()
280 );
281 }
282 }
283}
284
285
287(
288 PstreamBuffers& pBufs,
289 const pointField& p
290)
291{
292 // Recalculate geometry
293 initGeometry(pBufs);
294}
295
296
298(
299 PstreamBuffers& pBufs,
300 const pointField&
301)
302{
303 calcGeometry(pBufs);
304}
305
306
308{
310}
311
312
314{
315 referPatchID_ = -1;
317}
318
319
321(
322 PstreamBuffers& pBufs,
323 const primitivePatch& pp
324) const
325{
326 // Send the patch points and faces across. Note that this is exactly the
327 // same as the processorPolyPatch::initOrder in COINCIDENTFULLMATCH
328 // mode.
329 UOPstream toNeighbour(neighbProcNo(), pBufs);
330 toNeighbour << pp.localPoints()
331 << pp.localFaces();
332}
333
334
336(
337 PstreamBuffers& pBufs,
338 const primitivePatch& pp,
340 labelList& rotation
341) const
342{
343 // Receive the remote patch
344 vectorField masterPts;
345 faceList masterFaces;
346 autoPtr<primitivePatch> masterPtr;
347 {
348 UIPstream fromNeighbour(neighbProcNo(), pBufs);
349 fromNeighbour >> masterPts >> masterFaces;
350 masterPtr.reset
351 (
352 new primitivePatch(SubList<face>(masterFaces), masterPts)
353 );
354 }
355
356 const cyclicPolyPatch& cycPatch =
357 refCast<const cyclicPolyPatch>(referPatch());
358
359 // (ab)use the cyclicPolyPatch ordering:
360 // - owner side stores geometry
361 // - neighbour side does ordering according to owner side
362 cycPatch.neighbPatch().initOrder(pBufs, masterPtr());
363
364 return cycPatch.order(pBufs, pp, faceMap, rotation);
365}
366
367
369{
371 os.writeEntry("referPatch", referPatchName_);
372 os.writeEntryIfDifferent<label>("tag", -1, tag_);
373}
374
375
376// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:239
Ostream & writeEntryIfDifferent(const word &key, const T &value1, const T &value2)
Write a keyword/value entry only when the two values differ.
Definition: Ostream.H:251
A list of faces which address into the list of points.
const Field< point_type > & localPoints() const
Return pointField of points in patch.
const List< face_type > & localFaces() const
Return patch faces addressing into local point list.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
A List obtained as a section of another List.
Definition: SubList.H:70
static int & msgType() noexcept
Message tag of standard messages.
Definition: UPstream.H:556
static bool & parRun() noexcept
Test if this a parallel run.
Definition: UPstream.H:433
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
void reset(autoPtr< T > &&other) noexcept
Delete managed object and set to new given pointer.
Definition: autoPtrI.H:117
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
virtual void calcGeometry(PstreamBuffers &)=0
Calculate the patch geometry.
Cyclic plane patch.
virtual void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialize ordering for primitivePatch. Does not.
virtual bool order(PstreamBuffers &, const primitivePatch &, labelList &faceMap, labelList &rotation) const
Return new ordering for primitivePatch.
const cyclicPolyPatch & neighbPatch() const
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
void calcGeometry()
Calculate the geometry for the patches.
virtual bool write()
Write the output fields.
virtual void initMovePoints()
Initialise the patches for moving points.
Definition: fvPatch.C:188
order
Enumeration specifying required accuracy.
Definition: meshToMesh0.H:148
void movePoints()
Update for new mesh geometry.
void updateMesh()
Update for new mesh topology.
const labelHashSet & patchIDs() const
Return the patchIDs.
const word & name() const noexcept
The patch name.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
labelList indices(const wordRe &matcher, const bool useGroups=true) const
Return (sorted) patch indices for all matches.
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:75
static word newName(const word &cyclicPolyPatchName, const label myProcNo, const label neighbProcNo)
Return the name of a processorCyclicPolyPatch.
void initGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
virtual void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialize ordering for primitivePatch. Does not.
virtual int tag() const
Return message tag to use for communication.
virtual void initUpdateMesh(PstreamBuffers &)
Initialise the update of the patch topology.
Neighbour processor patch.
void initGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
static word newName(const label myProcNo, const label neighbProcNo)
Return the name of a processorPolyPatch.
virtual void initUpdateMesh(PstreamBuffers &)
Initialise the update of the patch topology.
Lookup type of boundary radiation properties.
Definition: lookup.H:66
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
Definition: wordRe.H:83
@ REGEX
Regular expression.
Definition: wordRe.H:105
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
volScalarField & p
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
OBJstream os(runTime.globalPath()/outputName)
Namespace for OpenFOAM.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:536
PrimitivePatch< SubList< face >, const pointField & > primitivePatch
A PrimitivePatch with a SubList addressing for the faces, const reference for the point field.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
error FatalError
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
dictionary dict
Hashing functor for string and derived string classes.
Definition: string.H:148