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-2014 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 transformType transform,
53  const word& patchType
54 )
55 :
57  (
58  name,
59  size,
60  start,
61  index,
62  bm,
63  myProcNo,
64  neighbProcNo,
65  transform,
66  patchType
67  ),
68  referPatchName_(referPatchName),
69  tag_(-1),
70  referPatchID_(-1)
71 {}
72 
73 
75 (
76  const word& name,
77  const dictionary& dict,
78  const label index,
79  const polyBoundaryMesh& bm,
80  const word& patchType
81 )
82 :
83  processorPolyPatch(name, dict, index, bm, patchType),
84  referPatchName_(dict.lookup("referPatch")),
85  tag_(dict.lookupOrDefault<int>("tag", -1)),
86  referPatchID_(-1)
87 {}
88 
89 
91 (
92  const processorCyclicPolyPatch& pp,
93  const polyBoundaryMesh& bm
94 )
95 :
96  processorPolyPatch(pp, bm),
97  referPatchName_(pp.referPatchName()),
98  tag_(pp.tag()),
99  referPatchID_(-1)
100 {}
101 
102 
104 (
105  const processorCyclicPolyPatch& pp,
106  const polyBoundaryMesh& bm,
107  const label index,
108  const label newSize,
109  const label newStart
110 )
111 :
112  processorPolyPatch(pp, bm, index, newSize, newStart),
113  referPatchName_(pp.referPatchName_),
114  tag_(pp.tag()),
115  referPatchID_(-1)
116 {}
117 
118 
120 (
121  const processorCyclicPolyPatch& pp,
122  const polyBoundaryMesh& bm,
123  const label index,
124  const label newSize,
125  const label newStart,
126  const word& referPatchName
127 )
128 :
129  processorPolyPatch(pp, bm, index, newSize, newStart),
130  referPatchName_(referPatchName),
131  tag_(-1),
132  referPatchID_(-1)
133 {}
134 
135 
137 (
138  const processorCyclicPolyPatch& pp,
139  const polyBoundaryMesh& bm,
140  const label index,
141  const labelUList& mapAddressing,
142  const label newStart
143 )
144 :
145  processorPolyPatch(pp, bm, index, mapAddressing, newStart),
146  referPatchName_(pp.referPatchName()),
147  tag_(-1),
148  referPatchID_(-1)
149 {}
150 
151 
152 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
153 
155 {}
156 
157 
158 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
159 
161 {
162  if (tag_ == -1)
163  {
164  // Get unique tag to use for all comms. Make sure that both sides
165  // use the same tag
166  const cyclicPolyPatch& cycPatch = refCast<const cyclicPolyPatch>
167  (
168  referPatch()
169  );
170 
171  if (owner())
172  {
173  tag_ = Hash<word>()(cycPatch.name()) % 32768u;
174  }
175  else
176  {
177  tag_ = Hash<word>()(cycPatch.neighbPatch().name()) % 32768u;
178  }
179 
180  if (tag_ == Pstream::msgType() || tag_ == -1)
181  {
182  FatalErrorIn("processorCyclicPolyPatch::tag() const")
183  << "Tag calculated from cyclic patch name " << tag_
184  << " is the same as the current message type "
185  << Pstream::msgType() << " or -1" << nl
186  << "Please set a non-conflicting, unique, tag by hand"
187  << " using the 'tag' entry"
188  << exit(FatalError);
189  }
190  if (debug)
191  {
192  Pout<< "processorCyclicPolyPatch " << name() << " uses tag " << tag_
193  << endl;
194  }
195  }
196  return tag_;
197 }
198 
199 
201 {
202  // Send over processorPolyPatch data
204 }
205 
206 
208 {
209  // Receive and initialise processorPolyPatch data
211 
212  if (Pstream::parRun())
213  {
214 
215  // Where do we store the calculated transformation?
216  // - on the processor patch?
217  // - on the underlying cyclic patch?
218  // - or do we not auto-calculate the transformation but
219  // have option of reading it.
220 
221  // Update underlying cyclic halves. Need to do both since only one
222  // half might be present as a processorCyclic.
223  coupledPolyPatch& pp = const_cast<coupledPolyPatch&>(referPatch());
224  pp.calcGeometry
225  (
226  *this,
227  faceCentres(),
228  faceAreas(),
229  faceCellCentres(),
230  neighbFaceCentres(),
231  neighbFaceAreas(),
232  neighbFaceCellCentres()
233  );
234 
235  if (isA<cyclicPolyPatch>(pp))
236  {
237  const cyclicPolyPatch& cpp = refCast<const cyclicPolyPatch>(pp);
238  const_cast<cyclicPolyPatch&>(cpp.neighbPatch()).calcGeometry
239  (
240  *this,
241  neighbFaceCentres(),
242  neighbFaceAreas(),
243  neighbFaceCellCentres(),
244  faceCentres(),
245  faceAreas(),
246  faceCellCentres()
247  );
248  }
249  }
250 }
251 
252 
254 (
255  PstreamBuffers& pBufs,
256  const pointField& p
257 )
258 {
259  // Recalculate geometry
260  initGeometry(pBufs);
261 }
262 
263 
265 (
266  PstreamBuffers& pBufs,
267  const pointField&
268 )
269 {
270  calcGeometry(pBufs);
271 }
272 
273 
275 {
277 }
278 
279 
281 {
282  referPatchID_ = -1;
284 }
285 
286 
288 (
289  PstreamBuffers& pBufs,
290  const primitivePatch& pp
291 ) const
292 {
293  // For now use the same algorithm as processorPolyPatch
295 }
296 
297 
298 // Return new ordering. Ordering is -faceMap: for every face index
299 // the new face -rotation:for every new face the clockwise shift
300 // of the original face. Return false if nothing changes (faceMap
301 // is identity, rotation is 0)
303 (
304  PstreamBuffers& pBufs,
305  const primitivePatch& pp,
306  labelList& faceMap,
307  labelList& rotation
308 ) const
309 {
310  // For now use the same algorithm as processorPolyPatch
311  return processorPolyPatch::order(pBufs, pp, faceMap, rotation);
312 }
313 
314 
316 {
318  os.writeKeyword("referPatch") << referPatchName_
319  << token::END_STATEMENT << nl;
320  if (tag_ != -1)
321  {
322  os.writeKeyword("tag") << tag_
323  << token::END_STATEMENT << nl;
324  }
325 }
326 
327 
328 // ************************************************************************* //
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:380
void initGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
const word & name() const
Return name.
virtual int tag() const
Return message tag to use for communication.
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
A class for handling words, derived from string.
Definition: word.H:59
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
void initGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
Namespace for OpenFOAM.
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
virtual void initUpdateMesh(PstreamBuffers &)
Initialise the update of the patch topology.
Hash function class for primitives. All non-primitives used to hash entries on hash tables likely nee...
Definition: Hash.H:54
static const char nl
Definition: Ostream.H:260
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Neighbour processor patch.
Foam::polyBoundaryMesh.
void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
virtual void calcGeometry(PstreamBuffers &)=0
Calculate the patch geometry.
static int & msgType()
Message tag of standard messages.
Definition: UPstream.H:451
Macros for easy insertion into run-time selection tables.
Cyclic plane patch.
virtual void initUpdateMesh(PstreamBuffers &)
Initialise the update of the patch topology.
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:59
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
A list of faces which address into the list of points.
void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
void movePoints(PstreamBuffers &, const pointField &)
Correct patches after moving points.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:452
error FatalError
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
virtual bool order(PstreamBuffers &, const primitivePatch &, labelList &faceMap, labelList &rotation) const
Return new ordering for primitivePatch.
const cyclicPolyPatch & neighbPatch() const
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
virtual void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialize ordering for primitivePatch. Does not.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
virtual bool order(PstreamBuffers &, const primitivePatch &, labelList &faceMap, labelList &rotation) const
Return new ordering for primitivePatch.
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 transformType transform=UNKNOWN, const word &patchType=typeName)
Construct from components.
virtual void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialize ordering for primitivePatch. Does not.
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
void initMovePoints(PstreamBuffers &, const pointField &)
Initialise the patches for moving points.
defineTypeNameAndDebug(combustionModel, 0)
prefixOSstream Pout(cout,"Pout")
Definition: IOstreams.H:53