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-2022 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 constructors
71 
72  //- Construct from components with specified name
74  (
75  const word& name,
76  const label size,
77  const label start,
78  const label index,
79  const polyBoundaryMesh& bm,
80  const int myProcNo,
81  const int neighbProcNo,
82  const word& referPatchName,
83  const word& patchType = typeName
84  );
85 
86 
87  // Protected Member functions
88 
89  //- Initialise the calculation of the patch geometry
91 
92  //- Calculate the patch geometry
94 
95  //- Calculate the patch geometry with externally
96  // provided geometry
97  virtual void calcGeometry
98  (
99  const primitivePatch& referPatch,
100  const pointField& thisCtrs,
101  const vectorField& thisAreas,
102  const pointField& thisCc,
103  const pointField& nbrCtrs,
104  const vectorField& nbrAreas,
105  const pointField& nbrCc
106  )
107  {
109  }
110 
111  //- Initialise the patches for moving points
113 
114  //- Correct patches after moving points
115  void movePoints(PstreamBuffers&, const pointField&);
116 
117  //- Initialise the update of the patch topology
118  virtual void initTopoChange(PstreamBuffers&);
119 
120  //- Update of the patch topology
121  virtual void topoChange(PstreamBuffers&);
122 
123 
124 public:
125 
126  //- Runtime type information
127  TypeName("processorCyclic");
128 
129 
130  // Constructors
131 
132  //- Construct from components
134  (
135  const label size,
136  const label start,
137  const label index,
138  const polyBoundaryMesh& bm,
139  const int myProcNo,
140  const int neighbProcNo,
141  const word& referPatchName,
142  const word& patchType = typeName
143  );
144 
145  //- Construct from dictionary
147  (
148  const word& name,
149  const dictionary& dict,
150  const label index,
151  const polyBoundaryMesh&,
152  const word& patchType
153  );
154 
155  //- Construct as copy, resetting the boundary mesh
157  (
159  const polyBoundaryMesh&
160  );
161 
162  //- Construct as given the original patch and resetting the
163  // face list and boundary mesh information
165  (
166  const processorCyclicPolyPatch& pp,
167  const polyBoundaryMesh& bm,
168  const label index,
169  const label newSize,
170  const label newStart
171  );
172 
173  //- Construct given the original patch and a map
175  (
176  const processorCyclicPolyPatch& pp,
177  const polyBoundaryMesh& bm,
178  const label index,
179  const labelUList& mapAddressing,
180  const label newStart
181  );
182 
183  //- Construct and return a clone, resetting the boundary mesh
184  virtual autoPtr<polyPatch> clone(const polyBoundaryMesh& bm) const
185  {
186  return autoPtr<polyPatch>(new processorCyclicPolyPatch(*this, bm));
187  }
188 
189  //- Construct and return a clone, resetting the face list
190  // and boundary mesh
192  (
193  const polyBoundaryMesh& bm,
194  const label index,
195  const label newSize,
196  const label newStart
197  ) const
198  {
199  return autoPtr<polyPatch>
200  (
202  (
203  *this,
204  bm,
205  index,
206  newSize,
207  newStart
208  )
209  );
210  }
211 
212  //- Construct and return a clone, resetting the face list
213  // and boundary mesh
215  (
216  const polyBoundaryMesh& bm,
217  const label index,
218  const labelUList& mapAddressing,
219  const label newStart
220  ) const
221  {
222  return autoPtr<polyPatch>
223  (
225  (
226  *this,
227  bm,
228  index,
229  mapAddressing,
230  newStart
231  )
232  );
233  }
234 
235 
236  // Destructor
237  virtual ~processorCyclicPolyPatch();
238 
239 
240  // Member Functions
241 
242  //- Return name of originating cyclicPolyPatch patch
243  const word& referPatchName() const
244  {
245  return referPatchName_;
246  }
247 
248  //- Return the name of a processorCyclicPolyPatch
249  // constructed from cyclicPolyPatch name and the processor IDs
250  static word newName
251  (
252  const word& cyclicPolyPatchName,
253  const label myProcNo,
254  const label neighbProcNo
255  );
256 
257  //- Return the indices of a processorCyclicPolyPatchs
258  // constructed from the given cyclicPolyPatch
259  static labelList patchIDs
260  (
261  const word& cyclicPolyPatchName,
262  const polyBoundaryMesh& bm
263  );
264 
265  //- Return the referring patchID
266  label referPatchID() const
267  {
268  if (referPatchID_ == -1)
269  {
270  referPatchID_ = this->boundaryMesh().findPatchID
271  (
272  referPatchName_
273  );
274  if (referPatchID_ == -1)
275  {
277  << "Illegal referPatch name " << referPatchName_
278  << endl << "Valid patch names are "
279  << this->boundaryMesh().names()
280  << exit(FatalError);
281  }
282  }
283  return referPatchID_;
284  }
285 
286  //- Return a reference to the referring patch
287  const cyclicPolyPatch& referPatch() const
288  {
289  const polyPatch& pp = this->boundaryMesh()[referPatchID()];
290  return refCast<const cyclicPolyPatch>(pp);
291  }
292 
293  //- Return message tag to use for communication
294  virtual int tag() const;
295 
296  //- Does this side own the patch ?
297  virtual bool owner() const
298  {
299  return referPatch().owner();
300  }
301 
302  //- Type of transform
304  {
305  return referPatch().transformType();
306  }
307 
308  //- Return transformation between the coupled patches
309  virtual const transformer& transform() const
310  {
311  return referPatch().transform();
312  }
313 
314  //- Initialise ordering for primitivePatch. Does not
315  // refer to *this (except for name() and type() etc.)
316  virtual void initOrder(PstreamBuffers&, const primitivePatch&) const;
317 
318  //- Return new ordering for primitivePatch.
319  // Ordering is -faceMap: for every face
320  // index of the new face -rotation:for every new face the clockwise
321  // shift of the original face. Return false if nothing changes
322  // (faceMap is identity, rotation is 0), true otherwise.
323  virtual bool order
324  (
326  const primitivePatch&,
328  labelList& rotation
329  ) const;
330 
331  //- Write the polyPatch data as a dictionary
332  virtual void write(Ostream&) const;
333 };
334 
335 
336 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
337 
338 } // End namespace Foam
339 
340 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
341 
342 #endif
343 
344 // ************************************************************************* //
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
label referPatchID() const
Return the referring patchID.
virtual bool owner() const
Does this side own the patch ?
void initCalcGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
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:306
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: polyPatch.C:297
virtual void initTopoChange(PstreamBuffers &)
Initialise the update of the patch topology.
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 void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialise ordering for primitivePatch. Does not.
virtual void topoChange(PstreamBuffers &)
Update of the patch topology.
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.
const cyclicPolyPatch & referPatch() const
Return a reference to the referring patch.
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).
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 word &patchType=typeName)
Construct from components with specified name.
void initMovePoints(PstreamBuffers &, const pointField &)
Initialise the patches for moving points.
autoPtr< PrimitivePatch< FaceList, PointField > > clone() const
Construct and return a clone.
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:353
Namespace for OpenFOAM.