patchInteractionDataList.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2020 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 
27 #include "stringListOps.H"
28 #include "emptyPolyPatch.H"
29 #include "cyclicAMIPolyPatch.H"
30 
31 // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
32 
34 :
36  patchGroupIDs_()
37 {}
38 
39 
41 (
42  const polyMesh& mesh,
43  const dictionary& dict
44 )
45 :
46  List<patchInteractionData>(dict.lookup("patches")),
47  patchGroupIDs_(this->size())
48 {
49  const polyBoundaryMesh& bMesh = mesh.boundaryMesh();
50  const wordList allPatchNames = bMesh.names();
51 
52  const List<patchInteractionData>& items = *this;
53  forAllReverse(items, i)
54  {
55  const word& patchName = items[i].patchName();
56  labelList patchIDs = findStrings(patchName, allPatchNames);
57 
58  if (patchIDs.empty())
59  {
61  << "Cannot find any patch names matching " << patchName
62  << endl;
63  }
64 
65  patchGroupIDs_[i].transfer(patchIDs);
66  }
67 
68  // Check that all patches are specified
69  DynamicList<word> badPatches;
70  forAll(bMesh, patchi)
71  {
72  const polyPatch& pp = bMesh[patchi];
73  if
74  (
75  !pp.coupled()
76  && !isA<emptyPolyPatch>(pp)
77  && applyToPatch(pp.index()) < 0
78  )
79  {
80  badPatches.append(pp.name());
81  }
82  }
83 
84  if (badPatches.size() > 0)
85  {
87  << "All patches must be specified when employing local patch "
88  << "interaction. Please specify data for patches:" << nl
89  << badPatches << nl << exit(FatalError);
90  }
91 }
92 
93 
95 (
96  const patchInteractionDataList& pidl
97 )
98 :
100  patchGroupIDs_(pidl.patchGroupIDs_)
101 {}
102 
103 
104 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
105 
107 {
108  forAll(patchGroupIDs_, groupI)
109  {
110  const labelList& patchIDs = patchGroupIDs_[groupI];
111  forAll(patchIDs, patchi)
112  {
113  if (patchIDs[patchi] == id)
114  {
115  return groupI;
116  }
117  }
118  }
119 
120  return -1;
121 }
122 
123 
124 // ************************************************************************* //
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:453
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
bool empty() const
Return true if the UList is empty (ie, size() is zero)
Definition: UListI.H:325
Helper class for the LocalInteraction patch interaction model.
const word & name() const
Return name.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
#define forAllReverse(list, i)
Reverse loop across all elements in list.
Definition: UList.H:446
Operations on lists of strings.
bool findStrings(const wordReListMatcher &matcher, const std::string &str)
Return true if string matches one of the regular expressions.
Definition: stringListOps.H:52
virtual bool coupled() const
Return true if this patch is geometrically coupled (i.e. faces and.
Definition: polyPatch.H:316
A class for handling words, derived from string.
Definition: word.H:59
wordList names() const
Return a list of patch names.
List container for patchInteractionData class.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
Definition: DynamicListI.H:296
label applyToPatch(const label id) const
Return label of group containing patch id.
Foam::polyBoundaryMesh.
static const char nl
Definition: Ostream.H:260
label patchi
#define WarningInFunction
Report a warning using Foam::Warning.
const polyBoundaryMesh & bMesh
label index() const
Return the index of this patch in the boundaryMesh.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:76
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
label size() const
Return the number of elements in the UList.
Definition: ListI.H:171
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
Definition: List.C:342
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:864