OpenFOAM logo
The Open Source CFD Toolbox
  Programmer’s C++ Doxygen OpenCFD Solutions Contact OpenFOAM

edgeVertex.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) 1991-2007 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     edgeVertex
00027 
00028 Description
00029     Combines edge or vertex in single label. Used to specify cuts across
00030     cell circumference.
00031 
00032 SourceFiles
00033 
00034 \*---------------------------------------------------------------------------*/
00035 
00036 #ifndef edgeVertex_H
00037 #define edgeVertex_H
00038 
00039 #include "label.H"
00040 #include "polyMesh.H"
00041 
00042 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00043 
00044 namespace Foam
00045 {
00046 
00047 // Class forward declarations
00048 class refineCell;
00049 
00050 /*---------------------------------------------------------------------------*\
00051                            Class edgeVertex Declaration
00052 \*---------------------------------------------------------------------------*/
00053 
00054 class edgeVertex
00055 {
00056     // Private data
00057 
00058         //- Reference to mesh. (could be primitive mesh but keeping polyMesh
00059         //  here saves storing reference at higher levels where we do need it)
00060         const polyMesh& mesh_;
00061 
00062     // Private Member Functions
00063 
00064         //- Disallow default bitwise copy construct
00065         edgeVertex(const edgeVertex&);
00066 
00067         //- Disallow default bitwise assignment
00068         void operator=(const edgeVertex&);
00069 
00070 
00071 public:
00072 
00073     // Static Functions
00074 
00075         //- Update refine list from map. Used to update cell/face labels
00076         //  after morphing
00077         static void updateLabels(const labelList& map, List<refineCell>&);
00078 
00079         //- Update map from map. Used to update cell/face labels
00080         //  after morphing
00081         static void updateLabels(const labelList& map, Map<label>&);
00082 
00083         //- Update map from map. Used to update cell/face labels
00084         //  after morphing
00085         static void updateLabels(const labelList& map, labelHashSet&);
00086 
00087 
00088 
00089     // Constructors
00090 
00091         //- Construct from mesh
00092         edgeVertex(const polyMesh& mesh)
00093         :
00094             mesh_(mesh)
00095         {}
00096 
00097 
00098     // Member Functions
00099 
00100         const polyMesh& mesh() const
00101         {
00102             return mesh_;
00103         }
00104 
00105 
00106     // EdgeVertex handling
00107 
00108         //- is eVert an edge?
00109         static bool isEdge(const primitiveMesh& mesh, const label eVert)
00110         {
00111             if (eVert < 0 || eVert >= (mesh.nPoints() + mesh.nEdges()))
00112             {
00113                 FatalErrorIn
00114                 (
00115                     "edgeVertex::isEdge(const primitiveMesh&, const label)"
00116                 )   << "EdgeVertex " << eVert << " out of range "
00117                     << mesh.nPoints() << " to "
00118                     << (mesh.nPoints() + mesh.nEdges() - 1)
00119                     << abort(FatalError);
00120             }
00121             
00122             return eVert >= mesh.nPoints();
00123         }
00124         bool isEdge(const label eVert) const
00125         {
00126             return isEdge(mesh_, eVert);
00127         }
00128 
00129         //- convert eVert to edge label
00130         static label getEdge(const primitiveMesh& mesh, const label eVert)
00131         {
00132             if (!isEdge(mesh, eVert))
00133             {
00134                 FatalErrorIn
00135                 (
00136                     "edgeVertex::getEdge(const primitiveMesh&, const label)"
00137                 )   << "EdgeVertex " << eVert << " not an edge"
00138                     << abort(FatalError);
00139             }
00140             return eVert - mesh.nPoints();
00141         }
00142         label getEdge(const label eVert) const
00143         {
00144             return getEdge(mesh_, eVert);
00145         }
00146 
00147         //- convert eVert to vertex label
00148         static label getVertex(const primitiveMesh& mesh, const label eVert)
00149         {
00150             if (isEdge(mesh, eVert) || (eVert < 0))
00151             {
00152                 FatalErrorIn
00153                 (
00154                     "edgeVertex::getVertex(const primitiveMesh&, const label)"
00155                 )   << "EdgeVertex " << eVert << " not a vertex"
00156                     << abort(FatalError);
00157             }            
00158             return eVert;
00159         }
00160         label getVertex(const label eVert) const
00161         {
00162             return getVertex(mesh_, eVert);
00163         }
00164 
00165         //- Convert pointI to eVert
00166         static label vertToEVert(const primitiveMesh& mesh, const label vertI)
00167         {
00168             if ((vertI < 0) || (vertI >= mesh.nPoints()))
00169             {
00170                 FatalErrorIn
00171                 (
00172                     "edgeVertex::vertToEVert(const primitiveMesh&, const label)"
00173                 )   << "Illegal vertex number " << vertI
00174                     << abort(FatalError);
00175             }
00176             return vertI;
00177         }
00178         label vertToEVert(const label vertI) const
00179         {
00180             return vertToEVert(mesh_, vertI);
00181         }
00182 
00183         //- Convert edgeI to eVert
00184         static label edgeToEVert(const primitiveMesh& mesh, const label edgeI)
00185         {
00186             if ((edgeI < 0) || (edgeI >= mesh.nEdges()))
00187             {
00188                 FatalErrorIn
00189                 (
00190                     "edgeVertex::edgeToEVert(const primitiveMesh&const label)"
00191                 )   << "Illegal edge number " << edgeI
00192                     << abort(FatalError);
00193             }
00194             return mesh.nPoints() + edgeI;
00195         }
00196         label edgeToEVert(const label edgeI) const
00197         {
00198             return edgeToEVert(mesh_, edgeI);
00199         }
00200 
00201         //- Return coordinate of cut (uses weight if edgeCut)
00202         static point coord
00203         (
00204             const primitiveMesh&,
00205             const label cut,
00206             const scalar weight
00207         );
00208         point coord(const label cut, const scalar weight) const
00209         {
00210             return coord(mesh_, cut, weight);
00211         }
00212 
00213         //- Find mesh edge (or -1) between two cuts. 
00214         static label cutPairToEdge
00215         (
00216             const primitiveMesh&,
00217             const label cut0,
00218             const label cut1
00219         );
00220         label cutPairToEdge(const label cut0, const label cut1) const
00221         {
00222             return cutPairToEdge(mesh_, cut0, cut1);
00223         }
00224 
00225         //- Write cut description to Ostream
00226         Ostream& writeCut(Ostream& os, const label cut, const scalar) const;
00227 
00228         //- Write cut descriptions to Ostream
00229         Ostream& writeCuts(Ostream& os, const labelList&, const scalarField&)
00230          const;
00231 };
00232 
00233 
00234 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00235 
00236 } // End namespace Foam
00237 
00238 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00239 
00240 #endif
00241 
00242 // ************************************************************************* //
Copyright © 2000-2007 OpenCFD Ltd