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-2022 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 {
35  defineTypeNameAndDebug(processorCyclicPolyPatch, 0);
36  addToRunTimeSelectionTable(polyPatch, processorCyclicPolyPatch, dictionary);
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  referPatchID_(-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  referPatchID_(-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  referPatchID_(-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  referPatchID_(-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  referPatchID_(-1)
143 {}
144 
145 
147 (
148  const processorCyclicPolyPatch& pp,
149  const polyBoundaryMesh& bm,
150  const label index,
151  const labelUList& mapAddressing,
152  const label newStart
153 )
154 :
155  processorPolyPatch(pp, bm, index, mapAddressing, newStart),
156  referPatchName_(pp.referPatchName()),
157  tag_(-1),
158  referPatchID_(-1)
159 {}
160 
161 
162 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
163 
165 {}
166 
167 
168 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
169 
171 (
172  const word& cyclicPolyPatchName,
173  const label myProcNo,
174  const label neighbProcNo
175 )
176 {
177  return
178  processorPolyPatch::newName(myProcNo, neighbProcNo)
179  + "through"
180  + cyclicPolyPatchName;
181 }
182 
183 
185 (
186  const word& cyclicPolyPatchName,
187  const polyBoundaryMesh& bm
188 )
189 {
190  return bm.findIndices
191  (
192  wordRe(string("procBoundary.*to.*through" + cyclicPolyPatchName))
193  );
194 }
195 
196 
198 {
199  if (tag_ == -1)
200  {
201  // Get unique tag to use for all comms. Make sure that both sides
202  // use the same tag.
203  const cyclicPolyPatch& cycPatch =
204  refCast<const cyclicPolyPatch>(referPatch());
205 
207  {
208  tag_ = Hash<word>()(cycPatch.name()) % 32768u;
209  }
210  else
211  {
212  tag_ = Hash<word>()(cycPatch.nbrPatch().name()) % 32768u;
213  }
214 
215  if (tag_ == Pstream::msgType() || tag_ == -1)
216  {
218  << "Tag calculated from cyclic patch name " << tag_
219  << " is the same as the current message type "
220  << Pstream::msgType() << " or -1" << nl
221  << "Please set a non-conflicting, unique, tag by hand"
222  << " using the 'tag' entry"
223  << exit(FatalError);
224  }
225 
226  if (debug)
227  {
228  Pout<< "processorCyclicPolyPatch " << name() << " uses tag " << tag_
229  << endl;
230  }
231  }
232  return tag_;
233 }
234 
235 
237 {
238  // Send over processorPolyPatch data
240 }
241 
242 
244 {
245  // Receive and initialise processorPolyPatch data
247 }
248 
249 
251 (
252  PstreamBuffers& pBufs,
253  const pointField& p
254 )
255 {
256  // Recalculate geometry
257  initCalcGeometry(pBufs);
258 }
259 
260 
262 (
263  PstreamBuffers& pBufs,
264  const pointField&
265 )
266 {
267  calcGeometry(pBufs);
268 }
269 
270 
272 {
274 }
275 
276 
278 {
279  referPatchID_ = -1;
281 }
282 
283 
285 (
286  PstreamBuffers& pBufs,
287  const primitivePatch& pp
288 ) const
289 {
291 }
292 
293 
295 (
296  PstreamBuffers& pBufs,
297  const primitivePatch& pp,
298  labelList& faceMap,
299  labelList& rotation
300 ) const
301 {
302  return processorPolyPatch::order(pBufs, pp, faceMap, rotation);
303 }
304 
305 
307 {
309  writeEntry(os, "referPatch", referPatchName_);
310  if (tag_ != -1)
311  {
312  writeEntry(os, "tag", tag_);
313  }
314 }
315 
316 
317 // ************************************************************************* //
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
void initCalcGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
const word & name() const
Return name.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
virtual void topoChange(PstreamBuffers &)
Update of the patch topology.
virtual void initTopoChange(PstreamBuffers &)
Initialise the update of the patch topology.
virtual void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialise ordering for primitivePatch. Does not.
static word newName(const label myProcNo, const label neighbProcNo)
Return the name of a processorPolyPatch.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
void movePoints(PstreamBuffers &, const pointField &)
Correct patches after moving points.
static int & msgType()
Message tag of standard messages.
Definition: UPstream.H:476
void initCalcGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
const cyclicPolyPatch & nbrPatch() const
virtual void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialise ordering for primitivePatch. Does not.
virtual void topoChange(PstreamBuffers &)
Update of the patch topology.
Macros for easy insertion into run-time selection tables.
Neighbour processor patch.
A list of faces which address into the list of points.
virtual bool order(PstreamBuffers &, const primitivePatch &, labelList &faceMap, labelList &rotation) const
Return new ordering for primitivePatch.
A class for handling words, derived from string.
Definition: word.H:59
Cyclic plane patch.
A wordRe is a word, but can also have a regular expression for matching words.
Definition: wordRe.H:74
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:60
Foam::polyBoundaryMesh.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
static const char nl
Definition: Ostream.H:260
defineTypeNameAndDebug(combustionModel, 0)
Buffers for inter-processor communications streams (UOPstream, UIPstream).
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
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.
void initMovePoints(PstreamBuffers &, const pointField &)
Initialise the patches for moving points.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
prefixOSstream Pout(cout, "Pout")
Definition: IOstreams.H:53
static labelList patchIDs(const word &cyclicPolyPatchName, const polyBoundaryMesh &bm)
Return the indices of a processorCyclicPolyPatchs.
Hash function class for primitives. All non-primitives used to hash entries on hash tables likely nee...
Definition: Hash.H:52
const word & referPatchName() const
Return name of originating cyclicPolyPatch patch.
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
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 calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
static word newName(const word &cyclicPolyPatchName, const label myProcNo, const label neighbProcNo)
Return the name of a processorCyclicPolyPatch.
labelList findIndices(const wordRe &, const bool usePatchGroups=true) const
Return patch indices for all matches. Optionally matches patchGroups.
Namespace for OpenFOAM.
virtual bool owner() const
Does the processor own the patch ?
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:864
virtual void initTopoChange(PstreamBuffers &)
Initialise the update of the patch topology.