ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / lagrangian / intermediate / submodels / Kinematic / PatchInteractionModel / LocalInteraction / patchInteractionDataList.C
blobbe889d47ae47e9bc8a69a6785b7681f936a56959
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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.
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.
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/>.
24 \*---------------------------------------------------------------------------*/
26 #include "patchInteractionDataList.H"
27 #include "stringListOps.H"
28 #include "wallPolyPatch.H"
30 // * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * * //
32 Foam::patchInteractionDataList::patchInteractionDataList()
34     List<patchInteractionData>(),
35     patchGroupIDs_()
39 Foam::patchInteractionDataList::patchInteractionDataList
41     const polyMesh& mesh,
42     const dictionary& dict
45     List<patchInteractionData>(dict.lookup("patches")),
46     patchGroupIDs_(this->size())
48     const polyBoundaryMesh& bMesh = mesh.boundaryMesh();
49     const wordList allPatchNames = bMesh.names();
51     const List<patchInteractionData>& items = *this;
52     forAllReverse(items, i)
53     {
54         const word& patchName = items[i].patchName();
55         labelList patchIDs = findStrings(patchName, allPatchNames);
57         if (patchIDs.empty())
58         {
59             WarningIn
60             (
61                 "Foam::patchInteractionDataList::patchInteractionDataList"
62                 "("
63                     "const polyMesh&, "
64                     "const dictionary&"
65                 ")"
66             )   << "Cannot find any patch names matching " << patchName
67                 << endl;
68         }
70         patchGroupIDs_[i].transfer(patchIDs);
71     }
73     // check that all walls are specified
74     DynamicList<word> badWalls;
75     forAll(bMesh, patchI)
76     {
77         const polyPatch& pp = bMesh[patchI];
78         if (isA<wallPolyPatch>(pp) && applyToPatch(pp.index()) < 0)
79         {
80             badWalls.append(pp.name());
81         }
82     }
84     if (badWalls.size() > 0)
85     {
86         FatalErrorIn
87         (
88             "Foam::patchInteractionDataList::patchInteractionDataList"
89             "("
90                 "const polyMesh&, "
91                 "const dictionary&"
92             ")"
93         )    << "All wall patches must be specified when employing local patch "
94             << "interaction. Please specify data for patches:" << nl
95             << badWalls << nl << exit(FatalError);
96     }
100 Foam::patchInteractionDataList::patchInteractionDataList
102     const patchInteractionDataList& pidl
105     List<patchInteractionData>(pidl),
106     patchGroupIDs_(pidl.patchGroupIDs_)
110 // * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //
112 Foam::label Foam::patchInteractionDataList::applyToPatch(const label id) const
114     forAll(patchGroupIDs_, groupI)
115     {
116         const labelList& patchIDs = patchGroupIDs_[groupI];
117         forAll(patchIDs, patchI)
118         {
119             if (patchIDs[patchI] == id)
120             {
121                 return groupI;
122             }
123         }
124     }
126     return -1;
130 // ************************************************************************* //