reactingEulerFoam: Added update interval for population balance source terms.

This can be used to speedup simulations that converge to a steady state
by only updating the source terms once every few iterations. The number
of iterations between each update is set in fvSolution as follows:

    solvers
    {
        bubbles
        {
            sourceUpdateInterval 10;
        }

        // etc ...
    }

By default the interval is 1, and so the sources update every time.

Based on a patch contributed by Juho Peltola, VTT.
This commit is contained in:
Will Bainbridge
2018-11-05 09:28:03 +00:00
parent 9ecbf3b46f
commit 1c35e8a2f5
3 changed files with 51 additions and 15 deletions

View File

@ -841,6 +841,15 @@ void Foam::diameterModels::populationBalanceModel::calcVelocity()
}
}
bool Foam::diameterModels::populationBalanceModel::updateSources()
{
const bool result = sourceUpdateCounter_ % sourceUpdateInterval() == 0;
++ sourceUpdateCounter_;
return result;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -927,7 +936,11 @@ Foam::diameterModels::populationBalanceModel::populationBalanceModel
nucleationRate_(),
alphas_(),
dsm_(),
U_()
U_(),
sourceUpdateCounter_
(
(mesh_.time().timeIndex()*nCorr())%sourceUpdateInterval()
)
{
this->registerVelocityAndSizeGroups();
@ -1224,22 +1237,14 @@ Foam::diameterModels::populationBalanceModel::continuousTurbulence() const
void Foam::diameterModels::populationBalanceModel::solve()
{
const dictionary& solutionControls = mesh_.solverDict(name_);
bool solveOnFinalIterOnly
(
solutionControls.lookupOrDefault<bool>
(
"solveOnFinalIterOnly",
false
)
);
bool solveOnFinalIterOnly =
solutionControls.lookupOrDefault<bool>("solveOnFinalIterOnly", false);
if (!solveOnFinalIterOnly || pimple_.finalIter())
{
label nCorr(readLabel(solutionControls.lookup("nCorr")));
scalar tolerance
(
readScalar(solutionControls.lookup("tolerance"))
);
const label nCorr = this->nCorr();
const scalar tolerance =
readScalar(solutionControls.lookup("tolerance"));
if (nCorr > 0)
{
@ -1257,7 +1262,10 @@ void Foam::diameterModels::populationBalanceModel::solve()
<< iCorr
<< endl;
sources();
if (updateSources())
{
sources();
}
dmdt();

View File

@ -277,6 +277,9 @@ class populationBalanceModel
//- Average velocity
autoPtr<volVectorField> U_;
//- Counter for interval between source term updates
label sourceUpdateCounter_;
// Private member functions
@ -316,6 +319,14 @@ class populationBalanceModel
void calcVelocity();
//- Return whether the sources should be updated on this iteration
bool updateSources();
//- Return the number of corrections
inline label nCorr() const;
//- Return the interval at which the sources are updated
inline label sourceUpdateInterval() const;
public:

View File

@ -23,6 +23,23 @@ License
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
inline Foam::label Foam::diameterModels::populationBalanceModel::nCorr() const
{
return mesh_.solverDict(name_).lookupType<label>("nCorr");
}
inline Foam::label
Foam::diameterModels::populationBalanceModel::sourceUpdateInterval() const
{
return
mesh_.solverDict(name_)
.lookupOrDefault<label>("sourceUpdateInterval", 1);
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::phaseSystem&