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-2023 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  const word& patchType
53 )
54 :
56  (
57  name,
58  size,
59  start,
60  index,
61  bm,
62  myProcNo,
63  neighbProcNo,
64  patchType
65  ),
66  referPatchName_(referPatchName),
67  tag_(-1),
68  referPatchIndex_(-1)
69 {}
70 
71 
73 (
74  const label size,
75  const label start,
76  const label index,
77  const polyBoundaryMesh& bm,
78  const int myProcNo,
79  const int neighbProcNo,
80  const word& referPatchName,
81  const word& patchType
82 )
83 :
85  (
86  newName(referPatchName, myProcNo, neighbProcNo),
87  size,
88  start,
89  index,
90  bm,
91  myProcNo,
92  neighbProcNo,
93  patchType
94  ),
95  referPatchName_(referPatchName),
96  tag_(-1),
97  referPatchIndex_(-1)
98 {}
99 
100 
102 (
103  const word& name,
104  const dictionary& dict,
105  const label index,
106  const polyBoundaryMesh& bm,
107  const word& patchType
108 )
109 :
110  processorPolyPatch(name, dict, index, bm, patchType),
111  referPatchName_(dict.lookup("referPatch")),
112  tag_(dict.lookupOrDefault<int>("tag", -1)),
113  referPatchIndex_(-1)
114 {}
115 
116 
118 (
119  const processorCyclicPolyPatch& pp,
120  const polyBoundaryMesh& bm
121 )
122 :
123  processorPolyPatch(pp, bm),
124  referPatchName_(pp.referPatchName()),
125  tag_(pp.tag()),
126  referPatchIndex_(-1)
127 {}
128 
129 
131 (
132  const processorCyclicPolyPatch& pp,
133  const polyBoundaryMesh& bm,
134  const label index,
135  const label newSize,
136  const label newStart
137 )
138 :
139  processorPolyPatch(pp, bm, index, newSize, newStart),
140  referPatchName_(pp.referPatchName_),
141  tag_(pp.tag()),
142  referPatchIndex_(-1)
143 {}
144 
145 
146 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
147 
149 {}
150 
151 
152 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
153 
155 (
156  const word& cyclicPolyPatchName,
157  const label myProcNo,
158  const label neighbProcNo
159 )
160 {
161  return
162  processorPolyPatch::newName(myProcNo, neighbProcNo)
163  + "through"
164  + cyclicPolyPatchName;
165 }
166 
167 
169 (
170  const word& cyclicPolyPatchName,
171  const polyBoundaryMesh& bm
172 )
173 {
174  return bm.findIndices
175  (
176  wordRe(string("procBoundary.*to.*through" + cyclicPolyPatchName))
177  );
178 }
179 
180 
182 {
183  if (tag_ == -1)
184  {
185  // Get unique tag to use for all comms. Make sure that both sides
186  // use the same tag.
187  const cyclicPolyPatch& cycPatch =
188  refCast<const cyclicPolyPatch>(referPatch());
189 
191  {
192  tag_ = Hash<word>()(cycPatch.name()) % 32768u;
193  }
194  else
195  {
196  tag_ = Hash<word>()(cycPatch.nbrPatch().name()) % 32768u;
197  }
198 
199  if (tag_ == Pstream::msgType() || tag_ == -1)
200  {
202  << "Tag calculated from cyclic patch name " << tag_
203  << " is the same as the current message type "
204  << Pstream::msgType() << " or -1" << nl
205  << "Please set a non-conflicting, unique, tag by hand"
206  << " using the 'tag' entry"
207  << exit(FatalError);
208  }
209 
210  if (debug)
211  {
212  Pout<< "processorCyclicPolyPatch " << name() << " uses tag " << tag_
213  << endl;
214  }
215  }
216  return tag_;
217 }
218 
219 
221 {
222  // Send over processorPolyPatch data
224 }
225 
226 
228 {
229  // Receive and initialise processorPolyPatch data
231 }
232 
233 
235 (
236  PstreamBuffers& pBufs,
237  const pointField& p
238 )
239 {
240  // Recalculate geometry
241  initCalcGeometry(pBufs);
242 }
243 
244 
246 (
247  PstreamBuffers& pBufs,
248  const pointField&
249 )
250 {
251  calcGeometry(pBufs);
252 }
253 
254 
256 {
258 }
259 
260 
262 {
263  referPatchIndex_ = -1;
265 }
266 
267 
269 (
270  PstreamBuffers& pBufs,
271  const primitivePatch& pp
272 ) const
273 {
275 }
276 
277 
279 (
280  PstreamBuffers& pBufs,
281  const primitivePatch& pp,
283  labelList& rotation
284 ) const
285 {
286  return processorPolyPatch::order(pBufs, pp, faceMap, rotation);
287 }
288 
289 
291 {
293  writeEntry(os, "referPatch", referPatchName_);
294  if (tag_ != -1)
295  {
296  writeEntry(os, "tag", tag_);
297  }
298 }
299 
300 
301 // ************************************************************************* //
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 keyword definitions, which are a keyword followed by any number of values (e....
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:70
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.
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.
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, const word &patchType=typeName)
Construct from components with specified name.
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:62
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
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:257
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
defineTypeNameAndDebug(combustionModel, 0)
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
prefixOSstream Pout(cout, "Pout")
Definition: IOstreams.H:53
error FatalError
static const char nl
Definition: Ostream.H:266
dictionary dict
volScalarField & p