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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2014 OpenFOAM Foundation
9 Copyright (C) 2020 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29#include "autoPatch.H"
31#include "surfaceFeatures.H"
32#include "triSurfaceMesh.H"
33#include "PatchTools.H"
34
35// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36
37namespace Foam
38{
39namespace searchableSurfaceModifiers
40{
43 (
44 searchableSurfaceModifier,
46 dictionary
47 );
48}
49}
50
51// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
52
54(
55 const searchableSurfaces& geometry,
56 const dictionary& dict
57)
58:
59 searchableSurfaceModifier(geometry, dict),
60 featureAngle_(dict.get<scalar>("featureAngle"))
61{}
62
63
64// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
65
67(
68 const labelList& regions,
69 searchableSurface& geom
70) const
71{
72 triSurface& surf = refCast<triSurfaceMesh>(geom);
73
74 surfaceFeatures set(surf, 180.0-featureAngle_);
75
76 Info<< nl
77 << "Feature set:" << nl
78 << " feature points : " << set.featurePoints().size() << nl
79 << " feature edges : " << set.featureEdges().size() << nl
80 << " of which" << nl
81 << " region edges : " << set.nRegionEdges() << nl
82 << " external edges : " << set.nExternalEdges() << nl
83 << " internal edges : " << set.nInternalEdges() << nl
84 << endl;
85
86
87 // Get per-edge status.
88 boolList borderEdge(surf.nEdges(), false);
89 forAll(set.featureEdges(), i)
90 {
91 borderEdge[set.featureEdges()[i]] = true;
92 }
93
94
95 bool changed = false;
96
97 forAll(regions, i)
98 {
99 label regionI = regions[i];
100
101 labelList subRegion(surf.size(), -1);
102 label nSub = 0;
103
104 forAll(surf, faceI)
105 {
106 if (surf[faceI].region() == regionI && subRegion[faceI] == -1)
107 {
108 PatchTools::markZone(surf, borderEdge, faceI, nSub, subRegion);
109 nSub++;
110 }
111 }
112
113 Info<< "For region " << surf.patches()[regionI].name()
114 << " detected sub regions " << nSub << endl;
115
116
117 if (nSub > 1)
118 {
119 label nOldPatches = surf.patches().size();
120
121 for (label subI = 0; subI < nSub; subI++)
122 {
123 geometricSurfacePatch patch
124 (
125 surf.patches()[regionI].name() + Foam::name(subI),
126 surf.patches().size(),
127 surf.patches()[regionI].geometricType()
128 );
129
130
131 Info<< "For region " << surf.patches()[regionI].name()
132 << " creating region " << patch.name() << endl;
133
134 surf.patches().append(patch);
135 }
136
137 forAll(subRegion, faceI)
138 {
139 if (subRegion[faceI] != -1)
140 {
141 surf[faceI].region() = nOldPatches + subRegion[faceI];
142 }
143 }
144 changed = true;
145 }
146 }
147
148 return changed;
149}
150
151
152// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
static void markZone(const PrimitivePatch< FaceList, PointField > &, const BoolListType &borderEdge, const label facei, const label currentZone, labelList &faceZone)
Fill faceZone with currentZone for every face reachable.
Patchify triangles based on a feature angle. Replacement of surfaceAutoPatch.
virtual bool modify(const labelList &regions, searchableSurface &) const
Apply this selector.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
void set(List< bool > &bools, const labelUList &locations)
Set the listed locations (assign 'true').
Definition: BitOps.C:38
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
const std::string patch
OpenFOAM patch number as a std::string.
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition: List.H:66
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
List< bool > boolList
A List of bools.
Definition: List.H:64
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333