Skip to content

Commit 1706ec9

Browse files
author
Henry Weller
committed
multiphaseEuler: nAlphaSubCycles is now a Function1 of the alpha Courant number
The explicit MULES sub-cycling control nAlphaSubCycles is now a Function1 of the alpha Courant number which allows a very convenient way to specify the number of sub-cycles independent of the time-step the case is run with while maintaining stability of the explicit solution of the phase-fraction. For example with the following entry in fvSolution of the pipeBend case: solvers { "alpha.*" { nAlphaSubCycles polynomial (0 3); } . . . nAlphaSubCycles is evaluated as three times the current maximum alpha Courant number rounded upwards to an integer, i.e. given the maximum Courant number is set to 1 for this case 3 sub-cycles will be executed.
1 parent db3fad6 commit 1706ec9

File tree

8 files changed

+84
-24
lines changed

8 files changed

+84
-24
lines changed

applications/modules/multiphaseEuler/multiphaseEuler.C

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ bool Foam::solvers::multiphaseEuler::read()
6161
nEnergyCorrectors =
6262
pimple.dict().lookupOrDefault<int>("nEnergyCorrectors", 1);
6363

64+
alphaControls.read(mesh.solution().solverDict("alpha"));
65+
6466
return true;
6567
}
6668

@@ -247,7 +249,8 @@ void Foam::solvers::multiphaseEuler::prePredictor()
247249
{
248250
if (pimple.thermophysics() || pimple.flow())
249251
{
250-
fluid_.solve(rAs);
252+
alphaControls.correct(CoNum);
253+
fluid_.solve(alphaControls, rAs);
251254
fluid_.correct();
252255
fluid_.correctContinuityError();
253256
}

applications/modules/multiphaseEuler/multiphaseEuler.H

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ protected:
9494
// Defaults to 1
9595
int nEnergyCorrectors;
9696

97+
phaseSystem::alphaControl alphaControls;
98+
9799

98100
//- Optional LTS reciprocal time-step field
99101
tmp<volScalarField> trDeltaT;

applications/modules/multiphaseEuler/phaseSystem/phaseSystem/phaseSystem.H

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,46 @@ class phaseSystem
7474
{
7575
public:
7676

77+
// Public Types
78+
79+
struct alphaControl
80+
{
81+
//- Function to calculate the number of explicit MULES sub-cycles
82+
// from the alpha Courant number
83+
autoPtr<Function1<scalar>> nAlphaSubCyclesPtr;
84+
85+
label nAlphaSubCycles;
86+
87+
//- Number of alpha correctors
88+
// Usually used to improve the accuracy at high Courant numbers
89+
// with semi-implicit MULES, MULESCorr = true
90+
label nAlphaCorr;
91+
92+
scalar vDotResidualAlpha;
93+
94+
void correct(const scalar CoNum)
95+
{
96+
nAlphaSubCycles = ceil(nAlphaSubCyclesPtr->value(CoNum));
97+
}
98+
99+
void read(const dictionary& dict)
100+
{
101+
nAlphaSubCyclesPtr = Function1<scalar>::New
102+
(
103+
"nAlphaSubCycles",
104+
dimless,
105+
dimless,
106+
dict
107+
);
108+
109+
nAlphaCorr = dict.lookupOrDefault<label>("nAlphaCorr", 1);
110+
111+
vDotResidualAlpha =
112+
dict.lookupOrDefault("vDotResidualAlpha", 1e-4);
113+
}
114+
};
115+
116+
77117
// Public Typedefs
78118

79119
typedef HashPtrTable<fvVectorMatrix> momentumTransferTable;
@@ -528,7 +568,11 @@ public:
528568
// Evolution
529569

530570
//- Solve for the phase fractions
531-
virtual void solve(const PtrList<volScalarField>& rAs);
571+
virtual void solve
572+
(
573+
const alphaControl& alphaControls,
574+
const PtrList<volScalarField>& rAs
575+
);
532576

533577
//- Correct the fluid properties other than those listed below
534578
virtual void correct();

applications/modules/multiphaseEuler/phaseSystem/phaseSystem/phaseSystemSolve.C

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
========= |
33
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
44
\\ / O peration | Website: https://openfoam.org
5-
\\ / A nd | Copyright (C) 2013-2024 OpenFOAM Foundation
5+
\\ / A nd | Copyright (C) 2013-2025 OpenFOAM Foundation
66
\\/ M anipulation |
77
-------------------------------------------------------------------------------
88
License
@@ -41,20 +41,15 @@ License
4141

4242
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
4343

44-
void Foam::phaseSystem::solve(const PtrList<volScalarField>& rAs)
44+
void Foam::phaseSystem::solve
45+
(
46+
const alphaControl& alphaControls,
47+
const PtrList<volScalarField>& rAs
48+
)
4549
{
46-
const dictionary& alphaControls = mesh_.solution().solverDict("alpha");
47-
48-
const label nAlphaSubCycles(alphaControls.lookup<label>("nAlphaSubCycles"));
49-
const label nAlphaCorr(alphaControls.lookup<label>("nAlphaCorr"));
50-
50+
const label nAlphaSubCycles = alphaControls.nAlphaSubCycles;
5151
const bool LTS = fv::localEulerDdt::enabled(mesh_);
5252

53-
const scalar vDotResidualAlpha
54-
(
55-
alphaControls.lookupOrDefault("vDotResidualAlpha", 1e-4)
56-
);
57-
5853
// Optional reference phase which is not solved for
5954
// but obtained from the sum of the other phases
6055
phaseModel* referencePhasePtr = nullptr;
@@ -122,7 +117,7 @@ void Foam::phaseSystem::solve(const PtrList<volScalarField>& rAs)
122117
}
123118
}
124119

125-
for (int acorr=0; acorr<nAlphaCorr; acorr++)
120+
for (int acorr=0; acorr<alphaControls.nAlphaCorr; acorr++)
126121
{
127122
PtrList<volScalarField::Internal> Sps(phases().size());
128123
PtrList<volScalarField::Internal> Sus(phases().size());
@@ -201,16 +196,28 @@ void Foam::phaseSystem::solve(const PtrList<volScalarField>& rAs)
201196
{
202197
Sp[celli] -=
203198
vDot[celli]
204-
/max(1 - alpha[celli], vDotResidualAlpha);
199+
/max
200+
(
201+
1 - alpha[celli],
202+
alphaControls.vDotResidualAlpha
203+
);
205204
Su[celli] +=
206205
vDot[celli]
207-
/max(1 - alpha[celli], vDotResidualAlpha);
206+
/max
207+
(
208+
1 - alpha[celli],
209+
alphaControls.vDotResidualAlpha
210+
);
208211
}
209212
else if (vDot[celli] < 0)
210213
{
211214
Sp[celli] +=
212215
vDot[celli]
213-
/max(alpha[celli], vDotResidualAlpha);
216+
/max
217+
(
218+
alpha[celli],
219+
alphaControls.vDotResidualAlpha
220+
);
214221
}
215222
}
216223
}

