fvBoundaryMesh.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) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2018-2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 "fvBoundaryMesh.H"
30 #include "fvMesh.H"
31 
32 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
33 
34 void Foam::fvBoundaryMesh::addPatches(const polyBoundaryMesh& basicBdry)
35 {
36  setSize(basicBdry.size());
37 
38  // Set boundary patches
39  fvPatchList& Patches = *this;
40 
41  forAll(Patches, patchi)
42  {
43  Patches.set(patchi, fvPatch::New(basicBdry[patchi], *this));
44  }
45 }
46 
47 
48 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
49 
50 Foam::fvBoundaryMesh::fvBoundaryMesh
51 (
52  const fvMesh& m
53 )
54 :
55  fvPatchList(),
56  mesh_(m)
57 {}
58 
59 
60 Foam::fvBoundaryMesh::fvBoundaryMesh
61 (
62  const fvMesh& m,
63  const polyBoundaryMesh& basicBdry
64 )
65 :
66  fvPatchList(basicBdry.size()),
67  mesh_(m)
68 {
69  addPatches(basicBdry);
70 }
71 
72 
73 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
74 
76 (
77  const wordRe& matcher,
78  const bool useGroups
79 ) const
80 {
81  return mesh().boundaryMesh().indices(matcher, useGroups);
82 }
83 
84 
86 (
87  const wordRes& matcher,
88  const bool useGroups
89 ) const
90 {
91  return mesh().boundaryMesh().indices(matcher, useGroups);
92 }
93 
94 
95 Foam::label Foam::fvBoundaryMesh::findPatchID(const word& patchName) const
96 {
97  if (patchName.empty())
98  {
99  return -1;
100  }
101 
102  const fvPatchList& patches = *this;
103 
104  forAll(patches, patchi)
105  {
106  if (patches[patchi].name() == patchName)
107  {
108  return patchi;
109  }
110  }
111 
112  // Not found, return -1
113  return -1;
114 }
115 
116 
118 {
119  fvPatchList& patches = *this;
120 
121  for (fvPatch& p : patches)
122  {
123  p.initMovePoints();
124  }
125 
126  for (fvPatch& p : patches)
127  {
128  p.movePoints();
129  }
130 }
131 
132 
135 {
136  const fvPatchList& patches = *this;
137 
138  UPtrList<const labelUList> list(patches.size());
139 
140  forAll(list, patchi)
141  {
142  list.set(patchi, &patches[patchi].faceCells());
143  }
144 
145  return list;
146 }
147 
148 
150 {
151  const fvPatchList& patches = *this;
152 
153  lduInterfacePtrsList list(patches.size());
154 
155  forAll(list, patchi)
156  {
157  const lduInterface* lduPtr = isA<lduInterface>(patches[patchi]);
158 
159  if (lduPtr)
160  {
161  list.set(patchi, lduPtr);
162  }
163  }
164 
165  return list;
166 }
167 
168 
169 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
170 
172 {
173  clear();
174  addPatches(basicBdry);
175 }
176 
177 
178 // * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
179 
180 const Foam::fvPatch& Foam::fvBoundaryMesh::operator[]
181 (
182  const word& patchName
183 ) const
184 {
185  const label patchi = findPatchID(patchName);
186 
187  if (patchi < 0)
188  {
190  << "Patch named " << patchName << " not found." << nl
191  << abort(FatalError);
192  }
193 
194  return operator[](patchi);
195 }
196 
197 
198 Foam::fvPatch& Foam::fvBoundaryMesh::operator[]
199 (
200  const word& patchName
201 )
202 {
203  const label patchi = findPatchID(patchName);
204 
205  if (patchi < 0)
206  {
208  << "Patch named " << patchName << " not found." << nl
209  << abort(FatalError);
210  }
211 
212  return operator[](patchi);
213 }
214 
215 
216 // ************************************************************************* //
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::polyBoundaryMesh
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
Definition: polyBoundaryMesh.H:63
Foam::fvBoundaryMesh::indices
labelList indices(const wordRe &matcher, const bool useGroups) const
Return (sorted) patch indices for all matches.
Definition: fvBoundaryMesh.C:76
Foam::lduInterface
An abstract base class for implicitly-coupled interfaces e.g. processor and cyclic patches.
Definition: lduInterface.H:54
Foam::fvBoundaryMesh::findPatchID
label findPatchID(const word &patchName) const
Find patch index given a name.
Definition: fvBoundaryMesh.C:95
Foam::fvPatch::New
static autoPtr< fvPatch > New(const polyPatch &, const fvBoundaryMesh &)
Return a pointer to a new patch created on freestore from polyPatch.
Definition: fvPatchNew.C:35
Foam::fvBoundaryMesh::readUpdate
void readUpdate(const polyBoundaryMesh &)
Update boundary based on new polyBoundaryMesh.
Definition: fvBoundaryMesh.C:171
Foam::polyMesh::boundaryMesh
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:444
Foam::wordRe
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
Definition: wordRe.H:80
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::fvPatchList
PtrList< fvPatch > fvPatchList
container classes for fvPatch
Definition: fvPatchList.H:47
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
Foam::PtrList::setSize
void setSize(const label newLen)
Same as resize()
Definition: PtrList.H:151
Foam::fvBoundaryMesh::interfaces
lduInterfacePtrsList interfaces() const
Definition: fvBoundaryMesh.C:149
Foam::UPtrList
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: UPtrList.H:62
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:59
fvBoundaryMesh.H
Foam::FatalError
error FatalError
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
fvMesh.H
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:144
Foam::fvBoundaryMesh::faceCells
UPtrList< const labelUList > faceCells() const
Return a list of faceCells for each patch.
Definition: fvBoundaryMesh.C:134
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
clear
patchWriters clear()
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::polyBoundaryMesh::indices
labelList indices(const wordRe &matcher, const bool useGroups=true) const
Return (sorted) patch indices for all matches.
Definition: polyBoundaryMesh.C:642
Foam::List< label >
Foam::wordRes
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:51
patches
const polyBoundaryMesh & patches
Definition: convertProcessorPatches.H:65
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::faceCells
Smooth ATC in cells next to a set of patches supplied by type.
Definition: faceCells.H:56
Foam::fvBoundaryMesh::movePoints
void movePoints()
Correct patches after moving points.
Definition: fvBoundaryMesh.C:117