twoPhaseVoFSolver.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-2025 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 "twoPhaseVoFSolver.H"
27 #include "fvcAverage.H"
28 #include "interfaceCompression.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 namespace solvers
35 {
37 }
38 }
39 
40 
41 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
42 
43 void Foam::solvers::twoPhaseVoFSolver::correctCoNum()
44 {
46 
47  const scalarField sumPhi
48  (
49  interface.nearInterface()().primitiveField()
50  *fvc::surfaceSum(mag(phi))().primitiveField()
51  );
52 
53  alphaCoNum =
54  0.5*gMax(sumPhi/mesh.V().primitiveField())*runTime.deltaTValue();
55 
56  const scalar meanAlphaCoNum =
57  0.5
58  *(gSum(sumPhi)/gSum(mesh.V().primitiveField()))
60 
61  Info<< "Interface Courant Number mean: " << meanAlphaCoNum
62  << " max: " << alphaCoNum << endl;
63 }
64 
65 
66 // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
67 
69 {
70  interface.correct();
71 }
72 
73 
76 {
77  return interface.surfaceTensionForce();
78 }
79 
80 
81 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
82 
84 (
85  fvMesh& mesh,
87 )
88 :
89  twoPhaseSolver(mesh, mixturePtr),
90 
91  interface(mixture, alpha1, alpha2, U)
92 {
93  const word alphaScheme(mesh.schemes().div(divAlphaName)[1].wordToken());
94 
95  if (!compressionSchemes.found(alphaScheme))
96  {
98  << "Scheme " << alphaScheme << " for " << divAlphaName
99  << " is not an interface compression scheme:"
100  << compressionSchemes.toc() << endl;
101  }
102 
103  const dictionary& alphaControls = mesh.solution().solverDict(alpha1.name());
104 
105  if (alphaControls.found("cAlpha"))
106  {
108  << "Deprecated and unused cAlpha entry specified in "
109  << alphaControls.name() << nl
110  << "Please update the case to use one of the run-time "
111  "selectable interface compression schemes:"
113  }
114 
115  if (transient())
116  {
117  correctCoNum();
118  }
119 }
120 
121 
122 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
123 
125 {}
126 
127 
128 // ************************************************************************* //
List< Key > toc() const
Return the table of contents.
Definition: HashTable.C:227
bool found(const Key &) const
Return true if hashedEntry is found in table.
Definition: HashTable.C:138
const word & name() const
Return name.
Definition: IOobject.H:307
scalar deltaTValue() const
Return time step value.
Definition: TimeStateI.H:34
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
const fileName & name() const
Return the dictionary name.
Definition: dictionary.H:111
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:539
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:96
const DimensionedField< scalar, volMesh > & V() const
Return cell volumes.
const fvSchemes & schemes() const
Return the fvSchemes.
Definition: fvMesh.C:1799
const fvSolution & solution() const
Return the fvSolution.
Definition: fvMesh.C:1810
ITstream & div(const word &name) const
Definition: fvSchemes.C:423
tmp< volScalarField > nearInterface() const
Indicator of the proximity of the interface.
const dictionary & solverDict(const word &name) const
Return the solver controls dictionary for the given field.
Definition: solution.C:348
const Time & runTime
Time.
Definition: solver.H:104
const fvMesh & mesh
Region mesh.
Definition: solver.H:101
const word divAlphaName
Name of the alpha convection scheme.
Definition: VoFSolver.H:85
const surfaceScalarField & phi
Reference to the mass-flux field.
Definition: VoFSolver.H:216
scalar alphaCoNum
Phase-fraction flux Courant number.
Definition: VoFSolver.H:88
virtual void correctCoNum()=0
Correct the cached Courant numbers.
Definition: VoFSolver.C:75
Solver module base-class for 2 immiscible fluids, with optional mesh motion and mesh topology changes...
volScalarField & alpha1
Reference to the phase1-fraction.
Solver module base-class for 2 immiscible fluids using a VOF (volume of fluid) phase-fraction based i...
twoPhaseVoFSolver(fvMesh &mesh, autoPtr< twoPhaseVoFMixture >)
Construct from region mesh.
virtual tmp< surfaceScalarField > surfaceTensionForce() const
Return the interface surface tension force for the momentum equation.
virtual void correctInterface()
Correct the interface properties following mesh-change.
virtual ~twoPhaseVoFSolver()
Destructor.
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:62
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
Area-weighted average a surfaceField creating a volField.
U
Definition: pEqn.H:72
#define WarningInFunction
Report a warning using Foam::Warning.
tmp< VolInternalField< Type > > surfaceSum(const SurfaceField< Type > &ssf)
defineTypeNameAndDebug(compressibleMultiphaseVoF, 0)
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Type gSum(const FieldField< Field, Type > &f)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:258
messageStream Info
void mag(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const wordHashSet compressionSchemes
error FatalError
static const char nl
Definition: Ostream.H:267
Type gMax(const FieldField< Field, Type > &f)