continuityPredictor.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 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 "fvcDdt.H"
28 #include "fvcDiv.H"
29 #include "fvmDdt.H"
30 
31 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
32 
33 void Foam::solvers::isothermalFilm::continuityPredictor()
34 {
35  // Update delta and alpha BCs for time-varying inlets etc.
38 
39  fvScalarMatrix alphaEqn
40  (
42  ==
43  fvModels().source(rho, alpha_)
44  );
45 
46  alphaEqn.solve();
47 
49 
50  // Remove potential unboundedness in alpha caused by div(alphaRhoPhi)
51  alpha_.max(0);
52 
53  // Calculate the continuity error caused by limiting alpha
54  // Reset to ~0 following the alpha corrector
55  correctContinuityError();
56 
57  // Update film thickness
58  correctDelta();
59 }
60 
61 
62 void Foam::solvers::isothermalFilm::correctContinuityError()
63 {
64  contErr =
65  (
66  fvc::ddt(rho, alpha)()() + fvc::div(alphaRhoPhi)()()
67  - (fvModels().source(rho, alpha) & alpha)()()
68  );
69 }
70 
71 
72 void Foam::solvers::isothermalFilm::correctDelta()
73 {
74  delta_ = alpha*VbyA;
75  delta_.correctBoundaryConditions();
76 }
77 
78 
79 // ************************************************************************* //
void max(const dimensioned< Type > &)
const Boundary & boundaryField() const
Return const-reference to the boundary field.
void correctBoundaryConditions()
Correct boundary field.
Boundary & boundaryFieldRef()
Return a reference to the boundary field.
bool constrain(fvMatrix< Type > &eqn) const
Apply constraints to an equation.
tmp< fvMatrix< Type > > source(const VolField< Type > &field) const
Return source for an equation.
Foam::fvModels & fvModels() const
Return the fvModels that are created on demand.
Definition: solver.C:96
Foam::fvConstraints & fvConstraints() const
Return the fvConstraints that are created on demand.
Definition: solver.C:107
const surfaceScalarField & alphaRhoPhi
Reference to the film mass-flux field.
volScalarField delta_
Film thickness.
const volScalarField & VbyA
Film cell volume/wall face area.
const volScalarField & delta
Film thickness.
const volScalarField & rho
Reference to the thermodynamic density field.
volScalarField alpha_
Film volume fraction in the cell layer.
Foam::fvModels & fvModels(Foam::fvModels::New(mesh))
Calculate the first temporal derivative.
Calculate the divergence of the given field.
Calculate the matrix for the first temporal derivative.
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
tmp< VolField< Type > > ddt(const dimensioned< Type > dt, const fvMesh &mesh)
Definition: fvcDdt.C:45
tmp< VolField< Type > > div(const SurfaceField< Type > &ssf)
Definition: fvcDiv.C:47
tmp< fvMatrix< Type > > ddt(const VolField< Type > &vf)
Definition: fvmDdt.C:46
fvMatrix< scalar > fvScalarMatrix
Definition: fvMatricesFwd.H:42