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-------------------------------------------------------------------------------
11License
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
105Foam::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// ************************************************************************* //
bool found
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
Definition: DynamicList.H:72
void append(const T &val)
Copy append an element to the end of this list.
Definition: DynamicListI.H:503
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
void transfer(List< T > &list)
Definition: List.C:447
A list of faces which address into the list of points.
bool empty() const noexcept
True if the UList is empty (ie, size() is zero)
Definition: UListI.H:427
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
List container for patchInteractionData class.
label applyToPatch(const label id) const
Return label of group containing patch id.
Helper class for the LocalInteraction patch interaction model.
A polyBoundaryMesh is a polyPatch list with additional search methods and registered IO.
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
const polyBoundaryMesh & boundaryMesh() const
Return boundary mesh.
Definition: polyMesh.H:456
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:75
Lookup type of boundary radiation properties.
Definition: lookup.H:66
A wordRe is a Foam::word, but can contain a regular expression for matching words or strings.
Definition: wordRe.H:83
dynamicFvMesh & mesh
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
#define WarningInFunction
Report a warning using Foam::Warning.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
error FatalError
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333
#define forAllReverse(list, i)
Reverse loop across all elements in list.
Definition: stdFoam.H:346