Skip to content
Snippets Groups Projects
Commit 8f0c8023 authored by Mark Olesen's avatar Mark Olesen
Browse files

Adjusted the timeVaryingUniformFixedValue pointPatch to match the fvPatch

parent 8e2182dd
Branches
Tags
No related merge requests found
......@@ -26,19 +26,14 @@ License
#include "timeVaryingUniformFixedValuePointPatchField.H"
#include "Time.H"
#include "pointMesh.H"
#include "Tuple2.H"
#include "IFstream.H"
#include "interpolateXY.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Type>
Foam::
timeVaryingUniformFixedValuePointPatchField<Type>::
timeVaryingUniformFixedValuePointPatchField
(
......@@ -51,35 +46,42 @@ timeVaryingUniformFixedValuePointPatchField
template<class Type>
Foam::
timeVaryingUniformFixedValuePointPatchField<Type>::
timeVaryingUniformFixedValuePointPatchField
(
const timeVaryingUniformFixedValuePointPatchField<Type>& ptf,
const pointPatch& p,
const DimensionedField<Type, pointMesh>& iF,
const dictionary& dict
const pointPatchFieldMapper& mapper
)
:
fixedValuePointPatchField<Type>(p, iF, dict),
timeDataFileName_(fileName(dict.lookup("timeDataFileName")).expand())
fixedValuePointPatchField<Type>(ptf, p, iF, mapper),
timeDataFile_(ptf.timeDataFile_),
timeSeries_(ptf.timeBounding())
{}
template<class Type>
Foam::
timeVaryingUniformFixedValuePointPatchField<Type>::
timeVaryingUniformFixedValuePointPatchField
(
const timeVaryingUniformFixedValuePointPatchField<Type>& ptf,
const pointPatch& p,
const DimensionedField<Type, pointMesh>& iF,
const pointPatchFieldMapper& mapper
const dictionary& dict
)
:
fixedValuePointPatchField<Type>(ptf, p, iF, mapper),
timeDataFileName_(ptf.timeDataFileName_)
{}
fixedValuePointPatchField<Type>(p, iF),
timeDataFile_(dict.lookup("timeDataFile")),
timeSeries_(word(dict.lookup("timeBounding")))
{
updateCoeffs();
}
template<class Type>
Foam::
timeVaryingUniformFixedValuePointPatchField<Type>::
timeVaryingUniformFixedValuePointPatchField
(
......@@ -87,11 +89,13 @@ timeVaryingUniformFixedValuePointPatchField
)
:
fixedValuePointPatchField<Type>(ptf),
timeDataFileName_(ptf.timeDataFileName_)
timeDataFile_(ptf.timeDataFile_),
timeSeries_(ptf.timeBounding())
{}
template<class Type>
Foam::
timeVaryingUniformFixedValuePointPatchField<Type>::
timeVaryingUniformFixedValuePointPatchField
(
......@@ -100,108 +104,91 @@ timeVaryingUniformFixedValuePointPatchField
)
:
fixedValuePointPatchField<Type>(ptf, iF),
timeDataFileName_(ptf.timeDataFileName_)
timeDataFile_(ptf.timeDataFile_),
timeSeries_(ptf.timeBounding())
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void timeVaryingUniformFixedValuePointPatchField<Type>::checkTable()
Type
Foam::timeVaryingUniformFixedValuePointPatchField<Type>::
currentValue()
{
const Time& tm = this->db().time();
if (times_.size() == 0)
if (timeSeries_.size() == 0)
{
if (timeDataFileName_.size() == 0)
fileName fName(timeDataFile_);
fName.expand();
if (fName.size() == 0)
{
FatalErrorIn
(
"timeVaryingUniformFixedValuePointPatchField<Type>"
"::checkTable()"
) << "timeDataFileName not specified for Patch "
"timeVaryingUniformFixedValuePointPatchField"
"::currentValue()"
) << "timeDataFile not specified for Patch "
<< this->patch().name()
<< exit(FatalError);
}
else
{
IFstream str(timeDataFileName_);
// relative path
if (fName[0] != '/')
{
fName = this->db().path()/fName;
}
List<Tuple2<scalar, Type> > timeValues(str);
// just in case we change the interface to timeSeries
word boundType = timeBounding();
times_.setSize(timeValues.size());
values_.setSize(timeValues.size());
IFstream(fName)() >> timeSeries_;
timeSeries_.bounding(boundType);
forAll(timeValues, i)
{
times_[i] = timeValues[i].first();
values_[i] = timeValues[i].second();
}
// be a bit paranoid and check that the list is okay
timeSeries_.check();
}
}
if (tm.value() < min(times_))
{
WarningIn
(
"timeVaryingUniformFixedValuePointPatchField<Type>::checkTable()"
) << "current time (" << tm.value()
<< ") is less than the minimum in the data table ("
<< min(times_) << ')' << endl
<< " Continuing with the value for the smallest time"
<< endl;
if (timeSeries_.size() == 0)
{
FatalErrorIn
(
"timeVaryingUniformFixedValuePointPatchField"
"::currentValue()"
) << "empty time series for Patch "
<< this->patch().name()
<< exit(FatalError);
}
}
if (tm.value() > max(times_))
{
WarningIn
(
"timeVaryingUniformFixedValuePointPatchField<Type>::checkTable()"
) << "current time (" << tm.value()
<< ") is greater than the maximum in the data table ("
<< max(times_) << ')' << endl
<< " Continuing with the value for the largest time"
<< endl;
}
return timeSeries_(this->db().time().timeOutputValue());
}
template<class Type>
void timeVaryingUniformFixedValuePointPatchField<Type>::updateCoeffs()
void Foam::timeVaryingUniformFixedValuePointPatchField<Type>::updateCoeffs()
{
if (this->updated())
{
return;
}
checkTable();
this->operator==
(
interpolateXY
(
this->db().time().value(),
times_,
values_
)
);
this->operator==(currentValue());
fixedValuePointPatchField<Type>::updateCoeffs();
}
template<class Type>
void timeVaryingUniformFixedValuePointPatchField<Type>::
write(Ostream& os) const
void Foam::timeVaryingUniformFixedValuePointPatchField<Type>::write(Ostream& os) const
{
fixedValuePointPatchField<Type>::write(os);
os.writeKeyword("timeDataFileName")
<< timeDataFileName_ << token::END_STATEMENT << nl;
os.writeKeyword("timeDataFile")
<< timeDataFile_ << token::END_STATEMENT << nl;
os.writeKeyword("timeBounding")
<< timeBounding() << token::END_STATEMENT << nl;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //
......@@ -26,7 +26,10 @@ Class
Foam::timeVaryingUniformFixedValuePointPatchField
Description
Foam::timeVaryingUniformFixedValuePointPatchField
A time-varying form of a uniform fixed value boundary condition.
See Also
Foam::timeVaryingUniformFixedValueFvField
SourceFiles
timeVaryingUniformFixedValuePointPatchField.C
......@@ -37,6 +40,7 @@ SourceFiles
#define timeVaryingUniformFixedValuePointPatchField_H
#include "fixedValuePointPatchField.H"
#include "timeSeries.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -44,7 +48,7 @@ namespace Foam
{
/*---------------------------------------------------------------------------*\
Class timeVaryingUniformFixedValuePointPatchField Declaration
Class timeVaryingUniformFixedValuePointPatchField Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
......@@ -54,13 +58,14 @@ class timeVaryingUniformFixedValuePointPatchField
{
// Private data
fileName timeDataFileName_;
scalarField times_;
Field<Type> values_;
//- file containing time/uniformFixedValue
fileName timeDataFile_;
void checkTable();
//- the time series being used, including the bounding treatment
timeSeries<Type> timeSeries_;
//- interpolate the value at the current time
Type currentValue();
public:
......@@ -85,7 +90,7 @@ public:
const dictionary&
);
//- Construct by mapping given patchField<Type> onto a new patch
//- Construct by mapping given patch field onto a new patch
timeVaryingUniformFixedValuePointPatchField
(
const timeVaryingUniformFixedValuePointPatchField<Type>&,
......@@ -105,10 +110,7 @@ public:
{
return autoPtr<pointPatchField<Type> >
(
new timeVaryingUniformFixedValuePointPatchField<Type>
(
*this
)
new timeVaryingUniformFixedValuePointPatchField<Type>(*this)
);
}
......@@ -119,7 +121,6 @@ public:
const DimensionedField<Type, pointMesh>&
);
//- Construct and return a clone setting internal field reference
virtual autoPtr<pointPatchField<Type> > clone
(
......@@ -128,11 +129,7 @@ public:
{
return autoPtr<pointPatchField<Type> >
(
new timeVaryingUniformFixedValuePointPatchField<Type>
(
*this,
iF
)
new timeVaryingUniformFixedValuePointPatchField<Type>(*this, iF)
);
}
......@@ -141,16 +138,16 @@ public:
// Access
//- Return the list of times in the interpolation table
const scalarField& times() const
//- Return the out-of-bounds treatment as a word
word timeBounding() const
{
return times_;
return timeSeries_.bounding();
}
//- Return the list of values in the interpolation table
const Field<Type>& values()
//- Return the time series used
const timeSeries<Type>& timeData() const
{
return values_;
return timeSeries_;
}
......@@ -159,8 +156,9 @@ public:
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
//- Write
virtual void write(Ostream&) const;
//- Write
virtual void write(Ostream&) const;
};
......@@ -171,7 +169,7 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "timeVaryingUniformFixedValuePointPatchField.C"
# include "timeVaryingUniformFixedValuePointPatchField.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment