correctAlpha.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) 2023-2026 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 
26 #include "isothermalFilm.H"
27 #include "surfaceTensionModel.H"
28 #include "constrainHbyA.H"
29 #include "fvcFlux.H"
30 #include "fvcSnGrad.H"
31 #include "fvcReconstruct.H"
32 #include "fvmDiv.H"
33 #include "fvmLaplacian.H"
34 
35 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
36 
37 void Foam::solvers::isothermalFilm::constrainFixedFlux
38 (
39  surfaceScalarField& pbByAlphaf,
40  surfaceScalarField& pbByAlphaGradRhof,
41  surfaceScalarField& phip
42 )
43 {
44  surfaceScalarField::Boundary& pbByAlphaBf = pbByAlphaf.boundaryFieldRef();
45 
46  surfaceScalarField::Boundary& pbByAlphaGradRhoBf =
47  pbByAlphaGradRhof.boundaryFieldRef();
48 
49  surfaceScalarField::Boundary& phipBf = phip.boundaryFieldRef();
50 
52 
54  {
55  if (!UBf[patchi].assignable())
56  {
57  pbByAlphaBf[patchi] = 0;
58  pbByAlphaGradRhoBf[patchi] = 0;
59  phipBf[patchi] = 0;
60  }
61  }
62 }
63 
64 
65 void Foam::solvers::isothermalFilm::correctAlpha()
66 {
67  volScalarField& alpha = alpha_;
68 
69  fvVectorMatrix& UEqn = tUEqn.ref();
70 
72 
73  surfaceScalarField pbByAlphaf(this->pbByAlphaf());
74  surfaceScalarField pbByAlphaGradRhof
75  (
76  constrainedField(this->pbByAlphaGradRhof()*mesh.magSf())
77  );
78 
80  (
81  constrainedField
82  (
83  fvc::snGrad(pe() + pc(surfaceTension->sigma()), "snGrad(p)")
84  *mesh.magSf()
85  - rhof*(g & mesh.Sf())
86  )
87  );
88 
89  constrainFixedFlux(pbByAlphaf, pbByAlphaGradRhof, phip);
90 
91  while (pimple.correct())
92  {
93  const volScalarField rAU(1/UEqn.A());
95 
96  const surfaceScalarField alphaf
97  (
98  constrainedField(fvc::interpolate(alpha))
99  );
100 
101  const surfaceScalarField alpharAUf
102  (
103  constrainedField(fvc::interpolate(alpha*rAU))
104  );
105 
106  const surfaceScalarField phig("phig", phip + pbByAlphaGradRhof*alphaf);
107 
108  phi_ = constrainedField(fvc::flux(HbyA) - alpharAUf*phig);
109 
110  const surfaceScalarField phid("phid", rhof*phi);
111 
112  const surfaceScalarField rAUf
113  (
114  "rAUf",
115  alphaf*rhof*alpharAUf*pbByAlphaf
116  );
117 
118  fvScalarMatrix alphadEqn
119  (
120  fvm::ddt(rho, alpha)
121  + fvm::div(phid, alpha)
122  ==
123  fvModels().source(rho, alpha)
124  );
125 
126  while (pimple.correctNonOrthogonal())
127  {
128  fvScalarMatrix alphaEqn(alphadEqn - fvm::laplacian(rAUf, alpha));
129 
130  alphaEqn.solve();
131 
132  if (pimple.finalNonOrthogonalIter())
133  {
134  alphaRhoPhi_ = alphaEqn.flux();
135  }
136  }
137 
138  const surfaceScalarField phiGradAlpha
139  (
140  constrainedField(pbByAlphaf*fvc::snGrad(alpha)*mesh.magSf())
141  );
142 
143  phi_ -= alpharAUf*phiGradAlpha;
144 
145  U_ = HbyA - rAU*fvc::reconstruct(alphaf*(phig + phiGradAlpha));
146 
147  // Remove film-normal component of velocity
148  U_ -= nHat*(nHat & U);
149 
150  U_.correctBoundaryConditions();
151 
152  fvConstraints().constrain(U_);
153 
155 
156  continuityErrors();
157  }
158 
159  // Update film thickness
160  correctDelta();
161 
162  tUEqn.clear();
163 }
164 
165 
166 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
const Boundary & boundaryField() const
Return const-reference to the boundary field.
GeometricBoundaryField< Type, GeoMesh, PrimitiveField > Boundary
Type of the boundary field.
bool constrain(fvMatrix< Type > &eqn) const
Apply constraints to an equation.
const fvBoundaryMesh & boundary() const
Return reference to boundary mesh.
Definition: fvMesh.C:932
const surfaceVectorField & Sf() const
Return cell face area vectors.
const surfaceScalarField & magSf() const
Return cell face area magnitudes.
const fvMesh & mesh
Region mesh.
Definition: solver.H:101
const volVectorField & U
Reference to the film velocity field.
tmp< fvVectorMatrix > tUEqn(fvm::div(phi, U)+MRF.DDt(rho, U)+turbulence->divDevTau(U)==fvModels.source(rho, U))
fvVectorMatrix & UEqn
Definition: UEqn.H:11
Foam::fvConstraints & fvConstraints(Foam::fvConstraints::New(mesh))
Foam::fvModels & fvModels(Foam::fvModels::New(mesh))
pimpleControl pimple(mesh)
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
Calculate the face-flux of the given field.
Reconstruct volField from a face flux field.
Calculate the snGrad of the given volField.
Calculate the matrix for the divergence of the given field and flux.
Calculate the matrix for the laplacian of the field.
label patchi
volScalarField rAU(1.0/UEqn.A())
U
Definition: pEqn.H:72
rho
Definition: pEqn.H:1
volVectorField & HbyA
Definition: pEqn.H:13
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
tmp< SurfaceField< typename innerProduct< vector, Type >::type > > flux(const VolField< Type > &vf)
Return the face-flux field obtained from the given volVectorField.
static tmp< SurfaceField< Type > > interpolate(const VolField< Type > &tvf, const surfaceScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
tmp< VolField< typename outerProduct< vector, Type >::type > > reconstruct(const SurfaceField< Type > &ssf)
tmp< SurfaceField< Type > > snGrad(const VolField< Type > &vf, const word &name)
Definition: fvcSnGrad.C:45
tmp< fvMatrix< Type > > laplacian(const VolField< Type > &vf, const word &name)
Definition: fvmLaplacian.C:47
tmp< fvMatrix< Type > > div(const surfaceScalarField &flux, const VolField< Type > &vf, const word &name)
Definition: fvmDiv.C:48
tmp< fvMatrix< Type > > ddt(const VolField< Type > &vf)
Definition: fvmDdt.C:46
VolField< vector > volVectorField
Definition: volFieldsFwd.H:63
fvMatrix< scalar > fvScalarMatrix
Definition: fvMatricesFwd.H:42
SurfaceField< scalar > surfaceScalarField
void constrainHbyA(volVectorField &HbyA, const volVectorField &U, const volScalarField &p)
Definition: constrainHbyA.C:34
VolField< scalar > volScalarField
Definition: volFieldsFwd.H:62
fvMatrix< vector > fvVectorMatrix
Definition: fvMatricesFwd.H:45