ENH: Added optional offset to timeVaryingMapped BC

This commit is contained in:
andy
2012-11-05 09:12:22 +00:00
parent f5ae1a6a60
commit 55913bf964
2 changed files with 26 additions and 11 deletions

View File

@ -52,7 +52,8 @@ timeVaryingMappedFixedValueFvPatchField
startAverage_(pTraits<Type>::zero),
endSampleTime_(-1),
endSampledValues_(0),
endAverage_(pTraits<Type>::zero)
endAverage_(pTraits<Type>::zero),
offSet_()
{}
@ -77,7 +78,8 @@ timeVaryingMappedFixedValueFvPatchField
startAverage_(pTraits<Type>::zero),
endSampleTime_(-1),
endSampledValues_(0),
endAverage_(pTraits<Type>::zero)
endAverage_(pTraits<Type>::zero),
offSet_()
{}
@ -101,7 +103,8 @@ timeVaryingMappedFixedValueFvPatchField
startAverage_(pTraits<Type>::zero),
endSampleTime_(-1),
endSampledValues_(0),
endAverage_(pTraits<Type>::zero)
endAverage_(pTraits<Type>::zero),
offSet_(DataEntry<Type>::New("offSet", dict))
{
dict.readIfPresent("fieldTableName", fieldTableName_);
@ -134,7 +137,8 @@ timeVaryingMappedFixedValueFvPatchField
startAverage_(ptf.startAverage_),
endSampleTime_(ptf.endSampleTime_),
endSampledValues_(ptf.endSampledValues_),
endAverage_(ptf.endAverage_)
endAverage_(ptf.endAverage_),
offSet_(ptf.offSet_().clone().ptr())
{}
@ -158,7 +162,8 @@ timeVaryingMappedFixedValueFvPatchField
startAverage_(ptf.startAverage_),
endSampleTime_(ptf.endSampleTime_),
endSampledValues_(ptf.endSampledValues_),
endAverage_(ptf.endAverage_)
endAverage_(ptf.endAverage_),
offSet_(ptf.offSet_().clone().ptr())
{}
@ -276,7 +281,7 @@ void timeVaryingMappedFixedValueFvPatchField<Type>::checkTable()
{
FatalErrorIn
(
"timeVaryingMappedFixedValueFvPatchField<Type>::checkTable"
"timeVaryingMappedFixedValueFvPatchField<Type>::checkTable()"
) << "Cannot find starting sampling values for current time "
<< this->db().time().value() << nl
<< "Have sampling values for times "
@ -366,6 +371,7 @@ void timeVaryingMappedFixedValueFvPatchField<Type>::checkTable()
/sampleTimes_[endSampleTime_].name()
<< endl;
}
// Reread values and interpolate
AverageIOField<Type> vals
(
@ -392,7 +398,6 @@ void timeVaryingMappedFixedValueFvPatchField<Type>::checkTable()
template<class Type>
void timeVaryingMappedFixedValueFvPatchField<Type>::updateCoeffs()
{
if (this->updated())
{
return;
@ -423,7 +428,7 @@ void timeVaryingMappedFixedValueFvPatchField<Type>::updateCoeffs()
scalar start = sampleTimes_[startSampleTime_].value();
scalar end = sampleTimes_[endSampleTime_].value();
scalar s = (this->db().time().value()-start)/(end-start);
scalar s = (this->db().time().value() - start)/(end - start);
if (debug)
{
@ -434,8 +439,8 @@ void timeVaryingMappedFixedValueFvPatchField<Type>::updateCoeffs()
<< " with weight:" << s << endl;
}
this->operator==((1-s)*startSampledValues_ + s*endSampledValues_);
wantedAverage = (1-s)*startAverage_ + s*endAverage_;
this->operator==((1 - s)*startSampledValues_ + s*endSampledValues_);
wantedAverage = (1 - s)*startAverage_ + s*endAverage_;
}
// Enforce average. Either by scaling (if scaling factor > 0.5) or by
@ -465,7 +470,7 @@ void timeVaryingMappedFixedValueFvPatchField<Type>::updateCoeffs()
Pout<< "updateCoeffs :"
<< " offsetting with:" << offset << endl;
}
this->operator==(fld+offset);
this->operator==(fld + offset);
}
else
{
@ -480,6 +485,10 @@ void timeVaryingMappedFixedValueFvPatchField<Type>::updateCoeffs()
}
}
// apply offset to mapped values
const scalar t = this->db().time().timeOutputValue();
this->operator==(*this + offSet_->value(t));
if (debug)
{
Pout<< "updateCoeffs : set fixedValue to min:" << gMin(*this)
@ -503,6 +512,8 @@ void timeVaryingMappedFixedValueFvPatchField<Type>::write(Ostream& os) const
<< token::END_STATEMENT << nl;
}
offSet_->writeData(os);
this->writeEntry("value", os);
}

View File

@ -80,6 +80,7 @@ SourceFiles
#include "FixedList.H"
#include "instantList.H"
#include "pointToPointPlanarInterpolation.H"
#include "DataEntry.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -130,6 +131,9 @@ class timeVaryingMappedFixedValueFvPatchField
//- If setAverage: end average value
Type endAverage_;
//- Time varying offset values to interpolated data
autoPtr<DataEntry<Type> > offSet_;
public: