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-2015 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,
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  {
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,
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 // ************************************************************************* //
Foam::token::END_STATEMENT
@ END_STATEMENT
Definition: token.H:99
Foam::processorCyclicPolyPatch::tag
virtual int tag() const
Return message tag to use for communication.
Definition: processorCyclicPolyPatch.C:160
Foam::faceMap
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Definition: blockMeshMergeFast.C:90
p
p
Definition: pEqn.H:62
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
SubField.H
Foam::polyBoundaryMesh
Foam::polyBoundaryMesh.
Definition: polyBoundaryMesh.H:60
Foam::processorCyclicPolyPatch
Neighbour processor patch.
Definition: processorCyclicPolyPatch.H:50
cyclicPolyPatch.H
Foam::cyclicPolyPatch
Cyclic plane patch.
Definition: cyclicPolyPatch.H:63
Foam::cyclicPolyPatch::neighbPatch
const cyclicPolyPatch & neighbPatch() const
Definition: cyclicPolyPatch.H:328
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
Foam::processorCyclicPolyPatch::initUpdateMesh
virtual void initUpdateMesh(PstreamBuffers &)
Initialise the update of the patch topology.
Definition: processorCyclicPolyPatch.C:274
Foam::processorCyclicPolyPatch::initOrder
virtual void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialize ordering for primitivePatch. Does not.
Definition: processorCyclicPolyPatch.C:288
Foam::PstreamBuffers
Buffers for inter-processor communications streams (UOPstream, UIPstream).
Definition: PstreamBuffers.H:85
Foam::processorCyclicPolyPatch::referPatchName_
const word referPatchName_
Name of originating patch.
Definition: processorCyclicPolyPatch.H:57
Foam::UPstream::parRun
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:377
Foam::processorCyclicPolyPatch::order
virtual bool order(PstreamBuffers &, const primitivePatch &, labelList &faceMap, labelList &rotation) const
Return new ordering for primitivePatch.
Definition: processorCyclicPolyPatch.C:303
Foam::processorCyclicPolyPatch::processorCyclicPolyPatch
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.
Definition: processorCyclicPolyPatch.C:43
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::coupledPolyPatch
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
Definition: coupledPolyPatch.H:51
processorCyclicPolyPatch.H
Foam::processorPolyPatch::calcGeometry
void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
Definition: processorPolyPatch.C:166
Foam::transform
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:465
Foam::processorCyclicPolyPatch::initMovePoints
void initMovePoints(PstreamBuffers &, const pointField &)
Initialise the patches for moving points.
Definition: processorCyclicPolyPatch.C:254
Foam::processorCyclicPolyPatch::movePoints
void movePoints(PstreamBuffers &, const pointField &)
Correct patches after moving points.
Definition: processorCyclicPolyPatch.C:265
Foam::Hash
Hash function class for primitives. All non-primitives used to hash entries on hash tables likely nee...
Definition: Hash.H:56
Foam::label
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
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::processorPolyPatch::initGeometry
void initGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
Definition: processorPolyPatch.C:152
Foam::processorPolyPatch
Neighbour processor patch.
Definition: processorPolyPatch.H:55
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Foam::processorPolyPatch::initUpdateMesh
virtual void initUpdateMesh(PstreamBuffers &)
Initialise the update of the patch topology.
Definition: processorPolyPatch.C:303
Foam::processorCyclicPolyPatch::write
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
Definition: processorCyclicPolyPatch.C:315
Foam::UPstream::msgType
static int & msgType()
Message tag of standard messages.
Definition: UPstream.H:452
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::processorCyclicPolyPatch::referPatchName
const word & referPatchName() const
Definition: processorCyclicPolyPatch.H:263
Foam::processorPolyPatch::write
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
Definition: processorPolyPatch.C:1076
Foam::Pout
prefixOSstream Pout(cout, "Pout")
Definition: IOstreams.H:53
Foam::processorPolyPatch::initOrder
virtual void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialize ordering for primitivePatch. Does not.
Definition: processorPolyPatch.C:487
Foam::processorCyclicPolyPatch::updateMesh
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
Definition: processorCyclicPolyPatch.C:280
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::Ostream::writeKeyword
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:59
Foam::UList
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::processorCyclicPolyPatch::calcGeometry
void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
Definition: processorCyclicPolyPatch.C:207
Foam::processorCyclicPolyPatch::~processorCyclicPolyPatch
virtual ~processorCyclicPolyPatch()
Definition: processorCyclicPolyPatch.C:154
Foam::processorPolyPatch::updateMesh
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
Definition: processorPolyPatch.C:350
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::coupledPolyPatch::transformType
transformType
Definition: coupledPolyPatch.H:57
Foam::coupledPolyPatch::calcGeometry
virtual void calcGeometry(PstreamBuffers &)=0
Calculate the patch geometry.
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::patchIdentifier::name
const word & name() const
Return name.
Definition: patchIdentifier.H:109
Foam::processorCyclicPolyPatch::initGeometry
void initGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
Definition: processorCyclicPolyPatch.C:200
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
Foam::processorPolyPatch::order
virtual bool order(PstreamBuffers &, const primitivePatch &, labelList &faceMap, labelList &rotation) const
Return new ordering for primitivePatch.
Definition: processorPolyPatch.C:685
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatchTemplate.H:88