1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
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
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
29 Combines edge or vertex in single label. Used to specify cuts across
34 \*---------------------------------------------------------------------------*/
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 // Forward declaration of classes
50 /*---------------------------------------------------------------------------*\
51 Class edgeVertex Declaration
52 \*---------------------------------------------------------------------------*/
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&);
75 //- Update refine list from map. Used to update cell/face labels
77 static void updateLabels(const labelList& map, List<refineCell>&);
79 //- Update map from map. Used to update cell/face labels
81 static void updateLabels(const labelList& map, Map<label>&);
83 //- Update map from map. Used to update cell/face labels
85 static void updateLabels(const labelList& map, labelHashSet&);
91 //- Construct from mesh
92 edgeVertex(const polyMesh& mesh)
100 const polyMesh& mesh() const
106 // EdgeVertex handling
108 //- is eVert an edge?
109 static bool isEdge(const primitiveMesh& mesh, const label eVert)
111 if (eVert < 0 || eVert >= (mesh.nPoints() + mesh.nEdges()))
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);
122 return eVert >= mesh.nPoints();
124 bool isEdge(const label eVert) const
126 return isEdge(mesh_, eVert);
129 //- convert eVert to edge label
130 static label getEdge(const primitiveMesh& mesh, const label eVert)
132 if (!isEdge(mesh, eVert))
136 "edgeVertex::getEdge(const primitiveMesh&, const label)"
137 ) << "EdgeVertex " << eVert << " not an edge"
138 << abort(FatalError);
140 return eVert - mesh.nPoints();
142 label getEdge(const label eVert) const
144 return getEdge(mesh_, eVert);
147 //- convert eVert to vertex label
148 static label getVertex(const primitiveMesh& mesh, const label eVert)
150 if (isEdge(mesh, eVert) || (eVert < 0))
154 "edgeVertex::getVertex(const primitiveMesh&, const label)"
155 ) << "EdgeVertex " << eVert << " not a vertex"
156 << abort(FatalError);
160 label getVertex(const label eVert) const
162 return getVertex(mesh_, eVert);
165 //- Convert pointI to eVert
166 static label vertToEVert(const primitiveMesh& mesh, const label vertI)
168 if ((vertI < 0) || (vertI >= mesh.nPoints()))
172 "edgeVertex::vertToEVert(const primitiveMesh&, const label)"
173 ) << "Illegal vertex number " << vertI
174 << abort(FatalError);
178 label vertToEVert(const label vertI) const
180 return vertToEVert(mesh_, vertI);
183 //- Convert edgeI to eVert
184 static label edgeToEVert(const primitiveMesh& mesh, const label edgeI)
186 if ((edgeI < 0) || (edgeI >= mesh.nEdges()))
190 "edgeVertex::edgeToEVert(const primitiveMesh&const label)"
191 ) << "Illegal edge number " << edgeI
192 << abort(FatalError);
194 return mesh.nPoints() + edgeI;
196 label edgeToEVert(const label edgeI) const
198 return edgeToEVert(mesh_, edgeI);
201 //- Return coordinate of cut (uses weight if edgeCut)
204 const primitiveMesh&,
208 point coord(const label cut, const scalar weight) const
210 return coord(mesh_, cut, weight);
213 //- Find mesh edge (or -1) between two cuts.
214 static label cutPairToEdge
216 const primitiveMesh&,
220 label cutPairToEdge(const label cut0, const label cut1) const
222 return cutPairToEdge(mesh_, cut0, cut1);
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&)
234 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
236 } // End namespace Foam
238 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
242 // ************************************************************************* //