FreeFOAM The Cross-Platform CFD Toolkit
referredCell.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) 2008-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::referredCell
26 
27 Description
28 
29 SourceFiles
30  referredCellI.H
31  referredCell.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef referredCell_H
36 #define referredCell_H
37 
38 #include <OpenFOAM/vector.H>
39 #include <OpenFOAM/vectorList.H>
40 #include <OpenFOAM/tensor.H>
41 #include <OpenFOAM/transform.H>
42 #include <OpenFOAM/DynamicList.H>
43 #include <OpenFOAM/labelList.H>
44 #include <OpenFOAM/edgeList.H>
45 #include <OpenFOAM/polyMesh.H>
46 
48 
49 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
50 
51 namespace Foam
52 {
53 
54 /*---------------------------------------------------------------------------*\
55  Class referredCell Declaration
56 \*---------------------------------------------------------------------------*/
57 
59 :
60  public DynamicList<referredMolecule>
61 {
62  // Private data
63 
64  label sourceProc_;
65 
66  label sourceCell_;
67 
68  //- Referred vertex positions
69  vectorList vertexPositions_;
70 
71  edgeList edges_;
72 
73  labelListList faces_;
74 
75  vectorList faceCentres_;
76 
77  vectorList faceAreas_;
78 
79  labelList realCellsForInteraction_;
80 
81  vector offset_;
82 
83  tensor rotation_;
84 
85 
86  // Private Member Functions
87 
88  void setConstructionData
89  (
90  const polyMesh& mesh,
91  const label sourceCell
92  );
93 
94  void locallyMapEdgeList
95  (
96  const labelList& points,
97  const edgeList& sourceCellEdges
98  );
99 
100  void locallyMapFaceList
101  (
102  const labelList& points,
103  const labelListList& sourceCellFaces
104  );
105 
106  vector referPosition(const vector& positionToRefer);
107 
108  vectorList referPositions(const vectorList& positionsToRefer);
109 
110  vector rotateVector(const vector& vectorToRotate);
111 
112  vectorList rotateVectors(const vectorList& vectorsToRotate);
113 
114 
115 public:
116 
117  // Constructors
118 
119  //- Construct null
120 
121  referredCell();
122 
123  //- Construct from components with external edge information
125  (
126  const polyMesh& mesh,
127  const label sourceProc,
128  const label sourceCell,
129  const vector& offset,
130  const tensor& rotation
131  );
132 
133  //- Construct from components with existing local edge information
135  (
136  const label sourceProc,
137  const label sourceCell,
139  const edgeList& localEdges,
140  const labelListList& localFaces,
141  const vectorList& faceCentres,
142  const vectorList& faceAreas,
143  const vector& offset,
144  const tensor& rotation
145  );
146 
147  //- Construct from pair of face centers (c) and plain
148  // face normals (n) (no need to make unit vectors or
149  // reverse one direction)
150  // Order of vectors important (S = source, D = Destination).
151  // External edge information.
152 
154  (
155  const polyMesh& mesh,
156  const label sourceProc,
157  const label sourceCell,
158  const vector& cS,
159  const vector& cD,
160  const vector& nS,
161  const vector& nD
162  );
163 
164 
165  // Destructor
166 
167  virtual ~referredCell();
168 
169 
170  // Member Functions
171 
172  //- Take this referredCell object that has already had it's transform
173  // calculated and refer it on again, retaining same source info.
175  (
176  const vector& cS,
177  const vector& cD,
178  const vector& nS,
179  const vector& nD
180  );
181 
182  //- Use internal transformatation values to transform the given
183  // postion to its new location.
184  vector referPosition(const vector& positionToRefer) const;
185 
186  //- Use internal transformatation values to transform the given
187  // list of postions to their new locations.
188  vectorList referPosition(const vectorList& positionsToRefer) const;
189 
190  //- Use internal transformatation values to rotate the given vector
191  vector rotateVector(const vector& vectorToRotate) const;
192 
193  //- Use internal transformatation values to rotate the given
194  // list of vectors
195  vectorList rotateVectors(const vectorList& vectorsToRotate) const;
196 
197  //- referInMols clears, the stored list of referred mols and takes
198  // in a list of referred mols coming from a source processor,
199  // transformingtheir positions
200  void referInMols(const List<referredMolecule>& incomingMols);
201 
202  //- duplicate() function to test whether a referred or real cell
203  // supplied by arguement is a duplicate of this referredCell.
204  // Can be used bi-directionally - i.e. can be called on an existing
205  // referred cell with a proposed referredCell as argument,
206  // or vice versa. Can only be called by a proposed referredCell with
207  // a real cell index as arguement to test to see if the proposed
208  // referredCell is a duplicate.
209  // A duplicate cell is defined as one which has the same source
210  // processor, source cell, and an equal offset. Real cells have zero
211  // offset by definition.
212  bool duplicate(const referredCell& refCellDupl) const;
213 
214  bool duplicate(const label procNo, const label nCells) const;
215 
216 
217  // Access
218 
219  inline label sourceProc() const;
220 
221  inline label sourceCell() const;
222 
223  inline const vector& offset() const;
224 
225  inline const tensor& rotation() const;
226 
227  inline const vectorList& vertexPositions() const;
228 
229  inline const edgeList& edges() const;
230 
231  inline const labelListList& faces() const;
232 
233  inline const vectorList& faceCentres() const;
234 
235  inline const vectorList& faceAreas() const;
236 
237  inline labelList& realCells();
238 
239  inline const labelList& realCellsForInteraction() const;
240 
241 
242  // Friend Operators
243 
244  inline friend bool operator==
245  (
246  const referredCell& a,
247  const referredCell& b
248  );
249 
250  inline friend bool operator!=
251  (
252  const referredCell& a,
253  const referredCell& b
254  );
255 
256 
257  // IOstream Operators
258 
260  friend Ostream& operator<<(Ostream&, const referredCell&);
261 };
262 
263 
264 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
265 
266 } // End namespace Foam
267 
268 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
269 
270 #include <molecule/referredCellI.H>
271 
272 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
273 
274 #endif
275 
276 // ************************ vim: set sw=4 sts=4 et: ************************ //