threePhaseInterfaceProperties.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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
19  for more details.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
27 #include "alphaContactAngleFvPatchScalarField.H"
28 #include "unitConversion.H"
29 #include "surfaceInterpolate.H"
30 #include "fvcDiv.H"
31 #include "fvcGrad.H"
32 #include "fvcSnGrad.H"
33 
34 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
35 
36 void Foam::threePhaseInterfaceProperties::correctContactAngle
37 (
38  surfaceVectorField::Boundary& nHatb
39 ) const
40 {
41  const volScalarField::Boundary& alpha1 =
42  mixture_.alpha1().boundaryField();
43  const volScalarField::Boundary& alpha2 =
44  mixture_.alpha2().boundaryField();
45  const volScalarField::Boundary& alpha3 =
46  mixture_.alpha3().boundaryField();
47  const volVectorField::Boundary& U =
48  mixture_.U().boundaryField();
49 
50  const fvMesh& mesh = mixture_.U().mesh();
51  const fvBoundaryMesh& boundary = mesh.boundary();
52 
53  forAll(boundary, patchi)
54  {
55  if (isA<alphaContactAngleFvPatchScalarField>(alpha1[patchi]))
56  {
57  const alphaContactAngleFvPatchScalarField& a2cap =
58  refCast<const alphaContactAngleFvPatchScalarField>
59  (alpha2[patchi]);
60 
61  const alphaContactAngleFvPatchScalarField& a3cap =
62  refCast<const alphaContactAngleFvPatchScalarField>
63  (alpha3[patchi]);
64 
65  scalarField twoPhaseAlpha2(max(a2cap, scalar(0)));
66  scalarField twoPhaseAlpha3(max(a3cap, scalar(0)));
67 
68  scalarField sumTwoPhaseAlpha
69  (
70  twoPhaseAlpha2 + twoPhaseAlpha3 + small
71  );
72 
73  twoPhaseAlpha2 /= sumTwoPhaseAlpha;
74  twoPhaseAlpha3 /= sumTwoPhaseAlpha;
75 
76  fvsPatchVectorField& nHatp = nHatb[patchi];
77 
78  scalarField theta
79  (
80  degToRad
81  (
82  twoPhaseAlpha2*(180 - a2cap.theta(U[patchi], nHatp))
83  + twoPhaseAlpha3*(180 - a3cap.theta(U[patchi], nHatp))
84  )
85  );
86 
87  vectorField nf(boundary[patchi].nf());
88 
89  // Reset nHatPatch to correspond to the contact angle
90 
91  scalarField a12(nHatp & nf);
92 
93  scalarField b1(cos(theta));
94 
95  scalarField b2(nHatp.size());
96 
97  forAll(b2, facei)
98  {
99  b2[facei] = cos(acos(a12[facei]) - theta[facei]);
100  }
101 
102  scalarField det(1.0 - a12*a12);
103 
104  scalarField a((b1 - a12*b2)/det);
105  scalarField b((b2 - a12*b1)/det);
106 
107  nHatp = a*nf + b*nHatp;
108 
109  nHatp /= (mag(nHatp) + deltaN_.value());
110  }
111  }
112 }
113 
114 
115 void Foam::threePhaseInterfaceProperties::calculateK()
116 {
117  const volScalarField& alpha1 = mixture_.alpha1();
118 
119  const fvMesh& mesh = alpha1.mesh();
120  const surfaceVectorField& Sf = mesh.Sf();
121 
122  // Cell gradient of alpha
123  volVectorField gradAlpha(fvc::grad(alpha1));
124 
125  // Interpolated face-gradient of alpha
126  surfaceVectorField gradAlphaf(fvc::interpolate(gradAlpha));
127 
128  // Face unit interface normal
129  surfaceVectorField nHatfv(gradAlphaf/(mag(gradAlphaf) + deltaN_));
130 
131  correctContactAngle(nHatfv.boundaryFieldRef());
132 
133  // Face unit interface normal flux
134  nHatf_ = nHatfv & Sf;
135 
136  // Simple expression for curvature
137  K_ = -fvc::div(nHatf_);
138 
139  // Complex expression for curvature.
140  // Correction is formally zero but numerically non-zero.
141  // volVectorField nHat = gradAlpha/(mag(gradAlpha) + deltaN_);
142  // nHat.boundaryField() = nHatfv.boundaryField();
143  // K_ = -fvc::div(nHatf_) + (nHat & fvc::grad(nHatfv) & nHat);
144 }
145 
146 
147 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
148 
150 (
151  const incompressibleThreePhaseMixture& mixture
152 )
153 :
154  mixture_(mixture),
155  cAlpha_
156  (
157  mixture.U().mesh().solverDict
158  (
159  mixture_.alpha1().name()
160  ).lookup<scalar>("cAlpha")
161  ),
162  sigma12_("sigma12", dimensionSet(1, 0, -2, 0, 0), mixture),
163  sigma13_("sigma13", dimensionSet(1, 0, -2, 0, 0), mixture),
164 
165  deltaN_
166  (
167  "deltaN",
168  1e-8/pow(average(mixture.U().mesh().V()), 1.0/3.0)
169  ),
170 
171  nHatf_
172  (
173  IOobject
174  (
175  "nHatf",
176  mixture.alpha1().time().timeName(),
177  mixture.alpha1().mesh()
178  ),
179  mixture.alpha1().mesh(),
181  ),
182 
183  K_
184  (
185  IOobject
186  (
187  "interfaceProperties:K",
188  mixture.alpha1().time().timeName(),
189  mixture.alpha1().mesh()
190  ),
191  mixture.alpha1().mesh(),
193  )
194 {
195  calculateK();
196 }
197 
198 
199 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
200 
203 {
204  return fvc::interpolate(sigmaK())*fvc::snGrad(mixture_.alpha1());
205 }
206 
207 
210 {
211  return max
212  (
213  pos0(mixture_.alpha1() - 0.01)*pos0(0.99 - mixture_.alpha1()),
214  pos0(mixture_.alpha2() - 0.01)*pos0(0.99 - mixture_.alpha2())
215  );
216 }
217 
218 
219 // ************************************************************************* //
fvsPatchField< vector > fvsPatchVectorField
tmp< GeometricField< typename outerProduct< vector, Type >::type, fvPatchField, volMesh >> grad(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcGrad.C:52
dimensionedScalar acos(const dimensionedScalar &ds)
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
tmp< volScalarField > nearInterface() const
Indicator of the proximity of the interface.
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
const Boundary & boundaryField() const
Return const-reference to the boundary field.
tmp< GeometricField< Type, fvPatchField, volMesh > > div(const GeometricField< Type, fvsPatchField, surfaceMesh > &ssf)
Definition: fvcDiv.C:47
Unit conversion functions.
GeometricField< vector, fvsPatchField, surfaceMesh > surfaceVectorField
Calculate the snGrad of the given volField.
dimensionedScalar det(const dimensionedSphericalTensor &dt)
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:58
scalar degToRad(const scalar deg)
Conversion from degrees to radians.
tmp< surfaceScalarField > surfaceTensionForce() const
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:57
stressControl lookup("compactNormalStress") >> compactNormalStress
dimensionedScalar cos(const dimensionedScalar &ds)
const dimensionedScalar & b
Wien displacement law constant: default SI units: [m K].
Definition: createFields.H:27
Calculate the gradient of the given field.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const Type & value() const
Return const reference to value.
word timeName
Definition: getTimeIndex.H:3
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &df)
Calculate the divergence of the given field.
dimensionedScalar pos0(const dimensionedScalar &ds)
threePhaseInterfaceProperties(const incompressibleThreePhaseMixture &mixture)
Construct from volume fraction field alpha and IOdictionary.
const Mesh & mesh() const
Return mesh.
const volVectorField & U() const
Return the velocity.
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
static tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &tvf, const surfaceScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
label patchi
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:47
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:50
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
dimensioned< scalar > mag(const dimensioned< Type > &)
Field< vector > vectorField
Specialisation of Field<T> for vector.
const doubleScalar e
Elementary charge.
Definition: doubleScalar.H:105
A class for managing temporary objects.
Definition: PtrList.H:53
phaseChangeTwoPhaseMixture & mixture
Definition: createFields.H:38
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > snGrad(const GeometricField< Type, fvPatchField, volMesh > &vf, const word &name)
Definition: fvcSnGrad.C:45
const dimensionSet dimArea(sqr(dimLength))
Definition: dimensionSets.H:57