BUG: TableBase: preserve address of tableSamples since referenced in interpolationWeights

This commit is contained in:
mattijs
2012-10-24 11:36:53 +01:00
parent 4b9550f426
commit 69a958fbea
2 changed files with 7 additions and 6 deletions

View File

@ -35,15 +35,16 @@ const Foam::interpolationWeights& Foam::TableBase<Type>::interpolator() const
if (interpolatorPtr_.empty()) if (interpolatorPtr_.empty())
{ {
// Re-work table into linear list // Re-work table into linear list
tableSamples_.setSize(table_.size()); tableSamplesPtr_.reset(new scalarField(table_.size()));
scalarField& tableSamples = tableSamplesPtr_();
forAll(table_, i) forAll(table_, i)
{ {
tableSamples_[i] = table_[i].first(); tableSamples[i] = table_[i].first();
} }
interpolatorPtr_ = interpolationWeights::New interpolatorPtr_ = interpolationWeights::New
( (
interpolationScheme_, interpolationScheme_,
tableSamples_ tableSamples
); );
} }
@ -81,7 +82,7 @@ Foam::TableBase<Type>::TableBase(const TableBase<Type>& tbl)
interpolationScheme_(tbl.interpolationScheme_), interpolationScheme_(tbl.interpolationScheme_),
table_(tbl.table_), table_(tbl.table_),
dimensions_(tbl.dimensions_), dimensions_(tbl.dimensions_),
tableSamples_(tbl.tableSamples_), tableSamplesPtr_(tbl.tableSamplesPtr_),
interpolatorPtr_(tbl.interpolatorPtr_) interpolatorPtr_(tbl.interpolatorPtr_)
{} {}
@ -341,7 +342,7 @@ void Foam::TableBase<Type>::convertTimeBase(const Time& t)
table_[i].first() = t.userTimeToTime(value); table_[i].first() = t.userTimeToTime(value);
} }
tableSamples_.clear(); tableSamplesPtr_.clear();
interpolatorPtr_.clear(); interpolatorPtr_.clear();
} }

View File

@ -97,7 +97,7 @@ protected:
dimensionSet dimensions_; dimensionSet dimensions_;
//- Extracted values //- Extracted values
mutable scalarField tableSamples_; mutable autoPtr<scalarField> tableSamplesPtr_;
//- Interpolator method //- Interpolator method
mutable autoPtr<interpolationWeights> interpolatorPtr_; mutable autoPtr<interpolationWeights> interpolatorPtr_;