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-2021 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 #include "cyclicPolyPatch.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 /*---------------------------------------------------------------------------*\
49  Class processorCyclicPolyPatch Declaration
50 \*---------------------------------------------------------------------------*/
51 
53 :
54  public processorPolyPatch
55 {
56  // Private Data
57 
58  //- Name of originating patch
59  const word referPatchName_;
60 
61  //- Message tag to use for communication
62  mutable int tag_;
63 
64  //- Index of originating patch
65  mutable label referPatchID_;
66 
67 
68 protected:
69 
70  // Protected Member functions
71 
72  //- Initialise the calculation of the patch geometry
74 
75  //- Calculate the patch geometry
77 
78  //- Calculate the patch geometry with externally
79  // provided geometry
80  virtual void calcGeometry
81  (
82  const primitivePatch& referPatch,
83  const pointField& thisCtrs,
84  const vectorField& thisAreas,
85  const pointField& thisCc,
86  const pointField& nbrCtrs,
87  const vectorField& nbrAreas,
88  const pointField& nbrCc
89  )
90  {
92  }
93 
94  //- Initialise the patches for moving points
96 
97  //- Correct patches after moving points
98  void movePoints(PstreamBuffers&, const pointField&);
99 
100  //- Initialise the update of the patch topology
101  virtual void initUpdateMesh(PstreamBuffers&);
102 
103  //- Update of the patch topology
104  virtual void updateMesh(PstreamBuffers&);
105 
106 
107 public:
108 
109  //- Runtime type information
110  TypeName("processorCyclic");
111 
112 
113  // Constructors
114 
115  //- Construct from components
117  (
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,
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 cyclicPolyPatch& referPatch() const
308  {
309  const polyPatch& pp = this->boundaryMesh()[referPatchID()];
310  return refCast<const cyclicPolyPatch>(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
324  {
325  return referPatch().transformType();
326  }
327 
328  //- Return transformation between the coupled patches
329  virtual const transformer& transform() const
330  {
331  return referPatch().transform();
332  }
333 
334  //- Initialise ordering for primitivePatch. Does not
335  // refer to *this (except for name() and type() etc.)
336  virtual void initOrder(PstreamBuffers&, const primitivePatch&) const;
337 
338  //- Return new ordering for primitivePatch.
339  // Ordering is -faceMap: for every face
340  // index of the new face -rotation:for every new face the clockwise
341  // shift of the original face. Return false if nothing changes
342  // (faceMap is identity, rotation is 0), true otherwise.
343  virtual bool order
344  (
346  const primitivePatch&,
348  labelList& rotation
349  ) const;
350 
351  //- Write the polyPatch data as a dictionary
352  virtual void write(Ostream&) const;
353 };
354 
355 
356 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
357 
358 } // End namespace Foam
359 
360 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
361 
362 #endif
363 
364 // ************************************************************************* //
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
label referPatchID() const
Referring patchID.
virtual bool owner() const
Does this side own the patch ?
void initCalcGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
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
Vector-tensor class used to perform translations, rotations and scaling operations in 3D space...
Definition: transformer.H:83
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:156
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:323
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: polyPatch.C:291
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
label findPatchID(const word &patchName) const
Find patch index given a name.
void movePoints(PstreamBuffers &, const pointField &)
Correct patches after moving points.
virtual const transformer & transform() const
Return transformation between the coupled patches.
virtual autoPtr< PrimitivePatch< FaceList, PointField > > clone() const
Construct and return a clone.
virtual void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialise ordering for primitivePatch. Does not.
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
Neighbour processor patch.
A list of faces which address into the list of points.
virtual bool owner() const
Does this side own the patch ?
virtual bool order(PstreamBuffers &, const primitivePatch &, labelList &faceMap, labelList &rotation) const
Return new ordering for primitivePatch.
A class for handling words, derived from string.
Definition: word.H:59
Cyclic plane patch.
wordList names() const
Return a list of patch names.
processorCyclicPolyPatch(const label size, const label start, const label index, const polyBoundaryMesh &bm, const int myProcNo, const int neighbProcNo, const word &referPatchName, const word &patchType=typeName)
Construct from components.
const cyclicPolyPatch & referPatch() const
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:60
Foam::polyBoundaryMesh.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
Buffers for inter-processor communications streams (UOPstream, UIPstream).
void initMovePoints(PstreamBuffers &, const pointField &)
Initialise the patches for moving points.
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.
virtual cyclicTransform::transformTypes transformType() const
Type of transform.
virtual const transformer & transform() const
Return transformation between the coupled patches.
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.
transformTypes transformType() const
Type of transform.
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:370
virtual void initUpdateMesh(PstreamBuffers &)
Initialise the update of the patch topology.
Namespace for OpenFOAM.