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  edgeVertex.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef edgeVertex_H
39 #define edgeVertex_H
40 
41 #include "label.H"
42 #include "polyMesh.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 // Forward Declarations
50 class refineCell;
51 
52 /*---------------------------------------------------------------------------*\
53  Class edgeVertex Declaration
54 \*---------------------------------------------------------------------------*/
55 
56 class edgeVertex
57 {
58  // Private Data
59 
60  //- Reference to mesh. (could be primitive mesh but keeping polyMesh
61  // here saves storing reference at higher levels where we do need it)
62  const polyMesh& mesh_;
63 
64  // Private Member Functions
65 
66  //- No copy construct
67  edgeVertex(const edgeVertex&) = delete;
68 
69  //- No copy assignment
70  void operator=(const edgeVertex&) = delete;
71 
72 
73 public:
74 
75  // Static Functions
76 
77  //- Update refine list from map. Used to update cell/face labels
78  // after morphing
79  static void updateLabels(const labelList& map, List<refineCell>&);
80 
81  //- Update map from map. Used to update cell/face labels
82  // after morphing
83  static void updateLabels(const labelList& map, Map<label>&);
84 
85  //- Update map from map. Used to update cell/face labels
86  // after morphing
87  static void updateLabels(const labelList& map, labelHashSet&);
88 
89 
90 
91  // Constructors
92 
93  //- Construct from mesh
94  explicit edgeVertex(const polyMesh& mesh)
95  :
96  mesh_(mesh)
97  {}
98 
99 
100  // Member Functions
101 
102  const polyMesh& mesh() const
103  {
104  return mesh_;
105  }
106 
107 
108  // EdgeVertex handling
109 
110  //- Is eVert an edge?
111  static bool isEdge(const primitiveMesh& mesh, const label eVert)
112  {
113  if (eVert < 0 || eVert >= (mesh.nPoints() + mesh.nEdges()))
114  {
116  << "EdgeVertex " << eVert << " out of range "
117  << mesh.nPoints() << " to "
118  << (mesh.nPoints() + mesh.nEdges() - 1)
119  << abort(FatalError);
120  }
121 
122  return eVert >= mesh.nPoints();
123  }
124  bool isEdge(const label eVert) const
125  {
126  return isEdge(mesh_, eVert);
127  }
128 
129  //- Convert eVert to edge label
130  static label getEdge(const primitiveMesh& mesh, const label eVert)
131  {
132  if (!isEdge(mesh, eVert))
133  {
135  << "EdgeVertex " << eVert << " not an edge"
136  << abort(FatalError);
137  }
138  return eVert - mesh.nPoints();
139  }
140  label getEdge(const label eVert) const
141  {
142  return getEdge(mesh_, eVert);
143  }
144 
145  //- Convert eVert to vertex label
146  static label getVertex(const primitiveMesh& mesh, const label eVert)
147  {
148  if (isEdge(mesh, eVert) || (eVert < 0))
149  {
151  << "EdgeVertex " << eVert << " not a vertex"
152  << abort(FatalError);
153  }
154  return eVert;
155  }
156  label getVertex(const label eVert) const
157  {
158  return getVertex(mesh_, eVert);
159  }
160 
161  //- Convert pointi to eVert
162  static label vertToEVert(const primitiveMesh& mesh, const label vertI)
163  {
164  if ((vertI < 0) || (vertI >= mesh.nPoints()))
165  {
167  << "Illegal vertex number " << vertI
168  << abort(FatalError);
169  }
170  return vertI;
171  }
172  label vertToEVert(const label vertI) const
173  {
174  return vertToEVert(mesh_, vertI);
175  }
176 
177  //- Convert edgeI to eVert
178  static label edgeToEVert(const primitiveMesh& mesh, const label edgeI)
179  {
180  if ((edgeI < 0) || (edgeI >= mesh.nEdges()))
181  {
183  << "Illegal edge number " << edgeI
184  << abort(FatalError);
185  }
186  return mesh.nPoints() + edgeI;
187  }
188  label edgeToEVert(const label edgeI) const
189  {
190  return edgeToEVert(mesh_, edgeI);
191  }
192 
193  //- Return coordinate of cut (uses weight if edgeCut)
194  static point coord
195  (
196  const primitiveMesh&,
197  const label cut,
198  const scalar weight
199  );
200  point coord(const label cut, const scalar weight) const
201  {
202  return coord(mesh_, cut, weight);
203  }
204 
205  //- Find mesh edge (or -1) between two cuts.
206  static label cutPairToEdge
207  (
208  const primitiveMesh&,
209  const label cut0,
210  const label cut1
211  );
212  label cutPairToEdge(const label cut0, const label cut1) const
213  {
214  return cutPairToEdge(mesh_, cut0, cut1);
215  }
216 
217  //- Write cut description to Ostream
218  Ostream& writeCut(Ostream& os, const label cut, const scalar) const;
219 
220  //- Write cut descriptions to Ostream
221  Ostream& writeCuts(Ostream& os, const labelList&, const scalarField&)
222  const;
223 };
224 
225 
226 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
227 
228 } // End namespace Foam
229 
230 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
231 
232 #endif
233 
234 // ************************************************************************* //
Foam::edgeVertex::writeCut
Ostream & writeCut(Ostream &os, const label cut, const scalar) const
Write cut description to Ostream.
Definition: edgeVertex.C:215
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:37
Foam::edgeVertex::isEdge
static bool isEdge(const primitiveMesh &mesh, const label eVert)
Is eVert an edge?
Definition: edgeVertex.H:110
Foam::edgeVertex::getEdge
label getEdge(const label eVert) const
Definition: edgeVertex.H:139
Foam::edgeVertex::coord
point coord(const label cut, const scalar weight) const
Definition: edgeVertex.H:199
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:55
Foam::Map< label >
polyMesh.H
Foam::HashSet< label, Hash< label > >
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::primitiveMesh::nPoints
label nPoints() const noexcept
Number of mesh points.
Definition: primitiveMeshI.H:37
Foam::edgeVertex::getVertex
label getVertex(const label eVert) const
Definition: edgeVertex.H:155
Foam::edgeVertex::edgeToEVert
static label edgeToEVert(const primitiveMesh &mesh, const label edgeI)
Convert edgeI to eVert.
Definition: edgeVertex.H:177
Foam::Field< scalar >
Foam::edgeVertex::vertToEVert
label vertToEVert(const label vertI) const
Definition: edgeVertex.H:171
Foam::edgeVertex::cutPairToEdge
label cutPairToEdge(const label cut0, const label cut1) const
Definition: edgeVertex.H:211
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:170
Foam::edgeVertex::getVertex
static label getVertex(const primitiveMesh &mesh, const label eVert)
Convert eVert to vertex label.
Definition: edgeVertex.H:145
cut
Patchify triangles based on orientation w.r.t other (triangulated or triangulatable) surfaces.
Foam::FatalError
error FatalError
os
OBJstream os(runTime.globalPath()/outputName)
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
Foam::edgeVertex::isEdge
bool isEdge(const label eVert) const
Definition: edgeVertex.H:123
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
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:192
Foam::List< label >
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:240
Foam::edgeVertex::edgeVertex
edgeVertex(const polyMesh &mesh)
Construct from mesh.
Definition: edgeVertex.H:93
Foam::edgeVertex::getEdge
static label getEdge(const primitiveMesh &mesh, const label eVert)
Convert eVert to edge label.
Definition: edgeVertex.H:129
Foam::edgeVertex::edgeToEVert
label edgeToEVert(const label edgeI) const
Definition: edgeVertex.H:187
Foam::edgeVertex::vertToEVert
static label vertToEVert(const primitiveMesh &mesh, const label vertI)
Convert pointi to eVert.
Definition: edgeVertex.H:161
Foam::edgeVertex::mesh
const polyMesh & mesh() const
Definition: edgeVertex.H:101
Foam::primitiveMesh
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:78