1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-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 "interfaceProperties.H"
27 #include <interfaceProperties/alphaContactAngleFvPatchScalarField.H>
28 #include <OpenFOAM/mathematicalConstants.H>
29 #include <finiteVolume/surfaceInterpolate.H>
30 #include <finiteVolume/fvcDiv.H>
31 #include <finiteVolume/fvcGrad.H>
32 #include <finiteVolume/fvcSnGrad.H>
34 // * * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * //
36 const Foam::scalar Foam::interfaceProperties::convertToRad =
37 Foam::mathematicalConstant::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];
74 convertToRad*acap.theta(U_.boundaryField()[patchi], nHatp);
76 vectorField nf = boundary[patchi].nf();
78 // Reset nHatp to correspond to the contact angle
80 scalarField a12 = nHatp & nf;
82 scalarField b1 = cos(theta);
84 scalarField b2(nHatp.size());
88 b2[facei] = cos(acos(a12[facei]) - theta[facei]);
91 scalarField det = 1.0 - a12*a12;
93 scalarField a = (b1 - a12*b2)/det;
94 scalarField b = (b2 - a12*b1)/det;
96 nHatp = a*nf + b*nHatp;
98 nHatp /= (mag(nHatp) + deltaN_.value());
100 acap.gradient() = (nf & nHatp)*mag(gradAlphaf[patchi]);
106 void Foam::interfaceProperties::calculateK()
108 const fvMesh& mesh = alpha1_.mesh();
109 const surfaceVectorField& Sf = mesh.Sf();
111 // Cell gradient of alpha
112 volVectorField gradAlpha = fvc::grad(alpha1_);
114 // Interpolated face-gradient of alpha
115 surfaceVectorField gradAlphaf = fvc::interpolate(gradAlpha);
117 // (mesh.Sf()/mesh.magSf())
118 // *(fvc::snGrad(alpha1_) - (mesh.Sf() & gradAlphaf)/mesh.magSf());
120 // Face unit interface normal
121 surfaceVectorField nHatfv = gradAlphaf/(mag(gradAlphaf) + deltaN_);
122 correctContactAngle(nHatfv.boundaryField(), gradAlphaf.boundaryField());
124 // Face unit interface normal flux
125 nHatf_ = nHatfv & Sf;
127 // Simple expression for curvature
128 K_ = -fvc::div(nHatf_);
130 // Complex expression for curvature.
131 // Correction is formally zero but numerically non-zero.
133 volVectorField nHat = gradAlpha/(mag(gradAlpha) + deltaN_);
134 forAll(nHat.boundaryField(), patchi)
136 nHat.boundaryField()[patchi] = nHatfv.boundaryField()[patchi];
139 K_ = -fvc::div(nHatf_) + (nHat & fvc::grad(nHatfv) & nHat);
144 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
146 Foam::interfaceProperties::interfaceProperties
148 const volScalarField& alpha1,
149 const volVectorField& U,
150 const IOdictionary& dict
153 transportPropertiesDict_(dict),
158 alpha1.mesh().solutionDict().subDict("PISO").lookup("cAlpha")
161 sigma_(dict.lookup("sigma")),
166 1e-8/pow(average(alpha1.mesh().V()), 1.0/3.0)
177 alpha1_.time().timeName(),
181 dimensionedScalar("nHatf", dimArea, 0.0)
189 alpha1_.time().timeName(),
193 dimensionedScalar("Kcond", dimless/dimLength, 0.0)
200 // ************************ vim: set sw=4 sts=4 et: ************************ //