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 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
29 #include "emptyPolyPatch.H"
30 
31 // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
32 
34 :
36  patchGroupIDs_()
37 {}
38 
39 
41 (
42  const polyMesh& mesh,
43  const dictionary& dict
44 )
45 :
47  patchGroupIDs_(this->size())
48 {
50  const List<patchInteractionData>& items = *this;
51  forAllReverse(items, i)
52  {
53  const keyType& patchName = items[i].patchName();
54  labelList ids = bMesh.indices(patchName);
55 
56  if (ids.empty())
57  {
59  << "Cannot find any patch names matching " << patchName
60  << endl;
61  }
62 
63  patchGroupIDs_[i].transfer(ids);
64  }
65 
66  // Check that all patches are specified
67  DynamicList<word> badPatches;
68  forAll(bMesh, patchi)
69  {
70  const polyPatch& pp = bMesh[patchi];
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.size() > 0)
83  {
85  << "All patches must be specified when employing local patch "
86  << "interaction. Please specify data for patches:" << nl
87  << badPatches << nl << exit(FatalError);
88  }
89 }
90 
91 
93 (
94  const patchInteractionDataList& pidl
95 )
96 :
98  patchGroupIDs_(pidl.patchGroupIDs_)
99 {}
100 
101 
102 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
103 
104 Foam::label Foam::patchInteractionDataList::applyToPatch(const label id) const
105 {
106  forAll(patchGroupIDs_, groupI)
107  {
108  const labelList& patchIDs = patchGroupIDs_[groupI];
109  forAll(patchIDs, patchi)
110  {
111  if (patchIDs[patchi] == id)
112  {
113  return groupI;
114  }
115  }
116  }
117 
118  return -1;
119 }
120 
121 
122 // ************************************************************************* //
Foam::patchInteractionData
Helper class for the LocalInteraction patch interaction model.
Definition: patchInteractionData.H:57
Foam::polyBoundaryMesh
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
Definition: polyBoundaryMesh.H:62
patchInteractionDataList.H
Foam::DynamicList< word >
Foam::patchInteractionDataList
List container for patchInteractionData class.
Definition: patchInteractionDataList.H:49
Foam::polyPatch::coupled
virtual bool coupled() const
Return true if this patch is geometrically coupled (i.e. faces and.
Definition: polyPatch.H:329
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:350
Foam::patchInteractionDataList::applyToPatch
label applyToPatch(const label id) const
Return label of group containing patch id.
Definition: patchInteractionDataList.C:104
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::keyType
A class for handling keywords in dictionaries.
Definition: keyType.H:60
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:474
Foam::dictionary::lookup
ITstream & lookup(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionary.C:424
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:121
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
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:381
Foam::nl
constexpr char nl
Definition: Ostream.H:385
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:33
forAllReverse
#define forAllReverse(list, i)
Reverse loop across all elements in list.
Definition: stdFoam.H:309
Foam::patchIdentifier::name
const word & name() const
The patch name.
Definition: patchIdentifier.H:134
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:303
Foam::patchIdentifier::index
label index() const
The index of this patch in the boundaryMesh.
Definition: patchIdentifier.H:158
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatch.H:85