mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Adjusted interpolationTable for smoother merge with Henry's changes.
- timeVaryingUniformFixedValuePointPatchField seems to have been missed
This commit is contained in:
@ -70,7 +70,7 @@ timeVaryingUniformFixedValuePointPatchField
|
||||
)
|
||||
:
|
||||
fixedValuePointPatchField<Type>(p, iF),
|
||||
timeSeries_(this->db(), dict)
|
||||
timeSeries_(dict)
|
||||
{
|
||||
updateCoeffs();
|
||||
}
|
||||
|
||||
@ -26,7 +26,34 @@ License
|
||||
|
||||
#include "interpolationTable.H"
|
||||
#include "IFstream.H"
|
||||
#include "objectRegistry.H"
|
||||
|
||||
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::interpolationTable<Type>::readTable()
|
||||
{
|
||||
// preserve the original (unexpanded) fileName to avoid absolute paths
|
||||
// appearing subsequently in the write() method
|
||||
fileName fName(fileName_);
|
||||
|
||||
fName.expand();
|
||||
|
||||
// Read data from file
|
||||
IFstream(fName)() >> *this;
|
||||
|
||||
// Check that the data are okay
|
||||
check();
|
||||
|
||||
if (this->size() == 0)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"Foam::interpolationTable<Type>::readTable()"
|
||||
) << "table is empty" << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
@ -40,43 +67,24 @@ Foam::interpolationTable<Type>::interpolationTable()
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::interpolationTable<Type>::interpolationTable
|
||||
(
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict
|
||||
)
|
||||
Foam::interpolationTable<Type>::interpolationTable(const fileName& fn)
|
||||
:
|
||||
List<Tuple2<scalar, Type> >(),
|
||||
boundsHandling_(interpolationTable::WARN),
|
||||
fileName_(fn)
|
||||
{
|
||||
readTable();
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::interpolationTable<Type>::interpolationTable(const dictionary& dict)
|
||||
:
|
||||
List<Tuple2<scalar, Type> >(),
|
||||
boundsHandling_(wordToBoundsHandling(dict.lookup("outOfBounds"))),
|
||||
fileName_(dict.lookup("fileName"))
|
||||
{
|
||||
// preserve the original (unexpanded) fileName to avoid absolute paths
|
||||
// appearing in the write() method
|
||||
fileName fName(fileName_);
|
||||
|
||||
fName.expand();
|
||||
|
||||
// Correct for relative path
|
||||
if (fName[0] != '/')
|
||||
{
|
||||
fName = obr.db().path()/fName;
|
||||
}
|
||||
|
||||
// Read data from file
|
||||
IFstream(fName)() >> *this;
|
||||
|
||||
// Check that the data is okay
|
||||
check();
|
||||
|
||||
if (this->size() == 0)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"Foam::interpolationTable<Type>::interpolationTable"
|
||||
"(const dictionary&)"
|
||||
) << "table is empty" << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
readTable();
|
||||
}
|
||||
|
||||
|
||||
@ -92,12 +100,6 @@ Foam::interpolationTable<Type>::interpolationTable
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::interpolationTable<Type>::~interpolationTable()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
@ -172,10 +174,23 @@ Foam::interpolationTable<Type>::wordToBoundsHandling
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
typename Foam::interpolationTable<Type>::boundsHandling
|
||||
Foam::interpolationTable<Type>::outOfBounds
|
||||
(
|
||||
const boundsHandling& bound
|
||||
)
|
||||
{
|
||||
boundsHandling prev = boundsHandling_;
|
||||
boundsHandling_ = bound;
|
||||
return prev;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::interpolationTable<Type>::check() const
|
||||
{
|
||||
label n = size();
|
||||
label n = this->size();
|
||||
scalar prevValue = List<Tuple2<scalar, Type> >::operator[](0).first();
|
||||
|
||||
for (label i=1; i<n; ++i)
|
||||
@ -198,19 +213,6 @@ void Foam::interpolationTable<Type>::check() const
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
typename Foam::interpolationTable<Type>::boundsHandling
|
||||
Foam::interpolationTable<Type>::outOfBounds
|
||||
(
|
||||
const boundsHandling& bound
|
||||
)
|
||||
{
|
||||
boundsHandling prev = boundsHandling_;
|
||||
boundsHandling_ = bound;
|
||||
return prev;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::interpolationTable<Type>::write(Ostream& os) const
|
||||
{
|
||||
@ -228,7 +230,7 @@ const Foam::Tuple2<Foam::scalar, Type>&
|
||||
Foam::interpolationTable<Type>::operator[](const label i) const
|
||||
{
|
||||
label ii = i;
|
||||
label n = size();
|
||||
label n = this->size();
|
||||
|
||||
if (n <= 1)
|
||||
{
|
||||
@ -322,7 +324,7 @@ Foam::interpolationTable<Type>::operator[](const label i) const
|
||||
template<class Type>
|
||||
Type Foam::interpolationTable<Type>::operator()(const scalar value) const
|
||||
{
|
||||
label n = size();
|
||||
label n = this->size();
|
||||
|
||||
if (n <= 1)
|
||||
{
|
||||
@ -479,4 +481,5 @@ Type Foam::interpolationTable<Type>::operator()(const scalar value) const
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -27,7 +27,7 @@ Class
|
||||
|
||||
Description
|
||||
A list of times and values.
|
||||
The time values must be positive monotonically increasing.
|
||||
The time values must be positive and monotonically increasing.
|
||||
|
||||
The handling of out-of-bounds values depends on the current setting
|
||||
of @a outOfBounds.
|
||||
@ -37,7 +37,7 @@ Description
|
||||
|
||||
Note
|
||||
- Accessing an empty list results in an error.
|
||||
- Accessing a list with a single element will always return the same value.
|
||||
- Accessing a list with a single element always returns the same value.
|
||||
|
||||
SourceFiles
|
||||
interpolationTable.C
|
||||
@ -55,8 +55,6 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class objectRegistry;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class interpolationTable Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
@ -91,6 +89,12 @@ private:
|
||||
fileName fileName_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Read the table of data from file
|
||||
void readTable();
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
@ -98,61 +102,44 @@ public:
|
||||
//- Construct null
|
||||
interpolationTable();
|
||||
|
||||
//- Construct from objectRegistry and dictionary
|
||||
interpolationTable(const objectRegistry& obr, const dictionary& dict);
|
||||
//- Construct given the name of the file containing the table of data
|
||||
interpolationTable(const fileName& fn);
|
||||
|
||||
//- Construct by reading the fileName and boundsHandling from dictionary
|
||||
// and read the table from that file.
|
||||
// This is a specialised constructor used by patchFields
|
||||
interpolationTable(const dictionary& dict);
|
||||
|
||||
//- Construct copy
|
||||
interpolationTable(const interpolationTable& interpTable);
|
||||
|
||||
|
||||
//- Destructor
|
||||
~interpolationTable();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
//- Return the out-of-bounds handling as a word
|
||||
word boundsHandlingToWord(const boundsHandling& bound) const;
|
||||
|
||||
//- Return the size
|
||||
label size() const
|
||||
{
|
||||
return List<Tuple2<scalar, Type> >::size();
|
||||
}
|
||||
//- Return the out-of-bounds handling as an enumeration
|
||||
boundsHandling wordToBoundsHandling(const word& bound) const;
|
||||
|
||||
//- Return the out-of-bounds handling as a word
|
||||
word boundsHandlingToWord(const boundsHandling& bound) const;
|
||||
//- Set the out-of-bounds handling from enum, return previous setting
|
||||
boundsHandling outOfBounds(const boundsHandling& bound);
|
||||
|
||||
//- Return the out-of-bounds handling as an enumeration
|
||||
boundsHandling wordToBoundsHandling(const word& bound) const;
|
||||
//- Check that list is monotonically increasing
|
||||
// Exit with a FatalError if there is a problem
|
||||
void check() const;
|
||||
|
||||
//- Write
|
||||
void write(Ostream& os) const;
|
||||
|
||||
|
||||
// Check
|
||||
// Member Operators
|
||||
|
||||
//- Check that list is monotonically increasing
|
||||
// Exit with a FatalError if there is a problem
|
||||
void check() const;
|
||||
//- Return an element of constant Tuple2<scalar, Type>
|
||||
const Tuple2<scalar, Type>& operator[](const label) const;
|
||||
|
||||
|
||||
// Edit
|
||||
|
||||
//- Set the out-of-bounds handling from enum,
|
||||
// return previous setting
|
||||
boundsHandling outOfBounds(const boundsHandling& bound);
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
//- Return an element of constant Tuple2<scalar, Type>
|
||||
const Tuple2<scalar, Type>& operator[](const label) const;
|
||||
|
||||
//- Return an interpolated value
|
||||
Type operator()(const scalar) const;
|
||||
|
||||
|
||||
// I-O
|
||||
|
||||
//- Write
|
||||
void write(Ostream& os) const;
|
||||
//- Return an interpolated value
|
||||
Type operator()(const scalar) const;
|
||||
};
|
||||
|
||||
|
||||
@ -166,6 +153,8 @@ public:
|
||||
# include "interpolationTable.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -30,12 +30,10 @@ License
|
||||
#include "fvPatchFieldMapper.H"
|
||||
#include "surfaceFields.H"
|
||||
#include "Time.H"
|
||||
#include "IFstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::
|
||||
timeVaryingFlowRateInletVelocityFvPatchVectorField::
|
||||
Foam::timeVaryingFlowRateInletVelocityFvPatchVectorField::
|
||||
timeVaryingFlowRateInletVelocityFvPatchVectorField
|
||||
(
|
||||
const fvPatch& p,
|
||||
@ -47,8 +45,7 @@ timeVaryingFlowRateInletVelocityFvPatchVectorField
|
||||
{}
|
||||
|
||||
|
||||
Foam::
|
||||
timeVaryingFlowRateInletVelocityFvPatchVectorField::
|
||||
Foam::timeVaryingFlowRateInletVelocityFvPatchVectorField::
|
||||
timeVaryingFlowRateInletVelocityFvPatchVectorField
|
||||
(
|
||||
const timeVaryingFlowRateInletVelocityFvPatchVectorField& ptf,
|
||||
@ -62,8 +59,7 @@ timeVaryingFlowRateInletVelocityFvPatchVectorField
|
||||
{}
|
||||
|
||||
|
||||
Foam::
|
||||
timeVaryingFlowRateInletVelocityFvPatchVectorField::
|
||||
Foam::timeVaryingFlowRateInletVelocityFvPatchVectorField::
|
||||
timeVaryingFlowRateInletVelocityFvPatchVectorField
|
||||
(
|
||||
const fvPatch& p,
|
||||
@ -72,12 +68,11 @@ timeVaryingFlowRateInletVelocityFvPatchVectorField
|
||||
)
|
||||
:
|
||||
flowRateInletVelocityFvPatchVectorField(p, iF, dict),
|
||||
timeSeries_(this->db(), dict)
|
||||
timeSeries_(dict)
|
||||
{}
|
||||
|
||||
|
||||
Foam::
|
||||
timeVaryingFlowRateInletVelocityFvPatchVectorField::
|
||||
Foam::timeVaryingFlowRateInletVelocityFvPatchVectorField::
|
||||
timeVaryingFlowRateInletVelocityFvPatchVectorField
|
||||
(
|
||||
const timeVaryingFlowRateInletVelocityFvPatchVectorField& ptf
|
||||
@ -88,8 +83,7 @@ timeVaryingFlowRateInletVelocityFvPatchVectorField
|
||||
{}
|
||||
|
||||
|
||||
Foam::
|
||||
timeVaryingFlowRateInletVelocityFvPatchVectorField::
|
||||
Foam::timeVaryingFlowRateInletVelocityFvPatchVectorField::
|
||||
timeVaryingFlowRateInletVelocityFvPatchVectorField
|
||||
(
|
||||
const timeVaryingFlowRateInletVelocityFvPatchVectorField& ptf,
|
||||
@ -103,8 +97,7 @@ timeVaryingFlowRateInletVelocityFvPatchVectorField
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::
|
||||
timeVaryingFlowRateInletVelocityFvPatchVectorField::
|
||||
void Foam::timeVaryingFlowRateInletVelocityFvPatchVectorField::
|
||||
updateCoeffs()
|
||||
{
|
||||
if (updated())
|
||||
@ -117,8 +110,7 @@ updateCoeffs()
|
||||
}
|
||||
|
||||
|
||||
void Foam::
|
||||
timeVaryingFlowRateInletVelocityFvPatchVectorField::
|
||||
void Foam::timeVaryingFlowRateInletVelocityFvPatchVectorField::
|
||||
write(Ostream& os) const
|
||||
{
|
||||
flowRateInletVelocityFvPatchVectorField::write(os);
|
||||
|
||||
@ -26,7 +26,6 @@ License
|
||||
|
||||
#include "timeVaryingUniformFixedValueFvPatchField.H"
|
||||
#include "Time.H"
|
||||
#include "IFstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
@ -53,7 +52,7 @@ timeVaryingUniformFixedValueFvPatchField
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<Type>(p, iF),
|
||||
timeSeries_(this->db(), dict)
|
||||
timeSeries_(dict)
|
||||
{
|
||||
if (dict.found("value"))
|
||||
{
|
||||
|
||||
@ -29,7 +29,6 @@ License
|
||||
#include "fvPatchFieldMapper.H"
|
||||
#include "volFields.H"
|
||||
#include "surfaceFields.H"
|
||||
#include "IFstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
@ -66,7 +65,7 @@ timeVaryingUniformTotalPressureFvPatchScalarField
|
||||
psiName_(dict.lookup("psi")),
|
||||
gamma_(readScalar(dict.lookup("gamma"))),
|
||||
p0_(readScalar(dict.lookup("p0"))),
|
||||
totalPressureTimeSeries_(this->db(), dict)
|
||||
totalPressureTimeSeries_(dict)
|
||||
{
|
||||
if (dict.found("value"))
|
||||
{
|
||||
@ -215,7 +214,8 @@ void Foam::timeVaryingUniformTotalPressureFvPatchScalarField::updateCoeffs()
|
||||
}
|
||||
|
||||
|
||||
void Foam::timeVaryingUniformTotalPressureFvPatchScalarField::write(Ostream& os) const
|
||||
void Foam::timeVaryingUniformTotalPressureFvPatchScalarField::
|
||||
write(Ostream& os) const
|
||||
{
|
||||
fvPatchScalarField::write(os);
|
||||
os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl;
|
||||
|
||||
Reference in New Issue
Block a user