OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

interfaceProperties.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "interfaceProperties.H"
00028 #include "alphaContactAngleFvPatchScalarField.H"
00029 #include "mathematicalConstants.H"
00030 #include "surfaceInterpolate.H"
00031 #include "fvcDiv.H"
00032 #include "fvcGrad.H"
00033 #include "fvcSnGrad.H"
00034 
00035 // * * * * * * * * * * * * * * * Static Member Data  * * * * * * * * * * * * //
00036 
00037 const Foam::scalar Foam::interfaceProperties::convertToRad =
00038     Foam::mathematicalConstant::pi/180.0;
00039 
00040 
00041 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00042 
00043 // Correction for the boundary condition on the unit normal nHat on
00044 // walls to produce the correct contact angle.
00045 
00046 // The dynamic contact angle is calculated from the component of the
00047 // velocity on the direction of the interface, parallel to the wall.
00048 
00049 void Foam::interfaceProperties::correctContactAngle
00050 (
00051     surfaceVectorField::GeometricBoundaryField& nHatb
00052 ) const
00053 {
00054     const fvMesh& mesh = alpha1_.mesh();
00055     const volScalarField::GeometricBoundaryField& gbf = alpha1_.boundaryField();
00056 
00057     const fvBoundaryMesh& boundary = mesh.boundary();
00058 
00059     forAll(boundary, patchi)
00060     {
00061         if (isA<alphaContactAngleFvPatchScalarField>(gbf[patchi]))
00062         {
00063             const alphaContactAngleFvPatchScalarField& gcap =
00064                 refCast<const alphaContactAngleFvPatchScalarField>
00065                 (gbf[patchi]);
00066 
00067             fvsPatchVectorField& nHatp = nHatb[patchi];
00068             scalarField theta =
00069                 convertToRad*gcap.theta(U_.boundaryField()[patchi], nHatp);
00070 
00071             vectorField nf = boundary[patchi].nf();
00072 
00073             // Reset nHatp to correspond to the contact angle
00074 
00075             scalarField a12 = nHatp & nf;
00076 
00077             scalarField b1 = cos(theta);
00078 
00079             scalarField b2(nHatp.size());
00080 
00081             forAll(b2, facei)
00082             {
00083                 b2[facei] = cos(acos(a12[facei]) - theta[facei]);
00084             }
00085 
00086             scalarField det = 1.0 - a12*a12;
00087 
00088             scalarField a = (b1 - a12*b2)/det;
00089             scalarField b = (b2 - a12*b1)/det;
00090 
00091             nHatp = a*nf + b*nHatp;
00092 
00093             nHatp /= (mag(nHatp) + deltaN_.value());
00094         }
00095     }
00096 }
00097 
00098 
00099 void Foam::interfaceProperties::calculateK()
00100 {
00101     const fvMesh& mesh = alpha1_.mesh();
00102     const surfaceVectorField& Sf = mesh.Sf();
00103 
00104     // Cell gradient of alpha
00105     volVectorField gradAlpha = fvc::grad(alpha1_);
00106 
00107     // Interpolated face-gradient of alpha
00108     surfaceVectorField gradAlphaf = fvc::interpolate(gradAlpha);
00109     //gradAlphaf -=
00110     //    (mesh.Sf()/mesh.magSf())
00111     //   *(fvc::snGrad(alpha1_) - (mesh.Sf() & gradAlphaf)/mesh.magSf());
00112 
00113     // Face unit interface normal
00114     surfaceVectorField nHatfv = gradAlphaf/(mag(gradAlphaf) + deltaN_);
00115     correctContactAngle(nHatfv.boundaryField());
00116 
00117     // Face unit interface normal flux
00118     nHatf_ = nHatfv & Sf;
00119 
00120     // Simple expression for curvature
00121     K_ = -fvc::div(nHatf_);
00122 
00123     // Complex expression for curvature.
00124     // Correction is formally zero but numerically non-zero.
00125     /*
00126     volVectorField nHat = gradAlpha/(mag(gradAlpha) + deltaN_);
00127     forAll(nHat.boundaryField(), patchi)
00128     {
00129         nHat.boundaryField()[patchi] = nHatfv.boundaryField()[patchi];
00130     }
00131 
00132     K_ = -fvc::div(nHatf_) + (nHat & fvc::grad(nHatfv) & nHat);
00133     */
00134 }
00135 
00136 
00137 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00138 
00139 Foam::interfaceProperties::interfaceProperties
00140 (
00141     const volScalarField& alpha1,
00142     const volVectorField& U,
00143     const IOdictionary& dict
00144 )
00145 :
00146     transportPropertiesDict_(dict),
00147     cAlpha_
00148     (
00149         readScalar
00150         (
00151             alpha1.mesh().solutionDict().subDict("PISO").lookup("cAlpha")
00152         )
00153     ),
00154     sigma_(dict.lookup("sigma")),
00155 
00156     deltaN_
00157     (
00158         "deltaN",
00159         1e-8/pow(average(alpha1.mesh().V()), 1.0/3.0)
00160     ),
00161 
00162     alpha1_(alpha1),
00163     U_(U),
00164 
00165     nHatf_
00166     (
00167         IOobject
00168         (
00169             "nHatf",
00170             alpha1_.time().timeName(),
00171             alpha1_.mesh()
00172         ),
00173         alpha1_.mesh(),
00174         dimensionedScalar("nHatf", dimArea, 0.0)
00175     ),
00176 
00177     K_
00178     (
00179         IOobject
00180         (
00181             "K",
00182             alpha1_.time().timeName(),
00183             alpha1_.mesh()
00184         ),
00185         alpha1_.mesh(),
00186         dimensionedScalar("K", dimless/dimLength, 0.0)
00187     )
00188 {
00189     calculateK();
00190 }
00191 
00192 
00193 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd