triSurfacePatchManipulatorFunctions.C
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 Description
25 
26 \*---------------------------------------------------------------------------*/
27 
29 #include "helperFunctions.H"
30 #include "demandDrivenData.H"
31 
32 # ifdef USE_OMP
33 #include <omp.h>
34 # endif
35 
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 
38 namespace Foam
39 {
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
44 {
45  const edgeLongList& edges = surf_.edges();
46  const VRWGraph& pEdges = surf_.pointEdges();
47 
48  //- allocate featureEdges list
49  featureEdges_.setSize(edges.size());
51 
52  const edgeLongList& featureEdges = surf_.featureEdges();
53 
54  forAll(featureEdges, feI)
55  {
56  const edge& e = featureEdges[feI];
57 
58  forAllRow(pEdges, e.start(), peI)
59  {
60  const label eI = pEdges(e.start(), peI);
61 
62  if( edges[eI] == e )
63  featureEdges_[eI] |= 1;
64  }
65  }
66 }
67 
69 {
70  nPatches_ = 0;
72  facetInPatch_ = -1;
73 
74  const VRWGraph& faceEdges = surf_.facetEdges();
75  const VRWGraph& edgeFaces = surf_.edgeFacets();
76 
77  forAll(facetInPatch_, triI)
78  {
79  if( facetInPatch_[triI] != -1 )
80  continue;
81 
82  labelLongList front;
83  front.append(triI);
84  facetInPatch_[triI] = nPatches_;
85 
86  while( front.size() )
87  {
88  const label fLabel = front.removeLastElement();
89 
90  const constRow fEdges = faceEdges[fLabel];
91 
92  forAll(fEdges, feI)
93  {
94  const label edgeI = fEdges[feI];
95 
96  //- check if th edges is marked as a feature edge
97  if( featureEdges_[edgeI] )
98  continue;
99 
100  const constRow eFaces = edgeFaces[edgeI];
101 
102  //- stop at non-manifold edges
103  if( eFaces.size() != 2 )
104  continue;
105 
106  label neiTri = eFaces[0];
107  if( neiTri == fLabel )
108  neiTri = eFaces[1];
109 
110  //- do not overwrite existing patch information
111  if( surf_[fLabel].region() != surf_[neiTri].region() )
112  continue;
113  if( facetInPatch_[neiTri] != -1 )
114  continue;
115 
116  facetInPatch_[neiTri] = nPatches_;
117  front.append(neiTri);
118  }
119  }
120 
121  ++nPatches_;
122  }
123 
124  Info << "Created " << nPatches_ << " surface patches" << endl;
125 }
126 
127 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
128 
129 } // End namespace Foam
130 
131 // ************************************************************************* //
Foam::LongList::append
void append(const T &e)
Append an element at the end of the list.
Definition: LongListI.H:265
Foam::triSurfacePatchManipulator::nPatches_
label nPatches_
number of patches
Definition: triSurfacePatchManipulator.H:65
triSurfacePatchManipulator.H
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
demandDrivenData.H
Template functions to aid in the implementation of demand driven data.
Foam::edge
An edge is a list of two point labels. The functionality it provides supports the discretisation on a...
Definition: edge.H:58
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::LongList::size
label size() const
Size of the active part of the list.
Definition: LongListI.H:203
Foam::triSurfFeatureEdges::featureEdges
const edgeLongList & featureEdges() const
access to feature edges
Definition: triSurfFeatureEdgesI.H:44
Foam::LongList< edge >
Foam::constRow
const typedef graphRow< const VRWGraph > constRow
Definition: graphRow.H:134
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::Info
messageStream Info
Foam::triSurfacePatchManipulator::featureEdges_
List< direction > featureEdges_
detected feature edges
Definition: triSurfacePatchManipulator.H:59
forAllRow
#define forAllRow(graph, rowI, index)
Definition: VRWGraph.H:277
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::triSurfacePatchManipulator::allocateFeatureEdges
void allocateFeatureEdges()
allocate and fill the feature edges list
Definition: triSurfacePatchManipulatorFunctions.C:43
Foam::e
const double e
Elementary charge.
Definition: doubleFloat.H:94
Foam::triSurfacePatchManipulator::facetInPatch_
labelList facetInPatch_
surface patches
Definition: triSurfacePatchManipulator.H:62
Foam::List::setSize
void setSize(const label)
Reset size of List.
helperFunctions.H
Foam::triSurfFacets::size
label size() const
return the number of triangles
Definition: triSurfFacetsI.H:39
Foam::triSurfAddressing::facetEdges
const VRWGraph & facetEdges() const
return facet-edges addressing
Definition: triSurfAddressingI.H:79
Foam::triSurfAddressing::edges
const LongList< edge > & edges() const
return edges
Definition: triSurfAddressingI.H:61
Foam::direction
unsigned char direction
Definition: direction.H:43
Foam::triSurfacePatchManipulator::createPatches
void createPatches()
create patches bounded by a set of feature edges
Definition: triSurfacePatchManipulatorFunctions.C:68
Foam::VRWGraph
Definition: VRWGraph.H:101
Foam::triSurfacePatchManipulator::surf_
const triSurf & surf_
const reference to triSurf
Definition: triSurfacePatchManipulator.H:56
Foam::LongList::removeLastElement
T removeLastElement()
Definition: LongListI.H:323
Foam::triSurfAddressing::edgeFacets
const VRWGraph & edgeFacets() const
return edge-facets addressing
Definition: triSurfAddressingI.H:97
Foam::triSurfAddressing::pointEdges
const VRWGraph & pointEdges() const
return point-edges addressing
Definition: triSurfAddressingI.H:115