initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / lagrangian / molecularDynamics / molecule / interactionLists / referredCell / referredCell.H
blob666b4f9268297675083c85fb810e85723951d14f
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2008-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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
25 Class
26     Foam::referredCell
28 Description
30 SourceFiles
31     referredCellI.H
32     referredCell.C
34 \*---------------------------------------------------------------------------*/
36 #ifndef referredCell_H
37 #define referredCell_H
39 #include "vector.H"
40 #include "vectorList.H"
41 #include "tensor.H"
42 #include "transform.H"
43 #include "DynamicList.H"
44 #include "labelList.H"
45 #include "edgeList.H"
46 #include "polyMesh.H"
48 #include "referredMolecule.H"
50 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 namespace Foam
55 /*---------------------------------------------------------------------------*\
56                           Class referredCell Declaration
57 \*---------------------------------------------------------------------------*/
59 class referredCell
61     public DynamicList<referredMolecule>
63     // Private data
65         label sourceProc_;
67         label sourceCell_;
69         //- Referred vertex positions
70         vectorList vertexPositions_;
72         edgeList edges_;
74         labelListList faces_;
76         vectorList faceCentres_;
78         vectorList faceAreas_;
80         labelList realCellsForInteraction_;
82         vector offset_;
84         tensor rotation_;
87     // Private Member Functions
89         void setConstructionData
90         (
91             const polyMesh& mesh,
92             const label sourceCell
93         );
95         void locallyMapEdgeList
96         (
97             const labelList& points,
98             const edgeList& sourceCellEdges
99         );
101         void locallyMapFaceList
102         (
103             const labelList& points,
104             const labelListList& sourceCellFaces
105         );
107         vector referPosition(const vector& positionToRefer);
109         vectorList referPositions(const vectorList& positionsToRefer);
111         vector rotateVector(const vector& vectorToRotate);
113         vectorList rotateVectors(const vectorList& vectorsToRotate);
116 public:
118     // Constructors
120         //- Construct null
122         referredCell();
124         //- Construct from components with external edge information
125         referredCell
126         (
127             const polyMesh& mesh,
128             const label sourceProc,
129             const label sourceCell,
130             const vector& offset,
131             const tensor& rotation
132         );
134         //- Construct from components with existing local edge information
135         referredCell
136         (
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
146         );
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.
154         referredCell
155         (
156             const polyMesh& mesh,
157             const label sourceProc,
158             const label sourceCell,
159             const vector& cS,
160             const vector& cD,
161             const vector& nS,
162             const vector& nD
163         );
166     // Destructor
168         virtual ~referredCell();
171     // Member Functions
173         //- Take this referredCell object that has already had it's transform
174         //  calculated and refer it on again, retaining same source info.
175         referredCell reRefer
176         (
177             const vector& cS,
178             const vector& cD,
179             const vector& nS,
180             const vector& nD
181         );
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
195         // list of vectors
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;
218         // Access
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;
243     // Friend Operators
245         inline friend bool operator==
246         (
247             const referredCell& a,
248             const referredCell& b
249         );
251         inline friend bool operator!=
252         (
253             const referredCell& a,
254             const referredCell& b
255         );
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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
275 #endif
277 // ************************************************************************* //