diff --git a/applications/modules/multicomponentFluid/thermophysicalPredictor.C b/applications/modules/multicomponentFluid/thermophysicalPredictor.C index 607724da94..d89d06777e 100644 --- a/applications/modules/multicomponentFluid/thermophysicalPredictor.C +++ b/applications/modules/multicomponentFluid/thermophysicalPredictor.C @@ -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 @@ -45,10 +45,10 @@ void Foam::solvers::multicomponentFluid::thermophysicalPredictor() forAll(Y, i) { + volScalarField& Yi = Y_[i]; + if (thermo_.solveSpecie(i)) { - volScalarField& Yi = Y_[i]; - fvScalarMatrix YiEqn ( fvm::ddt(rho, Yi) @@ -67,6 +67,10 @@ void Foam::solvers::multicomponentFluid::thermophysicalPredictor() fvConstraints().constrain(Yi); } + else + { + Yi.correctBoundaryConditions(); + } } thermo_.normaliseY(); diff --git a/applications/modules/multiphaseEuler/phaseSystem/phaseModel/phaseModel.H b/applications/modules/multiphaseEuler/phaseSystem/phaseModel/phaseModel.H index f66efefe2a..b70f2f9993 100644 --- a/applications/modules/multiphaseEuler/phaseSystem/phaseModel/phaseModel.H +++ b/applications/modules/multiphaseEuler/phaseSystem/phaseModel/phaseModel.H @@ -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& YRef() = 0; - //- Return the active species mass fractions - virtual const UPtrList& YActive() const = 0; - - //- Access the active species mass fractions - virtual UPtrList& 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 R(volScalarField& Yi) const = 0; diff --git a/applications/modules/multiphaseEuler/phaseSystem/phaseModels/MulticomponentPhaseModel/MulticomponentPhaseModel.C b/applications/modules/multiphaseEuler/phaseSystem/phaseModels/MulticomponentPhaseModel/MulticomponentPhaseModel.C index 97146e8b9e..b34de8664f 100644 --- a/applications/modules/multiphaseEuler/phaseSystem/phaseModels/MulticomponentPhaseModel/MulticomponentPhaseModel.C +++ b/applications/modules/multiphaseEuler/phaseSystem/phaseModels/MulticomponentPhaseModel/MulticomponentPhaseModel.C @@ -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::MulticomponentPhaseModel ) : BasePhaseModel(fluid, phaseName, referencePhase, index) -{ - PtrList& 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::YRef() template -const Foam::UPtrList& -Foam::MulticomponentPhaseModel::YActive() const +bool Foam::MulticomponentPhaseModel::solveSpecie +( + const label speciei +) const { - return YActive_; -} - - -template -Foam::UPtrList& -Foam::MulticomponentPhaseModel::YActiveRef() -{ - return YActive_; + return this->thermo_->solveSpecie(speciei); } diff --git a/applications/modules/multiphaseEuler/phaseSystem/phaseModels/MulticomponentPhaseModel/MulticomponentPhaseModel.H b/applications/modules/multiphaseEuler/phaseSystem/phaseModels/MulticomponentPhaseModel/MulticomponentPhaseModel.H index 44de613d85..33c9882666 100644 --- a/applications/modules/multiphaseEuler/phaseSystem/phaseModels/MulticomponentPhaseModel/MulticomponentPhaseModel.H +++ b/applications/modules/multiphaseEuler/phaseSystem/phaseModels/MulticomponentPhaseModel/MulticomponentPhaseModel.H @@ -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 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& YRef(); - //- Return the active species mass fractions - virtual const UPtrList& YActive() const; - - //- Access the active species mass fractions - virtual UPtrList& 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; }; diff --git a/applications/modules/multiphaseEuler/phaseSystem/phaseModels/PurePhaseModel/PurePhaseModel.C b/applications/modules/multiphaseEuler/phaseSystem/phaseModels/PurePhaseModel/PurePhaseModel.C index 9dbc66acb4..e2f14e33db 100644 --- a/applications/modules/multiphaseEuler/phaseSystem/phaseModels/PurePhaseModel/PurePhaseModel.C +++ b/applications/modules/multiphaseEuler/phaseSystem/phaseModels/PurePhaseModel/PurePhaseModel.C @@ -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::YRef() template -const Foam::UPtrList& -Foam::PurePhaseModel::YActive() const +bool Foam::PurePhaseModel::solveSpecie +( + const label speciei +) const { - // Y_ has never been set, so we are returning an empty list - - return Y_; -} - - -template -Foam::UPtrList& -Foam::PurePhaseModel::YActiveRef() -{ - FatalErrorInFunction - << "Cannot access the species fractions of for a pure phase" - << exit(FatalError); - - return Y_; + return false; } diff --git a/applications/modules/multiphaseEuler/phaseSystem/phaseModels/PurePhaseModel/PurePhaseModel.H b/applications/modules/multiphaseEuler/phaseSystem/phaseModels/PurePhaseModel/PurePhaseModel.H index be7b8c1f87..910b7b9545 100644 --- a/applications/modules/multiphaseEuler/phaseSystem/phaseModels/PurePhaseModel/PurePhaseModel.H +++ b/applications/modules/multiphaseEuler/phaseSystem/phaseModels/PurePhaseModel/PurePhaseModel.H @@ -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& YRef(); - //- Return the active species mass fractions - virtual const UPtrList& YActive() const; - - //- Access the active species mass fractions - virtual UPtrList& 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; }; diff --git a/applications/modules/multiphaseEuler/thermophysicalPredictor.C b/applications/modules/multiphaseEuler/thermophysicalPredictor.C index 145c6cf046..9b84bd6ac4 100644 --- a/applications/modules/multiphaseEuler/thermophysicalPredictor.C +++ b/applications/modules/multiphaseEuler/thermophysicalPredictor.C @@ -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,24 +47,34 @@ void Foam::solvers::multiphaseEuler::compositionPredictor() { phaseModel& phase = fluid_.multicomponentPhases()[multicomponentPhasei]; - UPtrList& Y = phase.YActiveRef(); + UPtrList& Y = phase.YRef(); const volScalarField& alpha = phase; const volScalarField& rho = phase.rho(); forAll(Y, i) { - fvScalarMatrix YiEqn - ( - phase.YiEqn(Y[i]) - == - *specieTransfer[Y[i].name()] - + fvModels().source(alpha, rho, Y[i]) - ); + if (phase.solveSpecie(i)) + { + fvScalarMatrix YiEqn + ( + phase.YiEqn(Y[i]) + == + *specieTransfer[Y[i].name()] + + fvModels().source(alpha, rho, Y[i]) + ); - YiEqn.relax(); - fvConstraints().constrain(YiEqn); - YiEqn.solve("Yi"); - fvConstraints().constrain(Y[i]); + YiEqn.relax(); + + fvConstraints().constrain(YiEqn); + + YiEqn.solve("Yi"); + + fvConstraints().constrain(Y[i]); + } + else + { + Y[i].correctBoundaryConditions(); + } } }