processorCyclicPolyPatch.H
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-2018 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  {
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 label size,
118  const label start,
119  const label index,
120  const polyBoundaryMesh& bm,
121  const int myProcNo,
122  const int neighbProcNo,
123  const word& referPatchName,
125  const word& patchType = typeName
126  );
127 
128  //- Construct from dictionary
130  (
131  const word& name,
132  const dictionary& dict,
133  const label index,
134  const polyBoundaryMesh&,
135  const word& patchType
136  );
137 
138  //- Construct as copy, resetting the boundary mesh
140  (
142  const polyBoundaryMesh&
143  );
144 
145  //- Construct as given the original patch and resetting the
146  // face list and boundary mesh information
148  (
149  const processorCyclicPolyPatch& pp,
150  const polyBoundaryMesh& bm,
151  const label index,
152  const label newSize,
153  const label newStart
154  );
155 
156  //- Construct as given the original patch and resetting the
157  // face list, boundary mesh information and referPatch
159  (
160  const processorCyclicPolyPatch& pp,
161  const polyBoundaryMesh& bm,
162  const label index,
163  const label newSize,
164  const label newStart,
165  const word& referPatchName
166  );
167 
168  //- Construct given the original patch and a map
170  (
171  const processorCyclicPolyPatch& pp,
172  const polyBoundaryMesh& bm,
173  const label index,
174  const labelUList& mapAddressing,
175  const label newStart
176  );
177 
178 
179  //- Construct and return a clone, resetting the boundary mesh
180  virtual autoPtr<polyPatch> clone(const polyBoundaryMesh& bm) const
181  {
182  return autoPtr<polyPatch>(new processorCyclicPolyPatch(*this, bm));
183  }
184 
185  //- Construct and return a clone, resetting the face list
186  // and boundary mesh
188  (
189  const polyBoundaryMesh& bm,
190  const label index,
191  const label newSize,
192  const label newStart
193  ) const
194  {
195  return autoPtr<polyPatch>
196  (
198  (
199  *this,
200  bm,
201  index,
202  newSize,
203  newStart
204  )
205  );
206  }
207 
208  //- Construct and return a clone, resetting the face list
209  // and boundary mesh
211  (
212  const polyBoundaryMesh& bm,
213  const label index,
214  const label newSize,
215  const label newStart,
216  const word& referPatchName
217  ) const
218  {
219  return autoPtr<polyPatch>
220  (
222  (
223  *this,
224  bm,
225  index,
226  newSize,
227  newStart,
228  referPatchName
229  )
230  );
231  }
232 
233  //- Construct and return a clone, resetting the face list
234  // and boundary mesh
236  (
237  const polyBoundaryMesh& bm,
238  const label index,
239  const labelUList& mapAddressing,
240  const label newStart
241  ) const
242  {
243  return autoPtr<polyPatch>
244  (
246  (
247  *this,
248  bm,
249  index,
250  mapAddressing,
251  newStart
252  )
253  );
254  }
255 
256 
257  // Destructor
258  virtual ~processorCyclicPolyPatch();
259 
260 
261  // Member functions
262 
263  //- Return name of originating cyclicPolyPatch patch
264  const word& referPatchName() const
265  {
266  return referPatchName_;
267  }
268 
269  //- Return the name of a processorCyclicPolyPatch
270  // constructed from cyclicPolyPatch name and the processor IDs
271  static word newName
272  (
273  const word& cyclicPolyPatchName,
274  const label myProcNo,
275  const label neighbProcNo
276  );
277 
278  //- Return the indices of a processorCyclicPolyPatchs
279  // constructed from the given cyclicPolyPatch
280  static labelList patchIDs
281  (
282  const word& cyclicPolyPatchName,
283  const polyBoundaryMesh& bm
284  );
285 
286  //- Referring patchID.
287  label referPatchID() const
288  {
289  if (referPatchID_ == -1)
290  {
291  referPatchID_ = this->boundaryMesh().findPatchID
292  (
293  referPatchName_
294  );
295  if (referPatchID_ == -1)
296  {
298  << "Illegal referPatch name " << referPatchName_
299  << endl << "Valid patch names are "
300  << this->boundaryMesh().names()
301  << exit(FatalError);
302  }
303  }
304  return referPatchID_;
305  }
307  const coupledPolyPatch& referPatch() const
308  {
309  const polyPatch& pp = this->boundaryMesh()[referPatchID()];
310  return refCast<const coupledPolyPatch>(pp);
311  }
312 
313  //- Return message tag to use for communication
314  virtual int tag() const;
315 
316  //- Does this side own the patch ?
317  virtual bool owner() const
318  {
319  return referPatch().owner();
320  }
321 
322  //- Type of transform
323  virtual transformType transform() const
324  {
325  return referPatch().transform();
326  }
327 
328  //- Type of transform
329  // This is currently only for use when collapsing generated
330  // meshes that can have zero area faces.
331  virtual transformType& transform()
332  {
333  return const_cast<coupledPolyPatch&>(referPatch()).transform();
334  }
335 
336  //- Transform a patch-based position from other side to this side
337  virtual void transformPosition(pointField& l) const
338  {
340  }
341 
342  //- Transform a patch-based position from other side to this side
343  virtual void transformPosition(point& l, const label facei) const
344  {
345  referPatch().transformPosition(l, facei);
346  }
347 
348  //- Are the planes separated.
349  virtual bool separated() const
350  {
351  return referPatch().separated();
352  }
353 
354  //- If the planes are separated the separation vector.
355  virtual const vectorField& separation() const
356  {
357  return referPatch().separation();
358  }
359 
360  //- Are the cyclic planes parallel.
361  virtual bool parallel() const
362  {
363  return referPatch().parallel();
364  }
365 
366  //- Return face transformation tensor.
367  virtual const tensorField& forwardT() const
368  {
369  return referPatch().forwardT();
370  }
371 
372  //- Return neighbour-cell transformation tensor.
373  virtual const tensorField& reverseT() const
374  {
375  return referPatch().reverseT();
376  }
377 
378  //- Are faces collocated. Either size 0,1 or length of patch
379  virtual const boolList& collocated() const
380  {
381  return referPatch().collocated();
382  }
383 
384 
385  //- Initialize ordering for primitivePatch. Does not
386  // refer to *this (except for name() and type() etc.)
387  virtual void initOrder(PstreamBuffers&, const primitivePatch&) const;
388 
389  //- Return new ordering for primitivePatch.
390  // Ordering is -faceMap: for every face
391  // index of the new face -rotation:for every new face the clockwise
392  // shift of the original face. Return false if nothing changes
393  // (faceMap is identity, rotation is 0), true otherwise.
394  virtual bool order
395  (
397  const primitivePatch&,
399  labelList& rotation
400  ) const;
401 
402 
403  //- Write the polyPatch data as a dictionary
404  virtual void write(Ostream&) const;
405 };
406 
407 
408 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
409 
410 } // End namespace Foam
411 
412 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
413 
414 #endif
415 
416 // ************************************************************************* //
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
label referPatchID() const
Referring patchID.
virtual autoPtr< polyPatch > clone(const polyBoundaryMesh &bm) const
Construct and return a clone, resetting the boundary mesh.
virtual bool owner() const
Does this side own the patch ?
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
virtual bool separated() const
Are the planes separated.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
virtual bool parallel() const
Are the cyclic planes parallel.
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 bool separated() const
Are the planes separated.
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: polyPatch.C:278
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:256
label findPatchID(const word &patchName) const
Find patch index given a name.
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...
virtual void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialize ordering for primitivePatch. Does not.
virtual const vectorField & separation() const
If the planes are separated the separation vector.
virtual const tensorField & forwardT() const
Return face transformation tensor.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
virtual void transformPosition(pointField &l) const
Transform a patch-based position from other side to this side.
Neighbour processor patch.
const coupledPolyPatch & referPatch() const
virtual bool parallel() const
Are the cyclic planes parallel.
A list of faces which address into the list of points.
virtual const vectorField & separation() const
If the planes are separated the separation vector.
virtual bool order(PstreamBuffers &, const primitivePatch &, labelList &faceMap, labelList &rotation) const
Return new ordering for primitivePatch.
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
wordList names() const
Return a list of patch names.
virtual bool owner() const =0
Does this side own the patch ?
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:61
Foam::polyBoundaryMesh.
virtual transformType transform() const
Type of transform.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
virtual const tensorField & forwardT() const
Return face transformation tensor.
virtual const boolList & collocated() const
Are faces collocated. Either size 0,1 or length of patch.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
void initGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
void initMovePoints(PstreamBuffers &, const pointField &)
Initialise the patches for moving points.
virtual const tensorField & reverseT() const
Return neighbour-cell transformation tensor.
virtual void transformPosition(pointField &) const =0
Transform a patch-based position from other side to this side.
TypeName("processorCyclic")
Runtime type information.
static labelList patchIDs(const word &cyclicPolyPatchName, const polyBoundaryMesh &bm)
Return the indices of a processorCyclicPolyPatchs.
const word & referPatchName() const
Return name of originating cyclicPolyPatch patch.
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 transformType transform() const
Type of transform.
virtual int tag() const
Return message tag to use for communication.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
virtual const tensorField & reverseT() const
Return neighbour-cell transformation tensor.
static word newName(const word &cyclicPolyPatchName, const label myProcNo, const label neighbProcNo)
Return the name of a processorCyclicPolyPatch.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:366
virtual void initUpdateMesh(PstreamBuffers &)
Initialise the update of the patch topology.
Namespace for OpenFOAM.