1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "LocalInteraction.H"
29 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
31 template <class CloudType>
32 Foam::label Foam::LocalInteraction<CloudType>::applyToPatch
34 const label globalPatchI
37 forAll(patchIds_, patchI)
39 if (patchIds_[patchI] == globalPatchI)
49 // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
51 template <class CloudType>
52 Foam::LocalInteraction<CloudType>::LocalInteraction
54 const dictionary& dict,
58 PatchInteractionModel<CloudType>(dict, cloud, typeName),
59 patchData_(this->coeffDict().lookup("patches")),
60 patchIds_(patchData_.size())
62 const polyMesh& mesh = cloud.mesh();
63 const polyBoundaryMesh& bMesh = mesh.boundaryMesh();
65 // check that user patches are valid region patches
66 forAll(patchData_, patchI)
68 const word& patchName = patchData_[patchI].patchName();
69 patchIds_[patchI] = bMesh.findPatchID(patchName);
70 if (patchIds_[patchI] < 0)
72 FatalErrorIn("LocalInteraction(const dictionary&, CloudType&)")
73 << "Patch " << patchName << " not found. Available patches "
74 << "are: " << bMesh.names() << nl << exit(FatalError);
78 // check that all walls are specified
79 DynamicList<word> badWalls;
84 bMesh[patchI].isWall()
85 && applyToPatch(bMesh[patchI].index()) < 0
88 badWalls.append(bMesh[patchI].name());
92 if (badWalls.size() > 0)
94 FatalErrorIn("LocalInteraction(const dictionary&, CloudType&)")
95 << "All wall patches must be specified when employing local patch "
96 << "interaction. Please specify data for patches:" << nl
97 << badWalls << nl << exit(FatalError);
100 // check that interactions are valid/specified
101 forAll(patchData_, patchI)
103 const word& interactionTypeName =
104 patchData_[patchI].interactionTypeName();
105 const typename PatchInteractionModel<CloudType>::interactionType& it =
106 this->wordToInteractionType(interactionTypeName);
108 if (it == PatchInteractionModel<CloudType>::itOther)
110 const word& patchName = patchData_[patchI].patchName();
111 FatalErrorIn("LocalInteraction(const dictionary&, CloudType&)")
112 << "Unknown patch interaction type "
113 << interactionTypeName << " for patch " << patchName
114 << ". Valid selections are:"
115 << this->PatchInteractionModel<CloudType>::interactionTypeNames_
116 << nl << exit(FatalError);
122 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
124 template <class CloudType>
125 Foam::LocalInteraction<CloudType>::~LocalInteraction()
129 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
131 template<class CloudType>
132 bool Foam::LocalInteraction<CloudType>::active() const
138 template <class CloudType>
139 bool Foam::LocalInteraction<CloudType>::correct
147 label patchI = applyToPatch(pp.index());
151 typename PatchInteractionModel<CloudType>::interactionType it =
152 this->wordToInteractionType
154 patchData_[patchI].interactionTypeName()
159 case PatchInteractionModel<CloudType>::itEscape:
161 keepParticle = false;
165 case PatchInteractionModel<CloudType>::itStick:
171 case PatchInteractionModel<CloudType>::itRebound:
175 vector nw = pp.faceAreas()[pp.whichFace(faceId)];
179 vector Ut = U - Un*nw;
183 U -= (1.0 + patchData_[patchI].e())*Un*nw;
186 U -= patchData_[patchI].mu()*Ut;
194 "bool LocalInteraction<CloudType>::correct"
201 ) << "Unknown interaction type "
202 << patchData_[patchI].interactionTypeName()
203 << "(" << it << ") for patch "
204 << patchData_[patchI].patchName()
205 << ". Valid selections are:" << this->interactionTypeNames_
206 << endl << abort(FatalError);
217 // ************************************************************************* //