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 | Copyright (C) 2011-2016 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 transformType transform,
52  const word& patchType
53 )
54 :
56  (
57  newName(referPatchName, myProcNo, neighbProcNo),
58  size,
59  start,
60  index,
61  bm,
62  myProcNo,
63  neighbProcNo,
64  transform,
65  patchType
66  ),
67  referPatchName_(referPatchName),
68  tag_(-1),
69  referPatchID_(-1)
70 {}
71 
72 
74 (
75  const word& name,
76  const dictionary& dict,
77  const label index,
78  const polyBoundaryMesh& bm,
79  const word& patchType
80 )
81 :
82  processorPolyPatch(name, dict, index, bm, patchType),
83  referPatchName_(dict.lookup("referPatch")),
84  tag_(dict.lookupOrDefault<int>("tag", -1)),
85  referPatchID_(-1)
86 {}
87 
88 
90 (
91  const processorCyclicPolyPatch& pp,
92  const polyBoundaryMesh& bm
93 )
94 :
95  processorPolyPatch(pp, bm),
96  referPatchName_(pp.referPatchName()),
97  tag_(pp.tag()),
98  referPatchID_(-1)
99 {}
100 
101 
103 (
104  const processorCyclicPolyPatch& pp,
105  const polyBoundaryMesh& bm,
106  const label index,
107  const label newSize,
108  const label newStart
109 )
110 :
111  processorPolyPatch(pp, bm, index, newSize, newStart),
112  referPatchName_(pp.referPatchName_),
113  tag_(pp.tag()),
114  referPatchID_(-1)
115 {}
116 
117 
119 (
120  const processorCyclicPolyPatch& pp,
121  const polyBoundaryMesh& bm,
122  const label index,
123  const label newSize,
124  const label newStart,
125  const word& referPatchName
126 )
127 :
128  processorPolyPatch(pp, bm, index, newSize, newStart),
129  referPatchName_(referPatchName),
130  tag_(-1),
131  referPatchID_(-1)
132 {}
133 
134 
136 (
137  const processorCyclicPolyPatch& pp,
138  const polyBoundaryMesh& bm,
139  const label index,
140  const labelUList& mapAddressing,
141  const label newStart
142 )
143 :
144  processorPolyPatch(pp, bm, index, mapAddressing, newStart),
145  referPatchName_(pp.referPatchName()),
146  tag_(-1),
147  referPatchID_(-1)
148 {}
149 
150 
151 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
152 
154 {}
155 
156 
157 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
158 
160 (
161  const word& cyclicPolyPatchName,
162  const label myProcNo,
163  const label neighbProcNo
164 )
165 {
166  return
167  processorPolyPatch::newName(myProcNo, neighbProcNo)
168  + "through"
169  + cyclicPolyPatchName;
170 }
171 
172 
174 (
175  const word& cyclicPolyPatchName,
176  const polyBoundaryMesh& bm
177 )
178 {
179  return bm.findIndices
180  (
181  string("procBoundary.*to.*through" + cyclicPolyPatchName)
182  );
183 }
184 
185 
187 {
188  if (tag_ == -1)
189  {
190  // Get unique tag to use for all comms. Make sure that both sides
191  // use the same tag
192  const cyclicPolyPatch& cycPatch = refCast<const cyclicPolyPatch>
193  (
194  referPatch()
195  );
196 
197  if (owner())
198  {
199  tag_ = Hash<word>()(cycPatch.name()) % 32768u;
200  }
201  else
202  {
203  tag_ = Hash<word>()(cycPatch.neighbPatch().name()) % 32768u;
204  }
205 
206  if (tag_ == Pstream::msgType() || tag_ == -1)
207  {
209  << "Tag calculated from cyclic patch name " << tag_
210  << " is the same as the current message type "
211  << Pstream::msgType() << " or -1" << nl
212  << "Please set a non-conflicting, unique, tag by hand"
213  << " using the 'tag' entry"
214  << exit(FatalError);
215  }
216  if (debug)
217  {
218  Pout<< "processorCyclicPolyPatch " << name() << " uses tag " << tag_
219  << endl;
220  }
221  }
222  return tag_;
223 }
224 
225 
227 {
228  // Send over processorPolyPatch data
230 }
231 
232 
234 {
235  // Receive and initialise processorPolyPatch data
237 
238  if (Pstream::parRun())
239  {
240 
241  // Where do we store the calculated transformation?
242  // - on the processor patch?
243  // - on the underlying cyclic patch?
244  // - or do we not auto-calculate the transformation but
245  // have option of reading it.
246 
247  // Update underlying cyclic halves. Need to do both since only one
248  // half might be present as a processorCyclic.
249  coupledPolyPatch& pp = const_cast<coupledPolyPatch&>(referPatch());
250  pp.calcGeometry
251  (
252  *this,
253  faceCentres(),
254  faceAreas(),
255  faceCellCentres(),
256  neighbFaceCentres(),
257  neighbFaceAreas(),
258  neighbFaceCellCentres()
259  );
260 
261  if (isA<cyclicPolyPatch>(pp))
262  {
263  const cyclicPolyPatch& cpp = refCast<const cyclicPolyPatch>(pp);
264  const_cast<cyclicPolyPatch&>(cpp.neighbPatch()).calcGeometry
265  (
266  *this,
267  neighbFaceCentres(),
268  neighbFaceAreas(),
269  neighbFaceCellCentres(),
270  faceCentres(),
271  faceAreas(),
272  faceCellCentres()
273  );
274  }
275  }
276 }
277 
278 
280 (
281  PstreamBuffers& pBufs,
282  const pointField& p
283 )
284 {
285  // Recalculate geometry
286  initGeometry(pBufs);
287 }
288 
289 
291 (
292  PstreamBuffers& pBufs,
293  const pointField&
294 )
295 {
296  calcGeometry(pBufs);
297 }
298 
299 
301 {
303 }
304 
305 
307 {
308  referPatchID_ = -1;
310 }
311 
312 
314 (
315  PstreamBuffers& pBufs,
316  const primitivePatch& pp
317 ) const
318 {
319  // For now use the same algorithm as processorPolyPatch
321 }
322 
323 
325 (
326  PstreamBuffers& pBufs,
327  const primitivePatch& pp,
328  labelList& faceMap,
329  labelList& rotation
330 ) const
331 {
332  // For now use the same algorithm as processorPolyPatch
333  return processorPolyPatch::order(pBufs, pp, faceMap, rotation);
334 }
335 
336 
338 {
340  os.writeKeyword("referPatch") << referPatchName_
341  << token::END_STATEMENT << nl;
342  if (tag_ != -1)
343  {
344  os.writeKeyword("tag") << tag_
345  << token::END_STATEMENT << nl;
346  }
347 }
348 
349 
350 // ************************************************************************* //
const cyclicPolyPatch & neighbPatch() const
virtual int tag() const
Return message tag to use for communication.
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
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:137
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
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:253
void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
virtual void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialize ordering for primitivePatch. Does not.
void movePoints(PstreamBuffers &, const pointField &)
Correct patches after moving points.
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
static int & msgType()
Message tag of standard messages.
Definition: UPstream.H:464
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.
virtual void calcGeometry(PstreamBuffers &)=0
Calculate the patch geometry.
virtual void initUpdateMesh(PstreamBuffers &)
Initialise the update of the patch topology.
A class for handling words, derived from string.
Definition: word.H:59
Cyclic plane patch.
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
const word & name() const
Return name.
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
void initGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
labelList findIndices(const keyType &, const bool usePatchGroups=true) const
Return patch indices for all matches. Optionally matches patchGroups.
Foam::polyBoundaryMesh.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
prefixOSstream Pout(cout,"Pout")
Definition: IOstreams.H:53
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
static const char nl
Definition: Ostream.H:262
defineTypeNameAndDebug(combustionModel, 0)
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:54
Buffers for inter-processor communications streams (UOPstream, UIPstream).
void initGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
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.
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:393
virtual void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialize ordering for primitivePatch. Does not.
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
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 void write(Ostream &) const
Write the polyPatch data as a dictionary.
const word & referPatchName() const
Return name of originating cyclicPolyPatch patch.
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.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
virtual void initUpdateMesh(PstreamBuffers &)
Initialise the update of the patch topology.
Namespace for OpenFOAM.
virtual bool order(PstreamBuffers &, const primitivePatch &, labelList &faceMap, labelList &rotation) const
Return new ordering for primitivePatch.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:451