ENH: Cloud composition - allow not-found species without triggering error

This commit is contained in:
andy
2012-08-01 17:00:52 +01:00
parent e2d7cd9a1a
commit c9f26a8264
2 changed files with 40 additions and 17 deletions

View File

@ -156,18 +156,20 @@ Foam::CompositionModel<CloudType>::componentNames(const label phaseI) const
template<class CloudType> template<class CloudType>
Foam::label Foam::CompositionModel<CloudType>::globalCarrierId Foam::label Foam::CompositionModel<CloudType>::globalCarrierId
( (
const word& cmptName const word& cmptName,
const bool allowNotFound
) const ) const
{ {
label id = thermo_.carrierId(cmptName); label id = thermo_.carrierId(cmptName);
if (id < 0) if (id < 0 && !allowNotFound)
{ {
FatalErrorIn FatalErrorIn
( (
"Foam::label Foam::CompositionModel<CloudType>::globalCarrierId" "Foam::label Foam::CompositionModel<CloudType>::globalCarrierId"
"(" "("
"const word&" "const word&, "
"const bool"
") const" ") const"
) << "Unable to determine global id for requested component " ) << "Unable to determine global id for requested component "
<< cmptName << ". Available components are " << nl << cmptName << ". Available components are " << nl
@ -182,19 +184,21 @@ template<class CloudType>
Foam::label Foam::CompositionModel<CloudType>::globalId Foam::label Foam::CompositionModel<CloudType>::globalId
( (
const label phaseI, const label phaseI,
const word& cmptName const word& cmptName,
const bool allowNotFound
) const ) const
{ {
label id = phaseProps_[phaseI].globalId(cmptName); label id = phaseProps_[phaseI].globalId(cmptName);
if (id < 0) if (id < 0 && !allowNotFound)
{ {
FatalErrorIn FatalErrorIn
( (
"Foam::label Foam::CompositionModel<CloudType>::globalId" "Foam::label Foam::CompositionModel<CloudType>::globalId"
"(" "("
"const label, " "const label, "
"const word&" "const word&, "
"const bool"
") const" ") const"
) << "Unable to determine global id for requested component " ) << "Unable to determine global id for requested component "
<< cmptName << abort(FatalError); << cmptName << abort(FatalError);
@ -218,19 +222,21 @@ template<class CloudType>
Foam::label Foam::CompositionModel<CloudType>::localId Foam::label Foam::CompositionModel<CloudType>::localId
( (
const label phaseI, const label phaseI,
const word& cmptName const word& cmptName,
const bool allowNotFound
) const ) const
{ {
label id = phaseProps_[phaseI].id(cmptName); label id = phaseProps_[phaseI].id(cmptName);
if (id < 0) if (id < 0 && !allowNotFound)
{ {
FatalErrorIn FatalErrorIn
( (
"Foam::label Foam::CompositionModel<CloudType>::localId" "Foam::label Foam::CompositionModel<CloudType>::localId"
"(" "("
"const label, " "const label, "
"const word&" "const word&, "
"const bool"
") const" ") const"
) << "Unable to determine local id for component " << cmptName ) << "Unable to determine local id for component " << cmptName
<< abort(FatalError); << abort(FatalError);
@ -244,12 +250,13 @@ template<class CloudType>
Foam::label Foam::CompositionModel<CloudType>::localToGlobalCarrierId Foam::label Foam::CompositionModel<CloudType>::localToGlobalCarrierId
( (
const label phaseI, const label phaseI,
const label id const label id,
const bool allowNotFound
) const ) const
{ {
label gid = phaseProps_[phaseI].globalCarrierIds()[id]; label gid = phaseProps_[phaseI].globalCarrierIds()[id];
if (gid < 0) if (gid < 0 && !allowNotFound)
{ {
FatalErrorIn FatalErrorIn
( (
@ -257,7 +264,8 @@ Foam::label Foam::CompositionModel<CloudType>::localToGlobalCarrierId
"Foam::CompositionModel<CloudType>::localToGlobalCarrierId" "Foam::CompositionModel<CloudType>::localToGlobalCarrierId"
"(" "("
"const label, " "const label, "
"const label" "const label, "
"const bool"
") const" ") const"
) << "Unable to determine global carrier id for phase " ) << "Unable to determine global carrier id for phase "
<< phaseI << " with local id " << id << phaseI << " with local id " << id

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -166,22 +166,37 @@ public:
const wordList& componentNames(const label phaseI) const; const wordList& componentNames(const label phaseI) const;
//- Return global id of component cmptName in carrier thermo //- Return global id of component cmptName in carrier thermo
label globalCarrierId(const word& cmptName) const; label globalCarrierId
(
const word& cmptName,
const bool allowNotFound = false
) const;
//- Return global id of component cmptName in phase phaseI //- Return global id of component cmptName in phase phaseI
label globalId(const label phaseI, const word& cmptName) const; label globalId
(
const label phaseI,
const word& cmptName,
const bool allowNotFound = false
) const;
//- Return global ids of for phase phaseI //- Return global ids of for phase phaseI
const labelList& globalIds(const label phaseI) const; const labelList& globalIds(const label phaseI) const;
//- Return local id of component cmptName in phase phaseI //- Return local id of component cmptName in phase phaseI
label localId(const label phaseI, const word& cmptName) const; label localId
(
const label phaseI,
const word& cmptName,
const bool allowNotFound = false
) const;
//- Return global carrier id of component given local id //- Return global carrier id of component given local id
label localToGlobalCarrierId label localToGlobalCarrierId
( (
const label phaseI, const label phaseI,
const label id const label id,
const bool allowNotFound = false
) const; ) const;
//- Return the list of phase phaseI mass fractions //- Return the list of phase phaseI mass fractions