boundaryInfo.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) 2015 OpenFOAM Foundation
9 Copyright (C) 2018 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 "boundaryInfo.H"
30#include "Time.H"
31#include "polyMesh.H"
32#include "processorPolyPatch.H"
33
34// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35
36namespace Foam
37{
38 defineTemplateTypeNameAndDebug(IOPtrList<entry>, 0);
39}
40
41// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
42
43Foam::IOPtrList<Foam::entry> Foam::boundaryInfo::readBoundaryDict
44(
45 const Time& runTime,
46 const word& regionName
47) const
48{
49 Info<< " Reading mesh boundaries" << endl;
50
52 IOPtrList<entry> boundaryPatchList
53 (
54 IOobject
55 (
56 "boundary",
59 runTime,
62 false
63 )
64 );
65
66 // remove zero-sized patches
67 PtrList<entry> boundaryPatchListNew;
68 forAll(boundaryPatchList, patchI)
69 {
70 const dictionary& dict = boundaryPatchList[patchI].dict();
71 const word pType = dict.get<word>("type");
72 bool procPatch = pType == processorPolyPatch::typeName;
73
74 bool addPatch = true;
75 if (!procPatch)
76 {
77 label nFaces = dict.get<label>("nFaces");
78 reduce(nFaces, sumOp<label>());
79 if (nFaces == 0)
80 {
81 addPatch = false;
82 }
83 }
84
85 if (addPatch)
86 {
87 boundaryPatchListNew.append(boundaryPatchList[patchI].clone());
88 }
89 }
90
91 boundaryPatchList.transfer(boundaryPatchListNew);
92
93 return boundaryPatchList;
94}
95
96
97// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
98
100:
101 boundaryDict_(readBoundaryDict(runTime, regionName)),
102 names_(),
103 types_(),
104 constraint_(),
105 groups_(),
106 allGroupNames_()
107{
108 names_.setSize(boundaryDict_.size());
109 types_.setSize(boundaryDict_.size());
110 constraint_.setSize(boundaryDict_.size(), false);
111 groups_.setSize(boundaryDict_.size());
112
113 forAll(boundaryDict_, patchI)
114 {
115 const dictionary& dict = boundaryDict_[patchI].dict();
116
117 names_[patchI] = dict.dictName();
118 dict.readEntry("type", types_[patchI]);
119 if (polyPatch::constraintType(types_[patchI]))
120 {
121 constraint_[patchI] = true;
122 }
123
124 if (dict.readIfPresent("inGroups", groups_[patchI]))
125 {
126 allGroupNames_.insert(groups_[patchI]);
127 }
128 }
129}
130
131
132// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
133
135{
136 return names_;
137}
138
139
141{
142 return types_;
143}
144
145
147{
148 return constraint_;
149}
150
151
153{
154 return groups_;
155}
156
157
159{
160 return allGroupNames_;
161}
162
163
164void Foam::boundaryInfo::setType(const label patchI, const word& condition)
165{
166 if (constraint_[patchI])
167 {
168 // not overriding constraint types
169 return;
170 }
171
172 if (regExp(".*[Mm]apped.*").match(types_[patchI]))
173 {
174 // ugly hack to avoid overriding mapped types
175 return;
176 }
177
178 if (condition == "wall")
179 {
180 types_[patchI] = condition;
181 }
182 else
183 {
184 types_[patchI] = "patch";
185 }
186
187 dictionary& patchDict = boundaryDict_[patchI].dict();
188 patchDict.add("type", types_[patchI], true);
189}
190
191
192void Foam::boundaryInfo::write() const
193{
194 boundaryDict_.write();
195}
196
197
198// ************************************************************************* //
A PtrList of objects of type <T> with automated input and output.
Definition: IOPtrList.H:57
word findInstance(const fileName &dir, const word &name=word::null, const IOobject::readOption rOpt=IOobject::MUST_READ, const word &stopInstance=word::null) const
Definition: Time.C:797
Class to interrogate the polyMesh/boundary file to provide mesh patching information,...
Definition: boundaryInfo.H:55
void write() const
Write the boundary dictionary.
const wordList & types() const
Patch types.
const List< wordList > & groups() const
Groups.
const wordList & names() const
Patch names.
const boolList & constraint() const
Constraint flag.
const wordHashSet & allGroupNames() const
Set of all group names.
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
Definition: polyMesh.H:324
virtual topoSetSource::sourceType setType() const
The source category is a cellSet.
#define defineTemplateTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information for templates, useful.
Definition: className.H:132
engineTime & runTime
Foam::word regionName(Foam::polyMesh::defaultRegion)
const labelList nFaces(UPstream::listGatherValues< label >(aMesh.nFaces()))
bool match(const UList< wordRe > &patterns, const std::string &text)
Return true if text matches one of the regular expressions.
Definition: stringOps.H:76
Namespace for OpenFOAM.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
regExpCxx regExp
Selection of preferred regular expression implementation.
Definition: regExpFwd.H:43
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333
static const char *const typeName
The type name used in ensight case files.