mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
updated time varying boundary conditions
This commit is contained in:
@ -28,8 +28,6 @@ License
|
||||
#include "Time.H"
|
||||
#include "IFstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
@ -57,8 +55,7 @@ timeVaryingUniformFixedValuePointPatchField
|
||||
)
|
||||
:
|
||||
fixedValuePointPatchField<Type>(ptf, p, iF, mapper),
|
||||
timeDataFile_(ptf.timeDataFile_),
|
||||
timeSeries_(ptf.timeBounding())
|
||||
timeSeries_(ptf.timeSeries_)
|
||||
{}
|
||||
|
||||
|
||||
@ -73,8 +70,7 @@ timeVaryingUniformFixedValuePointPatchField
|
||||
)
|
||||
:
|
||||
fixedValuePointPatchField<Type>(p, iF),
|
||||
timeDataFile_(dict.lookup("timeDataFile")),
|
||||
timeSeries_(word(dict.lookup("timeBounding")))
|
||||
timeSeries_(this->db(), dict)
|
||||
{
|
||||
updateCoeffs();
|
||||
}
|
||||
@ -89,8 +85,7 @@ timeVaryingUniformFixedValuePointPatchField
|
||||
)
|
||||
:
|
||||
fixedValuePointPatchField<Type>(ptf),
|
||||
timeDataFile_(ptf.timeDataFile_),
|
||||
timeSeries_(ptf.timeBounding())
|
||||
timeSeries_(ptf.timeSeries_)
|
||||
{}
|
||||
|
||||
|
||||
@ -104,67 +99,12 @@ timeVaryingUniformFixedValuePointPatchField
|
||||
)
|
||||
:
|
||||
fixedValuePointPatchField<Type>(ptf, iF),
|
||||
timeDataFile_(ptf.timeDataFile_),
|
||||
timeSeries_(ptf.timeBounding())
|
||||
timeSeries_(ptf.timeSeries_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Type
|
||||
Foam::timeVaryingUniformFixedValuePointPatchField<Type>::
|
||||
currentValue()
|
||||
{
|
||||
if (timeSeries_.size() == 0)
|
||||
{
|
||||
fileName fName(timeDataFile_);
|
||||
fName.expand();
|
||||
|
||||
if (fName.size() == 0)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"timeVaryingUniformFixedValuePointPatchField"
|
||||
"::currentValue()"
|
||||
) << "timeDataFile not specified for Patch "
|
||||
<< this->patch().name()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
else
|
||||
{
|
||||
// relative path
|
||||
if (fName[0] != '/')
|
||||
{
|
||||
fName = this->db().path()/fName;
|
||||
}
|
||||
|
||||
// just in case we change the interface to timeSeries
|
||||
word boundType = timeBounding();
|
||||
|
||||
IFstream(fName)() >> timeSeries_;
|
||||
timeSeries_.bounding(boundType);
|
||||
|
||||
// be a bit paranoid and check that the list is okay
|
||||
timeSeries_.check();
|
||||
}
|
||||
|
||||
if (timeSeries_.size() == 0)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"timeVaryingUniformFixedValuePointPatchField"
|
||||
"::currentValue()"
|
||||
) << "empty time series for Patch "
|
||||
<< this->patch().name()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
return timeSeries_(this->db().time().timeOutputValue());
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::timeVaryingUniformFixedValuePointPatchField<Type>::updateCoeffs()
|
||||
{
|
||||
@ -173,7 +113,7 @@ void Foam::timeVaryingUniformFixedValuePointPatchField<Type>::updateCoeffs()
|
||||
return;
|
||||
}
|
||||
|
||||
this->operator==(currentValue());
|
||||
this->operator==(timeSeries_(this->db().time().timeOutputValue()));
|
||||
fixedValuePointPatchField<Type>::updateCoeffs();
|
||||
}
|
||||
|
||||
@ -182,13 +122,8 @@ template<class Type>
|
||||
void Foam::timeVaryingUniformFixedValuePointPatchField<Type>::write(Ostream& os) const
|
||||
{
|
||||
fixedValuePointPatchField<Type>::write(os);
|
||||
os.writeKeyword("timeDataFile")
|
||||
<< timeDataFile_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("timeBounding")
|
||||
<< timeBounding() << token::END_STATEMENT << nl;
|
||||
timeSeries_.write(os);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -40,7 +40,7 @@ SourceFiles
|
||||
#define timeVaryingUniformFixedValuePointPatchField_H
|
||||
|
||||
#include "fixedValuePointPatchField.H"
|
||||
#include "timeSeries.H"
|
||||
#include "interpolationTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -58,14 +58,9 @@ class timeVaryingUniformFixedValuePointPatchField
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- file containing time/uniformFixedValue
|
||||
fileName timeDataFile_;
|
||||
|
||||
//- the time series being used, including the bounding treatment
|
||||
timeSeries<Type> timeSeries_;
|
||||
interpolationTable<Type> timeSeries_;
|
||||
|
||||
//- interpolate the value at the current time
|
||||
Type currentValue();
|
||||
|
||||
public:
|
||||
|
||||
@ -138,14 +133,8 @@ public:
|
||||
|
||||
// Access
|
||||
|
||||
//- Return the out-of-bounds treatment as a word
|
||||
word timeBounding() const
|
||||
{
|
||||
return timeSeries_.bounding();
|
||||
}
|
||||
|
||||
//- Return the time series used
|
||||
const timeSeries<Type>& timeData() const
|
||||
const interpolationTable<Type>& timeSeries() const
|
||||
{
|
||||
return timeSeries_;
|
||||
}
|
||||
|
||||
@ -0,0 +1,482 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "interpolationTable.H"
|
||||
#include "IFstream.H"
|
||||
#include "objectRegistry.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::interpolationTable<Type>::interpolationTable()
|
||||
:
|
||||
List<Tuple2<scalar, Type> >(),
|
||||
dict_(dictionary::null),
|
||||
boundAction_(interpolationTable::WARN),
|
||||
fileName_("undefined_fileName")
|
||||
{}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::interpolationTable<Type>::interpolationTable
|
||||
(
|
||||
const objectRegistry& obr,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
List<Tuple2<scalar, Type> >(),
|
||||
dict_(dict),
|
||||
boundAction_(wordToBoundAction(dict.lookup("boundAction"))),
|
||||
fileName_(dict.lookup("fileName"))
|
||||
{
|
||||
fileName_.expand();
|
||||
|
||||
// Correct for relative path
|
||||
if (fileName_[0] != '/')
|
||||
{
|
||||
fileName_ = obr.db().path()/fileName_;
|
||||
}
|
||||
|
||||
// Read data from file
|
||||
IFstream(fileName_)() >> *this;
|
||||
|
||||
// Check that the data is okay
|
||||
check();
|
||||
|
||||
if (this->size() == 0)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"Foam::interpolationTable<Type>::interpolationTable"
|
||||
"(const dictionary& dict)"
|
||||
) << "table is empty" << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::interpolationTable<Type>::interpolationTable
|
||||
(
|
||||
const interpolationTable& interpTable
|
||||
)
|
||||
:
|
||||
List<Tuple2<scalar, Type> >(interpTable),
|
||||
dict_(interpTable.dict_),
|
||||
boundAction_(interpTable.boundAction_),
|
||||
fileName_(interpTable.fileName_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::interpolationTable<Type>::~interpolationTable()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::word Foam::interpolationTable<Type>::boundActionToWord
|
||||
(
|
||||
const boundActions& bound
|
||||
) const
|
||||
{
|
||||
word enumName("warn");
|
||||
|
||||
switch (bound)
|
||||
{
|
||||
case interpolationTable::ERROR:
|
||||
{
|
||||
enumName = "error";
|
||||
break;
|
||||
}
|
||||
case interpolationTable::WARN:
|
||||
{
|
||||
enumName = "warn";
|
||||
break;
|
||||
}
|
||||
case interpolationTable::CLAMP:
|
||||
{
|
||||
enumName = "clamp";
|
||||
break;
|
||||
}
|
||||
case interpolationTable::REPEAT:
|
||||
{
|
||||
enumName = "repeat";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return enumName;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
typename Foam::interpolationTable<Type>::boundActions
|
||||
Foam::interpolationTable<Type>::wordToBoundAction
|
||||
(
|
||||
const word& bound
|
||||
) const
|
||||
{
|
||||
if (bound == "error")
|
||||
{
|
||||
return interpolationTable::ERROR;
|
||||
}
|
||||
else if (bound == "warn")
|
||||
{
|
||||
return interpolationTable::WARN;
|
||||
}
|
||||
else if (bound == "clamp")
|
||||
{
|
||||
return interpolationTable::CLAMP;
|
||||
}
|
||||
else if (bound == "repeat")
|
||||
{
|
||||
return interpolationTable::REPEAT;
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"Foam::interpolationTable<Type>::wordToBoundAction(const word&)"
|
||||
) << "bad bounding specifier " << bound << " using 'warn'" << endl;
|
||||
|
||||
return interpolationTable::WARN;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::interpolationTable<Type>::check() const
|
||||
{
|
||||
label n = size();
|
||||
scalar prevValue = List<Tuple2<scalar, Type> >::operator[](0).first();
|
||||
|
||||
for (label i=1; i<n; ++i)
|
||||
{
|
||||
const scalar currValue =
|
||||
List<Tuple2<scalar, Type> >::operator[](i).first();
|
||||
|
||||
// avoid duplicate values (divide-by-zero error)
|
||||
if (currValue <= prevValue)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"Foam::interpolationTable<Type>::checkOrder() const"
|
||||
) << "out-of-order value: "
|
||||
<< currValue << " at index " << i << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
prevValue = currValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
typename Foam::interpolationTable<Type>::boundActions
|
||||
Foam::interpolationTable<Type>::boundAction
|
||||
(
|
||||
const boundActions& bound
|
||||
)
|
||||
{
|
||||
boundActions prev = boundAction_;
|
||||
boundAction_ = bound;
|
||||
return prev;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::interpolationTable<Type>::write(Ostream& os) const
|
||||
{
|
||||
os.writeKeyword("fileName")
|
||||
<< fileName_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("boundAction")
|
||||
<< boundActionToWord(boundAction_) << token::END_STATEMENT << nl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
const Foam::Tuple2<Foam::scalar, Type>&
|
||||
Foam::interpolationTable<Type>::operator[](const label i) const
|
||||
{
|
||||
label ii = i;
|
||||
label n = size();
|
||||
|
||||
if (n <= 1)
|
||||
{
|
||||
ii = 0;
|
||||
}
|
||||
else if (ii < 0)
|
||||
{
|
||||
switch (boundAction_)
|
||||
{
|
||||
case interpolationTable::ERROR:
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"Foam::interpolationTable<Type>::operator[]"
|
||||
"(const label) const"
|
||||
) << "index (" << ii << ") underflow" << nl
|
||||
<< exit(FatalError);
|
||||
break;
|
||||
}
|
||||
case interpolationTable::WARN:
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"Foam::interpolationTable<Type>::operator[]"
|
||||
"(const label) const"
|
||||
) << "index (" << ii << ") underflow" << nl
|
||||
<< " Continuing with the first entry"
|
||||
<< endl;
|
||||
// fall-through to 'CLAMP'
|
||||
}
|
||||
case interpolationTable::CLAMP:
|
||||
{
|
||||
ii = 0;
|
||||
break;
|
||||
}
|
||||
case interpolationTable::REPEAT:
|
||||
{
|
||||
while (ii < 0)
|
||||
{
|
||||
ii += n;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (ii >= n)
|
||||
{
|
||||
switch (boundAction_)
|
||||
{
|
||||
case interpolationTable::ERROR:
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"Foam::interpolationTable<Type>::operator[]"
|
||||
"(const label) const"
|
||||
) << "index (" << ii << ") overflow" << nl
|
||||
<< exit(FatalError);
|
||||
break;
|
||||
}
|
||||
case interpolationTable::WARN:
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"Foam::interpolationTable<Type>::operator[]"
|
||||
"(const label) const"
|
||||
) << "index (" << ii << ") overflow" << nl
|
||||
<< " Continuing with the last entry"
|
||||
<< endl;
|
||||
// fall-through to 'CLAMP'
|
||||
}
|
||||
case interpolationTable::CLAMP:
|
||||
{
|
||||
ii = n - 1;
|
||||
break;
|
||||
}
|
||||
case interpolationTable::REPEAT:
|
||||
{
|
||||
while (ii >= n)
|
||||
{
|
||||
ii -= n;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return List<Tuple2<scalar, Type> >::operator[](ii);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::interpolationTable<Type>::operator()(const scalar value) const
|
||||
{
|
||||
label n = size();
|
||||
|
||||
if (n <= 1)
|
||||
{
|
||||
return List<Tuple2<scalar, Type> >::operator[](0).second();
|
||||
}
|
||||
|
||||
scalar minLimit = List<Tuple2<scalar, Type> >::operator[](0).first();
|
||||
scalar maxLimit = List<Tuple2<scalar, Type> >::operator[](n-1).first();
|
||||
scalar lookupValue = value;
|
||||
|
||||
if (lookupValue < minLimit)
|
||||
{
|
||||
switch (boundAction_)
|
||||
{
|
||||
case interpolationTable::ERROR:
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"Foam::interpolationTable<Type>::operator[]"
|
||||
"(const scalar) const"
|
||||
) << "value (" << lookupValue << ") underflow" << nl
|
||||
<< exit(FatalError);
|
||||
break;
|
||||
}
|
||||
case interpolationTable::WARN:
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"Foam::interpolationTable<Type>::operator[]"
|
||||
"(const scalar) const"
|
||||
) << "value (" << lookupValue << ") underflow" << nl
|
||||
<< " Continuing with the first entry"
|
||||
<< endl;
|
||||
// fall-through to 'CLAMP'
|
||||
}
|
||||
case interpolationTable::CLAMP:
|
||||
{
|
||||
return List<Tuple2<scalar, Type> >::operator[](0).second();
|
||||
break;
|
||||
}
|
||||
case interpolationTable::REPEAT:
|
||||
{
|
||||
// adjust lookupValue to >= 0
|
||||
while (lookupValue < 0)
|
||||
{
|
||||
lookupValue += maxLimit;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (lookupValue >= maxLimit)
|
||||
{
|
||||
switch (boundAction_)
|
||||
{
|
||||
case interpolationTable::ERROR:
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"Foam::interpolationTable<Type>::operator[]"
|
||||
"(const label) const"
|
||||
) << "value (" << lookupValue << ") overflow" << nl
|
||||
<< exit(FatalError);
|
||||
break;
|
||||
}
|
||||
case interpolationTable::WARN:
|
||||
{
|
||||
WarningIn
|
||||
(
|
||||
"Foam::interpolationTable<Type>::operator[]"
|
||||
"(const label) const"
|
||||
) << "value (" << lookupValue << ") overflow" << nl
|
||||
<< " Continuing with the last entry"
|
||||
<< endl;
|
||||
// fall-through to 'CLAMP'
|
||||
}
|
||||
case interpolationTable::CLAMP:
|
||||
{
|
||||
return List<Tuple2<scalar, Type> >::operator[](n-1).second();
|
||||
break;
|
||||
}
|
||||
case interpolationTable::REPEAT:
|
||||
{
|
||||
// adjust lookupValue <= maxLimit
|
||||
while (lookupValue > maxLimit)
|
||||
{
|
||||
lookupValue -= maxLimit;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
label lo = 0;
|
||||
label hi = 0;
|
||||
|
||||
// look for the correct range
|
||||
for (label i = 0; i < n; ++i)
|
||||
{
|
||||
if (lookupValue >= List<Tuple2<scalar, Type> >::operator[](i).first())
|
||||
{
|
||||
lo = hi = i;
|
||||
}
|
||||
else
|
||||
{
|
||||
hi = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (lo == hi)
|
||||
{
|
||||
// we are at the end of the table - or there is only a single entry
|
||||
return List<Tuple2<scalar, Type> >::operator[](hi).second();
|
||||
}
|
||||
else if (hi == 0)
|
||||
{
|
||||
// this treatment should should only occur under these conditions:
|
||||
// -> the 'REPEAT' treatment
|
||||
// -> (0 <= value <= minLimit)
|
||||
// -> minLimit > 0
|
||||
// Use the value at maxLimit as the value for value=0
|
||||
lo = n - 1;
|
||||
|
||||
return
|
||||
(
|
||||
List<Tuple2<scalar, Type> >::operator[](lo).second()
|
||||
+ (
|
||||
List<Tuple2<scalar, Type> >::operator[](hi).second()
|
||||
- List<Tuple2<scalar, Type> >::operator[](lo).second()
|
||||
)
|
||||
*(lookupValue / minLimit)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
// normal interpolation
|
||||
return
|
||||
(
|
||||
List<Tuple2<scalar, Type> >::operator[](lo).second()
|
||||
+ (
|
||||
List<Tuple2<scalar, Type> >::operator[](hi).second()
|
||||
- List<Tuple2<scalar, Type> >::operator[](lo).second()
|
||||
)
|
||||
*(
|
||||
lookupValue
|
||||
- List<Tuple2<scalar, Type> >::operator[](lo).first()
|
||||
)
|
||||
/(
|
||||
List<Tuple2<scalar, Type> >::operator[](hi).first()
|
||||
- List<Tuple2<scalar, Type> >::operator[](lo).first()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -23,7 +23,7 @@ License
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::timeSeries
|
||||
Foam::interpolationTable
|
||||
|
||||
Description
|
||||
A list of times and values.
|
||||
@ -40,12 +40,12 @@ Note
|
||||
- Accessing a list with a single element will always return the same value.
|
||||
|
||||
SourceFiles
|
||||
timeSeries.C
|
||||
interpolationTable.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef timeSeries_H
|
||||
#define timeSeries_H
|
||||
#ifndef interpolationTable_H
|
||||
#define interpolationTable_H
|
||||
|
||||
#include "List.H"
|
||||
#include "Tuple2.H"
|
||||
@ -55,21 +55,23 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class objectRegistry;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class timeSeries Declaration
|
||||
Class interpolationTable Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class T>
|
||||
class timeSeries
|
||||
template<class Type>
|
||||
class interpolationTable
|
||||
:
|
||||
public List<Tuple2<scalar, T> >
|
||||
public List<Tuple2<scalar, Type> >
|
||||
{
|
||||
public:
|
||||
|
||||
// Public data types
|
||||
|
||||
//- Enumeration for handling out-of-bound times
|
||||
enum bounds
|
||||
//- Enumeration for handling out-of-bound values
|
||||
enum boundActions
|
||||
{
|
||||
ERROR, /*!< Exit with a FatalError */
|
||||
WARN, /*!< Issue warning and clamp value (default) */
|
||||
@ -77,86 +79,96 @@ public:
|
||||
REPEAT /*!< Treat as a repeating list */
|
||||
};
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private data
|
||||
|
||||
//- Enumeration for handling out-of-bound times
|
||||
bounds bounding_;
|
||||
//- Parent dictionary
|
||||
const dictionary& dict_;
|
||||
|
||||
//- Enumeration for handling out-of-bound values
|
||||
boundActions boundAction_;
|
||||
|
||||
//- File name
|
||||
fileName fileName_;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null, optionally with a given bounding
|
||||
timeSeries(const bounds = timeSeries::WARN);
|
||||
//- Construct null
|
||||
interpolationTable();
|
||||
|
||||
//- Construct null with a given bounding
|
||||
timeSeries(const word&);
|
||||
//- Construct from objectRegistry and dictionary
|
||||
interpolationTable(const objectRegistry& obr, const dictionary& dict);
|
||||
|
||||
//- Construct from Istream, optionally with a given bounding
|
||||
timeSeries(Istream&, const bounds = timeSeries::WARN);
|
||||
//- Construct copy
|
||||
interpolationTable(const interpolationTable& interpTable);
|
||||
|
||||
//- Construct from Istream with a given bounding
|
||||
timeSeries(Istream&, const word&);
|
||||
|
||||
// Destructor
|
||||
//- Destructor
|
||||
~interpolationTable();
|
||||
|
||||
~timeSeries();
|
||||
|
||||
// Member Functions
|
||||
|
||||
// Access
|
||||
// Access
|
||||
|
||||
//- Return the size
|
||||
label size() const
|
||||
{
|
||||
return List<Tuple2<scalar, T> >::size();
|
||||
}
|
||||
//- Return the size
|
||||
label size() const
|
||||
{
|
||||
return List<Tuple2<scalar, Type> >::size();
|
||||
}
|
||||
|
||||
//- Return the out-of-bounds treatment as a word
|
||||
word bounding() const;
|
||||
//- Return the out-of-bounds treatment as a word
|
||||
word boundActionToWord(const boundActions& bound) const;
|
||||
|
||||
// Check
|
||||
//- Return the out-of-bounds treatment as an enumeration
|
||||
boundActions wordToBoundAction(const word& bound) const;
|
||||
|
||||
//- Check that list is monotonically increasing
|
||||
// Exit with a FatalError if there is a problem
|
||||
void check() const;
|
||||
|
||||
// Edit
|
||||
// Check
|
||||
|
||||
//- Set the out-of-bounds treatment from enum, return previous setting
|
||||
bounds bounding(const bounds& bound)
|
||||
{
|
||||
bounds prev = bounding_;
|
||||
bounding_ = bound;
|
||||
return prev;
|
||||
}
|
||||
//- Check that list is monotonically increasing
|
||||
// Exit with a FatalError if there is a problem
|
||||
void check() const;
|
||||
|
||||
//- Set the out-of-bounds treatment from word
|
||||
void bounding(const word& bound);
|
||||
|
||||
// Member Operators
|
||||
// Edit
|
||||
|
||||
//- Return an element of constant Tuple2<scalar, T>
|
||||
const Tuple2<scalar, T>& operator[](const label) const;
|
||||
//- Set the out-of-bounds treatment from enum, return previous
|
||||
// setting
|
||||
boundActions boundAction(const boundActions& bound);
|
||||
|
||||
//- Return an interpolated value
|
||||
T operator()(const scalar) const;
|
||||
|
||||
// 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;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "timeSeries.C"
|
||||
# include "interpolationTable.C"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,402 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2008 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "timeSeries.H"
|
||||
#include "Istream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<typename T>
|
||||
Foam::timeSeries<T>::timeSeries(const bounds bound)
|
||||
:
|
||||
List<Tuple2<scalar, T> >(),
|
||||
bounding_(bound)
|
||||
{}
|
||||
|
||||
|
||||
template<typename T>
|
||||
Foam::timeSeries<T>::timeSeries(const word& bound)
|
||||
:
|
||||
List<Tuple2<scalar, T> >(),
|
||||
bounding_(timeSeries::WARN)
|
||||
{
|
||||
bounding(bound);
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
Foam::timeSeries<T>::timeSeries(Istream& is, const bounds bound)
|
||||
:
|
||||
List<Tuple2<scalar, T> >(is),
|
||||
bounding_(bound)
|
||||
{}
|
||||
|
||||
|
||||
template<typename T>
|
||||
Foam::timeSeries<T>::timeSeries(Istream& is, const word& bound)
|
||||
:
|
||||
List<Tuple2<scalar, T> >(is),
|
||||
bounding_(timeSeries::WARN)
|
||||
{
|
||||
bounding(bound);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<typename T>
|
||||
Foam::timeSeries<T>::~timeSeries()
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<typename T>
|
||||
Foam::word Foam::timeSeries<T>::bounding() const
|
||||
{
|
||||
word enumName("warn");
|
||||
|
||||
switch (bounding_)
|
||||
{
|
||||
case timeSeries::ERROR:
|
||||
enumName = "error";
|
||||
break;
|
||||
|
||||
case timeSeries::WARN:
|
||||
enumName = "warn";
|
||||
break;
|
||||
|
||||
case timeSeries::CLAMP:
|
||||
enumName = "clamp";
|
||||
break;
|
||||
|
||||
case timeSeries::REPEAT:
|
||||
enumName = "repeat";
|
||||
break;
|
||||
}
|
||||
|
||||
return enumName;
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
void Foam::timeSeries<T>::bounding(const word& bound)
|
||||
{
|
||||
if (bound == "error")
|
||||
{
|
||||
bounding_ = timeSeries::ERROR;
|
||||
}
|
||||
else if (bound == "warn")
|
||||
{
|
||||
bounding_ = timeSeries::WARN;
|
||||
}
|
||||
else if (bound == "clamp")
|
||||
{
|
||||
bounding_ = timeSeries::CLAMP;
|
||||
}
|
||||
else if (bound == "repeat")
|
||||
{
|
||||
bounding_ = timeSeries::REPEAT;
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningIn("Foam::timeSeries<T>::boundingEnum(const word&)")
|
||||
<< "bad bounding specifier " << bound << " using 'warn'" << endl;
|
||||
|
||||
bounding_ = timeSeries::WARN;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
void Foam::timeSeries<T>::check() const
|
||||
{
|
||||
label n = size();
|
||||
scalar prevTime = List<Tuple2<scalar, T> >::operator[](0).first();
|
||||
|
||||
for (label i = 1; i < n; ++i)
|
||||
{
|
||||
const scalar currTime = List<Tuple2<scalar, T> >::operator[](i).first();
|
||||
|
||||
// avoid duplicate times (divide-by-zero error)
|
||||
if (currTime <= prevTime)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"Foam::timeSeries<T>::checkOrder() const"
|
||||
) << "out-of-order time: "
|
||||
<< currTime << " at index " << i << nl
|
||||
<< exit(FatalError);
|
||||
}
|
||||
prevTime = currTime;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
template<typename T>
|
||||
const Foam::Tuple2<Foam::scalar, T>&
|
||||
Foam::timeSeries<T>::operator[](const label i) const
|
||||
{
|
||||
label ii = i;
|
||||
label n = size();
|
||||
|
||||
if (n <= 1)
|
||||
{
|
||||
ii = 0;
|
||||
}
|
||||
else if (ii < 0)
|
||||
{
|
||||
switch (bounding_)
|
||||
{
|
||||
case timeSeries::ERROR:
|
||||
FatalErrorIn
|
||||
(
|
||||
"Foam::timeSeries<T>::operator[](const label) const"
|
||||
) << "index (" << ii << ") underflow" << nl
|
||||
<< exit(FatalError);
|
||||
break;
|
||||
|
||||
case timeSeries::WARN:
|
||||
WarningIn
|
||||
(
|
||||
"Foam::timeSeries<T>::operator[](const label) const"
|
||||
) << "index (" << ii << ") underflow" << nl
|
||||
<< " Continuing with the first entry"
|
||||
<< endl;
|
||||
// fall-through to 'CLAMP'
|
||||
|
||||
case timeSeries::CLAMP:
|
||||
ii = 0;
|
||||
break;
|
||||
|
||||
case timeSeries::REPEAT:
|
||||
while (ii < 0)
|
||||
{
|
||||
ii += n;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (ii >= n)
|
||||
{
|
||||
switch (bounding_)
|
||||
{
|
||||
case timeSeries::ERROR:
|
||||
FatalErrorIn
|
||||
(
|
||||
"Foam::timeSeries<T>::operator[](const label) const"
|
||||
) << "index (" << ii << ") overflow" << nl
|
||||
<< exit(FatalError);
|
||||
break;
|
||||
|
||||
case timeSeries::WARN:
|
||||
WarningIn
|
||||
(
|
||||
"Foam::timeSeries<T>::operator[](const label) const"
|
||||
) << "index (" << ii << ") overflow" << nl
|
||||
<< " Continuing with the last entry"
|
||||
<< endl;
|
||||
// fall-through to 'CLAMP'
|
||||
|
||||
case timeSeries::CLAMP:
|
||||
ii = n - 1;
|
||||
break;
|
||||
|
||||
case timeSeries::REPEAT:
|
||||
while (ii >= n)
|
||||
{
|
||||
ii -= n;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return List<Tuple2<scalar, T> >::operator[](ii);
|
||||
}
|
||||
|
||||
|
||||
template<typename T>
|
||||
T Foam::timeSeries<T>::operator()(const scalar timeValue) const
|
||||
{
|
||||
label n = size();
|
||||
|
||||
if (n <= 1)
|
||||
{
|
||||
return List<Tuple2<scalar, T> >::operator[](0).second();
|
||||
}
|
||||
|
||||
scalar minTime = List<Tuple2<scalar, T> >::operator[](0).first();
|
||||
scalar maxTime = List<Tuple2<scalar, T> >::operator[](n-1).first();
|
||||
scalar lookupTime = timeValue;
|
||||
|
||||
if (lookupTime < minTime)
|
||||
{
|
||||
switch (bounding_)
|
||||
{
|
||||
case timeSeries::ERROR:
|
||||
FatalErrorIn
|
||||
(
|
||||
"Foam::timeSeries<T>::operator[](const scalar) const"
|
||||
) << "time (" << lookupTime << ") underflow" << nl
|
||||
<< exit(FatalError);
|
||||
break;
|
||||
|
||||
case timeSeries::WARN:
|
||||
WarningIn
|
||||
(
|
||||
"Foam::timeSeries<T>::operator[](const scalar) const"
|
||||
) << "time (" << lookupTime << ") underflow" << nl
|
||||
<< " Continuing with the first entry"
|
||||
<< endl;
|
||||
// fall-through to 'CLAMP'
|
||||
|
||||
case timeSeries::CLAMP:
|
||||
return List<Tuple2<scalar, T> >::operator[](0).second();
|
||||
break;
|
||||
|
||||
case timeSeries::REPEAT:
|
||||
// adjust lookupTime to >= 0
|
||||
while (lookupTime < 0)
|
||||
{
|
||||
lookupTime += maxTime;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (lookupTime >= maxTime)
|
||||
{
|
||||
switch (bounding_)
|
||||
{
|
||||
case timeSeries::ERROR:
|
||||
FatalErrorIn
|
||||
(
|
||||
"Foam::timeSeries<T>::operator[](const label) const"
|
||||
) << "time (" << lookupTime << ") overflow" << nl
|
||||
<< exit(FatalError);
|
||||
break;
|
||||
|
||||
case timeSeries::WARN:
|
||||
WarningIn
|
||||
(
|
||||
"Foam::timeSeries<T>::operator[](const label) const"
|
||||
) << "time (" << lookupTime << ") overflow" << nl
|
||||
<< " Continuing with the last entry"
|
||||
<< endl;
|
||||
// fall-through to 'CLAMP'
|
||||
|
||||
case timeSeries::CLAMP:
|
||||
return List<Tuple2<scalar, T> >::operator[](n-1).second();
|
||||
break;
|
||||
|
||||
case timeSeries::REPEAT:
|
||||
// adjust lookupTime <= maxTime
|
||||
while (lookupTime > maxTime)
|
||||
{
|
||||
lookupTime -= maxTime;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
label lo = 0;
|
||||
label hi = 0;
|
||||
|
||||
// look for the correct range
|
||||
for (label i = 0; i < n; ++i)
|
||||
{
|
||||
if (lookupTime >= List<Tuple2<scalar, T> >::operator[](i).first())
|
||||
{
|
||||
lo = hi = i;
|
||||
}
|
||||
else
|
||||
{
|
||||
hi = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (lo == hi)
|
||||
{
|
||||
// we are at the end of the table - or there is only a single entry
|
||||
return List<Tuple2<scalar, T> >::operator[](hi).second();
|
||||
}
|
||||
else if (hi == 0)
|
||||
{
|
||||
// this treatment should should only occur under these condition:
|
||||
// -> the 'REPEAT' treatment
|
||||
// -> (0 <= time <= minTime)
|
||||
// -> minTime > 0
|
||||
// Use the value at maxTime as the value for time=0
|
||||
lo = n - 1;
|
||||
|
||||
return
|
||||
(
|
||||
List<Tuple2<scalar, T> >::operator[](lo).second()
|
||||
+
|
||||
(
|
||||
List<Tuple2<scalar, T> >::operator[](hi).second()
|
||||
- List<Tuple2<scalar, T> >::operator[](lo).second()
|
||||
)
|
||||
* (lookupTime / minTime)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
// normal interpolation
|
||||
return
|
||||
(
|
||||
List<Tuple2<scalar, T> >::operator[](lo).second()
|
||||
+
|
||||
(
|
||||
List<Tuple2<scalar, T> >::operator[](hi).second()
|
||||
- List<Tuple2<scalar, T> >::operator[](lo).second()
|
||||
)
|
||||
*
|
||||
(
|
||||
lookupTime
|
||||
- List<Tuple2<scalar, T> >::operator[](lo).first()
|
||||
)
|
||||
/
|
||||
(
|
||||
List<Tuple2<scalar, T> >::operator[](hi).first()
|
||||
- List<Tuple2<scalar, T> >::operator[](lo).first()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -78,7 +78,7 @@ $(derivedFvPatchFields)/freestream/freestreamFvPatchFields.C
|
||||
$(derivedFvPatchFields)/freestreamPressure/freestreamPressureFvPatchScalarField.C
|
||||
$(derivedFvPatchFields)/inletOutlet/inletOutletFvPatchFields.C
|
||||
$(derivedFvPatchFields)/inletOutletTotalTemperature/inletOutletTotalTemperatureFvPatchScalarField.C
|
||||
$(derivedFvPatchFields)/massFlowRateInletVelocity/massFlowRateInletVelocityFvPatchVectorField.C
|
||||
$(derivedFvPatchFields)/flowRateInletVelocity/flowRateInletVelocityFvPatchVectorField.C
|
||||
$(derivedFvPatchFields)/movingWallVelocity/movingWallVelocityFvPatchVectorField.C
|
||||
$(derivedFvPatchFields)/oscillatingFixedValue/oscillatingFixedValueFvPatchFields.C
|
||||
$(derivedFvPatchFields)/outletInlet/outletInletFvPatchFields.C
|
||||
@ -96,7 +96,7 @@ $(derivedFvPatchFields)/surfaceNormalFixedValue/surfaceNormalFixedValueFvPatchVe
|
||||
$(derivedFvPatchFields)/syringePressure/syringePressureFvPatchScalarField.C
|
||||
$(derivedFvPatchFields)/timeVaryingMappedFixedValue/AverageIOFields.C
|
||||
$(derivedFvPatchFields)/timeVaryingMappedFixedValue/timeVaryingMappedFixedValueFvPatchFields.C
|
||||
$(derivedFvPatchFields)/timeVaryingMassFlowRateInletVelocity/timeVaryingMassFlowRateInletVelocityFvPatchVectorField.C
|
||||
$(derivedFvPatchFields)/timeVaryingFlowRateInletVelocity/timeVaryingFlowRateInletVelocityFvPatchVectorField.C
|
||||
$(derivedFvPatchFields)/timeVaryingUniformFixedValue/timeVaryingUniformFixedValueFvPatchFields.C
|
||||
$(derivedFvPatchFields)/totalPressure/totalPressureFvPatchScalarField.C
|
||||
$(derivedFvPatchFields)/timeVaryingUniformTotalPressure/timeVaryingUniformTotalPressureFvPatchScalarField.C
|
||||
|
||||
@ -24,7 +24,7 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "massFlowRateInletVelocityFvPatchVectorField.H"
|
||||
#include "flowRateInletVelocityFvPatchVectorField.H"
|
||||
#include "volFields.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "fvPatchFieldMapper.H"
|
||||
@ -33,38 +33,40 @@ License
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::
|
||||
massFlowRateInletVelocityFvPatchVectorField::
|
||||
massFlowRateInletVelocityFvPatchVectorField
|
||||
flowRateInletVelocityFvPatchVectorField::
|
||||
flowRateInletVelocityFvPatchVectorField
|
||||
(
|
||||
const fvPatch& p,
|
||||
const DimensionedField<vector, volMesh>& iF
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<vector>(p, iF),
|
||||
massFlowRate_(0),
|
||||
flowRate_(0),
|
||||
phiName_("phi"),
|
||||
rhoName_("rho")
|
||||
{}
|
||||
|
||||
|
||||
Foam::
|
||||
massFlowRateInletVelocityFvPatchVectorField::
|
||||
massFlowRateInletVelocityFvPatchVectorField
|
||||
flowRateInletVelocityFvPatchVectorField::
|
||||
flowRateInletVelocityFvPatchVectorField
|
||||
(
|
||||
const massFlowRateInletVelocityFvPatchVectorField& ptf,
|
||||
const flowRateInletVelocityFvPatchVectorField& ptf,
|
||||
const fvPatch& p,
|
||||
const DimensionedField<vector, volMesh>& iF,
|
||||
const fvPatchFieldMapper& mapper
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<vector>(ptf, p, iF, mapper),
|
||||
massFlowRate_(ptf.massFlowRate_),
|
||||
flowRate_(ptf.flowRate_),
|
||||
phiName_(ptf.phiName_),
|
||||
rhoName_(ptf.rhoName_)
|
||||
{}
|
||||
|
||||
|
||||
Foam::
|
||||
massFlowRateInletVelocityFvPatchVectorField::
|
||||
massFlowRateInletVelocityFvPatchVectorField
|
||||
flowRateInletVelocityFvPatchVectorField::
|
||||
flowRateInletVelocityFvPatchVectorField
|
||||
(
|
||||
const fvPatch& p,
|
||||
const DimensionedField<vector, volMesh>& iF,
|
||||
@ -72,7 +74,7 @@ massFlowRateInletVelocityFvPatchVectorField
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<vector>(p, iF, dict),
|
||||
massFlowRate_(readScalar(dict.lookup("massFlowRate"))),
|
||||
flowRate_(readScalar(dict.lookup("flowRate"))),
|
||||
phiName_("phi"),
|
||||
rhoName_("rho")
|
||||
{
|
||||
@ -87,29 +89,31 @@ massFlowRateInletVelocityFvPatchVectorField
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Foam::
|
||||
massFlowRateInletVelocityFvPatchVectorField::
|
||||
massFlowRateInletVelocityFvPatchVectorField
|
||||
flowRateInletVelocityFvPatchVectorField::
|
||||
flowRateInletVelocityFvPatchVectorField
|
||||
(
|
||||
const massFlowRateInletVelocityFvPatchVectorField& ptf
|
||||
const flowRateInletVelocityFvPatchVectorField& ptf
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<vector>(ptf),
|
||||
massFlowRate_(ptf.massFlowRate_),
|
||||
flowRate_(ptf.flowRate_),
|
||||
phiName_(ptf.phiName_),
|
||||
rhoName_(ptf.rhoName_)
|
||||
{}
|
||||
|
||||
|
||||
Foam::
|
||||
massFlowRateInletVelocityFvPatchVectorField::
|
||||
massFlowRateInletVelocityFvPatchVectorField
|
||||
flowRateInletVelocityFvPatchVectorField::
|
||||
flowRateInletVelocityFvPatchVectorField
|
||||
(
|
||||
const massFlowRateInletVelocityFvPatchVectorField& ptf,
|
||||
const flowRateInletVelocityFvPatchVectorField& ptf,
|
||||
const DimensionedField<vector, volMesh>& iF
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<vector>(ptf, iF),
|
||||
massFlowRate_(ptf.massFlowRate_),
|
||||
flowRate_(ptf.flowRate_),
|
||||
phiName_(ptf.phiName_),
|
||||
rhoName_(ptf.rhoName_)
|
||||
{}
|
||||
@ -117,7 +121,7 @@ massFlowRateInletVelocityFvPatchVectorField
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::massFlowRateInletVelocityFvPatchVectorField::updateCoeffs()
|
||||
void Foam::flowRateInletVelocityFvPatchVectorField::updateCoeffs()
|
||||
{
|
||||
if (updated())
|
||||
{
|
||||
@ -125,7 +129,7 @@ void Foam::massFlowRateInletVelocityFvPatchVectorField::updateCoeffs()
|
||||
}
|
||||
|
||||
// a simpler way of doing this would be nice
|
||||
scalar avgU = -massFlowRate_/gSum(patch().magSf());
|
||||
scalar avgU = -flowRate_/gSum(patch().magSf());
|
||||
|
||||
vectorField n = patch().nf();
|
||||
|
||||
@ -151,23 +155,23 @@ void Foam::massFlowRateInletVelocityFvPatchVectorField::updateCoeffs()
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"massFlowRateInletVelocityFvPatchVectorField::updateCoeffs()"
|
||||
"flowRateInletVelocityFvPatchVectorField::updateCoeffs()"
|
||||
) << "dimensions of phi are incorrect"
|
||||
<< "\n on patch " << this->patch().name()
|
||||
<< " of field " << this->dimensionedInternalField().name()
|
||||
<< " in file " << this->dimensionedInternalField().objectPath()
|
||||
<< exit(FatalError);
|
||||
<< nl << exit(FatalError);
|
||||
}
|
||||
|
||||
fixedValueFvPatchField<vector>::updateCoeffs();
|
||||
}
|
||||
|
||||
|
||||
void Foam::massFlowRateInletVelocityFvPatchVectorField::write(Ostream& os) const
|
||||
void Foam::flowRateInletVelocityFvPatchVectorField::write(Ostream& os) const
|
||||
{
|
||||
fvPatchField<vector>::write(os);
|
||||
|
||||
os.writeKeyword("massFlowRate") << massFlowRate_
|
||||
os.writeKeyword("flowRate") << flowRate_
|
||||
<< token::END_STATEMENT << nl;
|
||||
|
||||
if (phiName_ != "phi")
|
||||
@ -191,7 +195,7 @@ namespace Foam
|
||||
makePatchTypeField
|
||||
(
|
||||
fvPatchVectorField,
|
||||
massFlowRateInletVelocityFvPatchVectorField
|
||||
flowRateInletVelocityFvPatchVectorField
|
||||
);
|
||||
}
|
||||
|
||||
@ -23,19 +23,22 @@ License
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::massFlowRateInletVelocityFvPatchVectorField
|
||||
Foam::flowRateInletVelocityFvPatchVectorField
|
||||
|
||||
Description
|
||||
Describes an massflow normal vector boundary condition by its magnitude
|
||||
as an integral over its area.
|
||||
The current density is used to correct the velocity.
|
||||
Describes an volumetric/mass flow normal vector boundary condition by its
|
||||
magnitude as an integral over its area.
|
||||
The basis of the patch (volumetric or mass) is determined by the
|
||||
dimensions of the flux, phi.
|
||||
The current density is used to correct the velocity when applying the mass
|
||||
basis.
|
||||
|
||||
Example of the boundary condition specification:
|
||||
@verbatim
|
||||
inlet
|
||||
{
|
||||
type massFlowRateInletVelocity;
|
||||
massFlowRate 0.2; // Mass flow rate [kg/s]
|
||||
type flowRateInletVelocity;
|
||||
flowRate 0.2; // Volumetric/mass flow rate [m3/s or kg/s]
|
||||
value uniform (0 0 0); // placeholder
|
||||
}
|
||||
@endverbatim
|
||||
@ -46,12 +49,12 @@ Note
|
||||
- Strange behaviour with potentialFoam since the U equation is not solved
|
||||
|
||||
SourceFiles
|
||||
massFlowRateInletVelocityFvPatchVectorField.C
|
||||
flowRateInletVelocityFvPatchVectorField.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef massFlowRateInletVelocityFvPatchVectorField_H
|
||||
#define massFlowRateInletVelocityFvPatchVectorField_H
|
||||
#ifndef flowRateInletVelocityFvPatchVectorField_H
|
||||
#define flowRateInletVelocityFvPatchVectorField_H
|
||||
|
||||
#include "fixedValueFvPatchFields.H"
|
||||
|
||||
@ -60,17 +63,17 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class massFlowRateInletVelocityFvPatch Declaration
|
||||
Class flowRateInletVelocityFvPatch Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class massFlowRateInletVelocityFvPatchVectorField
|
||||
class flowRateInletVelocityFvPatchVectorField
|
||||
:
|
||||
public fixedValueFvPatchVectorField
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Inlet integral mass flow rate
|
||||
scalar massFlowRate_;
|
||||
//- Inlet integral flow rate
|
||||
scalar flowRate_;
|
||||
|
||||
//- Name of the flux transporting the field
|
||||
word phiName_;
|
||||
@ -82,20 +85,20 @@ class massFlowRateInletVelocityFvPatchVectorField
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("massFlowRateInletVelocity");
|
||||
TypeName("flowRateInletVelocity");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from patch and internal field
|
||||
massFlowRateInletVelocityFvPatchVectorField
|
||||
flowRateInletVelocityFvPatchVectorField
|
||||
(
|
||||
const fvPatch&,
|
||||
const DimensionedField<vector, volMesh>&
|
||||
);
|
||||
|
||||
//- Construct from patch, internal field and dictionary
|
||||
massFlowRateInletVelocityFvPatchVectorField
|
||||
flowRateInletVelocityFvPatchVectorField
|
||||
(
|
||||
const fvPatch&,
|
||||
const DimensionedField<vector, volMesh>&,
|
||||
@ -103,20 +106,20 @@ public:
|
||||
);
|
||||
|
||||
//- Construct by mapping given
|
||||
// massFlowRateInletVelocityFvPatchVectorField
|
||||
// flowRateInletVelocityFvPatchVectorField
|
||||
// onto a new patch
|
||||
massFlowRateInletVelocityFvPatchVectorField
|
||||
flowRateInletVelocityFvPatchVectorField
|
||||
(
|
||||
const massFlowRateInletVelocityFvPatchVectorField&,
|
||||
const flowRateInletVelocityFvPatchVectorField&,
|
||||
const fvPatch&,
|
||||
const DimensionedField<vector, volMesh>&,
|
||||
const fvPatchFieldMapper&
|
||||
);
|
||||
|
||||
//- Construct as copy
|
||||
massFlowRateInletVelocityFvPatchVectorField
|
||||
flowRateInletVelocityFvPatchVectorField
|
||||
(
|
||||
const massFlowRateInletVelocityFvPatchVectorField&
|
||||
const flowRateInletVelocityFvPatchVectorField&
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
@ -124,14 +127,14 @@ public:
|
||||
{
|
||||
return tmp<fvPatchVectorField>
|
||||
(
|
||||
new massFlowRateInletVelocityFvPatchVectorField(*this)
|
||||
new flowRateInletVelocityFvPatchVectorField(*this)
|
||||
);
|
||||
}
|
||||
|
||||
//- Construct as copy setting internal field reference
|
||||
massFlowRateInletVelocityFvPatchVectorField
|
||||
flowRateInletVelocityFvPatchVectorField
|
||||
(
|
||||
const massFlowRateInletVelocityFvPatchVectorField&,
|
||||
const flowRateInletVelocityFvPatchVectorField&,
|
||||
const DimensionedField<vector, volMesh>&
|
||||
);
|
||||
|
||||
@ -143,7 +146,7 @@ public:
|
||||
{
|
||||
return tmp<fvPatchVectorField>
|
||||
(
|
||||
new massFlowRateInletVelocityFvPatchVectorField(*this, iF)
|
||||
new flowRateInletVelocityFvPatchVectorField(*this, iF)
|
||||
);
|
||||
}
|
||||
|
||||
@ -152,16 +155,16 @@ public:
|
||||
|
||||
// Access
|
||||
|
||||
//- Return the mass flux
|
||||
scalar massFlowRate() const
|
||||
//- Return the flux
|
||||
scalar flowRate() const
|
||||
{
|
||||
return massFlowRate_;
|
||||
return flowRate_;
|
||||
}
|
||||
|
||||
//- Return reference to the mass flux to allow adjustment
|
||||
scalar& massFlowRate()
|
||||
//- Return reference to the flux to allow adjustment
|
||||
scalar& flowRate()
|
||||
{
|
||||
return massFlowRate_;
|
||||
return flowRate_;
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,141 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2006-2008 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "timeVaryingFlowRateInletVelocityFvPatchVectorField.H"
|
||||
#include "volFields.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "fvPatchFieldMapper.H"
|
||||
#include "surfaceFields.H"
|
||||
#include "Time.H"
|
||||
#include "IFstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::
|
||||
timeVaryingFlowRateInletVelocityFvPatchVectorField::
|
||||
timeVaryingFlowRateInletVelocityFvPatchVectorField
|
||||
(
|
||||
const fvPatch& p,
|
||||
const DimensionedField<vector, volMesh>& iF
|
||||
)
|
||||
:
|
||||
flowRateInletVelocityFvPatchVectorField(p, iF),
|
||||
timeSeries_()
|
||||
{}
|
||||
|
||||
|
||||
Foam::
|
||||
timeVaryingFlowRateInletVelocityFvPatchVectorField::
|
||||
timeVaryingFlowRateInletVelocityFvPatchVectorField
|
||||
(
|
||||
const timeVaryingFlowRateInletVelocityFvPatchVectorField& ptf,
|
||||
const fvPatch& p,
|
||||
const DimensionedField<vector, volMesh>& iF,
|
||||
const fvPatchFieldMapper& mapper
|
||||
)
|
||||
:
|
||||
flowRateInletVelocityFvPatchVectorField(ptf, p, iF, mapper),
|
||||
timeSeries_(ptf.timeSeries_)
|
||||
{}
|
||||
|
||||
|
||||
Foam::
|
||||
timeVaryingFlowRateInletVelocityFvPatchVectorField::
|
||||
timeVaryingFlowRateInletVelocityFvPatchVectorField
|
||||
(
|
||||
const fvPatch& p,
|
||||
const DimensionedField<vector, volMesh>& iF,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
flowRateInletVelocityFvPatchVectorField(p, iF, dict),
|
||||
timeSeries_(this->db(), dict)
|
||||
{}
|
||||
|
||||
|
||||
Foam::
|
||||
timeVaryingFlowRateInletVelocityFvPatchVectorField::
|
||||
timeVaryingFlowRateInletVelocityFvPatchVectorField
|
||||
(
|
||||
const timeVaryingFlowRateInletVelocityFvPatchVectorField& ptf
|
||||
)
|
||||
:
|
||||
flowRateInletVelocityFvPatchVectorField(ptf),
|
||||
timeSeries_(ptf.timeSeries_)
|
||||
{}
|
||||
|
||||
|
||||
Foam::
|
||||
timeVaryingFlowRateInletVelocityFvPatchVectorField::
|
||||
timeVaryingFlowRateInletVelocityFvPatchVectorField
|
||||
(
|
||||
const timeVaryingFlowRateInletVelocityFvPatchVectorField& ptf,
|
||||
const DimensionedField<vector, volMesh>& iF
|
||||
)
|
||||
:
|
||||
flowRateInletVelocityFvPatchVectorField(ptf, iF),
|
||||
timeSeries_(ptf.timeSeries_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
void Foam::
|
||||
timeVaryingFlowRateInletVelocityFvPatchVectorField::
|
||||
updateCoeffs()
|
||||
{
|
||||
if (updated())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
flowRate() = timeSeries_(this->db().time().timeOutputValue());
|
||||
flowRateInletVelocityFvPatchVectorField::updateCoeffs();
|
||||
}
|
||||
|
||||
|
||||
void Foam::
|
||||
timeVaryingFlowRateInletVelocityFvPatchVectorField::
|
||||
write(Ostream& os) const
|
||||
{
|
||||
flowRateInletVelocityFvPatchVectorField::write(os);
|
||||
timeSeries_.write(os);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
makePatchTypeField
|
||||
(
|
||||
fvPatchVectorField,
|
||||
timeVaryingFlowRateInletVelocityFvPatchVectorField
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -23,19 +23,19 @@ License
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::timeVaryingMassFlowRateInletVelocityFvPatchVectorField
|
||||
Foam::timeVaryingFlowRateInletVelocityFvPatchVectorField
|
||||
|
||||
Description
|
||||
A time-varying form of a massflow normal vector boundary condition.
|
||||
A time-varying form of a flow normal vector boundary condition.
|
||||
|
||||
Example of the boundary condition specification:
|
||||
@verbatim
|
||||
inlet
|
||||
{
|
||||
type timeVaryingMassFlowRateInletVelocity;
|
||||
massFlowRate 0.2; // Massflow rate [kg/s]
|
||||
type timeVaryingFlowRateInletVelocity;
|
||||
flowRate 0.2; // Volumetric/mass flow rate [m3/s or kg/s]
|
||||
value uniform (0 0 0); // placeholder
|
||||
timeDataFile "time-series";
|
||||
fileName "time-series";
|
||||
timeBounding repeat; // (error|warn|clamp|repeat)
|
||||
}
|
||||
@endverbatim
|
||||
@ -46,58 +46,54 @@ Note
|
||||
- strange behaviour with potentialFoam since the U equation is not solved
|
||||
|
||||
See Also
|
||||
Foam::timeSeries and Foam::massFlowRateInletVelocityFvPatchVectorField
|
||||
Foam::timeSeries and Foam::flowRateInletVelocityFvPatchVectorField
|
||||
|
||||
SourceFiles
|
||||
timeVaryingMassFlowRateInletVelocityFvPatchVectorField.C
|
||||
timeVaryingFlowRateInletVelocityFvPatchVectorField.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef timeVaryingMassFlowRateInletVelocityFvPatchVectorField_H
|
||||
#define timeVaryingMassFlowRateInletVelocityFvPatchVectorField_H
|
||||
#ifndef timeVaryingFlowRateInletVelocityFvPatchVectorField_H
|
||||
#define timeVaryingFlowRateInletVelocityFvPatchVectorField_H
|
||||
|
||||
#include "flowRateInletVelocityFvPatchVectorField.H"
|
||||
#include "interpolationTable.H"
|
||||
|
||||
#include "massFlowRateInletVelocityFvPatchVectorField.H"
|
||||
#include "timeSeries.H"
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class timeVaryingMassFlowRateInletVelocityFvPatch Declaration
|
||||
Class timeVaryingFlowRateInletVelocityFvPatch Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class timeVaryingMassFlowRateInletVelocityFvPatchVectorField
|
||||
class timeVaryingFlowRateInletVelocityFvPatchVectorField
|
||||
:
|
||||
public massFlowRateInletVelocityFvPatchVectorField
|
||||
public flowRateInletVelocityFvPatchVectorField
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- file containing time/massFlowRate
|
||||
fileName timeDataFile_;
|
||||
|
||||
//- the time series being used, including the bounding treatment
|
||||
timeSeries<scalar> timeSeries_;
|
||||
interpolationTable<scalar> timeSeries_;
|
||||
|
||||
//- interpolate the value at the current time
|
||||
scalar currentValue();
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("timeVaryingMassFlowRateInletVelocity");
|
||||
TypeName("timeVaryingFlowRateInletVelocity");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from patch and internal field
|
||||
timeVaryingMassFlowRateInletVelocityFvPatchVectorField
|
||||
timeVaryingFlowRateInletVelocityFvPatchVectorField
|
||||
(
|
||||
const fvPatch&,
|
||||
const DimensionedField<vector, volMesh>&
|
||||
);
|
||||
|
||||
//- Construct from patch, internal field and dictionary
|
||||
timeVaryingMassFlowRateInletVelocityFvPatchVectorField
|
||||
timeVaryingFlowRateInletVelocityFvPatchVectorField
|
||||
(
|
||||
const fvPatch&,
|
||||
const DimensionedField<vector, volMesh>&,
|
||||
@ -105,18 +101,18 @@ public:
|
||||
);
|
||||
|
||||
//- Construct by mapping given patch field onto a new patch
|
||||
timeVaryingMassFlowRateInletVelocityFvPatchVectorField
|
||||
timeVaryingFlowRateInletVelocityFvPatchVectorField
|
||||
(
|
||||
const timeVaryingMassFlowRateInletVelocityFvPatchVectorField&,
|
||||
const timeVaryingFlowRateInletVelocityFvPatchVectorField&,
|
||||
const fvPatch&,
|
||||
const DimensionedField<vector, volMesh>&,
|
||||
const fvPatchFieldMapper&
|
||||
);
|
||||
|
||||
//- Construct as copy
|
||||
timeVaryingMassFlowRateInletVelocityFvPatchVectorField
|
||||
timeVaryingFlowRateInletVelocityFvPatchVectorField
|
||||
(
|
||||
const timeVaryingMassFlowRateInletVelocityFvPatchVectorField&
|
||||
const timeVaryingFlowRateInletVelocityFvPatchVectorField&
|
||||
);
|
||||
|
||||
//- Construct and return a clone
|
||||
@ -124,14 +120,14 @@ public:
|
||||
{
|
||||
return tmp<fvPatchVectorField>
|
||||
(
|
||||
new timeVaryingMassFlowRateInletVelocityFvPatchVectorField(*this)
|
||||
new timeVaryingFlowRateInletVelocityFvPatchVectorField(*this)
|
||||
);
|
||||
}
|
||||
|
||||
//- Construct as copy setting internal field reference
|
||||
timeVaryingMassFlowRateInletVelocityFvPatchVectorField
|
||||
timeVaryingFlowRateInletVelocityFvPatchVectorField
|
||||
(
|
||||
const timeVaryingMassFlowRateInletVelocityFvPatchVectorField&,
|
||||
const timeVaryingFlowRateInletVelocityFvPatchVectorField&,
|
||||
const DimensionedField<vector, volMesh>&
|
||||
);
|
||||
|
||||
@ -143,34 +139,34 @@ public:
|
||||
{
|
||||
return tmp<fvPatchVectorField>
|
||||
(
|
||||
new timeVaryingMassFlowRateInletVelocityFvPatchVectorField(*this, iF)
|
||||
new timeVaryingFlowRateInletVelocityFvPatchVectorField
|
||||
(
|
||||
*this,
|
||||
iF
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
// Access
|
||||
|
||||
//- Return the out-of-bounds treatment as a word
|
||||
word timeBounding() const
|
||||
{
|
||||
return timeSeries_.bounding();
|
||||
}
|
||||
|
||||
//- Return the time series used
|
||||
const timeSeries<scalar>& timeData() const
|
||||
const interpolationTable<scalar>& timeSeries() const
|
||||
{
|
||||
return timeSeries_;
|
||||
}
|
||||
|
||||
|
||||
// Evaluation functions
|
||||
|
||||
//- Update the coefficients associated with the patch field
|
||||
virtual void updateCoeffs();
|
||||
|
||||
|
||||
//- Write
|
||||
virtual void write(Ostream&) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@ -1,200 +0,0 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2006-2008 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "timeVaryingMassFlowRateInletVelocityFvPatchVectorField.H"
|
||||
#include "volFields.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
#include "fvPatchFieldMapper.H"
|
||||
#include "surfaceFields.H"
|
||||
#include "Time.H"
|
||||
#include "IFstream.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::
|
||||
timeVaryingMassFlowRateInletVelocityFvPatchVectorField::
|
||||
timeVaryingMassFlowRateInletVelocityFvPatchVectorField
|
||||
(
|
||||
const fvPatch& p,
|
||||
const DimensionedField<vector, volMesh>& iF
|
||||
)
|
||||
:
|
||||
massFlowRateInletVelocityFvPatchVectorField(p, iF)
|
||||
{}
|
||||
|
||||
|
||||
Foam::
|
||||
timeVaryingMassFlowRateInletVelocityFvPatchVectorField::
|
||||
timeVaryingMassFlowRateInletVelocityFvPatchVectorField
|
||||
(
|
||||
const timeVaryingMassFlowRateInletVelocityFvPatchVectorField& ptf,
|
||||
const fvPatch& p,
|
||||
const DimensionedField<vector, volMesh>& iF,
|
||||
const fvPatchFieldMapper& mapper
|
||||
)
|
||||
:
|
||||
massFlowRateInletVelocityFvPatchVectorField(ptf, p, iF, mapper),
|
||||
timeDataFile_(ptf.timeDataFile_),
|
||||
timeSeries_(ptf.timeBounding())
|
||||
{}
|
||||
|
||||
|
||||
Foam::
|
||||
timeVaryingMassFlowRateInletVelocityFvPatchVectorField::
|
||||
timeVaryingMassFlowRateInletVelocityFvPatchVectorField
|
||||
(
|
||||
const fvPatch& p,
|
||||
const DimensionedField<vector, volMesh>& iF,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
massFlowRateInletVelocityFvPatchVectorField(p, iF, dict),
|
||||
timeDataFile_(dict.lookup("timeDataFile")),
|
||||
timeSeries_(word(dict.lookup("timeBounding")))
|
||||
{}
|
||||
|
||||
|
||||
Foam::
|
||||
timeVaryingMassFlowRateInletVelocityFvPatchVectorField::
|
||||
timeVaryingMassFlowRateInletVelocityFvPatchVectorField
|
||||
(
|
||||
const timeVaryingMassFlowRateInletVelocityFvPatchVectorField& ptf
|
||||
)
|
||||
:
|
||||
massFlowRateInletVelocityFvPatchVectorField(ptf),
|
||||
timeDataFile_(ptf.timeDataFile_),
|
||||
timeSeries_(ptf.timeBounding())
|
||||
{}
|
||||
|
||||
|
||||
Foam::
|
||||
timeVaryingMassFlowRateInletVelocityFvPatchVectorField::
|
||||
timeVaryingMassFlowRateInletVelocityFvPatchVectorField
|
||||
(
|
||||
const timeVaryingMassFlowRateInletVelocityFvPatchVectorField& ptf,
|
||||
const DimensionedField<vector, volMesh>& iF
|
||||
)
|
||||
:
|
||||
massFlowRateInletVelocityFvPatchVectorField(ptf, iF),
|
||||
timeDataFile_(ptf.timeDataFile_),
|
||||
timeSeries_(ptf.timeBounding())
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::scalar
|
||||
Foam::timeVaryingMassFlowRateInletVelocityFvPatchVectorField::
|
||||
currentValue()
|
||||
{
|
||||
if (timeSeries_.size() == 0)
|
||||
{
|
||||
fileName fName(timeDataFile_);
|
||||
fName.expand();
|
||||
|
||||
if (fName.size() == 0)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"timeVaryingMassFlowRateInletVelocity"
|
||||
"::currentValue()"
|
||||
) << "timeDataFile not specified for Patch "
|
||||
<< this->patch().name()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
else
|
||||
{
|
||||
// relative path
|
||||
if (fName[0] != '/')
|
||||
{
|
||||
fName = this->db().path()/fName;
|
||||
}
|
||||
|
||||
// just in case we change the interface to timeSeries
|
||||
word boundType = timeBounding();
|
||||
|
||||
IFstream(fName)() >> timeSeries_;
|
||||
timeSeries_.bounding(boundType);
|
||||
|
||||
// be a bit paranoid and check that the list is okay
|
||||
timeSeries_.check();
|
||||
}
|
||||
|
||||
if (timeSeries_.size() == 0)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"timeVaryingMassFlowRateInletVelocity"
|
||||
"::currentValue()"
|
||||
) << "empty time series for Patch "
|
||||
<< this->patch().name()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
return timeSeries_(this->db().time().timeOutputValue());
|
||||
}
|
||||
|
||||
|
||||
void Foam::
|
||||
timeVaryingMassFlowRateInletVelocityFvPatchVectorField::
|
||||
updateCoeffs()
|
||||
{
|
||||
if (updated())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
massFlowRate() = currentValue();
|
||||
massFlowRateInletVelocityFvPatchVectorField::updateCoeffs();
|
||||
}
|
||||
|
||||
|
||||
void Foam::
|
||||
timeVaryingMassFlowRateInletVelocityFvPatchVectorField::
|
||||
write(Ostream& os) const
|
||||
{
|
||||
massFlowRateInletVelocityFvPatchVectorField::write(os);
|
||||
os.writeKeyword("timeDataFile")
|
||||
<< timeDataFile_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("timeBounding")
|
||||
<< timeBounding() << token::END_STATEMENT << nl;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
makePatchTypeField
|
||||
(
|
||||
fvPatchVectorField,
|
||||
timeVaryingMassFlowRateInletVelocityFvPatchVectorField
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -38,7 +38,8 @@ timeVaryingUniformFixedValueFvPatchField
|
||||
const DimensionedField<Type, volMesh>& iF
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<Type>(p, iF)
|
||||
fixedValueFvPatchField<Type>(p, iF),
|
||||
timeSeries_()
|
||||
{}
|
||||
|
||||
|
||||
@ -52,8 +53,7 @@ timeVaryingUniformFixedValueFvPatchField
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<Type>(p, iF),
|
||||
timeDataFile_(dict.lookup("timeDataFile")),
|
||||
timeSeries_(word(dict.lookup("timeBounding")))
|
||||
timeSeries_(this->db(), dict)
|
||||
{
|
||||
if (dict.found("value"))
|
||||
{
|
||||
@ -77,8 +77,7 @@ timeVaryingUniformFixedValueFvPatchField
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<Type>(ptf, p, iF, mapper),
|
||||
timeDataFile_(ptf.timeDataFile_),
|
||||
timeSeries_(ptf.timeBounding())
|
||||
timeSeries_(ptf.timeSeries_)
|
||||
{}
|
||||
|
||||
|
||||
@ -90,8 +89,7 @@ timeVaryingUniformFixedValueFvPatchField
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<Type>(ptf),
|
||||
timeDataFile_(ptf.timeDataFile_),
|
||||
timeSeries_(ptf.timeBounding())
|
||||
timeSeries_(ptf.timeSeries_)
|
||||
{}
|
||||
|
||||
|
||||
@ -104,66 +102,12 @@ timeVaryingUniformFixedValueFvPatchField
|
||||
)
|
||||
:
|
||||
fixedValueFvPatchField<Type>(ptf, iF),
|
||||
timeDataFile_(ptf.timeDataFile_),
|
||||
timeSeries_(ptf.timeBounding())
|
||||
timeSeries_(ptf.timeSeries_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Type Foam::timeVaryingUniformFixedValueFvPatchField<Type>::
|
||||
currentValue()
|
||||
{
|
||||
if (timeSeries_.size() == 0)
|
||||
{
|
||||
fileName fName(timeDataFile_);
|
||||
fName.expand();
|
||||
|
||||
if (fName.size() == 0)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"timeVaryingUniformFixedValueFvPatchField"
|
||||
"::currentValue()"
|
||||
) << "timeDataFile not specified for Patch "
|
||||
<< this->patch().name()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
else
|
||||
{
|
||||
// relative path
|
||||
if (fName[0] != '/')
|
||||
{
|
||||
fName = this->db().path()/fName;
|
||||
}
|
||||
|
||||
// just in case we change the interface to timeSeries
|
||||
word boundType = timeBounding();
|
||||
|
||||
IFstream(fName)() >> timeSeries_;
|
||||
timeSeries_.bounding(boundType);
|
||||
|
||||
// be a bit paranoid and check that the list is okay
|
||||
timeSeries_.check();
|
||||
}
|
||||
|
||||
if (timeSeries_.size() == 0)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"timeVaryingUniformFixedValueFvPatchField"
|
||||
"::currentValue()"
|
||||
) << "empty time series for Patch "
|
||||
<< this->patch().name()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
return timeSeries_(this->db().time().timeOutputValue());
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
void Foam::timeVaryingUniformFixedValueFvPatchField<Type>::updateCoeffs()
|
||||
{
|
||||
@ -172,7 +116,10 @@ void Foam::timeVaryingUniformFixedValueFvPatchField<Type>::updateCoeffs()
|
||||
return;
|
||||
}
|
||||
|
||||
fvPatchField<Type>::operator==(currentValue());
|
||||
fvPatchField<Type>::operator==
|
||||
(
|
||||
timeSeries_(this->db().time().timeOutputValue())
|
||||
);
|
||||
fixedValueFvPatchField<Type>::updateCoeffs();
|
||||
}
|
||||
|
||||
@ -184,10 +131,7 @@ void Foam::timeVaryingUniformFixedValueFvPatchField<Type>::write
|
||||
) const
|
||||
{
|
||||
fvPatchField<Type>::write(os);
|
||||
os.writeKeyword("timeDataFile")
|
||||
<< timeDataFile_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("timeBounding")
|
||||
<< timeBounding() << token::END_STATEMENT << nl;
|
||||
timeSeries_.write(os);
|
||||
this->writeEntry("value", os);
|
||||
}
|
||||
|
||||
|
||||
@ -54,7 +54,7 @@ SourceFiles
|
||||
#define timeVaryingUniformFixedValueFvPatchField_H
|
||||
|
||||
#include "fixedValueFvPatchField.H"
|
||||
#include "timeSeries.H"
|
||||
#include "interpolationTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -72,14 +72,8 @@ class timeVaryingUniformFixedValueFvPatchField
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- File containing time/uniformFixedValue
|
||||
fileName timeDataFile_;
|
||||
|
||||
//- The time series being used, including the bounding treatment
|
||||
timeSeries<Type> timeSeries_;
|
||||
|
||||
//- Interpolate the value at the current time
|
||||
Type currentValue();
|
||||
interpolationTable<Type> timeSeries_;
|
||||
|
||||
|
||||
public:
|
||||
@ -153,14 +147,8 @@ public:
|
||||
|
||||
// Access
|
||||
|
||||
//- Return the out-of-bounds treatment as a word
|
||||
word timeBounding() const
|
||||
{
|
||||
return timeSeries_.bounding();
|
||||
}
|
||||
|
||||
//- Return the time series used
|
||||
const timeSeries<Type>& timeData() const
|
||||
const interpolationTable<Type>& timeSeries() const
|
||||
{
|
||||
return timeSeries_;
|
||||
}
|
||||
|
||||
@ -46,8 +46,8 @@ timeVaryingUniformTotalPressureFvPatchScalarField
|
||||
rhoName_("undefined"),
|
||||
psiName_("undefined"),
|
||||
gamma_(0.0),
|
||||
p0_(0.0)
|
||||
|
||||
p0_(0.0),
|
||||
totalPressureTimeSeries_()
|
||||
{}
|
||||
|
||||
|
||||
@ -66,8 +66,7 @@ timeVaryingUniformTotalPressureFvPatchScalarField
|
||||
psiName_(dict.lookup("psi")),
|
||||
gamma_(readScalar(dict.lookup("gamma"))),
|
||||
p0_(readScalar(dict.lookup("p0"))),
|
||||
totalPressureDataFileName_(dict.lookup("totalPressureDataFileName")),
|
||||
totalPressureTimeSeries_(word(dict.lookup("timeBounding")))
|
||||
totalPressureTimeSeries_(this->db(), dict)
|
||||
{
|
||||
if (dict.found("value"))
|
||||
{
|
||||
@ -99,8 +98,7 @@ timeVaryingUniformTotalPressureFvPatchScalarField
|
||||
psiName_(ptf.psiName_),
|
||||
gamma_(ptf.gamma_),
|
||||
p0_(ptf.p0_),
|
||||
totalPressureDataFileName_(ptf.totalPressureDataFileName_),
|
||||
totalPressureTimeSeries_(ptf.timeBounding())
|
||||
totalPressureTimeSeries_(ptf.totalPressureTimeSeries_)
|
||||
{}
|
||||
|
||||
|
||||
@ -117,8 +115,7 @@ timeVaryingUniformTotalPressureFvPatchScalarField
|
||||
psiName_(tppsf.psiName_),
|
||||
gamma_(tppsf.gamma_),
|
||||
p0_(tppsf.p0_),
|
||||
totalPressureDataFileName_(tppsf.totalPressureDataFileName_),
|
||||
totalPressureTimeSeries_(tppsf.timeBounding())
|
||||
totalPressureTimeSeries_(tppsf.totalPressureTimeSeries_)
|
||||
{}
|
||||
|
||||
|
||||
@ -136,64 +133,12 @@ timeVaryingUniformTotalPressureFvPatchScalarField
|
||||
psiName_(tppsf.psiName_),
|
||||
gamma_(tppsf.gamma_),
|
||||
p0_(tppsf.p0_),
|
||||
totalPressureDataFileName_(tppsf.totalPressureDataFileName_),
|
||||
totalPressureTimeSeries_(tppsf.timeBounding())
|
||||
totalPressureTimeSeries_(tppsf.totalPressureTimeSeries_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
Foam::scalar Foam::timeVaryingUniformTotalPressureFvPatchScalarField::
|
||||
currentValue()
|
||||
{
|
||||
if (totalPressureTimeSeries_.size() == 0)
|
||||
{
|
||||
fileName fName(totalPressureDataFileName_);
|
||||
fName.expand();
|
||||
|
||||
if (fName.size() == 0)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"timeVaryingUniformFixedValueFvPatchField::currentValue()"
|
||||
) << "timeDataFile not specified for Patch "
|
||||
<< patch().name()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
else
|
||||
{
|
||||
// relative path
|
||||
if (fName[0] != '/')
|
||||
{
|
||||
fName = db().path()/fName;
|
||||
}
|
||||
|
||||
// just in case we change the interface to timeSeries
|
||||
word boundType = timeBounding();
|
||||
|
||||
IFstream(fName)() >> totalPressureTimeSeries_;
|
||||
totalPressureTimeSeries_.bounding(boundType);
|
||||
|
||||
// be a bit paranoid and check that the list is okay
|
||||
totalPressureTimeSeries_.check();
|
||||
}
|
||||
|
||||
if (totalPressureTimeSeries_.size() == 0)
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"timeVaryingUniformFixedValueFvPatchField"
|
||||
"::currentValue()"
|
||||
) << "empty time series for Patch "
|
||||
<< this->patch().name()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
}
|
||||
|
||||
return totalPressureTimeSeries_(this->db().time().timeOutputValue());
|
||||
}
|
||||
|
||||
|
||||
void Foam::timeVaryingUniformTotalPressureFvPatchScalarField::updateCoeffs
|
||||
(
|
||||
const vectorField& Up
|
||||
@ -204,7 +149,7 @@ void Foam::timeVaryingUniformTotalPressureFvPatchScalarField::updateCoeffs
|
||||
return;
|
||||
}
|
||||
|
||||
p0_ = currentValue();
|
||||
p0_ = totalPressureTimeSeries_(this->db().time().timeOutputValue());
|
||||
|
||||
const fvsPatchField<scalar>& phip =
|
||||
patch().lookupPatchField<surfaceScalarField, scalar>(phiName_);
|
||||
@ -279,10 +224,7 @@ void Foam::timeVaryingUniformTotalPressureFvPatchScalarField::write(Ostream& os)
|
||||
os.writeKeyword("psi") << psiName_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("gamma") << gamma_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("p0") << p0_ << token::END_STATEMENT << endl;
|
||||
os.writeKeyword("totalPressureDataFileName")
|
||||
<< totalPressureDataFileName_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("timeBounding")
|
||||
<< timeBounding() << token::END_STATEMENT << nl;
|
||||
totalPressureTimeSeries_.write(os);
|
||||
writeEntry("value", os);
|
||||
}
|
||||
|
||||
|
||||
@ -38,7 +38,7 @@ SourceFiles
|
||||
#define timeVaryingUniformTotalPressureFvPatchScalarField_H
|
||||
|
||||
#include "fixedValueFvPatchFields.H"
|
||||
#include "timeSeries.H"
|
||||
#include "interpolationTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -74,11 +74,8 @@ class timeVaryingUniformTotalPressureFvPatchScalarField
|
||||
//- Total pressure
|
||||
scalar p0_;
|
||||
|
||||
fileName totalPressureDataFileName_;
|
||||
timeSeries<scalar> totalPressureTimeSeries_;
|
||||
|
||||
//- Interpolate the value at the current time
|
||||
scalar currentValue();
|
||||
//- Table of time vs total pressure
|
||||
interpolationTable<scalar> totalPressureTimeSeries_;
|
||||
|
||||
|
||||
public:
|
||||
@ -189,14 +186,8 @@ public:
|
||||
return p0_;
|
||||
}
|
||||
|
||||
//- Return the out-of-bounds treatment as a word
|
||||
word timeBounding() const
|
||||
{
|
||||
return totalPressureTimeSeries_.bounding();
|
||||
}
|
||||
|
||||
//- Return the time series used
|
||||
const timeSeries<scalar>& totalPressureTimeSeries() const
|
||||
const interpolationTable<scalar>& totalPressureTimeSeries() const
|
||||
{
|
||||
return totalPressureTimeSeries_;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user