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-2023 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 
62 public:
63 
64  // Static Functions
65 
66  //- Update refine list from map. Used to update cell/face labels
67  // after morphing
68  static void updateLabels(const labelList& map, List<refineCell>&);
69 
70  //- Update map from map. Used to update cell/face labels
71  // after morphing
72  static void updateLabels(const labelList& map, Map<label>&);
73 
74  //- Update map from map. Used to update cell/face labels
75  // after morphing
76  static void updateLabels(const labelList& map, labelHashSet&);
77 
78 
79 
80  // Constructors
81 
82  //- Construct from mesh
83  edgeVertex(const polyMesh& mesh)
84  :
85  mesh_(mesh)
86  {}
87 
88  //- Disallow default bitwise copy construction
89  edgeVertex(const edgeVertex&) = delete;
90 
91 
92  // Member Functions
93 
94  const polyMesh& mesh() const
95  {
96  return mesh_;
97  }
98 
99 
100  // EdgeVertex handling
101 
102  //- Is eVert an edge?
103  static bool isEdge(const primitiveMesh& mesh, const label eVert)
104  {
105  if (eVert < 0 || eVert >= (mesh.nPoints() + mesh.nEdges()))
106  {
108  << "EdgeVertex " << eVert << " out of range "
109  << mesh.nPoints() << " to "
110  << (mesh.nPoints() + mesh.nEdges() - 1)
111  << abort(FatalError);
112  }
113 
114  return eVert >= mesh.nPoints();
115  }
116  bool isEdge(const label eVert) const
117  {
118  return isEdge(mesh_, eVert);
119  }
120 
121  //- Convert eVert to edge label
122  static label getEdge(const primitiveMesh& mesh, const label eVert)
123  {
124  if (!isEdge(mesh, eVert))
125  {
127  << "EdgeVertex " << eVert << " not an edge"
128  << abort(FatalError);
129  }
130  return eVert - mesh.nPoints();
131  }
132  label getEdge(const label eVert) const
133  {
134  return getEdge(mesh_, eVert);
135  }
136 
137  //- Convert eVert to vertex label
138  static label getVertex(const primitiveMesh& mesh, const label eVert)
139  {
140  if (isEdge(mesh, eVert) || (eVert < 0))
141  {
143  << "EdgeVertex " << eVert << " not a vertex"
144  << abort(FatalError);
145  }
146  return eVert;
147  }
148  label getVertex(const label eVert) const
149  {
150  return getVertex(mesh_, eVert);
151  }
152 
153  //- Convert pointi to eVert
154  static label vertToEVert(const primitiveMesh& mesh, const label vertI)
155  {
156  if ((vertI < 0) || (vertI >= mesh.nPoints()))
157  {
159  << "Illegal vertex number " << vertI
160  << abort(FatalError);
161  }
162  return vertI;
163  }
164  label vertToEVert(const label vertI) const
165  {
166  return vertToEVert(mesh_, vertI);
167  }
168 
169  //- Convert edgeI to eVert
170  static label edgeToEVert(const primitiveMesh& mesh, const label edgeI)
171  {
172  if ((edgeI < 0) || (edgeI >= mesh.nEdges()))
173  {
175  << "Illegal edge number " << edgeI
176  << abort(FatalError);
177  }
178  return mesh.nPoints() + edgeI;
179  }
180  label edgeToEVert(const label edgeI) const
181  {
182  return edgeToEVert(mesh_, edgeI);
183  }
184 
185  //- Return coordinate of cut (uses weight if edgeCut)
186  static point coord
187  (
188  const primitiveMesh&,
189  const label cut,
190  const scalar weight
191  );
192  point coord(const label cut, const scalar weight) const
193  {
194  return coord(mesh_, cut, weight);
195  }
196 
197  //- Find mesh edge (or -1) between two cuts.
198  static label cutPairToEdge
199  (
200  const primitiveMesh&,
201  const label cut0,
202  const label cut1
203  );
204  label cutPairToEdge(const label cut0, const label cut1) const
205  {
206  return cutPairToEdge(mesh_, cut0, cut1);
207  }
208 
209  //- Write cut description to Ostream
210  Ostream& writeCut(Ostream& os, const label cut, const scalar) const;
211 
212  //- Write cut descriptions to Ostream
214  (
215  Ostream& os,
216  const labelList&,
217  const scalarField&
218  ) const;
219 
220 
221  // Member Operators
222 
223  //- Disallow default bitwise assignment
224  void operator=(const edgeVertex&) = delete;
225 };
226 
227 
228 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
229 
230 } // End namespace Foam
231 
232 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
233 
234 #endif
235 
236 // ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Combines edge or vertex in single label. Used to specify cuts across cell circumference.
Definition: edgeVertex.H:53
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:169
static point coord(const primitiveMesh &, const label cut, const scalar weight)
Return coordinate of cut (uses weight if edgeCut)
Definition: edgeVertex.C:169
static bool isEdge(const primitiveMesh &mesh, const label eVert)
Is eVert an edge?
Definition: edgeVertex.H:102
static label vertToEVert(const primitiveMesh &mesh, const label vertI)
Convert pointi to eVert.
Definition: edgeVertex.H:153
static label getEdge(const primitiveMesh &mesh, const label eVert)
Convert eVert to edge label.
Definition: edgeVertex.H:121
edgeVertex(const polyMesh &mesh)
Construct from mesh.
Definition: edgeVertex.H:82
static void updateLabels(const labelList &map, List< refineCell > &)
Update refine list from map. Used to update cell/face labels.
Definition: edgeVertex.C:36
void operator=(const edgeVertex &)=delete
Disallow default bitwise assignment.
Ostream & writeCut(Ostream &os, const label cut, const scalar) const
Write cut description to Ostream.
Definition: edgeVertex.C:214
static label cutPairToEdge(const primitiveMesh &, const label cut0, const label cut1)
Find mesh edge (or -1) between two cuts.
Definition: edgeVertex.C:191
const polyMesh & mesh() const
Definition: edgeVertex.H:93
static label getVertex(const primitiveMesh &mesh, const label eVert)
Convert eVert to vertex label.
Definition: edgeVertex.H:137
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:75
label nEdges() const
label nPoints() const
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
Namespace for OpenFOAM.
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
errorManip< error > abort(error &err)
Definition: errorManip.H:131
vector point
Point is a vector.
Definition: point.H:41
error FatalError