1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. 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::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
53 const fvMesh& mesh = alpha1_.mesh();
54 const volScalarField::GeometricBoundaryField& gbf = alpha1_.boundaryField();
56 const fvBoundaryMesh& boundary = mesh.boundary();
58 forAll(boundary, patchi)
60 if (isA<alphaContactAngleFvPatchScalarField>(gbf[patchi]))
62 const alphaContactAngleFvPatchScalarField& gcap =
63 refCast<const alphaContactAngleFvPatchScalarField>
66 fvsPatchVectorField& nHatp = nHatb[patchi];
68 convertToRad*gcap.theta(U_.boundaryField()[patchi], nHatp);
70 vectorField nf = boundary[patchi].nf();
72 // Reset nHatp to correspond to the contact angle
74 scalarField a12 = nHatp & nf;
76 scalarField b1 = cos(theta);
78 scalarField b2(nHatp.size());
82 b2[facei] = cos(acos(a12[facei]) - theta[facei]);
85 scalarField det = 1.0 - a12*a12;
87 scalarField a = (b1 - a12*b2)/det;
88 scalarField b = (b2 - a12*b1)/det;
90 nHatp = a*nf + b*nHatp;
92 nHatp /= (mag(nHatp) + deltaN_.value());
98 void Foam::interfaceProperties::calculateK()
100 const fvMesh& mesh = alpha1_.mesh();
101 const surfaceVectorField& Sf = mesh.Sf();
103 // Cell gradient of alpha
104 volVectorField gradAlpha = fvc::grad(alpha1_);
106 // Interpolated face-gradient of alpha
107 surfaceVectorField gradAlphaf = fvc::interpolate(gradAlpha);
109 // (mesh.Sf()/mesh.magSf())
110 // *(fvc::snGrad(alpha1_) - (mesh.Sf() & gradAlphaf)/mesh.magSf());
112 // Face unit interface normal
113 surfaceVectorField nHatfv = gradAlphaf/(mag(gradAlphaf) + deltaN_);
114 correctContactAngle(nHatfv.boundaryField());
116 // Face unit interface normal flux
117 nHatf_ = nHatfv & Sf;
119 // Simple expression for curvature
120 K_ = -fvc::div(nHatf_);
122 // Complex expression for curvature.
123 // Correction is formally zero but numerically non-zero.
125 volVectorField nHat = gradAlpha/(mag(gradAlpha) + deltaN_);
126 forAll(nHat.boundaryField(), patchi)
128 nHat.boundaryField()[patchi] = nHatfv.boundaryField()[patchi];
131 K_ = -fvc::div(nHatf_) + (nHat & fvc::grad(nHatfv) & nHat);
136 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
138 Foam::interfaceProperties::interfaceProperties
140 const volScalarField& alpha1,
141 const volVectorField& U,
142 const IOdictionary& dict
145 transportPropertiesDict_(dict),
150 alpha1.mesh().solutionDict().subDict("PISO").lookup("cAlpha")
153 sigma_(dict.lookup("sigma")),
158 1e-8/pow(average(alpha1.mesh().V()), 1.0/3.0)
169 alpha1_.time().timeName(),
173 dimensionedScalar("nHatf", dimArea, 0.0)
181 alpha1_.time().timeName(),
185 dimensionedScalar("K", dimless/dimLength, 0.0)
192 // ************************************************************************* //