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-2015 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 
30 // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
31 
33 :
35  patchGroupIDs_()
36 {}
37 
38 
40 (
41  const polyMesh& mesh,
42  const dictionary& dict
43 )
44 :
46  patchGroupIDs_(this->size())
47 {
49  const wordList allPatchNames = bMesh.names();
50 
51  const List<patchInteractionData>& items = *this;
52  forAllReverse(items, i)
53  {
54  const word& patchName = items[i].patchName();
55  labelList patchIDs = findStrings(patchName, allPatchNames);
56 
57  if (patchIDs.empty())
58  {
60  << "Cannot find any patch names matching " << patchName
61  << endl;
62  }
63 
64  patchGroupIDs_[i].transfer(patchIDs);
65  }
66 
67  // Check that all patches are specified
68  DynamicList<word> badPatches;
69  forAll(bMesh, patchI)
70  {
71  const polyPatch& pp = bMesh[patchI];
72  if
73  (
74  !pp.coupled()
75  && !isA<emptyPolyPatch>(pp)
76  && applyToPatch(pp.index()) < 0
77  )
78  {
79  badPatches.append(pp.name());
80  }
81  }
82 
83  if (badPatches.size() > 0)
84  {
86  << "All patches must be specified when employing local patch "
87  << "interaction. Please specify data for patches:" << nl
88  << badPatches << nl << exit(FatalError);
89  }
90 }
91 
92 
94 (
95  const patchInteractionDataList& pidl
96 )
97 :
99  patchGroupIDs_(pidl.patchGroupIDs_)
100 {}
101 
102 
103 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
104 
106 {
107  forAll(patchGroupIDs_, groupI)
108  {
109  const labelList& patchIDs = patchGroupIDs_[groupI];
110  forAll(patchIDs, patchI)
111  {
112  if (patchIDs[patchI] == id)
113  {
114  return groupI;
115  }
116  }
117  }
118 
119  return -1;
120 }
121 
122 
123 // ************************************************************************* //
Foam::patchInteractionData
Helper class for the LocalInteraction patch interaction model.
Definition: patchInteractionData.H:55
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::polyBoundaryMesh
Foam::polyBoundaryMesh.
Definition: polyBoundaryMesh.H:60
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
patchInteractionDataList.H
Foam::DynamicList< word >
Foam::patchInteractionDataList
List container for patchInteractionData class.
Definition: patchInteractionDataList.H:47
Foam::polyPatch::coupled
virtual bool coupled() const
Return true if this patch is geometrically coupled (i.e. faces and.
Definition: polyPatch.H:322
Foam::dictionary::lookup
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:449
Foam::polyMesh::boundaryMesh
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:421
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
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:74
Foam::label
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
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:66
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
forAllReverse
#define forAllReverse(list, i)
Reverse loop across all elements in list.
Definition: UList.H:418
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
emptyPolyPatch.H
Foam::DynamicList::append
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Foam::findStrings
bool findStrings(const wordReListMatcher &matcher, const std::string &str)
Return true if string matches one of the regular expressions.
Definition: stringListOps.H:52
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::patchInteractionDataList::patchGroupIDs_
labelListList patchGroupIDs_
List of patch IDs for each patch group.
Definition: patchInteractionDataList.H:56
Foam::List
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
Foam::patchInteractionDataList::patchInteractionDataList
patchInteractionDataList()
Construct null.
Definition: patchInteractionDataList.C:32
stringListOps.H
Operations on lists of strings.
Foam::patchIdentifier::name
const word & name() const
Return name.
Definition: patchIdentifier.H:109
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:259
Foam::patchIdentifier::index
label index() const
Return the index of this patch in the boundaryMesh.
Definition: patchIdentifier.H:133
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatchTemplate.H:88