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 | Copyright (C) 2011-2016 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  && !isA<cyclicAMIPolyPatch>(pp)
78  && applyToPatch(pp.index()) < 0
79  )
80  {
81  badPatches.append(pp.name());
82  }
83  }
84 
85  if (badPatches.size() > 0)
86  {
88  << "All patches must be specified when employing local patch "
89  << "interaction. Please specify data for patches:" << nl
90  << badPatches << nl << exit(FatalError);
91  }
92 }
93 
94 
96 (
97  const patchInteractionDataList& pidl
98 )
99 :
101  patchGroupIDs_(pidl.patchGroupIDs_)
102 {}
103 
104 
105 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
106 
108 {
109  forAll(patchGroupIDs_, groupI)
110  {
111  const labelList& patchIDs = patchGroupIDs_[groupI];
112  forAll(patchIDs, patchI)
113  {
114  if (patchIDs[patchI] == id)
115  {
116  return groupI;
117  }
118  }
119  }
120 
121  return -1;
122 }
123 
124 
125 // ************************************************************************* //
virtual bool coupled() const
Return true if this patch is geometrically coupled (i.e. faces and.
Definition: polyPatch.H:310
const word & name() const
Return name.
void transfer(List< T > &)
Transfer the contents of the argument List into this list.
Definition: List.C:390
bool empty() const
Return true if the UList is empty (ie, size() is zero).
Definition: UListI.H:313
label index() const
Return the index of this patch in the boundaryMesh.
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
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:76
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
Definition: DynamicListI.H:310
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
wordList names() const
Return a list of patch names.
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
static const char nl
Definition: Ostream.H:260
#define WarningInFunction
Report a warning using Foam::Warning.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::polyBoundaryMesh.
bool findStrings(const wordReListMatcher &matcher, const std::string &str)
Return true if string matches one of the regular expressions.
Definition: stringListOps.H:52
#define forAll(list, i)
Definition: UList.H:421
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
List container for patchInteractionData class.
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:421
A list of faces which address into the list of points.
#define forAllReverse(list, i)
Definition: UList.H:424
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:452
error FatalError
label size() const
Return the number of elements in the UList.
Operations on lists of strings.
label applyToPatch(const label id) const
Return label of group containing patch id.
Helper class for the LocalInteraction patch interaction model.