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 "interfaceProperties.H"
27 #include "alphaContactAngleFvPatchScalarField.H"
28 #include "mathematicalConstants.H"
29 #include "surfaceInterpolate.H"
32 #include "fvcSnGrad.H"
34 // * * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * //
36 const Foam::scalar Foam::interfaceProperties::convertToRad =
37 Foam::constant::mathematical::pi/180.0;
40 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
42 // Correction for the boundary condition on the unit normal nHat on
43 // walls to produce the correct contact angle.
45 // The dynamic contact angle is calculated from the component of the
46 // velocity on the direction of the interface, parallel to the wall.
48 void Foam::interfaceProperties::correctContactAngle
50 surfaceVectorField::GeometricBoundaryField& nHatb,
51 surfaceVectorField::GeometricBoundaryField& gradAlphaf
54 const fvMesh& mesh = alpha1_.mesh();
55 const volScalarField::GeometricBoundaryField& abf = alpha1_.boundaryField();
57 const fvBoundaryMesh& boundary = mesh.boundary();
59 forAll(boundary, patchi)
61 if (isA<alphaContactAngleFvPatchScalarField>(abf[patchi]))
63 alphaContactAngleFvPatchScalarField& acap =
64 const_cast<alphaContactAngleFvPatchScalarField&>
66 refCast<const alphaContactAngleFvPatchScalarField>
72 fvsPatchVectorField& nHatp = nHatb[patchi];
73 const scalarField theta
75 convertToRad*acap.theta(U_.boundaryField()[patchi], nHatp)
83 // Reset nHatp to correspond to the contact angle
85 const scalarField a12(nHatp & nf);
86 const scalarField b1(cos(theta));
88 scalarField b2(nHatp.size());
91 b2[facei] = cos(acos(a12[facei]) - theta[facei]);
94 const scalarField det(1.0 - a12*a12);
96 scalarField a((b1 - a12*b2)/det);
97 scalarField b((b2 - a12*b1)/det);
99 nHatp = a*nf + b*nHatp;
100 nHatp /= (mag(nHatp) + deltaN_.value());
102 acap.gradient() = (nf & nHatp)*mag(gradAlphaf[patchi]);
109 void Foam::interfaceProperties::calculateK()
111 const fvMesh& mesh = alpha1_.mesh();
112 const surfaceVectorField& Sf = mesh.Sf();
114 // Cell gradient of alpha
115 const volVectorField gradAlpha(fvc::grad(alpha1_));
117 // Interpolated face-gradient of alpha
118 surfaceVectorField gradAlphaf(fvc::interpolate(gradAlpha));
121 // (mesh.Sf()/mesh.magSf())
122 // *(fvc::snGrad(alpha1_) - (mesh.Sf() & gradAlphaf)/mesh.magSf());
124 // Face unit interface normal
125 surfaceVectorField nHatfv(gradAlphaf/(mag(gradAlphaf) + deltaN_));
126 correctContactAngle(nHatfv.boundaryField(), gradAlphaf.boundaryField());
128 // Face unit interface normal flux
129 nHatf_ = nHatfv & Sf;
131 // Simple expression for curvature
132 K_ = -fvc::div(nHatf_);
134 // Complex expression for curvature.
135 // Correction is formally zero but numerically non-zero.
137 volVectorField nHat(gradAlpha/(mag(gradAlpha) + deltaN_));
138 forAll(nHat.boundaryField(), patchi)
140 nHat.boundaryField()[patchi] = nHatfv.boundaryField()[patchi];
143 K_ = -fvc::div(nHatf_) + (nHat & fvc::grad(nHatfv) & nHat);
148 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
150 Foam::interfaceProperties::interfaceProperties
152 const volScalarField& alpha1,
153 const volVectorField& U,
154 const IOdictionary& dict
157 transportPropertiesDict_(dict),
162 alpha1.mesh().solutionDict().subDict("PIMPLE").lookup("cAlpha")
165 sigma_(dict.lookup("sigma")),
170 1e-8/pow(average(alpha1.mesh().V()), 1.0/3.0)
181 alpha1_.time().timeName(),
185 dimensionedScalar("nHatf", dimArea, 0.0)
193 alpha1_.time().timeName(),
197 dimensionedScalar("K", dimless/dimLength, 0.0)
204 // ************************************************************************* //