initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / dynamicMesh / meshCut / edgeVertex / edgeVertex.H
blob2780b12498f58e831bebfeaf4e92c4ef931faa66
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-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::edgeVertex
28 Description
29     Combines edge or vertex in single label. Used to specify cuts across
30     cell circumference.
32 SourceFiles
34 \*---------------------------------------------------------------------------*/
36 #ifndef edgeVertex_H
37 #define edgeVertex_H
39 #include "label.H"
40 #include "polyMesh.H"
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 namespace Foam
47 // Forward declaration of classes
48 class refineCell;
50 /*---------------------------------------------------------------------------*\
51                            Class edgeVertex Declaration
52 \*---------------------------------------------------------------------------*/
54 class edgeVertex
56     // Private data
58         //- Reference to mesh. (could be primitive mesh but keeping polyMesh
59         //  here saves storing reference at higher levels where we do need it)
60         const polyMesh& mesh_;
62     // Private Member Functions
64         //- Disallow default bitwise copy construct
65         edgeVertex(const edgeVertex&);
67         //- Disallow default bitwise assignment
68         void operator=(const edgeVertex&);
71 public:
73     // Static Functions
75         //- Update refine list from map. Used to update cell/face labels
76         //  after morphing
77         static void updateLabels(const labelList& map, List<refineCell>&);
79         //- Update map from map. Used to update cell/face labels
80         //  after morphing
81         static void updateLabels(const labelList& map, Map<label>&);
83         //- Update map from map. Used to update cell/face labels
84         //  after morphing
85         static void updateLabels(const labelList& map, labelHashSet&);
89     // Constructors
91         //- Construct from mesh
92         edgeVertex(const polyMesh& mesh)
93         :
94             mesh_(mesh)
95         {}
98     // Member Functions
100         const polyMesh& mesh() const
101         {
102             return mesh_;
103         }
106     // EdgeVertex handling
108         //- is eVert an edge?
109         static bool isEdge(const primitiveMesh& mesh, const label eVert)
110         {
111             if (eVert < 0 || eVert >= (mesh.nPoints() + mesh.nEdges()))
112             {
113                 FatalErrorIn
114                 (
115                     "edgeVertex::isEdge(const primitiveMesh&, const label)"
116                 )   << "EdgeVertex " << eVert << " out of range "
117                     << mesh.nPoints() << " to "
118                     << (mesh.nPoints() + mesh.nEdges() - 1)
119                     << abort(FatalError);
120             }
121             
122             return eVert >= mesh.nPoints();
123         }
124         bool isEdge(const label eVert) const
125         {
126             return isEdge(mesh_, eVert);
127         }
129         //- convert eVert to edge label
130         static label getEdge(const primitiveMesh& mesh, const label eVert)
131         {
132             if (!isEdge(mesh, eVert))
133             {
134                 FatalErrorIn
135                 (
136                     "edgeVertex::getEdge(const primitiveMesh&, const label)"
137                 )   << "EdgeVertex " << eVert << " not an edge"
138                     << abort(FatalError);
139             }
140             return eVert - mesh.nPoints();
141         }
142         label getEdge(const label eVert) const
143         {
144             return getEdge(mesh_, eVert);
145         }
147         //- convert eVert to vertex label
148         static label getVertex(const primitiveMesh& mesh, const label eVert)
149         {
150             if (isEdge(mesh, eVert) || (eVert < 0))
151             {
152                 FatalErrorIn
153                 (
154                     "edgeVertex::getVertex(const primitiveMesh&, const label)"
155                 )   << "EdgeVertex " << eVert << " not a vertex"
156                     << abort(FatalError);
157             }            
158             return eVert;
159         }
160         label getVertex(const label eVert) const
161         {
162             return getVertex(mesh_, eVert);
163         }
165         //- Convert pointI to eVert
166         static label vertToEVert(const primitiveMesh& mesh, const label vertI)
167         {
168             if ((vertI < 0) || (vertI >= mesh.nPoints()))
169             {
170                 FatalErrorIn
171                 (
172                     "edgeVertex::vertToEVert(const primitiveMesh&, const label)"
173                 )   << "Illegal vertex number " << vertI
174                     << abort(FatalError);
175             }
176             return vertI;
177         }
178         label vertToEVert(const label vertI) const
179         {
180             return vertToEVert(mesh_, vertI);
181         }
183         //- Convert edgeI to eVert
184         static label edgeToEVert(const primitiveMesh& mesh, const label edgeI)
185         {
186             if ((edgeI < 0) || (edgeI >= mesh.nEdges()))
187             {
188                 FatalErrorIn
189                 (
190                     "edgeVertex::edgeToEVert(const primitiveMesh&const label)"
191                 )   << "Illegal edge number " << edgeI
192                     << abort(FatalError);
193             }
194             return mesh.nPoints() + edgeI;
195         }
196         label edgeToEVert(const label edgeI) const
197         {
198             return edgeToEVert(mesh_, edgeI);
199         }
201         //- Return coordinate of cut (uses weight if edgeCut)
202         static point coord
203         (
204             const primitiveMesh&,
205             const label cut,
206             const scalar weight
207         );
208         point coord(const label cut, const scalar weight) const
209         {
210             return coord(mesh_, cut, weight);
211         }
213         //- Find mesh edge (or -1) between two cuts. 
214         static label cutPairToEdge
215         (
216             const primitiveMesh&,
217             const label cut0,
218             const label cut1
219         );
220         label cutPairToEdge(const label cut0, const label cut1) const
221         {
222             return cutPairToEdge(mesh_, cut0, cut1);
223         }
225         //- Write cut description to Ostream
226         Ostream& writeCut(Ostream& os, const label cut, const scalar) const;
228         //- Write cut descriptions to Ostream
229         Ostream& writeCuts(Ostream& os, const labelList&, const scalarField&)
230          const;
234 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
236 } // End namespace Foam
238 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
240 #endif
242 // ************************************************************************* //