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 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 
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 keyType& key,
79  const bool useGroups
80 ) const
81 {
82  return mesh().boundaryMesh().indices(key, useGroups);
83 }
84 
85 
87 {
88  const fvPatchList& patches = *this;
89 
90  forAll(patches, patchi)
91  {
92  if (patches[patchi].name() == patchName)
93  {
94  return patchi;
95  }
96  }
97 
98  // Not found, return -1
99  return -1;
100 }
101 
102 
104 {
105  fvPatchList& patches = *this;
106 
107  for (fvPatch& p : patches)
108  {
109  p.initMovePoints();
110  }
111 
112  for (fvPatch& p : patches)
113  {
114  p.movePoints();
115  }
116 }
117 
118 
120 {
121  lduInterfacePtrsList interfaces(size());
122 
123  forAll(interfaces, patchi)
124  {
125  if (isA<lduInterface>(this->operator[](patchi)))
126  {
127  interfaces.set
128  (
129  patchi,
130  &refCast<const lduInterface>(this->operator[](patchi))
131  );
132  }
133  }
134 
135  return interfaces;
136 }
137 
138 
139 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
140 
142 {
143  clear();
144  addPatches(basicBdry);
145 }
146 
147 
148 // * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
149 
150 const Foam::fvPatch& Foam::fvBoundaryMesh::operator[]
151 (
152  const word& patchName
153 ) const
154 {
155  const label patchi = findPatchID(patchName);
156 
157  if (patchi < 0)
158  {
160  << "Patch named " << patchName << " not found." << nl
161  << abort(FatalError);
162  }
163 
164  return operator[](patchi);
165 }
166 
167 
168 Foam::fvPatch& Foam::fvBoundaryMesh::operator[]
169 (
170  const word& patchName
171 )
172 {
173  const label patchi = findPatchID(patchName);
174 
175  if (patchi < 0)
176  {
178  << "Patch named " << patchName << " not found." << nl
179  << abort(FatalError);
180  }
181 
182  return operator[](patchi);
183 }
184 
185 
186 // ************************************************************************* //
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::polyBoundaryMesh
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
Definition: polyBoundaryMesh.H:62
Foam::fvBoundaryMesh::findPatchID
label findPatchID(const word &patchName) const
Find patch index given a name.
Definition: fvBoundaryMesh.C:86
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::UPtrList::set
const T * set(const label i) const
Return const pointer to element (if set) or nullptr.
Definition: UPtrListI.H:176
Foam::fvBoundaryMesh::readUpdate
void readUpdate(const polyBoundaryMesh &)
Update boundary based on new polyBoundaryMesh.
Definition: fvBoundaryMesh.C:141
Foam::polyMesh::boundaryMesh
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:435
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:290
Foam::fvPatchList
PtrList< fvPatch > fvPatchList
container classes for fvPatch
Definition: fvPatchList.H:47
Foam::keyType
A class for handling keywords in dictionaries.
Definition: keyType.H:60
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:62
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:63
Foam::PtrList::setSize
void setSize(const label newLen)
Same as resize()
Definition: PtrListI.H:108
Foam::fvBoundaryMesh::interfaces
lduInterfacePtrsList interfaces() const
Return a list of pointers for each patch.
Definition: fvBoundaryMesh.C:119
Foam::UPtrList< const lduInterface >
Foam::PtrList
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers....
Definition: List.H:65
fvBoundaryMesh.H
Foam::FatalError
error FatalError
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvBoundaryMesh::indices
labelList indices(const keyType &key, const bool useGroups) const
Return patch indices for all matches.
Definition: fvBoundaryMesh.C:77
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:84
fvMesh.H
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:137
Foam::polyBoundaryMesh::indices
labelList indices(const keyType &key, const bool useGroups=true) const
Return patch indices for all matches.
Definition: polyBoundaryMesh.C:669
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:355
clear
patchWriters clear()
Foam::nl
constexpr char nl
Definition: Ostream.H:372
Foam::List< label >
patches
const polyBoundaryMesh & patches
Definition: convertProcessorPatches.H:65
Foam::fvBoundaryMesh::movePoints
void movePoints()
Correct patches after moving points.
Definition: fvBoundaryMesh.C:103