From 0be43e7bb6f87eddfa27098750fe9dd2aad7cd1d Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Wed, 12 May 2021 16:01:59 +0100 Subject: [PATCH] lagrangian: phaseProperties: Support species that don't exist in the carrier A cloud may now contain species that do not exist within the carrier thermodynamics. Correspondence between lagrangian and carrier components is only required when there is phase change. --- .../phaseProperties/phaseProperties.C | 26 +++++++++---------- .../phaseProperties/phaseProperties.H | 6 ++--- .../CompositionModel/CompositionModel.C | 12 ++++----- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/lagrangian/parcel/phaseProperties/phaseProperties/phaseProperties.C b/src/lagrangian/parcel/phaseProperties/phaseProperties/phaseProperties.C index 744b6b8deb..8bc21eb9c0 100644 --- a/src/lagrangian/parcel/phaseProperties/phaseProperties/phaseProperties.C +++ b/src/lagrangian/parcel/phaseProperties/phaseProperties/phaseProperties.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -117,14 +117,6 @@ void Foam::phaseProperties::setCarrierIds break; } } - if (carrierIds_[i] == -1) - { - FatalErrorInFunction - << "Could not find carrier specie " << names_[i] - << " in species list" << nl - << "Available species are: " << nl << carrierNames << nl - << exit(FatalError); - } } } @@ -233,8 +225,8 @@ void Foam::phaseProperties::reorder // Set the list of solid species to correspond to the complete list // defined in the thermodynamics package. reorder(solidNames); - // Assume there is no correspondence between the solid species and - // the species in the carrier phase (no sublimation). + // Set the ids of the corresponding species in the carrier phase + setCarrierIds(gasNames); break; } default: @@ -306,9 +298,17 @@ Foam::scalar& Foam::phaseProperties::Y(const label speciei) } -const Foam::labelList& Foam::phaseProperties::carrierIds() const +Foam::label Foam::phaseProperties::carrierId(const label speciei) const { - return carrierIds_; + if (carrierIds_[speciei] == -1) + { + FatalErrorInFunction + << "Could not find specie " << names_[speciei] + << " in carrier " << nl + << exit(FatalError); + } + + return carrierIds_[speciei]; } diff --git a/src/lagrangian/parcel/phaseProperties/phaseProperties/phaseProperties.H b/src/lagrangian/parcel/phaseProperties/phaseProperties/phaseProperties.H index 4e24dc1380..3ccf03e521 100644 --- a/src/lagrangian/parcel/phaseProperties/phaseProperties/phaseProperties.H +++ b/src/lagrangian/parcel/phaseProperties/phaseProperties/phaseProperties.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -162,8 +162,8 @@ public: //- Return non-const access to a specie mass fraction scalar& Y(const label speciei); - //- Return const access to the map to the carrier ids - const labelList& carrierIds() const; + //- Return the carrier id for a given specie + label carrierId(const label speciei) const; //- Return the id of a specie in the local list by name // Returns -1 if not found diff --git a/src/lagrangian/parcel/submodels/Reacting/CompositionModel/CompositionModel/CompositionModel.C b/src/lagrangian/parcel/submodels/Reacting/CompositionModel/CompositionModel/CompositionModel.C index 2b0ea28e54..608724c686 100644 --- a/src/lagrangian/parcel/submodels/Reacting/CompositionModel/CompositionModel/CompositionModel.C +++ b/src/lagrangian/parcel/submodels/Reacting/CompositionModel/CompositionModel/CompositionModel.C @@ -237,7 +237,7 @@ Foam::label Foam::CompositionModel::localToCarrierId const bool allowNotFound ) const { - label cid = phaseProps_[phasei].carrierIds()[id]; + label cid = phaseProps_[phasei].carrierId(id); if (cid < 0 && !allowNotFound) { @@ -277,7 +277,7 @@ Foam::scalarField Foam::CompositionModel::X { forAll(Y, i) { - label cid = props.carrierIds()[i]; + label cid = props.carrierId(i); X[i] = Y[i]/carrierMixture_->Wi(cid); WInv += X[i]; } @@ -323,7 +323,7 @@ Foam::scalar Foam::CompositionModel::H { forAll(Y, i) { - label cid = props.carrierIds()[i]; + label cid = props.carrierId(i); HMixture += Y[i]*carrierMixture_->Ha(cid, p, T); } break; @@ -372,7 +372,7 @@ Foam::scalar Foam::CompositionModel::Hs { forAll(Y, i) { - label cid = props.carrierIds()[i]; + label cid = props.carrierId(i); HsMixture += Y[i]*carrierMixture_->Hs(cid, p, T); } break; @@ -423,7 +423,7 @@ Foam::scalar Foam::CompositionModel::Hc { forAll(Y, i) { - label cid = props.carrierIds()[i]; + label cid = props.carrierId(i); HcMixture += Y[i]*carrierMixture_->Hf(cid); } break; @@ -473,7 +473,7 @@ Foam::scalar Foam::CompositionModel::Cp { forAll(Y, i) { - label cid = props.carrierIds()[i]; + label cid = props.carrierId(i); CpMixture += Y[i]*carrierMixture_->Cp(cid, p, T); } break;