1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
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 "reflectParcel.H"
28 #include "addToRunTimeSelectionTable.H"
29 #include "wallPolyPatch.H"
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38 defineTypeNameAndDebug(reflectParcel, 0);
40 addToRunTimeSelectionTable
48 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50 // Construct from components
51 reflectParcel::reflectParcel
53 const dictionary& dict,
54 const volVectorField& U,
58 wallModel(dict, U, sm),
60 coeffsDict_(dict.subDict(typeName + "Coeffs")),
61 elasticity_(readScalar(coeffsDict_.lookup("elasticity")))
65 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
67 reflectParcel::~reflectParcel()
71 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
73 // Return 'keepParcel'
74 bool reflectParcel::wallTreatment
77 const label globalFacei
80 label patchi = p.patch(globalFacei);
81 label facei = p.patchFace(patchi, globalFacei);
83 const polyMesh& mesh = spray_.mesh();
85 if (isType<wallPolyPatch>(mesh_.boundaryMesh()[patchi]))
87 // wallNormal defined to point outwards of domain
88 vector Sf = mesh_.Sf().boundaryField()[patchi][facei];
94 scalar Un = p.U() & Sf;
98 p.U() -= (1.0 + elasticity_)*Un*Sf;
105 vector Ub1 = U_.boundaryField()[patchi][facei];
106 vector Ub0 = U_.oldTime().boundaryField()[patchi][facei];
108 scalar dt = spray_.runTime().deltaT().value();
109 const vectorField& oldPoints = mesh.oldPoints();
111 const vector& Cf1 = mesh.faceCentres()[globalFacei];
113 vector Cf0 = mesh.faces()[globalFacei].centre(oldPoints);
114 vector Cf = Cf0 + p.stepFraction()*(Cf1 - Cf0);
115 vector Sf0 = mesh.faces()[globalFacei].normal(oldPoints);
117 // for layer addition Sf0 = vector::zero and we use Sf
118 if (mag(Sf0) > SMALL)
127 scalar magSfDiff = mag(Sf - Sf0);
129 vector Ub = Ub0 + p.stepFraction()*(Ub1 - Ub0);
131 if (magSfDiff > SMALL)
133 // rotation + translation
134 vector Sfp = Sf0 + p.stepFraction()*(Sf - Sf0);
136 vector omega = Sf0 ^ Sf;
137 scalar magOmega = mag(omega);
138 omega /= magOmega+SMALL;
140 scalar phiVel = ::asin(magOmega)/dt;
142 scalar dist = (p.position() - Cf) & Sfp;
143 vector pos = p.position() - dist*Sfp;
144 vector vrot = phiVel*(omega ^ (pos - Cf));
146 vector v = Ub + vrot;
148 scalar Un = ((p.U() - v) & Sfp);
152 p.U() -= (1.0 + elasticity_)*Un*Sfp;
158 vector Ur = p.U() - Ub;
159 scalar Urn = Ur & Sf;
161 if (mag(Ub-v) > SMALL)
163 Info << "reflectParcel:: v = " << v
165 << ", facei = " << facei
166 << ", patchi = " << patchi
167 << ", globalFacei = " << globalFacei
168 << ", name = " << mesh_.boundaryMesh()[patchi].name()
174 p.U() -= (1.0 + elasticity_)*Urn*Sf;
183 << "bool reflectParcel::wallTreatment(parcel& parcel) const "
184 << " parcel has hit a boundary "
185 << mesh_.boundary()[patchi].type()
186 << " which not yet has been implemented."
187 << abort(FatalError);
192 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
194 } // End namespace Foam
196 // ************************************************************************* //