edgeVertex.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 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  << "EdgeVertex " << eVert << " out of range "
114  << mesh.nPoints() << " to "
115  << (mesh.nPoints() + mesh.nEdges() - 1)
116  << abort(FatalError);
117  }
118 
119  return eVert >= mesh.nPoints();
120  }
121  bool isEdge(const label eVert) const
122  {
123  return isEdge(mesh_, eVert);
124  }
125 
126  //- Convert eVert to edge label
127  static label getEdge(const primitiveMesh& mesh, const label eVert)
128  {
129  if (!isEdge(mesh, eVert))
130  {
132  << "EdgeVertex " << eVert << " not an edge"
133  << abort(FatalError);
134  }
135  return eVert - mesh.nPoints();
136  }
137  label getEdge(const label eVert) const
138  {
139  return getEdge(mesh_, eVert);
140  }
141 
142  //- Convert eVert to vertex label
143  static label getVertex(const primitiveMesh& mesh, const label eVert)
144  {
145  if (isEdge(mesh, eVert) || (eVert < 0))
146  {
148  << "EdgeVertex " << eVert << " not a vertex"
149  << abort(FatalError);
150  }
151  return eVert;
152  }
153  label getVertex(const label eVert) const
154  {
155  return getVertex(mesh_, eVert);
156  }
157 
158  //- Convert pointi to eVert
159  static label vertToEVert(const primitiveMesh& mesh, const label vertI)
160  {
161  if ((vertI < 0) || (vertI >= mesh.nPoints()))
162  {
164  << "Illegal vertex number " << vertI
165  << abort(FatalError);
166  }
167  return vertI;
168  }
169  label vertToEVert(const label vertI) const
170  {
171  return vertToEVert(mesh_, vertI);
172  }
173 
174  //- Convert edgeI to eVert
175  static label edgeToEVert(const primitiveMesh& mesh, const label edgeI)
176  {
177  if ((edgeI < 0) || (edgeI >= mesh.nEdges()))
178  {
180  << "Illegal edge number " << edgeI
181  << abort(FatalError);
182  }
183  return mesh.nPoints() + edgeI;
184  }
185  label edgeToEVert(const label edgeI) const
186  {
187  return edgeToEVert(mesh_, edgeI);
188  }
189 
190  //- Return coordinate of cut (uses weight if edgeCut)
191  static point coord
192  (
193  const primitiveMesh&,
194  const label cut,
195  const scalar weight
196  );
197  point coord(const label cut, const scalar weight) const
198  {
199  return coord(mesh_, cut, weight);
200  }
201 
202  //- Find mesh edge (or -1) between two cuts.
203  static label cutPairToEdge
204  (
205  const primitiveMesh&,
206  const label cut0,
207  const label cut1
208  );
209  label cutPairToEdge(const label cut0, const label cut1) const
210  {
211  return cutPairToEdge(mesh_, cut0, cut1);
212  }
213 
214  //- Write cut description to Ostream
215  Ostream& writeCut(Ostream& os, const label cut, const scalar) const;
216 
217  //- Write cut descriptions to Ostream
218  Ostream& writeCuts(Ostream& os, const labelList&, const scalarField&)
219  const;
220 };
221 
222 
223 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
224 
225 } // End namespace Foam
226 
227 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
228 
229 #endif
230 
231 // ************************************************************************* //
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
error FatalError
static label cutPairToEdge(const primitiveMesh &, const label cut0, const label cut1)
Find mesh edge (or -1) between two cuts.
Definition: edgeVertex.C:191
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:74
Ostream & writeCut(Ostream &os, const label cut, const scalar) const
Write cut description to Ostream.
Definition: edgeVertex.C:214
Ostream & writeCuts(Ostream &os, const labelList &, const scalarField &) const
Write cut descriptions to Ostream.
Definition: edgeVertex.C:239
static label edgeToEVert(const primitiveMesh &mesh, const label edgeI)
Convert edgeI to eVert.
Definition: edgeVertex.H:174
static void updateLabels(const labelList &map, List< refineCell > &)
Update refine list from map. Used to update cell/face labels.
Definition: edgeVertex.C:36
static label vertToEVert(const primitiveMesh &mesh, const label vertI)
Convert pointi to eVert.
Definition: edgeVertex.H:158
Combines edge or vertex in single label. Used to specify cuts across cell circumference.
Definition: edgeVertex.H:52
static label getVertex(const primitiveMesh &mesh, const label eVert)
Convert eVert to vertex label.
Definition: edgeVertex.H:142
static label getEdge(const primitiveMesh &mesh, const label eVert)
Convert eVert to edge label.
Definition: edgeVertex.H:126
errorManip< error > abort(error &err)
Definition: errorManip.H:131
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
static bool isEdge(const primitiveMesh &mesh, const label eVert)
Is eVert an edge?
Definition: edgeVertex.H:107
label nEdges() const
label nPoints() const
static point coord(const primitiveMesh &, const label cut, const scalar weight)
Return coordinate of cut (uses weight if edgeCut)
Definition: edgeVertex.C:169
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Namespace for OpenFOAM.