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 "interfaceProperties.H"
28 #include "alphaContactAngleFvPatchScalarField.H"
29 #include "mathematicalConstants.H"
30 #include "surfaceInterpolate.H"
33 #include "fvcSnGrad.H"
35 // * * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * //
37 const Foam::scalar Foam::interfaceProperties::convertToRad =
38 Foam::mathematicalConstant::pi/180.0;
41 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
43 // Correction for the boundary condition on the unit normal nHat on
44 // walls to produce the correct contact angle.
46 // The dynamic contact angle is calculated from the component of the
47 // velocity on the direction of the interface, parallel to the wall.
49 void Foam::interfaceProperties::correctContactAngle
51 surfaceVectorField::GeometricBoundaryField& nHatb
54 const fvMesh& mesh = alpha1_.mesh();
55 const volScalarField::GeometricBoundaryField& gbf = alpha1_.boundaryField();
57 const fvBoundaryMesh& boundary = mesh.boundary();
59 forAll(boundary, patchi)
61 if (isA<alphaContactAngleFvPatchScalarField>(gbf[patchi]))
63 const alphaContactAngleFvPatchScalarField& gcap =
64 refCast<const alphaContactAngleFvPatchScalarField>
67 fvsPatchVectorField& nHatp = nHatb[patchi];
69 convertToRad*gcap.theta(U_.boundaryField()[patchi], nHatp);
71 vectorField nf = boundary[patchi].nf();
73 // Reset nHatp to correspond to the contact angle
75 scalarField a12 = nHatp & nf;
77 scalarField b1 = cos(theta);
79 scalarField b2(nHatp.size());
83 b2[facei] = cos(acos(a12[facei]) - theta[facei]);
86 scalarField det = 1.0 - a12*a12;
88 scalarField a = (b1 - a12*b2)/det;
89 scalarField b = (b2 - a12*b1)/det;
91 nHatp = a*nf + b*nHatp;
93 nHatp /= (mag(nHatp) + deltaN_.value());
99 void Foam::interfaceProperties::calculateK()
101 const fvMesh& mesh = alpha1_.mesh();
102 const surfaceVectorField& Sf = mesh.Sf();
104 // Cell gradient of alpha
105 volVectorField gradAlpha = fvc::grad(alpha1_);
107 // Interpolated face-gradient of alpha
108 surfaceVectorField gradAlphaf = fvc::interpolate(gradAlpha);
110 // (mesh.Sf()/mesh.magSf())
111 // *(fvc::snGrad(alpha1_) - (mesh.Sf() & gradAlphaf)/mesh.magSf());
113 // Face unit interface normal
114 surfaceVectorField nHatfv = gradAlphaf/(mag(gradAlphaf) + deltaN_);
115 correctContactAngle(nHatfv.boundaryField());
117 // Face unit interface normal flux
118 nHatf_ = nHatfv & Sf;
120 // Simple expression for curvature
121 K_ = -fvc::div(nHatf_);
123 // Complex expression for curvature.
124 // Correction is formally zero but numerically non-zero.
126 volVectorField nHat = gradAlpha/(mag(gradAlpha) + deltaN_);
127 forAll(nHat.boundaryField(), patchi)
129 nHat.boundaryField()[patchi] = nHatfv.boundaryField()[patchi];
132 K_ = -fvc::div(nHatf_) + (nHat & fvc::grad(nHatfv) & nHat);
137 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
139 Foam::interfaceProperties::interfaceProperties
141 const volScalarField& alpha1,
142 const volVectorField& U,
143 const IOdictionary& dict
146 transportPropertiesDict_(dict),
151 alpha1.mesh().solutionDict().subDict("PISO").lookup("cAlpha")
154 sigma_(dict.lookup("sigma")),
159 1e-8/pow(average(alpha1.mesh().V()), 1.0/3.0)
170 alpha1_.time().timeName(),
174 dimensionedScalar("nHatf", dimArea, 0.0)
182 alpha1_.time().timeName(),
186 dimensionedScalar("K", dimless/dimLength, 0.0)
193 // ************************************************************************* //