multicomponentFluid: Correct boundary conditions of non-solved species

Whilst the cell values of non-solved species do not change, the boundary
values might, and correcting them is necessary for certain
post-processing operations to produce sensible results.
This commit is contained in:
Will Bainbridge
2024-07-04 09:10:17 +01:00
parent 728c14c902
commit 71dd72fef4
7 changed files with 56 additions and 85 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2022-2024 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -44,11 +44,11 @@ void Foam::solvers::multicomponentFluid::thermophysicalPredictor()
reaction->correct();
forAll(Y, i)
{
if (thermo_.solveSpecie(i))
{
volScalarField& Yi = Y_[i];
if (thermo_.solveSpecie(i))
{
fvScalarMatrix YiEqn
(
fvm::ddt(rho, Yi)
@ -67,6 +67,10 @@ void Foam::solvers::multicomponentFluid::thermophysicalPredictor()
fvConstraints().constrain(Yi);
}
else
{
Yi.correctBoundaryConditions();
}
}
thermo_.normaliseY();

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2015-2023 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2015-2024 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -296,11 +296,9 @@ public:
//- Access the species mass fractions
virtual PtrList<volScalarField>& YRef() = 0;
//- Return the active species mass fractions
virtual const UPtrList<volScalarField>& YActive() const = 0;
//- Access the active species mass fractions
virtual UPtrList<volScalarField>& YActiveRef() = 0;
//- Should the given specie be solved for? I.e., is it active and
// not the default specie?
virtual bool solveSpecie(const label speciei) const = 0;
//- Return the fuel consumption rate matrix
virtual tmp<fvScalarMatrix> R(volScalarField& Yi) const = 0;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2015-2023 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2015-2024 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -47,19 +47,7 @@ Foam::MulticomponentPhaseModel<BasePhaseModel>::MulticomponentPhaseModel
)
:
BasePhaseModel(fluid, phaseName, referencePhase, index)
{
PtrList<volScalarField>& Y = this->thermo_->Y();
forAll(Y, i)
{
if (this->thermo_->solveSpecie(i))
{
const label j = YActive_.size();
YActive_.resize(j + 1);
YActive_.set(j, &Y[i]);
}
}
}
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
@ -142,18 +130,12 @@ Foam::MulticomponentPhaseModel<BasePhaseModel>::YRef()
template<class BasePhaseModel>
const Foam::UPtrList<Foam::volScalarField>&
Foam::MulticomponentPhaseModel<BasePhaseModel>::YActive() const
bool Foam::MulticomponentPhaseModel<BasePhaseModel>::solveSpecie
(
const label speciei
) const
{
return YActive_;
}
template<class BasePhaseModel>
Foam::UPtrList<Foam::volScalarField>&
Foam::MulticomponentPhaseModel<BasePhaseModel>::YActiveRef()
{
return YActive_;
return this->thermo_->solveSpecie(speciei);
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2015-2023 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2015-2024 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -52,14 +52,6 @@ class MulticomponentPhaseModel
:
public BasePhaseModel
{
protected:
// Protected data
//- Pointer list to active species
UPtrList<volScalarField> YActive_;
public:
// Constructors
@ -82,6 +74,7 @@ public:
//- Correct the species fractions
virtual void correctSpecies();
// Species
//- Return whether the phase is pure (i.e., not multi-component)
@ -99,11 +92,9 @@ public:
//- Access the species mass fractions
virtual PtrList<volScalarField>& YRef();
//- Return the active species mass fractions
virtual const UPtrList<volScalarField>& YActive() const;
//- Access the active species mass fractions
virtual UPtrList<volScalarField>& YActiveRef();
//- Should the given specie be solved for? I.e., is it active and
// not the default specie?
virtual bool solveSpecie(const label speciei) const;
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2015-2023 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2015-2024 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -104,24 +104,12 @@ Foam::PurePhaseModel<BasePhaseModel>::YRef()
template<class BasePhaseModel>
const Foam::UPtrList<Foam::volScalarField>&
Foam::PurePhaseModel<BasePhaseModel>::YActive() const
bool Foam::PurePhaseModel<BasePhaseModel>::solveSpecie
(
const label speciei
) const
{
// Y_ has never been set, so we are returning an empty list
return Y_;
}
template<class BasePhaseModel>
Foam::UPtrList<Foam::volScalarField>&
Foam::PurePhaseModel<BasePhaseModel>::YActiveRef()
{
FatalErrorInFunction
<< "Cannot access the species fractions of for a pure phase"
<< exit(FatalError);
return Y_;
return false;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2015-2023 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2015-2024 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -96,11 +96,9 @@ public:
//- Access the species mass fractions
virtual PtrList<volScalarField>& YRef();
//- Return the active species mass fractions
virtual const UPtrList<volScalarField>& YActive() const;
//- Access the active species mass fractions
virtual UPtrList<volScalarField>& YActiveRef();
//- Should the given specie be solved for? I.e., is it active and
// not the default specie?
virtual bool solveSpecie(const label speciei) const;
};

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | Website: https://openfoam.org
\\ / A nd | Copyright (C) 2022-2023 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2022-2024 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -47,11 +47,13 @@ void Foam::solvers::multiphaseEuler::compositionPredictor()
{
phaseModel& phase = fluid_.multicomponentPhases()[multicomponentPhasei];
UPtrList<volScalarField>& Y = phase.YActiveRef();
UPtrList<volScalarField>& Y = phase.YRef();
const volScalarField& alpha = phase;
const volScalarField& rho = phase.rho();
forAll(Y, i)
{
if (phase.solveSpecie(i))
{
fvScalarMatrix YiEqn
(
@ -62,10 +64,18 @@ void Foam::solvers::multiphaseEuler::compositionPredictor()
);
YiEqn.relax();
fvConstraints().constrain(YiEqn);
YiEqn.solve("Yi");
fvConstraints().constrain(Y[i]);
}
else
{
Y[i].correctBoundaryConditions();
}
}
}
fluid_.correctSpecies();