1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2004-2010 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
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 "reflectParcel.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "wallPolyPatch.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 defineTypeNameAndDebug(reflectParcel, 0);
36 addToRunTimeSelectionTable
45 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
47 Foam::reflectParcel::reflectParcel
49 const dictionary& dict,
50 const volVectorField& U,
54 wallModel(dict, U, sm),
56 coeffsDict_(dict.subDict(typeName + "Coeffs")),
57 elasticity_(readScalar(coeffsDict_.lookup("elasticity")))
61 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
63 Foam::reflectParcel::~reflectParcel()
67 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
69 // Return 'keepParcel'
70 bool Foam::reflectParcel::wallTreatment
73 const label globalFaceI
76 label patchI = p.patch(globalFaceI);
77 label faceI = p.patchFace(patchI, globalFaceI);
79 const polyMesh& mesh = spray_.mesh();
81 if (isA<wallPolyPatch>(mesh_.boundaryMesh()[patchI]))
83 // wallNormal defined to point outwards of domain
84 vector Sf = mesh_.Sf().boundaryField()[patchI][faceI];
90 scalar Un = p.U() & Sf;
94 p.U() -= (1.0 + elasticity_)*Un*Sf;
100 vector Ub1 = U_.boundaryField()[patchI][faceI];
101 vector Ub0 = U_.oldTime().boundaryField()[patchI][faceI];
103 scalar dt = spray_.runTime().deltaTValue();
104 const vectorField& oldPoints = mesh.oldPoints();
106 const vector& Cf1 = mesh.faceCentres()[globalFaceI];
108 vector Cf0 = mesh.faces()[globalFaceI].centre(oldPoints);
109 vector Cf = Cf0 + p.stepFraction()*(Cf1 - Cf0);
110 vector Sf0 = mesh.faces()[globalFaceI].normal(oldPoints);
112 // for layer addition Sf0 = vector::zero and we use Sf
113 if (mag(Sf0) > SMALL)
122 scalar magSfDiff = mag(Sf - Sf0);
124 vector Ub = Ub0 + p.stepFraction()*(Ub1 - Ub0);
126 if (magSfDiff > SMALL)
128 // rotation + translation
129 vector Sfp = Sf0 + p.stepFraction()*(Sf - Sf0);
131 vector omega = Sf0 ^ Sf;
132 scalar magOmega = mag(omega);
133 omega /= magOmega+SMALL;
135 scalar phiVel = ::asin(magOmega)/dt;
137 scalar dist = (p.position() - Cf) & Sfp;
138 vector pos = p.position() - dist*Sfp;
139 vector vrot = phiVel*(omega ^ (pos - Cf));
141 vector v = Ub + vrot;
143 scalar Un = ((p.U() - v) & Sfp);
147 p.U() -= (1.0 + elasticity_)*Un*Sfp;
153 vector Ur = p.U() - Ub;
154 scalar Urn = Ur & Sf;
156 if (mag(Ub-v) > SMALL)
158 Info<< "reflectParcel:: v = " << v
160 << ", faceI = " << faceI
161 << ", patchI = " << patchI
162 << ", globalFaceI = " << globalFaceI
163 << ", name = " << mesh_.boundaryMesh()[patchI].name()
169 p.U() -= (1.0 + elasticity_)*Urn*Sf;
177 FatalErrorIn("bool reflectParcel::wallTreatment(parcel& parcel) const")
178 << " parcel has hit a boundary " << mesh_.boundary()[patchI].type()
179 << " which not yet has been implemented." << nl
180 << abort(FatalError);
186 // ************************************************************************* //