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 :
48  patchGroupIDs_(this->size())
49 {
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 // ************************************************************************* //
Foam::patchInteractionData
Helper class for the LocalInteraction patch interaction model.
Definition: patchInteractionData.H:53
Foam::polyBoundaryMesh
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
Definition: polyBoundaryMesh.H:63
patchInteractionDataList.H
Foam::DynamicList< word >
Foam::patchInteractionDataList
List container for patchInteractionData class.
Definition: patchInteractionDataList.H:49
Foam::polyMesh::boundaryMesh
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:444
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::wordRe
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
Definition: wordRe.H:80
Foam::patchInteractionDataList::applyToPatch
label applyToPatch(const label id) const
Return label of group containing patch id.
Definition: patchInteractionDataList.C:105
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:68
Foam::DynamicList::append
DynamicList< T, SizeMin > & append(const T &val)
Append an element to the end of this list.
Definition: DynamicListI.H:511
Foam::dictionary::lookup
ITstream & lookup(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionary.C:386
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
emptyPolyPatch.H
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
found
bool found
Definition: TABSMDCalcMethod2.H:32
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:63
Foam::patchInteractionDataList::patchInteractionDataList
patchInteractionDataList()
Construct null.
Definition: patchInteractionDataList.C:34
forAllReverse
#define forAllReverse(list, i)
Reverse loop across all elements in list.
Definition: stdFoam.H:309
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:328
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatch.H:79