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 #include "PtrListOps.H"
32 
33 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
34 
35 void Foam::fvBoundaryMesh::addPatches(const polyBoundaryMesh& basicBdry)
36 {
37  setSize(basicBdry.size());
38 
39  // Set boundary patches
40  fvPatchList& Patches = *this;
41 
42  forAll(Patches, patchi)
43  {
44  Patches.set(patchi, fvPatch::New(basicBdry[patchi], *this));
45  }
46 }
47 
48 
49 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50 
51 Foam::fvBoundaryMesh::fvBoundaryMesh
52 (
53  const fvMesh& m
54 )
55 :
56  fvPatchList(),
57  mesh_(m)
58 {}
59 
60 
61 Foam::fvBoundaryMesh::fvBoundaryMesh
62 (
63  const fvMesh& m,
64  const polyBoundaryMesh& basicBdry
65 )
66 :
67  fvPatchList(basicBdry.size()),
68  mesh_(m)
69 {
70  addPatches(basicBdry);
71 }
72 
73 
74 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
75 
77 (
78  const wordRe& matcher,
79  const bool useGroups
80 ) const
81 {
82  return mesh().boundaryMesh().indices(matcher, useGroups);
83 }
84 
85 
87 (
88  const wordRes& matcher,
89  const bool useGroups
90 ) const
91 {
92  return mesh().boundaryMesh().indices(matcher, useGroups);
93 }
94 
95 
96 Foam::label Foam::fvBoundaryMesh::findPatchID(const word& patchName) const
97 {
98  if (patchName.empty())
99  {
100  return -1;
101  }
102 
103  // OR: return PtrListOps::firstMatching(*this, patchName);
104 
105  const fvPatchList& patches = *this;
106 
107  forAll(patches, patchi)
108  {
109  if (patches[patchi].name() == patchName)
110  {
111  return patchi;
112  }
113  }
114 
115  // Not found, return -1
116  return -1;
117 }
118 
119 
121 {
122  fvPatchList& patches = *this;
123 
124  for (fvPatch& p : patches)
125  {
126  p.initMovePoints();
127  }
128 
129  for (fvPatch& p : patches)
130  {
131  p.movePoints();
132  }
133 }
134 
135 
138 {
139  const fvPatchList& patches = *this;
140 
141  UPtrList<const labelUList> list(patches.size());
142 
143  forAll(list, patchi)
144  {
145  list.set(patchi, &patches[patchi].faceCells());
146  }
147 
148  return list;
149 }
150 
151 
153 {
154  const fvPatchList& patches = *this;
155 
157 
158  forAll(list, patchi)
159  {
160  const lduInterface* lduPtr = isA<lduInterface>(patches[patchi]);
161 
162  if (lduPtr)
163  {
164  list.set(patchi, lduPtr);
165  }
166  }
168  return list;
169 }
170 
171 
172 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
173 
175 {
176  clear();
177  addPatches(basicBdry);
178 }
179 
180 
181 // * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
182 
184 (
185  const word& patchName
186 ) const
187 {
188  const label patchi = findPatchID(patchName);
189 
190  if (patchi < 0)
191  {
193  << "Patch named " << patchName << " not found." << nl
194  << abort(FatalError);
195  }
196 
197  return operator[](patchi);
198 }
199 
200 
202 (
203  const word& patchName
204 )
205 {
206  const label patchi = findPatchID(patchName);
207 
208  if (patchi < 0)
209  {
211  << "Patch named " << patchName << " not found." << nl
212  << abort(FatalError);
213  }
214 
215  return operator[](patchi);
216 }
217 
218 
219 // ************************************************************************* //
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:578
label findPatchID(const word &patchName) const
Find patch index given a name.
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:49
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:70
Functions to operate on Pointer Lists.
Smooth ATC in cells next to a set of patches supplied by type.
Definition: faceCells.H:52
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:414
labelList indices(const wordRe &matcher, const bool useGroups=true) const
Return (sorted) patch indices for all matches.
void readUpdate(const polyBoundaryMesh &)
Update boundary based on new polyBoundaryMesh.
labelList indices(const wordRe &matcher, const bool useGroups) const
Return (sorted) patch indices for all matches.
dynamicFvMesh & mesh
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:52
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
Definition: polyMesh.H:584
A class for handling words, derived from Foam::string.
Definition: word.H:63
label size() const noexcept
The number of entries in the list.
Definition: UPtrListI.H:113
UPtrList< const lduInterface > lduInterfacePtrsList
Store lists of lduInterface as a UPtrList.
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:53
patchWriters clear()
friend Ostream & operator(Ostream &os, const UPtrList< T > &list)
Write UPtrList to Ostream.
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: HashTable.H:100
errorManip< error > abort(error &err)
Definition: errorManip.H:139
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings...
Definition: wordRe.H:78
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO...
UPtrList< const labelUList > faceCells() const
Return a list of faceCells for each patch.
lduInterfacePtrsList interfaces() const
Return a list of pointers for each patch with only those pointing to interfaces being set...
void setSize(const label newLen)
Same as resize()
Definition: PtrList.H:316
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Definition: List.H:55
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:79
const polyBoundaryMesh & patches
void movePoints()
Correct patches after moving points.
static autoPtr< fvPatch > New(const polyPatch &, const fvBoundaryMesh &)
Return a pointer to a new patch created on freestore from polyPatch.
Definition: fvPatchNew.C:28
volScalarField & p
PtrList< fvPatch > fvPatchList
Store lists of fvPatch as a PtrList.
Definition: fvPatch.H:59