processorCyclicPolyPatch.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2026 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
28 #include "SubField.H"
29 #include "cyclicPolyPatch.H"
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
37 }
38 
39 
40 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
41 
43 (
44  const word& name,
45  const label size,
46  const label start,
47  const label index,
48  const polyBoundaryMesh& bm,
49  const int myProcNo,
50  const int neighbProcNo,
51  const word& referPatchName
52 )
53 :
55  (
56  name,
57  size,
58  start,
59  index,
60  bm,
61  myProcNo,
62  neighbProcNo
63  ),
64  referPatchName_(referPatchName),
65  tag_(-1),
66  referPatchIndex_(-1)
67 {}
68 
69 
71 (
72  const label size,
73  const label start,
74  const label index,
75  const polyBoundaryMesh& bm,
76  const int myProcNo,
77  const int neighbProcNo,
78  const word& referPatchName
79 )
80 :
82  (
83  newName(referPatchName, myProcNo, neighbProcNo),
84  size,
85  start,
86  index,
87  bm,
88  myProcNo,
89  neighbProcNo
90  ),
91  referPatchName_(referPatchName),
92  tag_(-1),
93  referPatchIndex_(-1)
94 {}
95 
96 
98 (
99  const word& name,
100  const dictionary& dict,
101  const label index,
102  const polyBoundaryMesh& bm
103 )
104 :
105  processorPolyPatch(name, dict, index, bm),
106  referPatchName_(dict.lookup("referPatch")),
107  tag_(dict.lookupOrDefault<int>("tag", -1)),
108  referPatchIndex_(-1)
109 {}
110 
111 
113 (
114  const processorCyclicPolyPatch& pp,
115  const polyBoundaryMesh& bm
116 )
117 :
118  processorPolyPatch(pp, bm),
119  referPatchName_(pp.referPatchName()),
120  tag_(pp.tag()),
121  referPatchIndex_(-1)
122 {}
123 
124 
126 (
127  const processorCyclicPolyPatch& pp,
128  const polyBoundaryMesh& bm,
129  const label index,
130  const label newSize,
131  const label newStart
132 )
133 :
134  processorPolyPatch(pp, bm, index, newSize, newStart),
135  referPatchName_(pp.referPatchName_),
136  tag_(pp.tag()),
137  referPatchIndex_(-1)
138 {}
139 
140 
141 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
142 
144 {}
145 
146 
147 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
148 
150 (
151  const word& cyclicPolyPatchName,
152  const label myProcNo,
153  const label neighbProcNo
154 )
155 {
156  return
157  processorPolyPatch::newName(myProcNo, neighbProcNo)
158  + "through"
159  + cyclicPolyPatchName;
160 }
161 
162 
164 (
165  const word& cyclicPolyPatchName,
166  const polyBoundaryMesh& bm
167 )
168 {
169  return bm.findIndices
170  (
171  wordRe(string("procBoundary.*to.*through" + cyclicPolyPatchName))
172  );
173 }
174 
175 
177 {
178  if (tag_ == -1)
179  {
180  // Get unique tag to use for all comms. Make sure that both sides
181  // use the same tag.
182  const cyclicPolyPatch& cycPatch =
183  refCast<const cyclicPolyPatch>(referPatch());
184 
186  {
187  tag_ = Hash<word>()(cycPatch.name()) % 32768u;
188  }
189  else
190  {
191  tag_ = Hash<word>()(cycPatch.nbrPatch().name()) % 32768u;
192  }
193 
194  if (tag_ == Pstream::msgType() || tag_ == -1)
195  {
197  << "Tag calculated from cyclic patch name " << tag_
198  << " is the same as the current message type "
199  << Pstream::msgType() << " or -1" << nl
200  << "Please set a non-conflicting, unique, tag by hand"
201  << " using the 'tag' entry"
202  << exit(FatalError);
203  }
204 
205  if (debug)
206  {
207  Pout<< "processorCyclicPolyPatch " << name() << " uses tag " << tag_
208  << endl;
209  }
210  }
211  return tag_;
212 }
213 
214 
216 {
217  // Send over processorPolyPatch data
219 }
220 
221 
223 {
224  // Receive and initialise processorPolyPatch data
226 }
227 
228 
230 (
231  PstreamBuffers& pBufs,
232  const pointField& p
233 )
234 {
235  // Recalculate geometry
236  initCalcGeometry(pBufs);
237 }
238 
239 
241 (
242  PstreamBuffers& pBufs,
243  const pointField&
244 )
245 {
246  calcGeometry(pBufs);
247 }
248 
249 
251 {
253 }
254 
255 
257 {
258  referPatchIndex_ = -1;
260 }
261 
262 
264 (
265  PstreamBuffers& pBufs,
266  const primitivePatch& pp
267 ) const
268 {
270 }
271 
272 
274 (
275  PstreamBuffers& pBufs,
276  const primitivePatch& pp,
278  labelList& rotation
279 ) const
280 {
281  return processorPolyPatch::order(pBufs, pp, faceMap, rotation);
282 }
283 
284 
286 {
288  writeEntry(os, "referPatch", referPatchName_);
289  if (tag_ != -1)
290  {
291  writeEntry(os, "tag", tag_);
292  }
293 }
294 
295 
296 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
Hash function class for primitives. All non-primitives used to hash entries on hash tables likely nee...
Definition: Hash.H:53
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Buffers for inter-processor communications streams (UOPstream, UIPstream).
static int & msgType()
Message tag of standard messages.
Definition: UPstream.H:476
Cyclic plane patch.
const cyclicPolyPatch & nbrPatch() const
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
const word & name() const
Return name.
Foam::polyBoundaryMesh.
labelList findIndices(const wordRe &, const bool usePatchGroups=true) const
Return patch indices for all matches. Optionally matches patchGroups.
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:71
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.
static labelList patchIDs(const word &cyclicPolyPatchName, const polyBoundaryMesh &bm)
Return the indices of a processorCyclicPolyPatchs.
processorCyclicPolyPatch(const word &name, const label size, const label start, const label index, const polyBoundaryMesh &bm, const int myProcNo, const int neighbProcNo, const word &referPatchName)
Construct from components with specified name.
void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
virtual void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialise ordering for primitivePatch. Does not.
void initCalcGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
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 initTopoChange(PstreamBuffers &)
Initialise the update of the patch topology.
virtual void topoChange(PstreamBuffers &)
Update of the patch topology.
Neighbour processor patch.
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
virtual bool owner() const
Does the processor own the patch ?
void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
virtual void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialise ordering for primitivePatch. Does not.
void initCalcGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
static word newName(const label myProcNo, const label neighbProcNo)
Return the name of a processorPolyPatch.
virtual bool order(PstreamBuffers &, const primitivePatch &, labelList &faceMap, labelList &rotation) const
Return new ordering for primitivePatch.
virtual void initTopoChange(PstreamBuffers &)
Initialise the update of the patch topology.
virtual void topoChange(PstreamBuffers &)
Update of the patch topology.
A wordRe is a word, but can also have a regular expression for matching words.
Definition: wordRe.H:77
A class for handling words, derived from string.
Definition: word.H:63
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
const unitSet & lookup(const word &unitName)
Lookup and return the named unit from the table.
Definition: units.C:346
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
addToRunTimeSelectionTable(polyPatch, mergedCyclicPolyPatch, word)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:288
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
prefixOSstream Pout(cout, "Pout")
Definition: IOstreams.H:53
error FatalError
defineTypeNameAndDebug(atmosphericBoundaryLayer, 0)
void writeEntry(Ostream &os, const word &key, const DimensionedFieldFunction< DimensionedFieldType > &f)
static const char nl
Definition: Ostream.H:297
dictionary dict
volScalarField & p