processorCyclicPolyPatch.H
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 Class
25  Foam::processorCyclicPolyPatch
26 
27 Description
28  Neighbour processor patch.
29 
30  Note: morph patch face ordering is geometric.
31 
32 SourceFiles
33  processorCyclicPolyPatch.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef processorCyclicPolyPatch_H
38 #define processorCyclicPolyPatch_H
39 
40 #include "processorPolyPatch.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 /*---------------------------------------------------------------------------*\
48  Class processorCyclicPolyPatch Declaration
49 \*---------------------------------------------------------------------------*/
50 
52 :
53  public processorPolyPatch
54 {
55  // Private data
56 
57  //- Name of originating patch
58  const word referPatchName_;
59 
60  //- Message tag to use for communication
61  mutable int tag_;
62 
63  //- Index of originating patch
64  mutable label referPatchID_;
65 
66 
67 protected:
68 
69  // Protected Member functions
70 
71  //- Initialise the calculation of the patch geometry
73 
74  //- Calculate the patch geometry
76 
77  //- Calculate the patch geometry with externally
78  // provided geometry
79  virtual void calcGeometry
80  (
81  const primitivePatch& referPatch,
82  const pointField& thisCtrs,
83  const vectorField& thisAreas,
84  const pointField& thisCc,
85  const pointField& nbrCtrs,
86  const vectorField& nbrAreas,
87  const pointField& nbrCc
88  )
89  {
90  notImplemented("processorCyclicPolyPatch::calcGeometry(..)");
91  }
92 
93  //- Initialise the patches for moving points
95 
96  //- Correct patches after moving points
97  void movePoints(PstreamBuffers&, const pointField&);
98 
99  //- Initialise the update of the patch topology
100  virtual void initUpdateMesh(PstreamBuffers&);
101 
102  //- Update of the patch topology
103  virtual void updateMesh(PstreamBuffers&);
104 
105 
106 public:
107 
108  //- Runtime type information
109  TypeName("processorCyclic");
110 
111 
112  // Constructors
113 
114  //- Construct from components
116  (
117  const word& name,
118  const label size,
119  const label start,
120  const label index,
121  const polyBoundaryMesh& bm,
122  const int myProcNo,
123  const int neighbProcNo,
124  const word& referPatchName,
126  const word& patchType = typeName
127  );
128 
129  //- Construct from dictionary
131  (
132  const word& name,
133  const dictionary& dict,
134  const label index,
135  const polyBoundaryMesh&,
136  const word& patchType
137  );
138 
139  //- Construct as copy, resetting the boundary mesh
141  (
143  const polyBoundaryMesh&
144  );
145 
146  //- Construct as given the original patch and resetting the
147  // face list and boundary mesh information
149  (
150  const processorCyclicPolyPatch& pp,
151  const polyBoundaryMesh& bm,
152  const label index,
153  const label newSize,
154  const label newStart
155  );
156 
157  //- Construct as given the original patch and resetting the
158  // face list, boundary mesh information and referPatch
160  (
161  const processorCyclicPolyPatch& pp,
162  const polyBoundaryMesh& bm,
163  const label index,
164  const label newSize,
165  const label newStart,
166  const word& referPatchName
167  );
168 
169  //- Construct given the original patch and a map
171  (
172  const processorCyclicPolyPatch& pp,
173  const polyBoundaryMesh& bm,
174  const label index,
175  const labelUList& mapAddressing,
176  const label newStart
177  );
178 
179 
180  //- Construct and return a clone, resetting the boundary mesh
181  virtual autoPtr<polyPatch> clone(const polyBoundaryMesh& bm) const
182  {
183  return autoPtr<polyPatch>(new processorCyclicPolyPatch(*this, bm));
184  }
185 
186  //- Construct and return a clone, resetting the face list
187  // and boundary mesh
189  (
190  const polyBoundaryMesh& bm,
191  const label index,
192  const label newSize,
193  const label newStart
194  ) const
195  {
196  return autoPtr<polyPatch>
197  (
199  (
200  *this,
201  bm,
202  index,
203  newSize,
204  newStart
205  )
206  );
207  }
208 
209  //- Construct and return a clone, resetting the face list
210  // and boundary mesh
212  (
213  const polyBoundaryMesh& bm,
214  const label index,
215  const label newSize,
216  const label newStart,
217  const word& referPatchName
218  ) const
219  {
220  return autoPtr<polyPatch>
221  (
223  (
224  *this,
225  bm,
226  index,
227  newSize,
228  newStart,
229  referPatchName
230  )
231  );
232  }
233 
234  //- Construct and return a clone, resetting the face list
235  // and boundary mesh
237  (
238  const polyBoundaryMesh& bm,
239  const label index,
240  const labelUList& mapAddressing,
241  const label newStart
242  ) const
243  {
244  return autoPtr<polyPatch>
245  (
247  (
248  *this,
249  bm,
250  index,
251  mapAddressing,
252  newStart
253  )
254  );
255  }
256 
257 
258  // Destructor
259  virtual ~processorCyclicPolyPatch();
260 
261 
262  // Member functions
264  const word& referPatchName() const
265  {
266  return referPatchName_;
267  }
268 
269  //- Referring patchID.
270  label referPatchID() const
271  {
272  if (referPatchID_ == -1)
273  {
274  referPatchID_ = this->boundaryMesh().findPatchID
275  (
276  referPatchName_
277  );
278  if (referPatchID_ == -1)
279  {
281  (
282  "processorCyclicPolyPatch::referPatchID() const"
283  ) << "Illegal referPatch name " << referPatchName_
284  << endl << "Valid patch names are "
285  << this->boundaryMesh().names()
286  << exit(FatalError);
287  }
288  }
289  return referPatchID_;
290  }
292  const coupledPolyPatch& referPatch() const
293  {
294  const polyPatch& pp = this->boundaryMesh()[referPatchID()];
295  return refCast<const coupledPolyPatch>(pp);
296  }
297 
298  //- Return message tag to use for communication
299  virtual int tag() const;
300 
301  //- Does this side own the patch ?
302  virtual bool owner() const
303  {
304  return referPatch().owner();
305  }
306 
307  //- Type of transform
308  virtual transformType transform() const
309  {
310  return referPatch().transform();
311  }
312 
313  //- Type of transform
314  // This is currently only for use when collapsing generated
315  // meshes that can have zero area faces.
316  virtual transformType& transform()
317  {
318  return const_cast<coupledPolyPatch&>(referPatch()).transform();
319  }
320 
321  //- Transform a patch-based position from other side to this side
322  virtual void transformPosition(pointField& l) const
323  {
325  }
326 
327  //- Transform a patch-based position from other side to this side
328  virtual void transformPosition(point& l, const label facei) const
329  {
330  referPatch().transformPosition(l, facei);
331  }
332 
333  //- Are the planes separated.
334  virtual bool separated() const
335  {
336  return referPatch().separated();
337  }
338 
339  //- If the planes are separated the separation vector.
340  virtual const vectorField& separation() const
341  {
342  return referPatch().separation();
343  }
344 
345  //- Are the cyclic planes parallel.
346  virtual bool parallel() const
347  {
348  return referPatch().parallel();
349  }
350 
351  //- Return face transformation tensor.
352  virtual const tensorField& forwardT() const
353  {
354  return referPatch().forwardT();
355  }
356 
357  //- Return neighbour-cell transformation tensor.
358  virtual const tensorField& reverseT() const
359  {
360  return referPatch().reverseT();
361  }
362 
363  //- Are faces collocated. Either size 0,1 or length of patch
364  virtual const boolList& collocated() const
365  {
366  return referPatch().collocated();
367  }
368 
369 
370  //- Initialize ordering for primitivePatch. Does not
371  // refer to *this (except for name() and type() etc.)
372  virtual void initOrder(PstreamBuffers&, const primitivePatch&) const;
373 
374  //- Return new ordering for primitivePatch.
375  // Ordering is -faceMap: for every face
376  // index of the new face -rotation:for every new face the clockwise
377  // shift of the original face. Return false if nothing changes
378  // (faceMap is identity, rotation is 0), true otherwise.
379  virtual bool order
380  (
382  const primitivePatch&,
384  labelList& rotation
385  ) const;
386 
387 
388  //- Write the polyPatch data as a dictionary
389  virtual void write(Ostream&) const;
390 };
391 
392 
393 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
394 
395 } // End namespace Foam
396 
397 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
398 
399 #endif
400 
401 // ************************************************************************* //
virtual const tensorField & forwardT() const
Return face transformation tensor.
virtual void transformPosition(pointField &l) const
Transform a patch-based position from other side to this side.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
virtual bool separated() const
Are the planes separated.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
virtual int tag() const
Return message tag to use for communication.
virtual const boolList & collocated() const
Are faces collocated. Either size 0,1 or length of patch.
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
virtual void transformPosition(pointField &) const =0
Transform a patch-based position from other side to this side.
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: polyPatch.C:278
virtual bool separated() const
Are the planes separated.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
virtual const tensorField & reverseT() const
Return neighbour-cell transformation tensor.
Namespace for OpenFOAM.
virtual void updateMesh(PstreamBuffers &)
Update of the patch topology.
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
wordList names() const
Return a list of patch names.
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Neighbour processor patch.
virtual bool parallel() const
Are the cyclic planes parallel.
TypeName("processorCyclic")
Runtime type information.
Foam::polyBoundaryMesh.
void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
virtual const vectorField & separation() const
If the planes are separated the separation vector.
virtual bool parallel() const
Are the cyclic planes parallel.
label referPatchID() const
Referring patchID.
virtual void initUpdateMesh(PstreamBuffers &)
Initialise the update of the patch topology.
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
const coupledPolyPatch & referPatch() const
A list of faces which address into the list of points.
void movePoints(PstreamBuffers &, const pointField &)
Correct patches after moving points.
virtual transformType transform() const
Type of transform.
virtual transformType transform() const
Type of transform.
error FatalError
virtual bool order(PstreamBuffers &, const primitivePatch &, labelList &faceMap, labelList &rotation) const
Return new ordering for primitivePatch.
virtual const vectorField & separation() const
If the planes are separated the separation vector.
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
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
virtual bool owner() const =0
Does this side own the patch ?
virtual autoPtr< polyPatch > clone(const polyBoundaryMesh &bm) const
Construct and return a clone, resetting the boundary mesh.
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.
#define notImplemented(functionName)
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:356
The coupledPolyPatch is an abstract base class for patches that couple regions of the computational d...
label findPatchID(const word &patchName) const
Find patch index given a name.
virtual const boolList & collocated() const
Are faces collocated. Either size 0,1 or length of patch.
virtual const tensorField & forwardT() const
Return face transformation tensor.
void initMovePoints(PstreamBuffers &, const pointField &)
Initialise the patches for moving points.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
virtual const tensorField & reverseT() const
Return neighbour-cell transformation tensor.
virtual bool owner() const
Does this side own the patch ?