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-2026 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 referPatchIndex_;
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  );
84 
85 
86  // Protected Member functions
87 
88  //- Initialise the calculation of the patch geometry
90 
91  //- Calculate the patch geometry
93 
94  //- Calculate the patch geometry with externally
95  // provided geometry
96  virtual void calcGeometry
97  (
99  const pointField& thisCtrs,
100  const vectorField& thisAreas,
101  const pointField& thisCc,
102  const pointField& nbrCtrs,
103  const vectorField& nbrAreas,
104  const pointField& nbrCc
105  )
106  {
108  }
109 
110  //- Initialise the patches for moving points
112 
113  //- Correct patches after moving points
114  void movePoints(PstreamBuffers&, const pointField&);
115 
116  //- Initialise the update of the patch topology
117  virtual void initTopoChange(PstreamBuffers&);
118 
119  //- Update of the patch topology
120  virtual void topoChange(PstreamBuffers&);
121 
122 
123 public:
124 
125  //- Runtime type information
126  TypeName("processorCyclic");
127 
128 
129  // Constructors
130 
131  //- Construct from components
133  (
134  const label size,
135  const label start,
136  const label index,
137  const polyBoundaryMesh& bm,
138  const int myProcNo,
139  const int neighbProcNo,
140  const word& referPatchName
141  );
142 
143  //- Construct from dictionary
145  (
146  const word& name,
147  const dictionary& dict,
148  const label index,
149  const polyBoundaryMesh&
150  );
151 
152  //- Construct as copy, resetting the boundary mesh
154  (
156  const polyBoundaryMesh&
157  );
158 
159  //- Construct as given the original patch and resetting the
160  // face list and boundary mesh information
162  (
163  const processorCyclicPolyPatch& pp,
164  const polyBoundaryMesh& bm,
165  const label index,
166  const label newSize,
167  const label newStart
168  );
169 
170  //- Construct and return a clone, resetting the boundary mesh
171  virtual autoPtr<polyPatch> clone(const polyBoundaryMesh& bm) const
172  {
173  return autoPtr<polyPatch>(new processorCyclicPolyPatch(*this, bm));
174  }
175 
176  //- Construct and return a clone, resetting the face list
177  // and boundary mesh
178  virtual autoPtr<polyPatch> clone
179  (
180  const polyBoundaryMesh& bm,
181  const label index,
182  const label newSize,
183  const label newStart
184  ) const
185  {
186  return autoPtr<polyPatch>
187  (
189  (
190  *this,
191  bm,
192  index,
193  newSize,
194  newStart
195  )
196  );
197  }
198 
199 
200  // Destructor
201  virtual ~processorCyclicPolyPatch();
202 
203 
204  // Member Functions
205 
206  //- Return name of originating cyclicPolyPatch patch
207  const word& referPatchName() const
208  {
209  return referPatchName_;
210  }
211 
212  //- Return the name of a processorCyclicPolyPatch
213  // constructed from cyclicPolyPatch name and the processor IDs
214  static word newName
215  (
216  const word& cyclicPolyPatchName,
217  const label myProcNo,
218  const label neighbProcNo
219  );
220 
221  //- Return the indices of a processorCyclicPolyPatchs
222  // constructed from the given cyclicPolyPatch
223  static labelList patchIDs
224  (
225  const word& cyclicPolyPatchName,
226  const polyBoundaryMesh& bm
227  );
228 
229  //- Return the referring patchID
230  label referPatchIndex() const
231  {
232  if (referPatchIndex_ == -1)
233  {
234  referPatchIndex_ = this->boundaryMesh().findIndex
235  (
236  referPatchName_
237  );
238  if (referPatchIndex_ == -1)
239  {
241  << "Illegal referPatch name " << referPatchName_
242  << endl << "Valid patch names are "
243  << this->boundaryMesh().names()
244  << exit(FatalError);
245  }
246  }
247  return referPatchIndex_;
248  }
249 
250  //- Return a reference to the referring patch
251  const cyclicPolyPatch& referPatch() const
252  {
253  const polyPatch& pp = this->boundaryMesh()[referPatchIndex()];
254  return refCast<const cyclicPolyPatch>(pp);
255  }
256 
257  //- Return message tag to use for communication
258  virtual int tag() const;
259 
260  //- Does this side own the patch ?
261  virtual bool owner() const
262  {
263  return referPatch().owner();
264  }
265 
266  //- Type of transform
268  {
269  return referPatch().transformType();
270  }
271 
272  //- Return transformation between the coupled patches
273  virtual const transformer& transform() const
274  {
275  return referPatch().transform();
276  }
277 
278  //- Initialise ordering for primitivePatch. Does not
279  // refer to *this (except for name() and type() etc.)
280  virtual void initOrder(PstreamBuffers&, const primitivePatch&) const;
281 
282  //- Return new ordering for primitivePatch.
283  // Ordering is -faceMap: for every face
284  // index of the new face -rotation:for every new face the clockwise
285  // shift of the original face. Return false if nothing changes
286  // (faceMap is identity, rotation is 0), true otherwise.
287  virtual bool order
288  (
290  const primitivePatch&,
292  labelList& rotation
293  ) const;
294 
295  //- Write the polyPatch data as a dictionary
296  virtual void write(Ostream&) const;
297 };
298 
299 
300 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
301 
302 } // End namespace Foam
303 
304 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
305 
306 #endif
307 
308 // ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
autoPtr< PrimitivePatch< SubList< face >, const pointField & > > clone() const
Construct and return a clone.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
label size() const
Return the number of elements in the UList.
Definition: UListI.H:311
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
Cyclic plane patch.
virtual bool owner() const
Does this side own the patch ?
virtual const transformer & transform() const
Return transformation between the coupled patches.
transformTypes transformType() const
Type of transform.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
label index() const
Return the index of this patch in the boundaryMesh.
const word & name() const
Return name.
Foam::polyBoundaryMesh.
label findIndex(const word &patchName) const
Find patch index given a name.
wordList names() const
Return the list of patch names.
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:71
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:277
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: polyPatch.C:215
label referPatchIndex() const
Return the referring patchID.
TypeName("processorCyclic")
Runtime type information.
virtual void write(Ostream &) const
Write the polyPatch data as a dictionary.
void initMovePoints(PstreamBuffers &, const pointField &)
Initialise the patches for moving points.
static word newName(const word &cyclicPolyPatchName, const label myProcNo, const label neighbProcNo)
Return the name of a processorCyclicPolyPatch.
virtual bool owner() const
Does this side own the patch ?
static labelList patchIDs(const word &cyclicPolyPatchName, const polyBoundaryMesh &bm)
Return the indices of a processorCyclicPolyPatchs.
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)
Construct from components with specified name.
void calcGeometry(PstreamBuffers &)
Calculate the patch geometry.
virtual void initOrder(PstreamBuffers &, const primitivePatch &) const
Initialise ordering for primitivePatch. Does not.
void initCalcGeometry(PstreamBuffers &)
Initialise the calculation of the patch geometry.
virtual const transformer & transform() const
Return transformation between the coupled patches.
const word & referPatchName() const
Return name of originating cyclicPolyPatch patch.
const cyclicPolyPatch & referPatch() const
Return a reference to the referring patch.
virtual int tag() const
Return message tag to use for communication.
virtual bool order(PstreamBuffers &, const primitivePatch &, labelList &faceMap, labelList &rotation) const
Return new ordering for primitivePatch.
void movePoints(PstreamBuffers &, const pointField &)
Correct patches after moving points.
virtual void initTopoChange(PstreamBuffers &)
Initialise the update of the patch topology.
virtual cyclicTransform::transformTypes transformType() const
Type of transform.
virtual void topoChange(PstreamBuffers &)
Update of the patch topology.
Neighbour processor patch.
int myProcNo() const
Return processor number.
int neighbProcNo() const
Return neighbour processor number.
Vector-tensor class used to perform translations, rotations and scaling operations in 3D space.
Definition: transformer.H:84
A class for handling words, derived from string.
Definition: word.H:63
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:381
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
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
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:288
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
error FatalError
dictionary dict