1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
28 Combines edge or vertex in single label. Used to specify cuts across
33 \*---------------------------------------------------------------------------*/
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 // Forward declaration of classes
49 /*---------------------------------------------------------------------------*\
50 Class edgeVertex Declaration
51 \*---------------------------------------------------------------------------*/
57 //- Reference to mesh. (could be primitive mesh but keeping polyMesh
58 // here saves storing reference at higher levels where we do need it)
59 const polyMesh& mesh_;
61 // Private Member Functions
63 //- Disallow default bitwise copy construct
64 edgeVertex(const edgeVertex&);
66 //- Disallow default bitwise assignment
67 void operator=(const edgeVertex&);
74 //- Update refine list from map. Used to update cell/face labels
76 static void updateLabels(const labelList& map, List<refineCell>&);
78 //- Update map from map. Used to update cell/face labels
80 static void updateLabels(const labelList& map, Map<label>&);
82 //- Update map from map. Used to update cell/face labels
84 static void updateLabels(const labelList& map, labelHashSet&);
90 //- Construct from mesh
91 edgeVertex(const polyMesh& mesh)
99 const polyMesh& mesh() const
105 // EdgeVertex handling
107 //- is eVert an edge?
108 static bool isEdge(const primitiveMesh& mesh, const label eVert)
110 if (eVert < 0 || eVert >= (mesh.nPoints() + mesh.nEdges()))
114 "edgeVertex::isEdge(const primitiveMesh&, const label)"
115 ) << "EdgeVertex " << eVert << " out of range "
116 << mesh.nPoints() << " to "
117 << (mesh.nPoints() + mesh.nEdges() - 1)
118 << abort(FatalError);
121 return eVert >= mesh.nPoints();
123 bool isEdge(const label eVert) const
125 return isEdge(mesh_, eVert);
128 //- convert eVert to edge label
129 static label getEdge(const primitiveMesh& mesh, const label eVert)
131 if (!isEdge(mesh, eVert))
135 "edgeVertex::getEdge(const primitiveMesh&, const label)"
136 ) << "EdgeVertex " << eVert << " not an edge"
137 << abort(FatalError);
139 return eVert - mesh.nPoints();
141 label getEdge(const label eVert) const
143 return getEdge(mesh_, eVert);
146 //- convert eVert to vertex label
147 static label getVertex(const primitiveMesh& mesh, const label eVert)
149 if (isEdge(mesh, eVert) || (eVert < 0))
153 "edgeVertex::getVertex(const primitiveMesh&, const label)"
154 ) << "EdgeVertex " << eVert << " not a vertex"
155 << abort(FatalError);
159 label getVertex(const label eVert) const
161 return getVertex(mesh_, eVert);
164 //- Convert pointI to eVert
165 static label vertToEVert(const primitiveMesh& mesh, const label vertI)
167 if ((vertI < 0) || (vertI >= mesh.nPoints()))
171 "edgeVertex::vertToEVert(const primitiveMesh&, const label)"
172 ) << "Illegal vertex number " << vertI
173 << abort(FatalError);
177 label vertToEVert(const label vertI) const
179 return vertToEVert(mesh_, vertI);
182 //- Convert edgeI to eVert
183 static label edgeToEVert(const primitiveMesh& mesh, const label edgeI)
185 if ((edgeI < 0) || (edgeI >= mesh.nEdges()))
189 "edgeVertex::edgeToEVert(const primitiveMesh&const label)"
190 ) << "Illegal edge number " << edgeI
191 << abort(FatalError);
193 return mesh.nPoints() + edgeI;
195 label edgeToEVert(const label edgeI) const
197 return edgeToEVert(mesh_, edgeI);
200 //- Return coordinate of cut (uses weight if edgeCut)
203 const primitiveMesh&,
207 point coord(const label cut, const scalar weight) const
209 return coord(mesh_, cut, weight);
212 //- Find mesh edge (or -1) between two cuts.
213 static label cutPairToEdge
215 const primitiveMesh&,
219 label cutPairToEdge(const label cut0, const label cut1) const
221 return cutPairToEdge(mesh_, cut0, cut1);
224 //- Write cut description to Ostream
225 Ostream& writeCut(Ostream& os, const label cut, const scalar) const;
227 //- Write cut descriptions to Ostream
228 Ostream& writeCuts(Ostream& os, const labelList&, const scalarField&)
233 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
235 } // End namespace Foam
237 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
241 // ************************************************************************* //