helperFunctionsTopologyManipulation.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | cfMesh: A library for mesh generation
4  \\ / O peration |
5  \\ / A nd | Author: Franjo Juretic (franjo.juretic@c-fields.com)
6  \\/ M anipulation | Copyright (C) Creative Fields, Ltd.
7 -------------------------------------------------------------------------------
8 License
9  This file is part of cfMesh.
10 
11  cfMesh is free software; you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by the
13  Free Software Foundation; either version 3 of the License, or (at your
14  option) any later version.
15 
16  cfMesh 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 cfMesh. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  helperFunctions
26 
27 Description
28  Topology modifiers and queries useful for mesh generation
29 
30 SourceFiles
31 
32 \*---------------------------------------------------------------------------*/
33 
34 #ifndef helperFunctionsTopologyManipulation_H
35 #define helperFunctionsTopologyManipulation_H
36 
37 #include "DynList.H"
38 #include "face.H"
39 #include "boolList.H"
40 #include "HashSet.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 
47 /*---------------------------------------------------------------------------*\
48  Namespace help functions Declaration
49 \*---------------------------------------------------------------------------*/
50 
51 namespace help
52 {
53  //- check if the faces are equal
54  template<class faceType1, class faceType2>
55  bool areFacesEqual(const faceType1& f1, const faceType2& f2);
56 
57  //- local position of element in a list
58  template<class T, class ListType>
59  label positionInList(const T& elmt, const ListType& l);
60 
61  //- reverse the face
62  template<class faceType>
63  faceType reverseFace(const faceType& f);
64 
65  //- returns a merged face
66  template<class faceType1, class faceType2>
67  inline face mergeTwoFaces
68  (
69  const faceType1& f1,
70  const faceType2& f2
71  );
72 
73  //- remove edges until faces share only one edge
74  inline edgeList modifyFacesToShareOneEdge(face& f1, face& f2);
75 
76  //- create a face from the removed part
77  inline face createFaceFromRemovedPart(const face& fOrig, const face& fCut);
78 
79  //- remove edges from face
80  inline face removeEdgesFromFace
81  (
82  const face& fOrig,
83  const DynList<edge>& removeEdges
84  );
85 
86  //- find open edges for a set of faces forming a cell
87  inline void findOpenEdges
88  (
89  const faceList& cellFaces,
90  DynList<edge>& openEdges
91  );
92 
93  //- check if two faces share an edge
94  template<class faceType1, class faceType2>
95  inline bool shareAnEdge(const faceType1& f1, const faceType2& f2);
96 
97  //- return the edge shared by the faces
98  template<class faceType1, class faceType2>
99  inline edge sharedEdge(const faceType1& f1, const faceType2& f2);
100 
101  //- return the position of edge in the face, -1 otherwise
102  template<class faceType>
103  inline label positionOfEdgeInFace(const edge& e, const faceType& f);
104 
105  //- check if two faces share a vertex
106  template<class faceType1, class faceType2>
107  inline bool shareAVertex(const faceType1& f1, const faceType2& f2);
108 
109  //- shared vertex of two faces
110  template<class faceType1, class faceType2>
111  inline label sharedVertex(const faceType1& f1, const faceType2& f2);
112 
113  //- find a vertex label common to all faces in the list
114  template<class faceListType>
115  inline label sharedVertex(const faceListType& fcs);
116 
117  //- check if selected elements are in one singly-connected chain
118  template<class boolListType>
119  inline bool areElementsInChain(const boolListType& sel);
120 
121  //- sort the edge chain such that the end of one edge is the beginning
122  //- of the next one (valid for singly-connected chains, only)
123  inline labelList sortEdgeChain(const DynList<edge>& bEdges);
124 
125  //- creates closed edge chains from the open chain
126  inline void zipOpenChain(DynList<edge>& bEdges);
127 
128 } // End namespace help
129 
130 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
131 
132 } // End namespace Foam
133 
134 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
135 
137 
138 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
139 
140 #endif
141 
142 // ************************************************************************* //
Foam::help::sharedEdge
edge sharedEdge(const faceType1 &f1, const faceType2 &f2)
return the edge shared by the faces
Definition: helperFunctionsTopologyManipulationI.H:343
Foam::help::positionInList
label positionInList(const T &elmt, const ListType &l)
local position of element in a list
Definition: helperFunctionsTopologyManipulationI.H:103
boolList.H
Foam::edgeList
List< edge > edgeList
Definition: edgeList.H:38
Foam::labelList
List< label > labelList
A List of labels.
Definition: labelList.H:56
Foam::help::areFacesEqual
bool areFacesEqual(const faceType1 &f1, const faceType2 &f2)
check if the faces are equal
Definition: helperFunctionsTopologyManipulationI.H:46
DynList
A dynamic list is a 1-D vector of objects of type T which resizes itself as necessary to accept the n...
face.H
Foam::help::sortEdgeChain
labelList sortEdgeChain(const DynList< edge > &bEdges)
Definition: helperFunctionsTopologyManipulationI.H:524
Foam::help::shareAVertex
bool shareAVertex(const faceType1 &f1, const faceType2 &f2)
check if two faces share a vertex
Definition: helperFunctionsTopologyManipulationI.H:387
Foam::help::createFaceFromRemovedPart
face createFaceFromRemovedPart(const face &fOrig, const face &fCut)
create a face from the removed part
Definition: helperFunctionsTopologyManipulationI.H:219
helperFunctionsTopologyManipulationI.H
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:59
Foam::help::modifyFacesToShareOneEdge
edgeList modifyFacesToShareOneEdge(face &f1, face &f2)
remove edges until faces share only one edge
Definition: helperFunctionsTopologyManipulationI.H:175
Foam::T
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
Definition: FieldFieldFunctions.C:55
f1
scalar f1
Definition: createFields.H:28
Foam::help::removeEdgesFromFace
face removeEdgesFromFace(const face &fOrig, const DynList< edge > &removeEdges)
remove edges from face
Definition: helperFunctionsTopologyManipulationI.H:252
Foam::help::sharedVertex
label sharedVertex(const faceType1 &f1, const faceType2 &f2)
shared vertex of two faces
Definition: helperFunctionsTopologyManipulationI.H:376
Foam::help::mergeTwoFaces
face mergeTwoFaces(const faceType1 &f1, const faceType2 &f2)
returns a merged face
Definition: helperFunctionsTopologyManipulationI.H:128
HashSet.H
Foam::help::areElementsInChain
bool areElementsInChain(const boolListType &sel)
check if selected elements are in one singly-connected chain
Definition: helperFunctionsTopologyManipulationI.H:426
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::e
const double e
Elementary charge.
Definition: doubleFloat.H:94
Foam::help::zipOpenChain
void zipOpenChain(DynList< edge > &bEdges)
creates closed edge chains from the open chain
Definition: helperFunctionsTopologyManipulationI.H:466
f
labelList f(nPoints)
Foam::faceList
List< face > faceList
Definition: faceListFwd.H:43
Foam::help::findOpenEdges
void findOpenEdges(const faceList &cellFaces, DynList< edge > &openEdges)
find open edges for a set of faces forming a cell
Definition: helperFunctionsTopologyManipulationI.H:279
Foam::help::reverseFace
faceType reverseFace(const faceType &f)
reverse the face
Definition: helperFunctionsTopologyManipulationI.H:113
Foam::help::positionOfEdgeInFace
label positionOfEdgeInFace(const edge &e, const faceType &f)
return the position of edge in the face, -1 otherwise
Definition: helperFunctionsTopologyManipulationI.H:362
DynList.H
Foam::help::shareAnEdge
bool shareAnEdge(const faceType1 &f1, const faceType2 &f2)
check if two faces share an edge
Definition: helperFunctionsTopologyManipulationI.H:324