autoPatch.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2014 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 \*---------------------------------------------------------------------------*/
25 
26 #include "autoPatch.H"
28 #include "surfaceFeatures.H"
29 #include "triSurfaceMesh.H"
30 #include "PatchTools.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 namespace searchableSurfaceModifiers
37 {
40  (
41  searchableSurfaceModifier,
42  autoPatch,
43  dictionary
44  );
45 }
46 }
47 
48 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
49 
51 (
52  const searchableSurfaces& geometry,
53  const dictionary& dict
54 )
55 :
56  searchableSurfaceModifier(geometry, dict),
57  featureAngle_(readScalar(dict.lookup("featureAngle")))
58 {}
59 
60 
61 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
62 
64 {}
65 
66 
67 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
68 
70 (
71  const labelList& regions,
72  searchableSurface& geom
73 ) const
74 {
75  triSurface& surf = refCast<triSurfaceMesh>(geom);
76 
77  surfaceFeatures set(surf, 180.0-featureAngle_);
78 
79  Info<< nl
80  << "Feature set:" << nl
81  << " feature points : " << set.featurePoints().size() << nl
82  << " feature edges : " << set.featureEdges().size() << nl
83  << " of which" << nl
84  << " region edges : " << set.nRegionEdges() << nl
85  << " external edges : " << set.nExternalEdges() << nl
86  << " internal edges : " << set.nInternalEdges() << nl
87  << endl;
88 
89 
90  // Get per-edge status.
91  boolList borderEdge(surf.nEdges(), false);
92  forAll(set.featureEdges(), i)
93  {
94  borderEdge[set.featureEdges()[i]] = true;
95  }
96 
97 
98  bool changed = false;
99 
100  forAll(regions, i)
101  {
102  label regionI = regions[i];
103 
104  labelList subRegion(surf.size(), -1);
105  label nSub = 0;
106 
107  forAll(surf, faceI)
108  {
109  if (surf[faceI].region() == regionI && subRegion[faceI] == -1)
110  {
111  PatchTools::markZone(surf, borderEdge, faceI, nSub, subRegion);
112  nSub++;
113  }
114  }
115 
116  Info<< "For region " << surf.patches()[regionI].name()
117  << " detected sub regions " << nSub << endl;
118 
119 
120  if (nSub > 1)
121  {
122  label nOldPatches = surf.patches().size();
123 
124  for (label subI = 0; subI < nSub; subI++)
125  {
126  geometricSurfacePatch patch
127  (
128  surf.patches()[regionI].geometricType(),
129  surf.patches()[regionI].name() + Foam::name(subI),
130  surf.patches().size()
131  );
132 
133 
134  Info<< "For region " << surf.patches()[regionI].name()
135  << " creating region " << patch.name() << endl;
136 
137  surf.patches().append(patch);
138  }
139 
140  forAll(subRegion, faceI)
141  {
142  if (subRegion[faceI] != -1)
143  {
144  surf[faceI].region() = nOldPatches + subRegion[faceI];
145  }
146  }
147  changed = true;
148  }
149  }
150 
151  return changed;
152 }
153 
154 
155 // ************************************************************************* //
Foam::labelList
List< label > labelList
A List of labels.
Definition: labelList.H:56
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
surfaceFeatures.H
autoPatch.H
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::searchableSurfaceModifiers::autoPatch::~autoPatch
virtual ~autoPatch()
Destructor.
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::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
Foam::PatchTools::markZone
static void markZone(const PrimitivePatch< Face, FaceList, PointField, PointType > &, const BoolListType &borderEdge, const label faceI, const label currentZone, labelList &faceZone)
Fill faceZone with currentZone for every face reachable.
Definition: PatchToolsSearch.C:46
dict
dictionary dict
Definition: searchingEngine.H:14
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::boolList
List< bool > boolList
Bool container classes.
Definition: boolList.H:50
autoPatch
Patchify triangles based on a feature angle. Replacement of surfaceAutoPatch.
readScalar
#define readScalar
Definition: doubleScalar.C:38
Foam::searchableSurfaceModifiers::autoPatch::modify
virtual bool modify(const labelList &regions, searchableSurface &) const
Apply this selector.
Foam::searchableSurfaceModifiers::autoPatch::autoPatch
autoPatch(const searchableSurfaces &, const dictionary &)
Construct from dictionary.
triSurfaceMesh.H
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
lookup
stressControl lookup("compactNormalStress") >> compactNormalStress