Loading...
Searching...
No Matches
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-2023 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"
33
34// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35
36namespace Foam
37{
40}
41
42
43// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
44
46(
47 const word& cyclicPolyPatchName,
48 const label myProcNo,
49 const label neighbProcNo
50)
51{
52 return word
53 (
55 + "through"
56 + cyclicPolyPatchName
57 );
58}
59
60
62(
63 const word& cyclicPolyPatchName,
64 const polyBoundaryMesh& bm
65)
66{
67 return bm.indices
68 (
69 wordRe
70 (
71 "procBoundary.*to.*through" + cyclicPolyPatchName,
73 )
74 );
75}
76
77
78// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
79
81(
82 const label size,
83 const label start,
84 const label index,
85 const polyBoundaryMesh& bm,
86 const int myProcNo,
87 const int neighbProcNo,
88 const word& referPatchName,
89 const transformType transform,
90 const word& patchType
91)
92:
94 (
95 newName(referPatchName, myProcNo, neighbProcNo),
96 size,
97 start,
98 index,
99 bm,
100 myProcNo,
101 neighbProcNo,
102 transform,
103 patchType
104 ),
105 referPatchName_(referPatchName),
106 tag_(-1),
107 referPatchID_(-1)
108{}
109
110
112(
113 const word& name,
114 const dictionary& dict,
115 const label index,
116 const polyBoundaryMesh& bm,
117 const word& patchType
118)
119:
121 referPatchName_(dict.lookup("referPatch")),
122 tag_(dict.getOrDefault<int>("tag", -1)),
123 referPatchID_(-1)
124{}
125
126
128(
130 const polyBoundaryMesh& bm
131)
132:
134 referPatchName_(pp.referPatchName()),
135 tag_(pp.tag()),
136 referPatchID_(-1)
137{}
138
139
141(
143 const polyBoundaryMesh& bm,
144 const label index,
145 const label newSize,
146 const label newStart
147)
148:
149 processorPolyPatch(pp, bm, index, newSize, newStart),
150 referPatchName_(pp.referPatchName_),
151 tag_(pp.tag()),
152 referPatchID_(-1)
153{}
154
155
157(
159 const polyBoundaryMesh& bm,
160 const label index,
161 const label newSize,
162 const label newStart,
163 const word& referPatchName
164)
165:
166 processorPolyPatch(pp, bm, index, newSize, newStart),
167 referPatchName_(referPatchName),
168 tag_(-1),
169 referPatchID_(-1)
170{}
171
172
174(
176 const polyBoundaryMesh& bm,
177 const label index,
178 const labelUList& mapAddressing,
179 const label newStart
180)
181:
182 processorPolyPatch(pp, bm, index, mapAddressing, newStart),
183 referPatchName_(pp.referPatchName()),
184 tag_(-1),
185 referPatchID_(-1)
186{}
187
188
189// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
190
192{
193 if (referPatchID_ == -1)
194 {
195 referPatchID_ = this->boundaryMesh().findPatchID
196 (
197 referPatchName_
198 );
199
200 if (referPatchID_ == -1)
201 {
203 << "Illegal referPatch name " << referPatchName_ << nl
204 << "Valid patch names: "
205 << this->boundaryMesh().names() << nl
206 << exit(FatalError);
208 }
209
210 return referPatchID_;
211}
212
213
215{
216 if (tag_ == -1)
217 {
218 // Get unique tag to use for all comms. Make sure that both sides
219 // use the same tag
221 (
222 referPatch()
223 );
224
225 if (owner())
226 {
227 tag_ = string::hasher()(cycPatch.name()) % 32768u;
228 }
229 else
230 {
231 tag_ = string::hasher()(cycPatch.neighbPatch().name()) % 32768u;
232 }
233
234 if (tag_ == UPstream::msgType() || tag_ == -1)
235 {
237 << "Tag calculated from cyclic patch name " << tag_
238 << " is the same as the current message type "
239 << UPstream::msgType() << " or -1" << nl
240 << "Please set a non-conflicting, unique, tag by hand"
241 << " using the 'tag' entry"
242 << exit(FatalError);
243 }
244 if (debug)
245 {
246 Pout<< "processorCyclicPolyPatch " << name() << " uses tag " << tag_
248 }
249 }
250 return tag_;
251}
252
253
255{
256 // Send over processorPolyPatch data
258}
259
260
262{
263 // Receive and initialise processorPolyPatch data
265
266 if (UPstream::parRun())
267 {
268 // Where do we store the calculated transformation?
269 // - on the processor patch?
270 // - on the underlying cyclic patch?
271 // - or do we not auto-calculate the transformation but
272 // have option of reading it.
273
274 // Update underlying cyclic halves. Need to do both since only one
275 // half might be present as a processorCyclic.
276 coupledPolyPatch& pp = const_cast<coupledPolyPatch&>(referPatch());
277 pp.calcGeometry
278 (
279 *this,
280 faceCentres(),
281 faceAreas(),
282 faceCellCentres(),
283 neighbFaceCentres(),
284 neighbFaceAreas(),
285 neighbFaceCellCentres()
286 );
287
289 {
291 const_cast<cyclicPolyPatch&>(cpp.neighbPatch()).calcGeometry
292 (
293 *this,
294 neighbFaceCentres(),
295 neighbFaceAreas(),
296 neighbFaceCellCentres(),
297 faceCentres(),
298 faceAreas(),
300 );
301 }
302 }
303}
304
305
307(
308 PstreamBuffers& pBufs,
309 const pointField& p
311{
312 // Recalculate geometry
313 initGeometry(pBufs);
314}
315
316
318(
319 PstreamBuffers& pBufs,
321)
322{
323 calcGeometry(pBufs);
324}
325
331
332
334{
335 referPatchID_ = -1;
337}
338
339
341(
342 PstreamBuffers& pBufs,
343 const primitivePatch& pp
344) const
345{
346 // Send the patch points and faces across. Note that this is exactly the
347 // same as the processorPolyPatch::initOrder in COINCIDENTFULLMATCH
348 // mode.
349 UOPstream toNeighbour(neighbProcNo(), pBufs);
350 toNeighbour << pp.localPoints()
351 << pp.localFaces();
352}
353
354
356(
357 PstreamBuffers& pBufs,
358 const primitivePatch& pp,
360 labelList& rotation
361) const
362{
363 // Receive the remote patch
364 vectorField masterPts;
365 faceList masterFaces;
366 autoPtr<primitivePatch> masterPtr;
367 {
368 UIPstream fromNeighbour(neighbProcNo(), pBufs);
369 fromNeighbour >> masterPts >> masterFaces;
370 masterPtr.reset
371 (
372 new primitivePatch(SubList<face>(masterFaces), masterPts)
373 );
374 }
375
376 const cyclicPolyPatch& cycPatch =
377 refCast<const cyclicPolyPatch>(referPatch());
378
379 // (ab)use the cyclicPolyPatch ordering:
380 // - owner side stores geometry
381 // - neighbour side does ordering according to owner side
382 cycPatch.neighbPatch().initOrder(pBufs, masterPtr());
383
384 return cycPatch.order(pBufs, pp, faceMap, rotation);
385}
386
387
389{
391 os.writeEntry("referPatch", referPatchName_);
392 os.writeEntryIfDifferent<label>("tag", -1, tag_);
393}
394
395
396// ************************************************************************* //
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())
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
Buffers for inter-processor communications streams (UOPstream, UIPstream).
A non-owning sub-view of a List (allocated or unallocated storage).
Definition SubList.H:61
Input inter-processor communications stream using MPI send/recv etc. - operating on external buffer.
Definition UIPstream.H:313
void size(const label n)
Definition UList.H:118
Output inter-processor communications stream using MPI send/recv etc. - operating on external buffer.
Definition UOPstream.H:408
static bool parRun(const bool on) noexcept
Set as parallel run on/off.
Definition UPstream.H:1669
static int & msgType() noexcept
Message tag of standard messages.
Definition UPstream.H:1926
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
void reset(T *p=nullptr) noexcept
Delete managed object and set to new given pointer.
Definition autoPtrI.H:37
Addressing for all faces on surface of mesh. Can either be read from polyMesh or from triSurface....
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
Cyclic plane patch.
virtual void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
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:133
label index() const noexcept
The index of this patch in the boundaryMesh.
const word & name() const noexcept
The patch name.
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh,...
labelList indices(const wordRe &matcher, const bool useGroups=true) const
The (sorted) patch indices for all matches, optionally matching patch groups.
A patch is a list of labels that address the faces in the global face list.
Definition polyPatch.H:73
const vectorField::subField faceAreas() const
Return face normals.
Definition polyPatch.C:326
const vectorField::subField faceCentres() const
Return face centres.
Definition polyPatch.C:320
label start() const noexcept
Return start label of this patch in the polyMesh face list.
Definition polyPatch.H:446
tmp< vectorField > faceCellCentres() const
Return face cell centres.
Definition polyPatch.C:332
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
virtual transformType transform() const
Type of transform.
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
void initMovePoints(PstreamBuffers &, const pointField &)
Initialise the patches for moving points.
static word newName(const word &cyclicPolyPatchName, const label myProcNo, const label neighbProcNo)
Return the name of a processorCyclicPolyPatch constructed from the cyclicPolyPatch name and the pair ...
processorCyclicPolyPatch(const label size, const label start, const label index, const polyBoundaryMesh &bm, const int myProcNo, const int neighbProcNo, const word &referPatchName, const transformType transform=UNKNOWN, const word &patchType=typeName)
Construct from components.
virtual bool owner() const
Does this side own the patch ?
static labelList patchIDs(const word &cyclicPolyPatchName, const polyBoundaryMesh &bm)
Return the indices of a processorCyclicPolyPatchs.
const coupledPolyPatch & referPatch() const
The referred coupled patch.
void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
virtual label referPatchID() const
The referring patchID. Searches for referPatchName() on the first call.
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 bool order(PstreamBuffers &, const primitivePatch &, labelList &faceMap, labelList &rotation) const
Return new ordering for primitivePatch.
void movePoints(PstreamBuffers &, const pointField &)
Correct patches after moving points.
virtual void initUpdateMesh(PstreamBuffers &)
Initialise the update of the patch topology.
const word & referPatchName() const
Return name of originating cyclicPolyPatch patch.
Neighbour processor patch.
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
int neighbProcNo() const noexcept
Return neighbour processor number.
void initGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
const vectorField & neighbFaceAreas() const noexcept
Return processor-neighbour patch face areas.
static word newName(const label myProcNo, const label neighbProcNo)
Return the name of a processorPolyPatch ("procBoundary..") constructed from the pair of processor IDs...
processorPolyPatch(const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm, const int myProcNo, const int neighbProcNo, const transformType transform=UNKNOWN, const word &patchType=typeName)
Construct from components with specified name.
int myProcNo() const noexcept
Return processor number.
virtual void initUpdateMesh(PstreamBuffers &)
Initialise the update of the patch topology.
const vectorField & neighbFaceCellCentres() const noexcept
Return processor-neighbour patch neighbour cell centres.
const vectorField & neighbFaceCentres() const noexcept
Return processor-neighbour patch face centres.
Lookup type of boundary radiation properties.
Definition lookup.H:60
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
Definition wordRe.H:81
@ REGEX
Regular expression.
Definition wordRe.H:110
A class for handling words, derived from Foam::string.
Definition word.H:66
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
volScalarField & p
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
OBJstream os(runTime.globalPath()/outputName)
auto & name
Namespace for handling debugging switches.
Definition debug.C:45
Namespace for OpenFOAM.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
Definition typeInfo.H:172
List< label > labelList
A List of labels.
Definition List.H:62
refinementData transform(const tensor &, const refinementData val)
No-op rotational transform for base types.
PrimitivePatch< SubList< face >, const pointField & > primitivePatch
A PrimitivePatch with a SubList addressing for the faces, const reference for the point field.
List< face > faceList
List of faces.
Definition faceListFwd.H:41
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
Definition typeInfo.H:87
Field< vector > vectorField
Specialisation of Field<T> for vector.
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
vectorField pointField
pointField is a vectorField.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125
UList< label > labelUList
A UList of labels.
Definition UList.H:75
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
dictionary dict
Hashing functor for string and derived string classes.
Definition string.H:173