applications/modules/multiphaseEuler/phaseSystems/PopulationBalancePhaseSystem/PopulationBalancePhaseSystem.C

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
========= |
33
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
44
\\ / O peration | Website: https://openfoam.org
5-
\\ / A nd | Copyright (C) 2017-2023 OpenFOAM Foundation
5+
\\ / A nd | Copyright (C) 2017-2025 OpenFOAM Foundation
66
\\/ M anipulation |
77
-------------------------------------------------------------------------------
88
License
@@ -175,10 +175,11 @@ Foam::PopulationBalancePhaseSystem<BasePhaseSystem>::specieTransfer() const
175175
template<class BasePhaseSystem>
176176
void Foam::PopulationBalancePhaseSystem<BasePhaseSystem>::solve
177177
(
178+
const phaseSystem::alphaControl& alphaControls,
178179
const PtrList<volScalarField>& rAs
179180
)
180181
{
181-
BasePhaseSystem::solve(rAs);
182+
BasePhaseSystem::solve(alphaControls, rAs);
182183

183184
forAll(populationBalances_, i)
184185
{

applications/modules/multiphaseEuler/phaseSystems/PopulationBalancePhaseSystem/PopulationBalancePhaseSystem.H

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
========= |
33
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
44
\\ / O peration | Website: https://openfoam.org
5-
\\ / A nd | Copyright (C) 2017-2023 OpenFOAM Foundation
5+
\\ / A nd | Copyright (C) 2017-2025 OpenFOAM Foundation
66
\\/ M anipulation |
77
-------------------------------------------------------------------------------
88
License
@@ -97,7 +97,11 @@ public:
9797
specieTransfer() const;
9898

9999
//- Solve all population balance equations
100-
virtual void solve(const PtrList<volScalarField>& rAs);
100+
virtual void solve
101+
(
102+
const phaseSystem::alphaControl& alphaControls,
103+
const PtrList<volScalarField>& rAs
104+
);
101105

102106
//- Correct derived properties
103107
virtual void correct();

tutorials/multiphaseEuler/bubbleColumn/system/fvSolution

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ solvers
1818
{
1919
"alpha.*"
2020
{
21-
nAlphaCorr 1;
2221
nAlphaSubCycles 2;
2322
}
2423

tutorials/multiphaseEuler/pipeBend/system/fvSolution

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ solvers
1818
"alpha.*"
1919
{
2020
nAlphaCorr 1;
21-
nAlphaSubCycles 3;
21+
nAlphaSubCycles polynomial (0 3);
2222
implicitPhasePressure yes;
2323
solver PBiCGStab;
2424
preconditioner DIC;

0 commit comments

Comments
 (0)