multiphaseVoFSolver.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 "multiphaseVoFSolver.H"
27 #include "localEulerDdtScheme.H"
28 #include "fvcAverage.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::multiphaseVoFSolver::correctCoNum()
44 {
46 
47  const scalarField sumPhi
48  (
49  mixture.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 {
71 
72  const dictionary& alphaControls = mesh.solution().solverDict("alpha");
73 
74  cAlpha = alphaControls.lookup<scalar>("cAlpha");
75 
76  nAlphaSubCyclesPtr =
78  (
79  alphaControls.found("nAlphaSubCycles")
80  ? "nAlphaSubCycles"
81  : "nSubCycles",
82  dimless,
83  dimless,
84  alphaControls
85  );
86 
87  MULEScontrols.read(alphaControls);
88 
89  return true;
90 }
91 
92 
94 {}
95 
96 
99 {
100  return mixture.surfaceTensionForce(U);
101 }
102 
103 
104 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
105 
107 (
108  fvMesh& mesh,
110 )
111 :
112  VoFSolver(mesh, autoPtr<VoFMixture>(mixturePtr.ptr())),
113 
115 
116  phases(mixture.phases())
117 {
118  read();
119 
120  if (transient())
121  {
122  correctCoNum();
123  }
124 }
125 
126 
127 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
128 
130 {}
131 
132 
133 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
134 
136 {
138 }
139 
140 
142 {
143  alphaPredictor();
144 }
145 
146 
147 // ************************************************************************* //
static autoPtr< Function1< Type > > New(const word &name, const Function1s::unitConversions &units, const dictionary &dict)
Select from dictionary.
Definition: Function1New.C:32
scalar deltaTValue() const
Return time step value.
Definition: TimeStateI.H:34
Two-phase VoF mixture.
Definition: VoFMixture.H:52
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:740
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 fvSolution & solution() const
Return the fvSolution.
Definition: fvMesh.C:1810
Multiphase VoF mixture with support for interface properties.
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
Base solver module base-class for the solution of immiscible fluids using a VOF (volume of fluid) pha...
Definition: VoFSolver.H:73
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 preSolve()
Called at the start of the time-step, before the PIMPLE loop.
Definition: VoFSolver.C:199
virtual void correctCoNum()=0
Correct the cached Courant numbers.
Definition: VoFSolver.C:75
virtual bool read()
Read controls.
Definition: fluidSolver.C:51
Base solver module for the solution of multiple immiscible fluids using a VOF (volume of fluid) phase...
virtual tmp< surfaceScalarField > surfaceTensionForce() const
Return the interface surface tension force for the momentum equation.
virtual void prePredictor()
Called at the start of the PIMPLE loop.
multiphaseVoFSolver(fvMesh &mesh, autoPtr< multiphaseVoFMixture >)
Construct from region mesh.
multiphaseVoFMixture & mixture
Reference to the multiphaseVoFMixture.
virtual void preSolve()
Called at the start of the time-step, before the PIMPLE loop.
virtual void correctInterface()
Correct the interface properties following mesh-change.
virtual bool read()
Read controls.
A class for managing temporary objects.
Definition: tmp.H:55
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
Area-weighted average a surfaceField creating a volField.
U
Definition: pEqn.H:72
tmp< VolInternalField< Type > > surfaceSum(const SurfaceField< Type > &ssf)
defineTypeNameAndDebug(compressibleMultiphaseVoF, 0)
Namespace for OpenFOAM.
Type gSum(const FieldField< Field, Type > &f)
To & refCast(From &r)
Reference type cast template function.
Definition: typeInfo.H:134
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:258
const dimensionSet dimless
messageStream Info
void mag(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Type gMax(const FieldField< Field, Type > &f)