mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: refPtr/tmp is_reference() to complement is_pointer() method
STYLE: return nullptr instead of tmp<...>() for failure
This commit is contained in:
@ -175,10 +175,13 @@ public:
|
||||
bool good() const noexcept { return bool(ptr_); }
|
||||
|
||||
//- If the stored/referenced content is const
|
||||
bool is_const() const noexcept { return type_ == CREF; }
|
||||
bool is_const() const noexcept { return (type_ == CREF); }
|
||||
|
||||
//- True if this is a managed pointer (not a reference)
|
||||
bool is_pointer() const noexcept { return type_ == PTR; }
|
||||
bool is_pointer() const noexcept { return (type_ == PTR); }
|
||||
|
||||
//- True if this is a reference (not a pointer)
|
||||
bool is_reference() const noexcept { return (type_ != PTR); }
|
||||
|
||||
//- True if this is a non-null managed pointer
|
||||
inline bool movable() const noexcept;
|
||||
|
||||
@ -191,10 +191,13 @@ public:
|
||||
bool good() const noexcept { return bool(ptr_); }
|
||||
|
||||
//- If the stored/referenced content is const
|
||||
bool is_const() const noexcept { return type_ == CREF; }
|
||||
bool is_const() const noexcept { return (type_ == CREF); }
|
||||
|
||||
//- True if this is a managed pointer (not a reference)
|
||||
bool is_pointer() const noexcept { return type_ == PTR; }
|
||||
bool is_pointer() const noexcept { return (type_ == PTR); }
|
||||
|
||||
//- True if this is a reference (not a pointer)
|
||||
bool is_reference() const noexcept { return (type_ != PTR); }
|
||||
|
||||
//- True if this is a non-null managed pointer with a unique ref-count
|
||||
inline bool movable() const noexcept;
|
||||
|
||||
@ -52,7 +52,7 @@ Foam::fv::atmAmbientTurbSource::atmAmbientTurbSource
|
||||
)
|
||||
:
|
||||
fv::cellSetOption(sourceName, modelType, dict, mesh),
|
||||
isEpsilon_(true),
|
||||
isEpsilon_(false),
|
||||
rhoName_(coeffs_.getOrDefault<word>("rho", "rho")),
|
||||
kAmb_
|
||||
(
|
||||
@ -112,15 +112,16 @@ Foam::fv::atmAmbientTurbSource::atmAmbientTurbSource
|
||||
tmp<volScalarField> tepsilon = turbPtr->epsilon();
|
||||
tmp<volScalarField> tomega = turbPtr->omega();
|
||||
|
||||
if (!tepsilon.isTmp())
|
||||
if (tepsilon.is_reference())
|
||||
{
|
||||
isEpsilon_ = true;
|
||||
fieldNames_[0] = tepsilon().name();
|
||||
|
||||
const dictionary& turbDict = turbPtr->coeffDict();
|
||||
|
||||
C2_.read("C2", turbDict);
|
||||
}
|
||||
else if (!tomega.isTmp())
|
||||
else if (tomega.is_reference())
|
||||
{
|
||||
isEpsilon_ = false;
|
||||
fieldNames_[0] = tomega().name();
|
||||
|
||||
@ -134,7 +134,7 @@ Foam::fv::atmBuoyancyTurbSource::atmBuoyancyTurbSource
|
||||
)
|
||||
:
|
||||
fv::cellSetOption(sourceName, modelType, dict, mesh),
|
||||
isEpsilon_(true),
|
||||
isEpsilon_(false),
|
||||
rhoName_(coeffs_.getOrDefault<word>("rho", "rho")),
|
||||
Lmax_
|
||||
(
|
||||
@ -203,8 +203,9 @@ Foam::fv::atmBuoyancyTurbSource::atmBuoyancyTurbSource
|
||||
tmp<volScalarField> tepsilon = turbPtr->epsilon();
|
||||
tmp<volScalarField> tomega = turbPtr->omega();
|
||||
|
||||
if (!tepsilon.isTmp())
|
||||
if (tepsilon.is_reference())
|
||||
{
|
||||
isEpsilon_ = true;
|
||||
fieldNames_[0] = tepsilon().name();
|
||||
|
||||
const dictionary& turbDict = turbPtr->coeffDict();
|
||||
@ -213,7 +214,7 @@ Foam::fv::atmBuoyancyTurbSource::atmBuoyancyTurbSource
|
||||
C1_.read("C1", turbDict);
|
||||
C2_.read("C2", turbDict);
|
||||
}
|
||||
else if (!tomega.isTmp())
|
||||
else if (tomega.is_reference())
|
||||
{
|
||||
isEpsilon_ = false;
|
||||
fieldNames_[0] = tomega().name();
|
||||
|
||||
@ -88,7 +88,7 @@ Foam::fv::atmLengthScaleTurbSource::atmLengthScaleTurbSource
|
||||
)
|
||||
:
|
||||
fv::cellSetOption(sourceName, modelType, dict, mesh),
|
||||
isEpsilon_(true),
|
||||
isEpsilon_(false),
|
||||
rhoName_(coeffs_.getOrDefault<word>("rho", "rho")),
|
||||
Lmax_
|
||||
(
|
||||
@ -139,8 +139,9 @@ Foam::fv::atmLengthScaleTurbSource::atmLengthScaleTurbSource
|
||||
tmp<volScalarField> tepsilon = turbPtr->epsilon();
|
||||
tmp<volScalarField> tomega = turbPtr->omega();
|
||||
|
||||
if (!tepsilon.isTmp())
|
||||
if (tepsilon.is_reference())
|
||||
{
|
||||
isEpsilon_ = true;
|
||||
fieldNames_[0] = tepsilon().name();
|
||||
|
||||
const dictionary& turbDict = turbPtr->coeffDict();
|
||||
@ -149,7 +150,7 @@ Foam::fv::atmLengthScaleTurbSource::atmLengthScaleTurbSource
|
||||
C2_.read("C2", turbDict);
|
||||
C3_.read("C3", turbDict);
|
||||
}
|
||||
else if (!tomega.isTmp())
|
||||
else if (tomega.is_reference())
|
||||
{
|
||||
isEpsilon_ = false;
|
||||
fieldNames_[0] = tomega().name();
|
||||
|
||||
@ -92,7 +92,7 @@ Foam::fv::atmNutSource::atmNutSource
|
||||
|
||||
const tmp<volScalarField>& tnut = turbPtr->nut();
|
||||
|
||||
if (!tnut.isTmp())
|
||||
if (tnut.is_reference())
|
||||
{
|
||||
fieldNames_[0] = tnut().name();
|
||||
}
|
||||
|
||||
@ -65,7 +65,7 @@ Foam::fv::atmPlantCanopyTurbSource::atmPlantCanopyTurbSource
|
||||
)
|
||||
:
|
||||
fv::cellSetOption(sourceName, modelType, dict, mesh),
|
||||
isEpsilon_(true),
|
||||
isEpsilon_(false),
|
||||
rhoName_(coeffs_.getOrDefault<word>("rho", "rho")),
|
||||
Cmu_(Zero),
|
||||
C1_(Zero),
|
||||
@ -113,8 +113,9 @@ Foam::fv::atmPlantCanopyTurbSource::atmPlantCanopyTurbSource
|
||||
tmp<volScalarField> tepsilon = turbPtr->epsilon();
|
||||
tmp<volScalarField> tomega = turbPtr->omega();
|
||||
|
||||
if (!tepsilon.isTmp())
|
||||
if (tepsilon.is_reference())
|
||||
{
|
||||
isEpsilon_ = true;
|
||||
fieldNames_[0] = tepsilon().name();
|
||||
|
||||
const dictionary& turbDict = turbPtr->coeffDict();
|
||||
@ -122,7 +123,7 @@ Foam::fv::atmPlantCanopyTurbSource::atmPlantCanopyTurbSource
|
||||
C1_.read("C1", turbDict);
|
||||
C2_.read("C2", turbDict);
|
||||
}
|
||||
else if (!tomega.isTmp())
|
||||
else if (tomega.is_reference())
|
||||
{
|
||||
isEpsilon_ = false;
|
||||
fieldNames_[0] = tomega().name();
|
||||
|
||||
@ -320,7 +320,7 @@ Foam::PatchFunction1Types::Sampled<Type>::integrate
|
||||
) const
|
||||
{
|
||||
NotImplemented;
|
||||
return tmp<Field<Type>>(nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -114,8 +114,7 @@ public:
|
||||
) const
|
||||
{
|
||||
NotImplemented;
|
||||
|
||||
return tmp<surfaceScalarField>(nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//- Return the face-interpolate of the given cell field
|
||||
|
||||
@ -114,8 +114,7 @@ public:
|
||||
) const
|
||||
{
|
||||
NotImplemented;
|
||||
|
||||
return tmp<surfaceScalarField>(nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//- Return the face-interpolate of the given cell field
|
||||
|
||||
@ -114,8 +114,7 @@ public:
|
||||
) const
|
||||
{
|
||||
NotImplemented;
|
||||
|
||||
return tmp<surfaceScalarField>(nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
//- Return the face-interpolate of the given cell field
|
||||
|
||||
@ -183,12 +183,12 @@ Foam::fv::buoyancyTurbSource::buoyancyTurbSource
|
||||
tmp<volScalarField> tepsilon = turbPtr->epsilon();
|
||||
tmp<volScalarField> tomega = turbPtr->omega();
|
||||
|
||||
if (!tepsilon.isTmp())
|
||||
if (tepsilon.is_reference())
|
||||
{
|
||||
isEpsilon_ = true;
|
||||
fieldNames_[0] = tepsilon().name();
|
||||
}
|
||||
else if (!tomega.isTmp())
|
||||
else if (tomega.is_reference())
|
||||
{
|
||||
isEpsilon_ = false;
|
||||
fieldNames_[0] = tomega().name();
|
||||
|
||||
@ -1240,7 +1240,7 @@ Foam::autoPtr<Foam::mapDistribute> Foam::holeToFace::calcClosure
|
||||
if (returnReduce(closureFaces.size(), sumOp<label>()) == 0)
|
||||
{
|
||||
closureToBlocked.clear();
|
||||
return autoPtr<mapDistribute>(nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -75,7 +75,7 @@ variablesSet::variablesSet
|
||||
autoPtr<variablesSet> variablesSet::clone() const
|
||||
{
|
||||
NotImplemented
|
||||
return autoPtr<variablesSet>();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -131,7 +131,7 @@ Foam::dragModels::AttouFerschneider::CdRe() const
|
||||
<< "Drag coefficient is not defined for the AttouFerschneider model."
|
||||
<< exit(FatalError);
|
||||
|
||||
return tmp<volScalarField>(nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@ -167,7 +167,7 @@ Foam::dragModels::AttouFerschneider::K() const
|
||||
<< "phase models."
|
||||
<< exit(FatalError);
|
||||
|
||||
return tmp<volScalarField>(nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -79,7 +79,7 @@ Foam::IsothermalPhaseModel<BasePhaseModel>::heEqn()
|
||||
<< "Cannot construct an energy equation for an isothermal phase"
|
||||
<< exit(FatalError);
|
||||
|
||||
return tmp<fvScalarMatrix>();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -66,7 +66,7 @@ Foam::PurePhaseModel<BasePhaseModel>::YiEqn(volScalarField& Yi)
|
||||
<< "Cannot construct a species fraction equation for a pure phase"
|
||||
<< exit(FatalError);
|
||||
|
||||
return tmp<fvScalarMatrix>();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -122,7 +122,7 @@ Foam::StationaryPhaseModel<BasePhaseModel>::UEqn()
|
||||
<< "Cannot construct a momentum equation for a stationary phase"
|
||||
<< exit(FatalError);
|
||||
|
||||
return tmp<fvVectorMatrix>();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@ -134,7 +134,7 @@ Foam::StationaryPhaseModel<BasePhaseModel>::UfEqn()
|
||||
<< "Cannot construct a momentum equation for a stationary phase"
|
||||
<< exit(FatalError);
|
||||
|
||||
return tmp<fvVectorMatrix>();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
@ -270,7 +270,7 @@ template<class BasePhaseModel>
|
||||
Foam::tmp<Foam::volScalarField>
|
||||
Foam::StationaryPhaseModel<BasePhaseModel>::divU() const
|
||||
{
|
||||
return tmp<volScalarField>();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -116,7 +116,7 @@ public:
|
||||
autoPtr<binaryBreakupModel> clone() const
|
||||
{
|
||||
NotImplemented;
|
||||
return autoPtr<binaryBreakupModel>(nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -114,7 +114,7 @@ public:
|
||||
autoPtr<coalescenceModel> clone() const
|
||||
{
|
||||
NotImplemented;
|
||||
return autoPtr<coalescenceModel>(nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -114,7 +114,7 @@ public:
|
||||
autoPtr<driftModel> clone() const
|
||||
{
|
||||
NotImplemented;
|
||||
return autoPtr<driftModel>(nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -114,7 +114,7 @@ public:
|
||||
autoPtr<nucleationModel> clone() const
|
||||
{
|
||||
NotImplemented;
|
||||
return autoPtr<nucleationModel>(nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -118,7 +118,7 @@ public:
|
||||
autoPtr<IATEsource> clone() const
|
||||
{
|
||||
NotImplemented;
|
||||
return autoPtr<IATEsource>(nullptr);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -67,7 +67,7 @@ void Foam::radiation::noSoot::correct()
|
||||
const Foam::volScalarField& Foam::radiation::noSoot::soot() const
|
||||
{
|
||||
NotImplemented;
|
||||
return tmp<volScalarField>(); // Placeholder
|
||||
return volScalarField::null(); // Placeholder
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Reference in New Issue
Block a user