patchInteractionDataList.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-2017 OpenFOAM Foundation
9  Copyright (C) 2021 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 
30 #include "emptyPolyPatch.H"
31 
32 // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
33 
35 :
37  patchGroupIDs_()
38 {}
39 
40 
42 (
43  const polyMesh& mesh,
44  const dictionary& dict
45 )
46 :
47  List<patchInteractionData>(dict.lookup("patches")),
48  patchGroupIDs_(this->size())
49 {
50  const polyBoundaryMesh& bMesh = mesh.boundaryMesh();
51  const List<patchInteractionData>& items = *this;
52  forAllReverse(items, i)
53  {
54  const wordRe& patchName = items[i].patchName();
55  labelList ids = bMesh.indices(patchName);
56 
57  if (ids.empty())
58  {
60  << "Cannot find any patch names matching "
61  << patchName << endl;
62  }
63 
64  patchGroupIDs_[i].transfer(ids);
65  }
66 
67  // Check that all patches are specified
68  DynamicList<word> badPatches;
69  for (const polyPatch& pp : bMesh)
70  {
71  if
72  (
73  !pp.coupled()
74  && !isA<emptyPolyPatch>(pp)
75  && applyToPatch(pp.index()) < 0
76  )
77  {
78  badPatches.append(pp.name());
79  }
80  }
81 
82  if (!badPatches.empty())
83  {
85  << "All patches must be specified when employing local patch "
86  << "interaction. Please specify data for patches:" << nl
87  << badPatches << nl
88  << exit(FatalError);
89  }
90 }
91 
92 
94 (
95  const patchInteractionDataList& pidl
96 )
97 :
99  patchGroupIDs_(pidl.patchGroupIDs_)
100 {}
101 
102 
103 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
104 
105 Foam::label Foam::patchInteractionDataList::applyToPatch(const label id) const
106 {
107  forAll(patchGroupIDs_, groupi)
108  {
109  if (patchGroupIDs_[groupi].found(id))
110  {
111  return groupi;
112  }
113  }
114 
115  return -1;
116 }
117 
118 
119 // ************************************************************************* //
dictionary dict
Helper class for the LocalInteraction patch interaction model.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
Definition: List.C:326
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:598
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:56
constexpr char nl
The newline &#39;\n&#39; character (0x0a)
Definition: Ostream.H:50
bool empty() const noexcept
True if List is empty (ie, size() is zero)
Definition: UList.H:666
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
Lookup type of boundary radiation properties.
Definition: lookup.H:57
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
A list of faces which address into the list of points.
dynamicFvMesh & mesh
label applyToPatch(const label id) const
Return label of group containing patch id.
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...
#define WarningInFunction
Report a warning using Foam::Warning.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
#define forAllReverse(list, i)
Reverse loop across all elements in list.
Definition: stdFoam.H:437
PrimitivePatch< List< face >, const pointField > bMesh
Holder of faceList and points. (v.s. e.g. primitivePatch which references points) ...
Definition: bMesh.H:39
bool found
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())