FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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