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-2020 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 label size,
45  const label start,
46  const label index,
47  const polyBoundaryMesh& bm,
48  const int myProcNo,
49  const int neighbProcNo,
50  const word& referPatchName,
51  const word& patchType
52 )
53 :
55  (
56  newName(referPatchName, myProcNo, neighbProcNo),
57  size,
58  start,
59  index,
60  bm,
61  myProcNo,
62  neighbProcNo,
63  patchType
64  ),
65  referPatchName_(referPatchName),
66  tag_(-1),
67  referPatchID_(-1)
68 {}
69 
70 
72 (
73  const word& name,
74  const dictionary& dict,
75  const label index,
76  const polyBoundaryMesh& bm,
77  const word& patchType
78 )
79 :
80  processorPolyPatch(name, dict, index, bm, patchType),
81  referPatchName_(dict.lookup("referPatch")),
82  tag_(dict.lookupOrDefault<int>("tag", -1)),
83  referPatchID_(-1)
84 {}
85 
86 
88 (
89  const processorCyclicPolyPatch& pp,
90  const polyBoundaryMesh& bm
91 )
92 :
93  processorPolyPatch(pp, bm),
94  referPatchName_(pp.referPatchName()),
95  tag_(pp.tag()),
96  referPatchID_(-1)
97 {}
98 
99 
101 (
102  const processorCyclicPolyPatch& pp,
103  const polyBoundaryMesh& bm,
104  const label index,
105  const label newSize,
106  const label newStart
107 )
108 :
109  processorPolyPatch(pp, bm, index, newSize, newStart),
110  referPatchName_(pp.referPatchName_),
111  tag_(pp.tag()),
112  referPatchID_(-1)
113 {}
114 
115 
117 (
118  const processorCyclicPolyPatch& pp,
119  const polyBoundaryMesh& bm,
120  const label index,
121  const label newSize,
122  const label newStart,
123  const word& referPatchName
124 )
125 :
126  processorPolyPatch(pp, bm, index, newSize, newStart),
127  referPatchName_(referPatchName),
128  tag_(-1),
129  referPatchID_(-1)
130 {}
131 
132 
134 (
135  const processorCyclicPolyPatch& pp,
136  const polyBoundaryMesh& bm,
137  const label index,
138  const labelUList& mapAddressing,
139  const label newStart
140 )
141 :
142  processorPolyPatch(pp, bm, index, mapAddressing, newStart),
143  referPatchName_(pp.referPatchName()),
144  tag_(-1),
145  referPatchID_(-1)
146 {}
147 
148 
149 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
150 
152 {}
153 
154 
155 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
156 
158 (
159  const word& cyclicPolyPatchName,
160  const label myProcNo,
161  const label neighbProcNo
162 )
163 {
164  return
165  processorPolyPatch::newName(myProcNo, neighbProcNo)
166  + "through"
167  + cyclicPolyPatchName;
168 }
169 
170 
172 (
173  const word& cyclicPolyPatchName,
174  const polyBoundaryMesh& bm
175 )
176 {
177  return bm.findIndices
178  (
179  keyType(string("procBoundary.*to.*through" + cyclicPolyPatchName))
180  );
181 }
182 
183 
185 {
186  if (tag_ == -1)
187  {
188  // Get unique tag to use for all comms. Make sure that both sides
189  // use the same tag
190  const cyclicPolyPatch& cycPatch = refCast<const cyclicPolyPatch>
191  (
192  referPatch()
193  );
194 
195  if (owner())
196  {
197  tag_ = Hash<word>()(cycPatch.name()) % 32768u;
198  }
199  else
200  {
201  tag_ = Hash<word>()(cycPatch.nbrPatch().name()) % 32768u;
202  }
203 
204  if (tag_ == Pstream::msgType() || tag_ == -1)
205  {
207  << "Tag calculated from cyclic patch name " << tag_
208  << " is the same as the current message type "
209  << Pstream::msgType() << " or -1" << nl
210  << "Please set a non-conflicting, unique, tag by hand"
211  << " using the 'tag' entry"
212  << exit(FatalError);
213  }
214  if (debug)
215  {
216  Pout<< "processorCyclicPolyPatch " << name() << " uses tag " << tag_
217  << endl;
218  }
219  }
220  return tag_;
221 }
222 
223 
225 {
226  // Send over processorPolyPatch data
228 }
229 
230 
232 {
233  // Receive and initialise processorPolyPatch data
235 }
236 
237 
239 (
240  PstreamBuffers& pBufs,
241  const pointField& p
242 )
243 {
244  // Recalculate geometry
245  initCalcGeometry(pBufs);
246 }
247 
248 
250 (
251  PstreamBuffers& pBufs,
252  const pointField&
253 )
254 {
255  calcGeometry(pBufs);
256 }
257 
258 
260 {
262 }
263 
264 
266 {
267  referPatchID_ = -1;
269 }
270 
271 
273 (
274  PstreamBuffers& pBufs,
275  const primitivePatch& pp
276 ) const
277 {
279 }
280 
281 
283 (
284  PstreamBuffers& pBufs,
285  const primitivePatch& pp,
286  labelList& faceMap,
287  labelList& rotation
288 ) const
289 {
290  return processorPolyPatch::order(pBufs, pp, faceMap, rotation);
291 }
292 
293 
295 {
297  writeEntry(os, "referPatch", referPatchName_);
298  if (tag_ != -1)
299  {
300  writeEntry(os, "tag", tag_);
301  }
302 }
303 
304 
305 // ************************************************************************* //
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
A class for handling keywords in dictionaries.
Definition: keyType.H:66
void initCalcGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
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
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:158
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
virtual void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialize 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
Initialize ordering for primitivePatch. Does not.
Macros for easy insertion into run-time selection tables.
Neighbour processor patch.
A list of faces which address into the list of points.
virtual void initUpdateMesh(PstreamBuffers &)
Initialise the update of the patch topology.
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.
processorCyclicPolyPatch(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.
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
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)
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
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
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
labelList findIndices(const keyType &, const bool usePatchGroups=true) const
Return patch indices for all matches. Optionally matches patchGroups.
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:54
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.
virtual void initUpdateMesh(PstreamBuffers &)
Initialise the update of the patch topology.
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:812