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

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -166,22 +166,37 @@ public:
const wordList& componentNames(const label phaseI) const;
//- 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
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
const labelList& globalIds(const label phaseI) const;
//- 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
label localToGlobalCarrierId
(
const label phaseI,
const label id
const label id,
const bool allowNotFound = false
) const;
//- Return the list of phase phaseI mass fractions