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 | Copyright (C) 2011 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "fvBoundaryMesh.H"
27 #include "fvMesh.H"
28 
29 
30 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
31 
32 void Foam::fvBoundaryMesh::addPatches(const polyBoundaryMesh& basicBdry)
33 {
34  setSize(basicBdry.size());
35 
36  // Set boundary patches
37  fvPatchList& Patches = *this;
38 
39  forAll(Patches, patchI)
40  {
41  Patches.set(patchI, fvPatch::New(basicBdry[patchI], *this));
42  }
43 }
44 
45 
46 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
47 
48 Foam::fvBoundaryMesh::fvBoundaryMesh
49 (
50  const fvMesh& m
51 )
52 :
53  fvPatchList(0),
54  mesh_(m)
55 {}
56 
57 
58 Foam::fvBoundaryMesh::fvBoundaryMesh
59 (
60  const fvMesh& m,
61  const polyBoundaryMesh& basicBdry
62 )
63 :
64  fvPatchList(basicBdry.size()),
65  mesh_(m)
66 {
67  addPatches(basicBdry);
68 }
69 
70 
71 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
72 
74 {
75  const fvPatchList& patches = *this;
76 
77  forAll(patches, patchI)
78  {
79  if (patches[patchI].name() == patchName)
80  {
81  return patchI;
82  }
83  }
84 
85  // Not found, return -1
86  return -1;
87 }
88 
89 
91 (
92  const keyType& key,
93  const bool usePatchGroups
94 ) const
95 {
96  return mesh().boundaryMesh().findIndices(key, usePatchGroups);
97 }
98 
99 
101 {
102  forAll(*this, patchI)
103  {
104  operator[](patchI).initMovePoints();
105  }
106 
107  forAll(*this, patchI)
108  {
109  operator[](patchI).movePoints();
110  }
111 }
112 
113 
115 {
117 
118  forAll(interfaces, patchI)
119  {
120  if (isA<lduInterface>(this->operator[](patchI)))
121  {
122  interfaces.set
123  (
124  patchI,
125  &refCast<const lduInterface>(this->operator[](patchI))
126  );
127  }
128  }
129 
130  return interfaces;
131 }
132 
133 
135 {
136  clear();
137  addPatches(basicBdry);
138 }
139 
140 
141 // * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
142 
144 (
145  const word& patchName
146 ) const
147 {
148  const label patchI = findPatchID(patchName);
149 
150  if (patchI < 0)
151  {
153  (
154  "fvBoundaryMesh::operator[](const word&) const"
155  ) << "Patch named " << patchName << " not found." << nl
156  << abort(FatalError);
157  }
158 
159  return operator[](patchI);
160 }
161 
162 
164 (
165  const word& patchName
166 )
167 {
168  const label patchI = findPatchID(patchName);
169 
170  if (patchI < 0)
171  {
173  (
174  "fvBoundaryMesh::operator[](const word&)"
175  ) << "Patch named " << patchName << " not found." << nl
176  << abort(FatalError);
177  }
178 
179  return operator[](patchI);
180 }
181 
182 
183 // ************************************************************************* //
const fvPatch & operator[](const word &) const
Return const reference to fvPatch by name.
void setSize(const label)
Reset size of PtrList. If extending the PtrList, new entries are.
Definition: PtrList.C:142
static autoPtr< fvPatch > New(const polyPatch &, const fvBoundaryMesh &)
Return a pointer to a new patch created on freestore from polyPatch.
Definition: fvPatchNew.C:33
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
label size() const
Return the number of elements in the PtrList.
Definition: PtrListI.H:32
A templated 1D list of pointers to objects of type <T>, where the size of the array is known and used...
Definition: List.H:61
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
labelList findIndices(const keyType &, const bool useGroups) const
Find patch indices given a name.
void clear()
Clear the PtrList, i.e. set size to zero deleting all the.
Definition: PtrList.C:185
A class for handling words, derived from string.
Definition: word.H:59
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:59
friend Ostream & operator(Ostream &, const PtrList< T > &)
A class for handling keywords in dictionaries.
Definition: keyType.H:56
patches[0]
static const char nl
Definition: Ostream.H:260
void movePoints()
Correct patches after moving points.
Foam::polyBoundaryMesh.
#define forAll(list, i)
Definition: UList.H:421
errorManip< error > abort(error &err)
Definition: errorManip.H:131
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:421
bool set(const label) const
Is element set.
Definition: UPtrListI.H:80
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
label findPatchID(const word &patchName) const
Find patch index given a name.
const fvMesh & mesh() const
Return the mesh reference.
virtual void initMovePoints()
Initialise the patches for moving points.
Definition: fvPatch.C:156
error FatalError
labelList findIndices(const keyType &, const bool usePatchGroups=true) const
Return patch indices for all matches. Optionally matches patchGroups.
virtual void movePoints()
Correct patches after moving points.
Definition: fvPatch.C:160
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
lduInterfacePtrsList interfaces() const
Return a list of pointers for each patch.
PtrList< fvPatch > fvPatchList
container classes for fvPatch
Definition: fvPatchList.H:45
void readUpdate(const polyBoundaryMesh &)
Update boundary based on new polyBoundaryMesh.