edgeVertex.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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.
20 
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/>.
23 
24 Class
25  Foam::edgeVertex
26 
27 Description
28  Combines edge or vertex in single label. Used to specify cuts across
29  cell circumference.
30 
31 SourceFiles
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef edgeVertex_H
36 #define edgeVertex_H
37 
38 #include "label.H"
39 #include "polyMesh.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 // Forward declaration of classes
47 class refineCell;
48 
49 /*---------------------------------------------------------------------------*\
50  Class edgeVertex Declaration
51 \*---------------------------------------------------------------------------*/
52 
53 class edgeVertex
54 {
55  // Private data
56 
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_;
60 
61  // Private Member Functions
62 
63  //- Disallow default bitwise copy construct
64  edgeVertex(const edgeVertex&);
65 
66  //- Disallow default bitwise assignment
67  void operator=(const edgeVertex&);
68 
69 
70 public:
71 
72  // Static Functions
73 
74  //- Update refine list from map. Used to update cell/face labels
75  // after morphing
76  static void updateLabels(const labelList& map, List<refineCell>&);
77 
78  //- Update map from map. Used to update cell/face labels
79  // after morphing
80  static void updateLabels(const labelList& map, Map<label>&);
81 
82  //- Update map from map. Used to update cell/face labels
83  // after morphing
84  static void updateLabels(const labelList& map, labelHashSet&);
85 
86 
87 
88  // Constructors
89 
90  //- Construct from mesh
91  edgeVertex(const polyMesh& mesh)
92  :
93  mesh_(mesh)
94  {}
95 
96 
97  // Member Functions
98 
99  const polyMesh& mesh() const
100  {
101  return mesh_;
102  }
103 
104 
105  // EdgeVertex handling
106 
107  //- Is eVert an edge?
108  static bool isEdge(const primitiveMesh& mesh, const label eVert)
109  {
110  if (eVert < 0 || eVert >= (mesh.nPoints() + mesh.nEdges()))
111  {
113  (
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);
119  }
120 
121  return eVert >= mesh.nPoints();
122  }
123  bool isEdge(const label eVert) const
124  {
125  return isEdge(mesh_, eVert);
126  }
127 
128  //- Convert eVert to edge label
129  static label getEdge(const primitiveMesh& mesh, const label eVert)
130  {
131  if (!isEdge(mesh, eVert))
132  {
134  (
135  "edgeVertex::getEdge(const primitiveMesh&, const label)"
136  ) << "EdgeVertex " << eVert << " not an edge"
137  << abort(FatalError);
138  }
139  return eVert - mesh.nPoints();
140  }
141  label getEdge(const label eVert) const
142  {
143  return getEdge(mesh_, eVert);
144  }
145 
146  //- Convert eVert to vertex label
147  static label getVertex(const primitiveMesh& mesh, const label eVert)
148  {
149  if (isEdge(mesh, eVert) || (eVert < 0))
150  {
152  (
153  "edgeVertex::getVertex(const primitiveMesh&, const label)"
154  ) << "EdgeVertex " << eVert << " not a vertex"
155  << abort(FatalError);
156  }
157  return eVert;
158  }
159  label getVertex(const label eVert) const
160  {
161  return getVertex(mesh_, eVert);
162  }
163 
164  //- Convert pointI to eVert
165  static label vertToEVert(const primitiveMesh& mesh, const label vertI)
166  {
167  if ((vertI < 0) || (vertI >= mesh.nPoints()))
168  {
170  (
171  "edgeVertex::vertToEVert(const primitiveMesh&, const label)"
172  ) << "Illegal vertex number " << vertI
173  << abort(FatalError);
174  }
175  return vertI;
176  }
177  label vertToEVert(const label vertI) const
178  {
179  return vertToEVert(mesh_, vertI);
180  }
181 
182  //- Convert edgeI to eVert
183  static label edgeToEVert(const primitiveMesh& mesh, const label edgeI)
184  {
185  if ((edgeI < 0) || (edgeI >= mesh.nEdges()))
186  {
188  (
189  "edgeVertex::edgeToEVert(const primitiveMesh&const label)"
190  ) << "Illegal edge number " << edgeI
191  << abort(FatalError);
192  }
193  return mesh.nPoints() + edgeI;
194  }
195  label edgeToEVert(const label edgeI) const
196  {
197  return edgeToEVert(mesh_, edgeI);
198  }
199 
200  //- Return coordinate of cut (uses weight if edgeCut)
201  static point coord
202  (
203  const primitiveMesh&,
204  const label cut,
205  const scalar weight
206  );
207  point coord(const label cut, const scalar weight) const
208  {
209  return coord(mesh_, cut, weight);
210  }
211 
212  //- Find mesh edge (or -1) between two cuts.
213  static label cutPairToEdge
214  (
215  const primitiveMesh&,
216  const label cut0,
217  const label cut1
218  );
219  label cutPairToEdge(const label cut0, const label cut1) const
220  {
221  return cutPairToEdge(mesh_, cut0, cut1);
222  }
223 
224  //- Write cut description to Ostream
225  Ostream& writeCut(Ostream& os, const label cut, const scalar) const;
226 
227  //- Write cut descriptions to Ostream
228  Ostream& writeCuts(Ostream& os, const labelList&, const scalarField&)
229  const;
230 };
231 
232 
233 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
234 
235 } // End namespace Foam
236 
237 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
238 
239 #endif
240 
241 // ************************************************************************* //
static bool isEdge(const primitiveMesh &mesh, const label eVert)
Is eVert an edge?
Definition: edgeVertex.H:107
static label getEdge(const primitiveMesh &mesh, const label eVert)
Convert eVert to edge label.
Definition: edgeVertex.H:128
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
label nEdges() const
Namespace for OpenFOAM.
static label edgeToEVert(const primitiveMesh &mesh, const label edgeI)
Convert edgeI to eVert.
Definition: edgeVertex.H:182
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:74
Ostream & writeCuts(Ostream &os, const labelList &, const scalarField &) const
Write cut descriptions to Ostream.
Definition: edgeVertex.C:242
errorManip< error > abort(error &err)
Definition: errorManip.H:131
static void updateLabels(const labelList &map, List< refineCell > &)
Update refine list from map. Used to update cell/face labels.
Definition: edgeVertex.C:36
static point coord(const primitiveMesh &, const label cut, const scalar weight)
Return coordinate of cut (uses weight if edgeCut)
Definition: edgeVertex.C:172
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Ostream & writeCut(Ostream &os, const label cut, const scalar) const
Write cut description to Ostream.
Definition: edgeVertex.C:217
error FatalError
const polyMesh & mesh() const
Definition: edgeVertex.H:98
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
Combines edge or vertex in single label. Used to specify cuts across cell circumference.
Definition: edgeVertex.H:52
static label vertToEVert(const primitiveMesh &mesh, const label vertI)
Convert pointI to eVert.
Definition: edgeVertex.H:164
static label cutPairToEdge(const primitiveMesh &, const label cut0, const label cut1)
Find mesh edge (or -1) between two cuts.
Definition: edgeVertex.C:194
label nPoints() const
static label getVertex(const primitiveMesh &mesh, const label eVert)
Convert eVert to vertex label.
Definition: edgeVertex.H:146