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-2023 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& pbm)
36 {
37  // Set boundary patches
38  fvPatchList& patches = *this;
39 
40  patches.resize_null(pbm.size());
41 
42  forAll(patches, patchi)
43  {
44  patches.set(patchi, fvPatch::New(pbm[patchi], *this));
45  }
46 }
47 
48 
49 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50 
52 (
53  const fvMesh& m
54 )
55 :
56  fvPatchList(),
57  mesh_(m)
58 {}
59 
60 
62 (
63  const fvMesh& m,
64  const polyBoundaryMesh& pbm
65 )
66 :
67  fvPatchList(),
68  mesh_(m)
69 {
70  addPatches(pbm);
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 
97 (
98  const wordRes& select,
99  const wordRes& ignore,
100  const bool useGroups
101 ) const
102 {
103  return mesh().boundaryMesh().indices(select, ignore, useGroups);
104 }
105 
106 
107 Foam::label Foam::fvBoundaryMesh::findPatchID(const word& patchName) const
108 {
109  if (patchName.empty())
110  {
111  return -1;
112  }
113  return PtrListOps::firstMatching(*this, patchName);
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 
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  }
165  return list;
166 }
167 
168 
169 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
170 
172 {
173  addPatches(pbm);
174 }
175 
176 
177 // * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
178 
180 (
181  const word& patchName
182 ) const
183 {
184  const label patchi = findPatchID(patchName);
185 
186  if (patchi < 0)
187  {
189  << "Patch named " << patchName << " not found." << nl
190  << abort(FatalError);
191  }
192 
193  return operator[](patchi);
194 }
195 
196 
198 (
199  const word& patchName
200 )
201 {
202  const label patchi = findPatchID(patchName);
203 
204  if (patchi < 0)
205  {
207  << "Patch named " << patchName << " not found." << nl
208  << abort(FatalError);
209  }
210 
211  return operator[](patchi);
212 }
213 
214 
215 // ************************************************************************* //
const polyBoundaryMesh & pbm
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:598
label findPatchID(const word &patchName) const
Find patch index given a name.
List< bool > select(const label n, const labelUList &locations)
Construct a selection list of bools (all false) with the given pre-size, subsequently add specified l...
Definition: BitOps.C:134
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
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:421
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
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
Definition: polyMesh.H:608
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:106
UPtrList< const lduInterface > lduInterfacePtrsList
Store lists of lduInterface as a UPtrList.
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:53
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:106
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...
fvBoundaryMesh(const fvBoundaryMesh &)=delete
No copy construct.
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:78
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
label firstMatching(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
Find first list item with &#39;name()&#39; that matches, -1 on failure.