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-------------------------------------------------------------------------------
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
32// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
33
34void 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
51(
52 const fvMesh& m
53)
54:
56 mesh_(m)
57{}
58
59
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
95Foam::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
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 }
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
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
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// ************************************************************************* //
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: PtrList.H:73
void setSize(const label newLen)
Same as resize()
Definition: PtrList.H:151
const labelUList & indices() const noexcept
Return the list of sorted indices (updated every sort).
Definition: SortListI.H:54
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
A list of pointers to objects of type <T>, without allocation/deallocation management of the pointers...
Definition: UPtrList.H:71
const T * set(const label i) const
Definition: UPtrList.H:248
label size() const noexcept
The number of elements in the list.
Definition: UPtrListI.H:106
friend Ostream & operator(Ostream &, const faMatrix< Type > &)
Smooth ATC in cells next to a set of patches supplied by type.
Definition: faceCells.H:59
Foam::fvBoundaryMesh.
lduInterfacePtrsList interfaces() const
UPtrList< const labelUList > faceCells() const
Return a list of faceCells for each patch.
void movePoints()
Correct patches after moving points.
label findPatchID(const word &patchName) const
Find patch index given a name.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
virtual readUpdateState readUpdate()
Update the mesh based on the mesh files saved in time.
Definition: fvMesh.C:675
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:71
An abstract base class for implicitly-coupled interfaces e.g. processor and cyclic patches.
Definition: lduInterface.H:58
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
labelList indices(const wordRe &matcher, const bool useGroups=true) const
Return (sorted) patch indices for all matches.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:456
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
Definition: wordRe.H:83
A List of wordRe with additional matching capabilities.
Definition: wordRes.H:54
A class for handling words, derived from Foam::string.
Definition: word.H:68
volScalarField & p
const polyBoundaryMesh & patches
patchWriters clear()
dynamicFvMesh & mesh
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
PtrList< fvPatch > fvPatchList
Store lists of fvPatch as a PtrList.
Definition: fvPatch.H:64
errorManip< error > abort(error &err)
Definition: errorManip.H:144
error FatalError
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333