1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
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
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 "StandardWallInteraction.H"
28 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
30 template<class CloudType>
31 void Foam::StandardWallInteraction<CloudType>::readProps()
33 if (!this->owner().solution().transient())
38 IOobject propsDictHeader
40 "standardWallInteractionProperties",
41 this->owner().db().time().timeName(),
42 "uniform"/cloud::prefix/this->owner().name(),
44 IOobject::MUST_READ_IF_MODIFIED,
49 if (propsDictHeader.headerOk())
51 const IOdictionary propsDict(propsDictHeader);
52 propsDict.readIfPresent("nEscape", nEscape0_);
53 propsDict.readIfPresent("massEscape", massEscape0_);
54 propsDict.readIfPresent("nStick", nStick0_);
55 propsDict.readIfPresent("massStick", massStick0_);
60 template<class CloudType>
61 void Foam::StandardWallInteraction<CloudType>::writeProps
64 const scalar massEscape,
66 const scalar massStick
69 if (!this->owner().solution().transient())
74 if (this->owner().db().time().outputTime())
76 IOdictionary propsDict
80 "standardWallInteractionProperties",
81 this->owner().db().time().timeName(),
82 "uniform"/cloud::prefix/this->owner().name(),
90 propsDict.add("nEscape", nEscape);
91 propsDict.add("massEscape", massEscape);
92 propsDict.add("nStick", nStick);
93 propsDict.add("massStick", massStick);
98 IOstream::currentVersion,
99 this->owner().db().time().writeCompression()
105 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
107 template<class CloudType>
108 Foam::StandardWallInteraction<CloudType>::StandardWallInteraction
110 const dictionary& dict,
114 PatchInteractionModel<CloudType>(dict, cloud, typeName),
117 this->wordToInteractionType(this->coeffDict().lookup("type"))
130 switch (interactionType_)
132 case PatchInteractionModel<CloudType>::itOther:
134 const word interactionTypeName(this->coeffDict().lookup("type"));
138 "StandardWallInteraction<CloudType>::StandardWallInteraction"
140 "const dictionary&, "
143 ) << "Unknown interaction result type "
144 << interactionTypeName
145 << ". Valid selections are:" << this->interactionTypeNames_
146 << endl << exit(FatalError);
150 case PatchInteractionModel<CloudType>::itRebound:
152 e_ = this->coeffDict().lookupOrDefault("e", 1.0);
153 mu_ = this->coeffDict().lookupOrDefault("mu", 0.0);
164 template<class CloudType>
165 Foam::StandardWallInteraction<CloudType>::StandardWallInteraction
167 const StandardWallInteraction<CloudType>& pim
170 PatchInteractionModel<CloudType>(pim),
171 interactionType_(pim.interactionType_),
174 nEscape0_(pim.nEscape0_),
175 massEscape0_(pim.massEscape0_),
176 nStick0_(pim.nStick0_),
177 massStick0_(pim.massStick0_),
178 nEscape_(pim.nEscape_),
179 massEscape_(pim.massEscape_),
180 nStick_(pim.nStick_),
181 massStick_(pim.massStick_)
185 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
187 template<class CloudType>
188 Foam::StandardWallInteraction<CloudType>::~StandardWallInteraction()
192 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
194 template<class CloudType>
195 bool Foam::StandardWallInteraction<CloudType>::correct
197 typename CloudType::parcelType& p,
200 const scalar trackFraction,
201 const tetIndices& tetIs
206 bool& active = p.active();
208 if (isA<wallPolyPatch>(pp))
210 switch (interactionType_)
212 case PatchInteractionModel<CloudType>::itEscape:
214 keepParticle = false;
220 case PatchInteractionModel<CloudType>::itStick:
228 case PatchInteractionModel<CloudType>::itRebound:
236 this->patchData(p, pp, trackFraction, tetIs, nw, Up);
238 // Calculate motion relative to patch velocity
242 vector Ut = U - Un*nw;
246 U -= (1.0 + e_)*Un*nw;
251 // Return velocity to global space
260 "bool StandardWallInteraction<CloudType>::correct"
267 ) << "Unknown interaction type "
268 << this->interactionTypeToWord(interactionType_)
269 << "(" << interactionType_ << ")" << endl
270 << abort(FatalError);
281 template<class CloudType>
282 void Foam::StandardWallInteraction<CloudType>::info(Ostream& os) const
284 label npe = returnReduce(nEscape_, sumOp<label>()) + nEscape0_;
285 scalar mpe = returnReduce(massEscape_, sumOp<scalar>()) + massEscape0_;
287 label nps = returnReduce(nStick_, sumOp<label>()) + nStick0_;
288 scalar mps = returnReduce(massStick_, sumOp<scalar>()) + massStick0_;
290 os << " Parcel fates:" << nl
291 << " - escape = " << npe << ", " << mpe << nl
292 << " - stick = " << nps << ", " << mps << nl;
294 writeProps(npe, mpe, nps, mps);
298 // ************************************************************************* //