FreeFOAM The Cross-Platform CFD Toolkit
processorPolyPatch.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
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::processorPolyPatch
26 
27 Description
28  Neighbour processor patch.
29 
30  Note: morph patch face ordering comes geometric or topological.
31  Geometric: no cyclics allowed (assumes faces coincident)
32  Topological: needs unmodified faces on both sides to correspond. Also
33  needs at least one per connected patch area (so all patch faces can be
34  visited from an unmodified face)
35 
36 SourceFiles
37  processorPolyPatch.C
38  processorPolyPatchMorph.C
39 
40 \*---------------------------------------------------------------------------*/
41 
42 #ifndef processorPolyPatch_H
43 #define processorPolyPatch_H
44 
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 namespace Foam
50 {
51 
52 /*---------------------------------------------------------------------------*\
53  Class processorPolyPatch Declaration
54 \*---------------------------------------------------------------------------*/
55 
57 :
58  public coupledPolyPatch
59 {
60  // Private data
61 
62  int myProcNo_;
63  int neighbProcNo_;
64 
65  //- Processor-neighbbour patch face centres
66  vectorField neighbFaceCentres_;
67 
68  //- Processor-neighbbour patch face areas
69  vectorField neighbFaceAreas_;
70 
71  //- Processor-neighbbour patch neighbour cell centres
72  vectorField neighbFaceCellCentres_;
73 
74  //- Corresponding neighbouring local point label for every local point
75  // (so localPoints()[i] == neighb.localPoints()[neighbPoints_[i]])
76  mutable labelList* neighbPointsPtr_;
77 
78  //- Corresponding neighbouring local edge label for every local edge
79  // (so edges()[i] == neighb.edges()[neighbEdges_[i]])
80  mutable labelList* neighbEdgesPtr_;
81 
82 
83 
84  // Private static data
85 
86  //- Whether to use geometric or topological matching
87  static bool geometricMatch_;
88 
89  //- Relative tolerance (for geometric matching only). Is factor of
90  // maximum edge length per face.
91  static scalar matchTol_;
92 
93 
94 protected:
95 
96  // Protected Member functions
97 
98  //- Initialise the calculation of the patch geometry
99  void initGeometry();
100 
101  //- Calculate the patch geometry
102  void calcGeometry();
103 
104  //- Initialise the patches for moving points
105  void initMovePoints(const pointField&);
106 
107  //- Correct patches after moving points
108  void movePoints(const pointField&);
109 
110  //- Initialise the update of the patch topology
111  virtual void initUpdateMesh();
112 
113  //- Update of the patch topology
114  virtual void updateMesh();
115 
116 
117 public:
118 
119  //- Runtime type information
120  TypeName("processor");
121 
122 
123  // Constructors
124 
125  //- Construct from components
127  (
128  const word& name,
129  const label size,
130  const label start,
131  const label index,
132  const polyBoundaryMesh& bm,
133  const int myProcNo,
134  const int neighbProcNo
135  );
136 
137  //- Construct from dictionary
139  (
140  const word& name,
141  const dictionary& dict,
142  const label index,
143  const polyBoundaryMesh&
144  );
145 
146  //- Construct as copy, resetting the boundary mesh
148 
149  //- Construct as given the original patch and resetting the
150  // face list and boundary mesh information
152  (
153  const processorPolyPatch& pp,
154  const polyBoundaryMesh& bm,
155  const label index,
156  const label newSize,
157  const label newStart
158  );
159 
160  //- Construct and return a clone, resetting the boundary mesh
161  virtual autoPtr<polyPatch> clone(const polyBoundaryMesh& bm) const
162  {
163  return autoPtr<polyPatch>(new processorPolyPatch(*this, bm));
164  }
165 
166  //- Construct and return a clone, resetting the face list
167  // and boundary mesh
168  virtual autoPtr<polyPatch> clone
169  (
170  const polyBoundaryMesh& bm,
171  const label index,
172  const label newSize,
173  const label newStart
174  ) const
175  {
176  return autoPtr<polyPatch>
177  (
179  (
180  refCast<const processorPolyPatch>(*this),
181  bm,
182  index,
183  newSize,
184  newStart
185  )
186  );
187  }
188 
189 
190  // Destructor
191 
192  virtual ~processorPolyPatch();
193 
194 
195  // Member functions
196 
197  //- Return processor number
198  int myProcNo() const
199  {
200  return myProcNo_;
201  }
202 
203  //- Return neigbour processor number
204  int neighbProcNo() const
205  {
206  return neighbProcNo_;
207  }
208 
209  //- Does the processor own the patch ?
210  bool owner() const
211  {
212  return (myProcNo_ < neighbProcNo_);
213  }
214 
215  //- Is the processor the patch neighbour ?
216  bool neighbour() const
217  {
218  return !owner();
219  }
220 
221  //- Return processor-neighbbour patch face centres
223  {
224  return neighbFaceCentres_;
225  }
226 
227  //- Return processor-neighbbour patch face areas
229  {
230  return neighbFaceAreas_;
231  }
232 
233  //- Return processor-neighbbour patch neighbour cell centres
235  {
236  return neighbFaceCellCentres_;
237  }
238 
239  //- Return neighbour point labels. This is for my local point (-1 or)
240  // the corresponding local point on the other side. It is -1 if
241  // there are multiple corresponding points on this or the other side
242  // (can happen for cyclics being converted into proc patches)
243  const labelList& neighbPoints() const;
244 
245  //- Return neighbour edge labels. This is for my local edge (-1 or) the
246  // corresponding local edge on the other side. See above for -1 cause.
247  const labelList& neighbEdges() const;
248 
249 
250  //- Initialize ordering for primitivePatch. Does not
251  // refer to *this (except for name() and type() etc.)
252  virtual void initOrder(const primitivePatch&) const;
253 
254  //- Return new ordering for primitivePatch.
255  // Ordering is -faceMap: for every face
256  // index of the new face -rotation:for every new face the clockwise
257  // shift of the original face. Return false if nothing changes
258  // (faceMap is identity, rotation is 0), true otherwise.
259  virtual bool order
260  (
261  const primitivePatch&,
262  labelList& faceMap,
263  labelList& rotation
264  ) const;
265 
266 
267  //- Write the polyPatch data as a dictionary
268  virtual void write(Ostream&) const;
269 };
270 
271 
272 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
273 
274 } // End namespace Foam
275 
276 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
277 
278 #endif
279 
280 // ************************ vim: set sw=4 sts=4 et: ************************ //