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  (
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 and return a clone, resetting the boundary mesh
174  virtual autoPtr<polyPatch> clone(const polyBoundaryMesh& bm) const
175  {
176  return autoPtr<polyPatch>(new processorCyclicPolyPatch(*this, bm));
177  }
178 
179  //- Construct and return a clone, resetting the face list
180  // and boundary mesh
181  virtual autoPtr<polyPatch> clone
182  (
183  const polyBoundaryMesh& bm,
184  const label index,
185  const label newSize,
186  const label newStart
187  ) const
188  {
189  return autoPtr<polyPatch>
190  (
192  (
193  *this,
194  bm,
195  index,
196  newSize,
197  newStart
198  )
199  );
200  }
201 
202 
203  // Destructor
204  virtual ~processorCyclicPolyPatch();
205 
206 
207  // Member Functions
208 
209  //- Return name of originating cyclicPolyPatch patch
210  const word& referPatchName() const
211  {
212  return referPatchName_;
213  }
214 
215  //- Return the name of a processorCyclicPolyPatch
216  // constructed from cyclicPolyPatch name and the processor IDs
217  static word newName
218  (
219  const word& cyclicPolyPatchName,
220  const label myProcNo,
221  const label neighbProcNo
222  );
223 
224  //- Return the indices of a processorCyclicPolyPatchs
225  // constructed from the given cyclicPolyPatch
226  static labelList patchIDs
227  (
228  const word& cyclicPolyPatchName,
229  const polyBoundaryMesh& bm
230  );
231 
232  //- Return the referring patchID
233  label referPatchID() const
234  {
235  if (referPatchID_ == -1)
236  {
237  referPatchID_ = this->boundaryMesh().findPatchID
238  (
239  referPatchName_
240  );
241  if (referPatchID_ == -1)
242  {
244  << "Illegal referPatch name " << referPatchName_
245  << endl << "Valid patch names are "
246  << this->boundaryMesh().names()
247  << exit(FatalError);
248  }
249  }
250  return referPatchID_;
251  }
252 
253  //- Return a reference to the referring patch
254  const cyclicPolyPatch& referPatch() const
255  {
256  const polyPatch& pp = this->boundaryMesh()[referPatchID()];
257  return refCast<const cyclicPolyPatch>(pp);
258  }
259 
260  //- Return message tag to use for communication
261  virtual int tag() const;
262 
263  //- Does this side own the patch ?
264  virtual bool owner() const
265  {
266  return referPatch().owner();
267  }
268 
269  //- Type of transform
271  {
272  return referPatch().transformType();
273  }
274 
275  //- Return transformation between the coupled patches
276  virtual const transformer& transform() const
277  {
278  return referPatch().transform();
279  }
280 
281  //- Initialise ordering for primitivePatch. Does not
282  // refer to *this (except for name() and type() etc.)
283  virtual void initOrder(PstreamBuffers&, const primitivePatch&) const;
284 
285  //- Return new ordering for primitivePatch.
286  // Ordering is -faceMap: for every face
287  // index of the new face -rotation:for every new face the clockwise
288  // shift of the original face. Return false if nothing changes
289  // (faceMap is identity, rotation is 0), true otherwise.
290  virtual bool order
291  (
293  const primitivePatch&,
295  labelList& rotation
296  ) const;
297 
298  //- Write the polyPatch data as a dictionary
299  virtual void write(Ostream&) const;
300 };
301 
302 
303 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
304 
305 } // End namespace Foam
306 
307 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
308 
309 #endif
310 
311 // ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A list of faces which address into the list of points.
autoPtr< PrimitivePatch< FaceList, PointField > > clone() const
Construct and return a clone.
Buffers for inter-processor communications streams (UOPstream, UIPstream).
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 keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
label index() const
Return the index of this patch in the boundaryMesh.
const word & name() const
Return name.
Foam::polyBoundaryMesh.
label findPatchID(const word &patchName) const
Find patch index given a name.
wordList names() const
Return a list of patch names.
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:70
label start() const
Return start label of this patch in the polyMesh face list.
Definition: polyPatch.H:280
const polyBoundaryMesh & boundaryMesh() const
Return boundaryMesh reference.
Definition: polyPatch.C:270
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.
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.
label referPatchID() const
Return the referring patchID.
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.
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.
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:62
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:353
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
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:251
Pair< int > faceMap(const label facePi, const face &faceP, const label faceNi, const face &faceN)
error FatalError
dictionary dict