COMP: protect against null tmp field (freestream BC)

This commit is contained in:
Mark Olesen 2023-03-09 09:38:47 +00:00
parent b519a8e128
commit 06df44a588
2 changed files with 16 additions and 23 deletions

View File

@ -38,7 +38,7 @@ Foam::freestreamFvPatchField<Type>::freestreamFvPatchField
)
:
inletOutletFvPatchField<Type>(p, iF),
freestreamBCPtr_()
freestreamBCPtr_(nullptr)
{}
@ -51,7 +51,7 @@ Foam::freestreamFvPatchField<Type>::freestreamFvPatchField
)
:
inletOutletFvPatchField<Type>(p, iF),
freestreamBCPtr_()
freestreamBCPtr_(nullptr)
{
fvPatchFieldBase::readDict(dict);
@ -93,7 +93,7 @@ Foam::freestreamFvPatchField<Type>::freestreamFvPatchField
)
:
inletOutletFvPatchField<Type>(ptf, p, iF, mapper),
freestreamBCPtr_()
freestreamBCPtr_(nullptr)
{
if (ptf.freestreamBCPtr_)
{
@ -110,7 +110,7 @@ Foam::freestreamFvPatchField<Type>::freestreamFvPatchField
)
:
inletOutletFvPatchField<Type>(ptf),
freestreamBCPtr_()
freestreamBCPtr_(nullptr)
{
if (ptf.freestreamBCPtr_)
{
@ -127,7 +127,7 @@ Foam::freestreamFvPatchField<Type>::freestreamFvPatchField
)
:
inletOutletFvPatchField<Type>(ptf, iF),
freestreamBCPtr_()
freestreamBCPtr_(nullptr)
{
if (ptf.freestreamBCPtr_)
{
@ -160,7 +160,7 @@ void Foam::freestreamFvPatchField<Type>::rmap
const auto& fsptf = refCast<const freestreamFvPatchField<Type>>(ptf);
if (fsptf.freestreamBCPtr_)
if (freestreamBCPtr_ && fsptf.freestreamBCPtr_)
{
freestreamBCPtr_->rmap(fsptf.freestreamBCPtr_(), addr);
}

View File

@ -83,8 +83,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef freestreamFvPatchField_H
#define freestreamFvPatchField_H
#ifndef Foam_freestreamFvPatchField_H
#define Foam_freestreamFvPatchField_H
#include "inletOutletFvPatchField.H"
@ -102,7 +102,7 @@ class freestreamFvPatchField
:
public inletOutletFvPatchField<Type>
{
// Private data
// Private Data
//- BC to supply the freestream value
tmp<fvPatchField<Type>> freestreamBCPtr_;
@ -175,7 +175,13 @@ public:
}
// Member functions
// Member Functions
// Access
const Field<Type>& freestreamValue() const { return this->refValue(); }
Field<Type>& freestreamValue() { return this->refValue(); }
// Mapping functions
@ -193,19 +199,6 @@ public:
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
// Return defining fields
const Field<Type>& freestreamValue() const
{
return this->refValue();
}
Field<Type>& freestreamValue()
{
return this->refValue();
}
//- Write
virtual void write(Ostream&) const;
};