1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2008 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
29 Properties to aid interFoam :
30 1. Correct the gamma boundary condition for dynamic contact angle.
31 2. Calculate interface curvature.
33 \*---------------------------------------------------------------------------*/
35 #include "interfaceProperties.H"
36 #include "gammaContactAngleFvPatchScalarField.H"
37 #include "mathematicalConstants.H"
38 #include "surfaceInterpolate.H"
41 #include "fvcSnGrad.H"
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 // * * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * //
50 const scalar interfaceProperties::convertToRad =
51 mathematicalConstant::pi/180.0;
54 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
56 // Correction for the boundary condition on the unit normal nHat on
57 // walls to produce the correct contact angle.
59 // The dynamic contact angle is calculated from the component of the
60 // velocity on the direction of the interface, parallel to the wall.
62 void interfaceProperties::correctContactAngle
64 surfaceVectorField::GeometricBoundaryField& nHatb
67 const fvMesh& mesh = gamma_.mesh();
68 const volScalarField::GeometricBoundaryField& gbf = gamma_.boundaryField();
70 const fvBoundaryMesh& boundary = mesh.boundary();
72 forAll(boundary, patchi)
74 if (isA<gammaContactAngleFvPatchScalarField>(gbf[patchi]))
76 const gammaContactAngleFvPatchScalarField& gcap =
77 refCast<const gammaContactAngleFvPatchScalarField>
80 fvsPatchVectorField& nHatp = nHatb[patchi];
82 convertToRad*gcap.theta(U_.boundaryField()[patchi], nHatp);
84 vectorField nf = boundary[patchi].nf();
86 // Reset nHatp to correspond to the contact angle
88 scalarField a12 = nHatp & nf;
90 scalarField b1 = cos(theta);
92 scalarField b2(nHatp.size());
96 b2[facei] = cos(acos(a12[facei]) - theta[facei]);
99 scalarField det = 1.0 - a12*a12;
101 scalarField a = (b1 - a12*b2)/det;
102 scalarField b = (b2 - a12*b1)/det;
104 nHatp = a*nf + b*nHatp;
106 nHatp /= (mag(nHatp) + deltaN_.value());
112 void interfaceProperties::calculateK()
114 const fvMesh& mesh = gamma_.mesh();
115 const surfaceVectorField& Sf = mesh.Sf();
117 // Cell gradient of gamma
118 volVectorField gradGamma = fvc::grad(gamma_);
120 // Interpolated face-gradient of gamma
121 surfaceVectorField gradGammaf = fvc::interpolate(gradGamma);
123 // (mesh.Sf()/mesh.magSf())
124 // *(fvc::snGrad(gamma_) - (mesh.Sf() & gradGammaf)/mesh.magSf());
126 // Face unit interface normal
127 surfaceVectorField nHatfv = gradGammaf/(mag(gradGammaf) + deltaN_);
128 correctContactAngle(nHatfv.boundaryField());
130 // Face unit interface normal flux
131 nHatf_ = nHatfv & Sf;
133 // Simple expression for curvature
134 K_ = -fvc::div(nHatf_);
136 // Complex expression for curvature.
137 // Correction is formally zero but numerically non-zero.
139 volVectorField nHat = gradGamma/(mag(gradGamma) + deltaN_);
140 forAll(nHat.boundaryField(), patchi)
142 nHat.boundaryField()[patchi] = nHatfv.boundaryField()[patchi];
145 K_ = -fvc::div(nHatf_) + (nHat & fvc::grad(nHatfv) & nHat);
150 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
152 interfaceProperties::interfaceProperties
154 const volScalarField& gamma,
155 const volVectorField& U,
156 const IOdictionary& dict
159 transportPropertiesDict_(dict),
164 gamma.mesh().solutionDict().subDict("PISO").lookup("cGamma")
167 sigma_(dict.lookup("sigma")),
172 1e-8/pow(average(gamma.mesh().V()), 1.0/3.0)
183 gamma_.time().timeName(),
187 dimensionedScalar("nHatf", dimArea, 0.0)
195 gamma_.time().timeName(),
199 dimensionedScalar("K", dimless/dimLength, 0.0)
206 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
208 } // End namespace Foam
210 // ************************************************************************* //