ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / lagrangian / intermediate / submodels / Kinematic / PatchInteractionModel / MultiInteraction / MultiInteraction.C
blobae8d7963445e1cb1fa92558a909c323ac82acf65
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 "MultiInteraction.H"
28 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
30 template<class CloudType>
31 bool Foam::MultiInteraction<CloudType>::read(const dictionary& dict)
33     // Count dictionaries
35     Info<< "Patch interaction model " << typeName << nl
36         << "Executing in turn " << endl;
38     label nModels = 0;
39     forAllConstIter(dictionary, dict, iter)
40     {
41         if (iter().isDict())
42         {
43             Info<< "    " << iter().name() << endl;
45             nModels++;
46         }
47     }
49     models_.setSize(nModels);
50     nModels = 0;
51     forAllConstIter(dictionary, dict, iter)
52     {
53         if (iter().isDict())
54         {
55             models_.set
56             (
57                 nModels++,
58                 PatchInteractionModel<CloudType>::New
59                 (
60                     iter().dict(),
61                     this->owner()
62                 )
63             );
64         }
65     }
67     oneInteractionOnly_ = Switch(dict.lookup("oneInteractionOnly"));
69     if (oneInteractionOnly_)
70     {
71         Info<< "Stopping upon first model that interacts with particle."
72             << nl << endl;
73     }
74     else
75     {
76         Info<< "Allowing multiple models to interact."
77             << nl << endl;
78     }
80     return true;
84 // * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * * //
86 template<class CloudType>
87 Foam::MultiInteraction<CloudType>::MultiInteraction
89     const dictionary& dict,
90     CloudType& cloud
93     PatchInteractionModel<CloudType>(dict, cloud, typeName)
95     read(this->coeffDict());
99 template<class CloudType>
100 Foam::MultiInteraction<CloudType>::MultiInteraction
102     const MultiInteraction<CloudType>& pim
105     PatchInteractionModel<CloudType>(pim),
106     oneInteractionOnly_(pim.oneInteractionOnly_),
107     models_(pim.models_)
111 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
113 template <class CloudType>
114 Foam::MultiInteraction<CloudType>::~MultiInteraction()
118 // * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * * //
120 template<class CloudType>
121 bool Foam::MultiInteraction<CloudType>::active() const
123     forAll(models_, i)
124     {
125         if (models_[i].active())
126         {
127             return true;
128         }
129     }
130     return false;
134 template <class CloudType>
135 bool Foam::MultiInteraction<CloudType>::correct
137     typename CloudType::parcelType& p,
138     const polyPatch& pp,
139     bool& keepParticle,
140     const scalar trackFraction,
141     const tetIndices& tetIs
144     label origFacei = p.face();
145     label patchi = pp.index();
147     bool interacted = false;
149     forAll(models_, i)
150     {
151         bool myInteracted = models_[i].correct
152         (
153             p,
154             this->owner().pMesh().boundaryMesh()[patchi],
155             keepParticle,
156             trackFraction,
157             tetIs
158         );
160         if (myInteracted && oneInteractionOnly_)
161         {
162             break;
163         }
165         interacted = (interacted || myInteracted);
168         // Check if perhaps the interaction model has changed patches
169         // (CoincidentBaffleInteraction can do this)
171         if (p.face() != origFacei)
172         {
173             origFacei = p.face();
174             patchi = p.patch(p.face());
176             // Interaction model has moved particle off wall?
177             if (patchi == -1)
178             {
179                 break;
180             }
181         }
182     }
184     return interacted;
188 // ************************************************************************* //