1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2008-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
34 \*---------------------------------------------------------------------------*/
36 #ifndef referredCell_H
37 #define referredCell_H
40 #include "vectorList.H"
42 #include "transform.H"
43 #include "DynamicList.H"
44 #include "labelList.H"
48 #include "referredMolecule.H"
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
55 /*---------------------------------------------------------------------------*\
56 Class referredCell Declaration
57 \*---------------------------------------------------------------------------*/
61 public DynamicList<referredMolecule>
69 //- Referred vertex positions
70 vectorList vertexPositions_;
76 vectorList faceCentres_;
78 vectorList faceAreas_;
80 labelList realCellsForInteraction_;
87 // Private Member Functions
89 void setConstructionData
92 const label sourceCell
95 void locallyMapEdgeList
97 const labelList& points,
98 const edgeList& sourceCellEdges
101 void locallyMapFaceList
103 const labelList& points,
104 const labelListList& sourceCellFaces
107 vector referPosition(const vector& positionToRefer);
109 vectorList referPositions(const vectorList& positionsToRefer);
111 vector rotateVector(const vector& vectorToRotate);
113 vectorList rotateVectors(const vectorList& vectorsToRotate);
124 //- Construct from components with external edge information
127 const polyMesh& mesh,
128 const label sourceProc,
129 const label sourceCell,
130 const vector& offset,
131 const tensor& rotation
134 //- Construct from components with existing local edge information
137 const label sourceProc,
138 const label sourceCell,
139 const vectorList& vertexPositions,
140 const edgeList& localEdges,
141 const labelListList& localFaces,
142 const vectorList& faceCentres,
143 const vectorList& faceAreas,
144 const vector& offset,
145 const tensor& rotation
148 //- Construct from pair of face centers (c) and plain
149 // face normals (n) (no need to make unit vectors or
150 // reverse one direction)
151 // Order of vectors important (S = source, D = Destination).
152 // External edge information.
156 const polyMesh& mesh,
157 const label sourceProc,
158 const label sourceCell,
168 virtual ~referredCell();
173 //- Take this referredCell object that has already had it's transform
174 // calculated and refer it on again, retaining same source info.
183 //- Use internal transformatation values to transform the given
184 // postion to its new location.
185 vector referPosition(const vector& positionToRefer) const;
187 //- Use internal transformatation values to transform the given
188 // list of postions to their new locations.
189 vectorList referPosition(const vectorList& positionsToRefer) const;
191 //- Use internal transformatation values to rotate the given vector
192 vector rotateVector(const vector& vectorToRotate) const;
194 //- Use internal transformatation values to rotate the given
196 vectorList rotateVectors(const vectorList& vectorsToRotate) const;
198 //- referInMols clears, the stored list of referred mols and takes
199 // in a list of referred mols coming from a source processor,
200 // transformingtheir positions
201 void referInMols(const List<referredMolecule>& incomingMols);
203 //- duplicate() function to test whether a referred or real cell
204 // supplied by arguement is a duplicate of this referredCell.
205 // Can be used bi-directionally - i.e. can be called on an existing
206 // referred cell with a proposed referredCell as argument,
207 // or vice versa. Can only be called by a proposed referredCell with
208 // a real cell index as arguement to test to see if the proposed
209 // referredCell is a duplicate.
210 // A duplicate cell is defined as one which has the same source
211 // processor, source cell, and an equal offset. Real cells have zero
212 // offset by definition.
213 bool duplicate(const referredCell& refCellDupl) const;
215 bool duplicate(const label procNo, const label nCells) const;
220 inline label sourceProc() const;
222 inline label sourceCell() const;
224 inline const vector& offset() const;
226 inline const tensor& rotation() const;
228 inline const vectorList& vertexPositions() const;
230 inline const edgeList& edges() const;
232 inline const labelListList& faces() const;
234 inline const vectorList& faceCentres() const;
236 inline const vectorList& faceAreas() const;
238 inline labelList& realCells();
240 inline const labelList& realCellsForInteraction() const;
245 inline friend bool operator==
247 const referredCell& a,
248 const referredCell& b
251 inline friend bool operator!=
253 const referredCell& a,
254 const referredCell& b
258 // IOstream Operators
260 friend Istream& operator>>(Istream&, referredCell&);
261 friend Ostream& operator<<(Ostream&, const referredCell&);
265 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
267 } // End namespace Foam
269 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
271 #include "referredCellI.H"
273 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
277 // ************************************************************************* //