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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::edgeVertex
28 
29 Description
30  Combines edge or vertex in single label. Used to specify cuts across
31  cell circumference.
32 
33 SourceFiles
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef edgeVertex_H
38 #define edgeVertex_H
39 
40 #include "label.H"
41 #include "polyMesh.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 // Forward declaration of classes
49 class refineCell;
50 
51 /*---------------------------------------------------------------------------*\
52  Class edgeVertex Declaration
53 \*---------------------------------------------------------------------------*/
54 
55 class edgeVertex
56 {
57  // Private data
58 
59  //- Reference to mesh. (could be primitive mesh but keeping polyMesh
60  // here saves storing reference at higher levels where we do need it)
61  const polyMesh& mesh_;
62 
63  // Private Member Functions
64 
65  //- No copy construct
66  edgeVertex(const edgeVertex&) = delete;
67 
68  //- No copy assignment
69  void operator=(const edgeVertex&) = delete;
70 
71 
72 public:
73 
74  // Static Functions
75 
76  //- Update refine list from map. Used to update cell/face labels
77  // after morphing
78  static void updateLabels(const labelList& map, List<refineCell>&);
79 
80  //- Update map from map. Used to update cell/face labels
81  // after morphing
82  static void updateLabels(const labelList& map, Map<label>&);
83 
84  //- Update map from map. Used to update cell/face labels
85  // after morphing
86  static void updateLabels(const labelList& map, labelHashSet&);
87 
88 
89 
90  // Constructors
91 
92  //- Construct from mesh
93  edgeVertex(const polyMesh& mesh)
94  :
95  mesh_(mesh)
96  {}
97 
98 
99  // Member Functions
100 
101  const polyMesh& mesh() const
102  {
103  return mesh_;
104  }
105 
106 
107  // EdgeVertex handling
108 
109  //- Is eVert an edge?
110  static bool isEdge(const primitiveMesh& mesh, const label eVert)
111  {
112  if (eVert < 0 || eVert >= (mesh.nPoints() + mesh.nEdges()))
113  {
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  << "EdgeVertex " << eVert << " not an edge"
135  << abort(FatalError);
136  }
137  return eVert - mesh.nPoints();
138  }
139  label getEdge(const label eVert) const
140  {
141  return getEdge(mesh_, eVert);
142  }
143 
144  //- Convert eVert to vertex label
145  static label getVertex(const primitiveMesh& mesh, const label eVert)
146  {
147  if (isEdge(mesh, eVert) || (eVert < 0))
148  {
150  << "EdgeVertex " << eVert << " not a vertex"
151  << abort(FatalError);
152  }
153  return eVert;
154  }
155  label getVertex(const label eVert) const
156  {
157  return getVertex(mesh_, eVert);
158  }
159 
160  //- Convert pointi to eVert
161  static label vertToEVert(const primitiveMesh& mesh, const label vertI)
162  {
163  if ((vertI < 0) || (vertI >= mesh.nPoints()))
164  {
166  << "Illegal vertex number " << vertI
167  << abort(FatalError);
168  }
169  return vertI;
170  }
171  label vertToEVert(const label vertI) const
172  {
173  return vertToEVert(mesh_, vertI);
174  }
175 
176  //- Convert edgeI to eVert
177  static label edgeToEVert(const primitiveMesh& mesh, const label edgeI)
178  {
179  if ((edgeI < 0) || (edgeI >= mesh.nEdges()))
180  {
182  << "Illegal edge number " << edgeI
183  << abort(FatalError);
184  }
185  return mesh.nPoints() + edgeI;
186  }
187  label edgeToEVert(const label edgeI) const
188  {
189  return edgeToEVert(mesh_, edgeI);
190  }
191 
192  //- Return coordinate of cut (uses weight if edgeCut)
193  static point coord
194  (
195  const primitiveMesh&,
196  const label cut,
197  const scalar weight
198  );
199  point coord(const label cut, const scalar weight) const
200  {
201  return coord(mesh_, cut, weight);
202  }
203 
204  //- Find mesh edge (or -1) between two cuts.
205  static label cutPairToEdge
206  (
207  const primitiveMesh&,
208  const label cut0,
209  const label cut1
210  );
211  label cutPairToEdge(const label cut0, const label cut1) const
212  {
213  return cutPairToEdge(mesh_, cut0, cut1);
214  }
215 
216  //- Write cut description to Ostream
217  Ostream& writeCut(Ostream& os, const label cut, const scalar) const;
218 
219  //- Write cut descriptions to Ostream
220  Ostream& writeCuts(Ostream& os, const labelList&, const scalarField&)
221  const;
222 };
223 
224 
225 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
226 
227 } // End namespace Foam
228 
229 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
230 
231 #endif
232 
233 // ************************************************************************* //
Foam::edgeVertex::writeCut
Ostream & writeCut(Ostream &os, const label cut, const scalar) const
Write cut description to Ostream.
Definition: edgeVertex.C:216
Foam::edgeVertex::updateLabels
static void updateLabels(const labelList &map, List< refineCell > &)
Update refine list from map. Used to update cell/face labels.
Definition: edgeVertex.C:38
Foam::edgeVertex::isEdge
static bool isEdge(const primitiveMesh &mesh, const label eVert)
Is eVert an edge?
Definition: edgeVertex.H:109
Foam::edgeVertex::getEdge
label getEdge(const label eVert) const
Definition: edgeVertex.H:138
Foam::edgeVertex::coord
point coord(const label cut, const scalar weight) const
Definition: edgeVertex.H:198
Foam::primitiveMesh::nEdges
label nEdges() const
Number of mesh edges.
Definition: primitiveMeshI.H:67
Foam::edgeVertex
Combines edge or vertex in single label. Used to specify cuts across cell circumference.
Definition: edgeVertex.H:54
Foam::Map< label >
polyMesh.H
Foam::HashSet< label, Hash< label > >
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::edgeVertex::getVertex
label getVertex(const label eVert) const
Definition: edgeVertex.H:154
Foam::edgeVertex::edgeToEVert
static label edgeToEVert(const primitiveMesh &mesh, const label edgeI)
Convert edgeI to eVert.
Definition: edgeVertex.H:176
Foam::label
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:62
Foam::Field< scalar >
Foam::edgeVertex::vertToEVert
label vertToEVert(const label vertI) const
Definition: edgeVertex.H:170
Foam::edgeVertex::cutPairToEdge
label cutPairToEdge(const label cut0, const label cut1) const
Definition: edgeVertex.H:210
Foam::edgeVertex::coord
static point coord(const primitiveMesh &, const label cut, const scalar weight)
Return coordinate of cut (uses weight if edgeCut)
Definition: edgeVertex.C:171
Foam::edgeVertex::getVertex
static label getVertex(const primitiveMesh &mesh, const label eVert)
Convert eVert to vertex label.
Definition: edgeVertex.H:144
cut
Patchify triangles based on orientation w.r.t other (triangulated or triangulatable) surfaces.
Foam::FatalError
error FatalError
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:137
Foam::edgeVertex::isEdge
bool isEdge(const label eVert) const
Definition: edgeVertex.H:122
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:355
Foam::Vector< scalar >
label.H
Foam::edgeVertex::cutPairToEdge
static label cutPairToEdge(const primitiveMesh &, const label cut0, const label cut1)
Find mesh edge (or -1) between two cuts.
Definition: edgeVertex.C:193
Foam::List< label >
Foam::primitiveMesh::nPoints
label nPoints() const
Number of mesh points.
Definition: primitiveMeshI.H:37
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::point
vector point
Point is a vector.
Definition: point.H:43
Foam::edgeVertex::writeCuts
Ostream & writeCuts(Ostream &os, const labelList &, const scalarField &) const
Write cut descriptions to Ostream.
Definition: edgeVertex.C:241
Foam::edgeVertex::edgeVertex
edgeVertex(const polyMesh &mesh)
Construct from mesh.
Definition: edgeVertex.H:92
Foam::edgeVertex::getEdge
static label getEdge(const primitiveMesh &mesh, const label eVert)
Convert eVert to edge label.
Definition: edgeVertex.H:128
Foam::edgeVertex::edgeToEVert
label edgeToEVert(const label edgeI) const
Definition: edgeVertex.H:186
Foam::edgeVertex::vertToEVert
static label vertToEVert(const primitiveMesh &mesh, const label vertI)
Convert pointi to eVert.
Definition: edgeVertex.H:160
Foam::edgeVertex::mesh
const polyMesh & mesh() const
Definition: edgeVertex.H:100
Foam::primitiveMesh
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:78