Loading...
Searching...
No Matches
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-2025 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 "fvBoundaryMesh.H"
30#include "fvMesh.H"
31#include "PtrListOps.H"
32
33// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
34
35void 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
55:
57 mesh_(m)
58{}
59
60
62(
63 const fvMesh& m,
65)
66:
68 mesh_(m)
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& allow,
99 const wordRes& deny,
100 const bool useGroups
101) const
102{
103 return mesh().boundaryMesh().indices(allow, deny, useGroups);
104}
105
106
107Foam::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
117const Foam::fvPatch*
118Foam::fvBoundaryMesh::cfindPatch(const word& patchName) const
119{
120 const fvPatchList& patches = *this;
121
122 if (!patchName.empty())
123 {
124 // Note: get() handles out-of-range access properly
126 }
127
128 return nullptr;
129}
130
131
133{
134 fvPatchList& patches = *this;
135
136 for (fvPatch& p : patches)
137 {
138 p.initMovePoints();
139 }
140
141 for (fvPatch& p : patches)
143 p.movePoints();
144 }
145}
146
147
150{
151 const fvPatchList& patches = *this;
152
153 UPtrList<const labelUList> list(patches.size());
154
155 forAll(list, patchi)
156 {
157 list.set(patchi, &patches[patchi].faceCells());
158 }
159
160 return list;
161}
162
163
165{
166 const fvPatchList& patches = *this;
167
168 lduInterfacePtrsList list(patches.size());
169
170 forAll(list, patchi)
171 {
172 const lduInterface* lduPtr = isA<lduInterface>(patches[patchi]);
173
174 if (lduPtr)
175 {
176 list.set(patchi, lduPtr);
177 }
178 }
180 return list;
181}
182
183
184// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
185
188 addPatches(pbm);
189}
190
191
192// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
193
194const Foam::fvPatch& Foam::fvBoundaryMesh::operator[]
195(
196 const word& patchName
197) const
198{
199 const label patchi = findPatchID(patchName);
200
201 if (patchi < 0)
202 {
204 << "Patch named " << patchName << " not found." << nl
206 }
207
208 return operator[](patchi);
209}
210
211
212Foam::fvPatch& Foam::fvBoundaryMesh::operator[]
213(
214 const word& patchName
215)
216{
217 const label patchi = findPatchID(patchName);
218
219 if (patchi < 0)
220 {
222 << "Patch named " << patchName << " not found." << nl
223 << abort(FatalError);
224 }
225
226 return operator[](patchi);
227}
228
229
230// ************************************************************************* //
Functions to operate on Pointer Lists.
const polyBoundaryMesh & pbm
void resize_null(const label newLen)
Set the addressed list to the given size, deleting all existing entries. Afterwards the list contains...
Definition PtrListI.H:113
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition UPtrList.H:101
const T * set(const label i) const
Return const pointer to element (can be nullptr), or nullptr for out-of-range access (ie,...
Definition UPtrList.H:366
const fvPatch & operator[](const word &patchName) const
Return const reference to fvPatch by name.
lduInterfacePtrsList interfaces() const
Return a list of pointers for each patch with only those pointing to interfaces being set.
UPtrList< const labelUList > faceCells() const
Return a list of faceCells for each patch.
friend class fvMesh
Declare friendship with fvMesh.
void movePoints()
Correct patches after moving points.
void readUpdate(const polyBoundaryMesh &)
Update boundary based on new polyBoundaryMesh.
labelList indices(const wordRe &matcher, const bool useGroups) const
The (sorted) patch indices for all matches, optionally matching patch groups.
const fvPatch * cfindPatch(const word &patchName) const
Find patch by name and return const pointer.
label findPatchID(const word &patchName) const
Find patch index given a name.
fvBoundaryMesh(const fvBoundaryMesh &)=delete
No copy construct.
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition fvPatch.H:71
static autoPtr< fvPatch > New(const polyPatch &, const fvBoundaryMesh &)
Return a pointer to a new patch created on freestore from polyPatch.
Definition fvPatchNew.C:28
An abstract base class for implicitly-coupled interfaces e.g. processor and cyclic patches.
A polyBoundaryMesh is a polyPatch list with registered IO, a reference to the associated polyMesh,...
labelList indices(const wordRe &matcher, const bool useGroups=true) const
The (sorted) patch indices for all matches, optionally matching patch groups.
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
Definition polyMesh.H:609
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
Definition wordRe.H:81
A List of wordRe with additional matching capabilities.
Definition wordRes.H:56
A class for handling words, derived from Foam::string.
Definition word.H:66
volScalarField & p
const polyBoundaryMesh & patches
dynamicFvMesh & mesh
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
label firstMatching(const UPtrList< T > &list, const UnaryMatchPredicate &matcher)
Find first list item with 'name()' that matches, -1 on failure.
PtrList< fvPatch > fvPatchList
Store lists of fvPatch as a PtrList.
Definition fvPatch.H:64
List< label > labelList
A List of labels.
Definition List.H:62
UPtrList< const lduInterface > lduInterfacePtrsList
Store lists of lduInterface as a UPtrList.
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
Definition typeInfo.H:87
errorManip< error > abort(error &err)
Definition errorManip.H:139
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299