OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

referredCell.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 2008-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Class
00026     Foam::referredCell
00027 
00028 Description
00029 
00030 SourceFiles
00031     referredCellI.H
00032     referredCell.C
00033 
00034 \*---------------------------------------------------------------------------*/
00035 
00036 #ifndef referredCell_H
00037 #define referredCell_H
00038 
00039 #include "vector.H"
00040 #include "vectorList.H"
00041 #include "tensor.H"
00042 #include "transform.H"
00043 #include "DynamicList.H"
00044 #include "labelList.H"
00045 #include "edgeList.H"
00046 #include "polyMesh.H"
00047 
00048 #include "referredMolecule.H"
00049 
00050 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00051 
00052 namespace Foam
00053 {
00054 
00055 /*---------------------------------------------------------------------------*\
00056                           Class referredCell Declaration
00057 \*---------------------------------------------------------------------------*/
00058 
00059 class referredCell
00060 :
00061     public DynamicList<referredMolecule>
00062 {
00063     // Private data
00064 
00065         label sourceProc_;
00066 
00067         label sourceCell_;
00068 
00069         //- Referred vertex positions
00070         vectorList vertexPositions_;
00071 
00072         edgeList edges_;
00073 
00074         labelListList faces_;
00075 
00076         vectorList faceCentres_;
00077 
00078         vectorList faceAreas_;
00079 
00080         labelList realCellsForInteraction_;
00081 
00082         vector offset_;
00083 
00084         tensor rotation_;
00085 
00086 
00087     // Private Member Functions
00088 
00089         void setConstructionData
00090         (
00091             const polyMesh& mesh,
00092             const label sourceCell
00093         );
00094 
00095         void locallyMapEdgeList
00096         (
00097             const labelList& points,
00098             const edgeList& sourceCellEdges
00099         );
00100 
00101         void locallyMapFaceList
00102         (
00103             const labelList& points,
00104             const labelListList& sourceCellFaces
00105         );
00106 
00107         vector referPosition(const vector& positionToRefer);
00108 
00109         vectorList referPositions(const vectorList& positionsToRefer);
00110 
00111         vector rotateVector(const vector& vectorToRotate);
00112 
00113         vectorList rotateVectors(const vectorList& vectorsToRotate);
00114 
00115 
00116 public:
00117 
00118     // Constructors
00119 
00120         //- Construct null
00121 
00122         referredCell();
00123 
00124         //- Construct from components with external edge information
00125         referredCell
00126         (
00127             const polyMesh& mesh,
00128             const label sourceProc,
00129             const label sourceCell,
00130             const vector& offset,
00131             const tensor& rotation
00132         );
00133 
00134         //- Construct from components with existing local edge information
00135         referredCell
00136         (
00137             const label sourceProc,
00138             const label sourceCell,
00139             const vectorList& vertexPositions,
00140             const edgeList& localEdges,
00141             const labelListList& localFaces,
00142             const vectorList& faceCentres,
00143             const vectorList& faceAreas,
00144             const vector& offset,
00145             const tensor& rotation
00146         );
00147 
00148         //- Construct from pair of face centers (c) and plain
00149         //  face normals (n) (no need to make unit vectors or
00150         //  reverse one direction)
00151         //  Order of vectors important (S = source, D = Destination).
00152         //  External edge information.
00153 
00154         referredCell
00155         (
00156             const polyMesh& mesh,
00157             const label sourceProc,
00158             const label sourceCell,
00159             const vector& cS,
00160             const vector& cD,
00161             const vector& nS,
00162             const vector& nD
00163         );
00164 
00165 
00166     // Destructor
00167 
00168         virtual ~referredCell();
00169 
00170 
00171     // Member Functions
00172 
00173         //- Take this referredCell object that has already had it's transform
00174         //  calculated and refer it on again, retaining same source info.
00175         referredCell reRefer
00176         (
00177             const vector& cS,
00178             const vector& cD,
00179             const vector& nS,
00180             const vector& nD
00181         );
00182 
00183         //- Use internal transformatation values to transform the given
00184         //  postion to its new location.
00185         vector referPosition(const vector& positionToRefer) const;
00186 
00187         //- Use internal transformatation values to transform the given
00188         //  list of postions to their new locations.
00189         vectorList referPosition(const vectorList& positionsToRefer) const;
00190 
00191         //- Use internal transformatation values to rotate the given vector
00192         vector rotateVector(const vector& vectorToRotate) const;
00193 
00194         //- Use internal transformatation values to rotate the given
00195         // list of vectors
00196         vectorList rotateVectors(const vectorList& vectorsToRotate) const;
00197 
00198         //- referInMols clears, the stored list of referred mols and takes
00199         //  in a list of referred mols coming from a source processor,
00200         //  transformingtheir positions
00201         void referInMols(const List<referredMolecule>& incomingMols);
00202 
00203         //- duplicate() function to test whether a referred or real cell
00204         //  supplied by arguement is a duplicate of this referredCell.
00205         //  Can be used bi-directionally - i.e. can be called on an existing
00206         //  referred cell with a proposed referredCell as argument,
00207         //  or vice versa.  Can only be called by a proposed referredCell with
00208         //  a real cell index as arguement to test to see if the proposed
00209         //  referredCell is a duplicate.
00210         //  A duplicate cell is defined as one which has the same source
00211         //  processor, source cell, and an equal offset. Real cells have zero
00212         //  offset by definition.
00213         bool duplicate(const referredCell& refCellDupl) const;
00214 
00215         bool duplicate(const label procNo, const label nCells) const;
00216 
00217 
00218         // Access
00219 
00220             inline label sourceProc() const;
00221 
00222             inline label sourceCell() const;
00223 
00224             inline const vector& offset() const;
00225 
00226             inline const tensor& rotation() const;
00227 
00228             inline const vectorList& vertexPositions() const;
00229 
00230             inline const edgeList& edges() const;
00231 
00232             inline const labelListList& faces() const;
00233 
00234             inline const vectorList& faceCentres() const;
00235 
00236             inline const vectorList& faceAreas() const;
00237 
00238             inline labelList& realCells();
00239 
00240             inline const labelList& realCellsForInteraction() const;
00241 
00242 
00243     // Friend Operators
00244 
00245         inline friend bool operator==
00246         (
00247             const referredCell& a,
00248             const referredCell& b
00249         );
00250 
00251         inline friend bool operator!=
00252         (
00253             const referredCell& a,
00254             const referredCell& b
00255         );
00256 
00257 
00258     // IOstream Operators
00259 
00260         friend Istream& operator>>(Istream&, referredCell&);
00261         friend Ostream& operator<<(Ostream&, const referredCell&);
00262 };
00263 
00264 
00265 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00266 
00267 } // End namespace Foam
00268 
00269 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00270 
00271 #include "referredCellI.H"
00272 
00273 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00274 
00275 #endif
00276 
00277 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd