mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Adding dimensioSet to DataEntry and modify MRFZone entry types
This commit is contained in:
@ -154,6 +154,16 @@ dimensioned<Type>::dimensioned
|
||||
}
|
||||
|
||||
|
||||
template <class Type>
|
||||
dimensioned<Type>::dimensioned
|
||||
()
|
||||
:
|
||||
name_("undefined"),
|
||||
dimensions_(dimless),
|
||||
value_(pTraits<Type>::zero)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template <class Type>
|
||||
|
||||
@ -107,6 +107,9 @@ public:
|
||||
//- Construct from an Istream with a given name and dimensions
|
||||
dimensioned(const word&, const dimensionSet&, Istream&);
|
||||
|
||||
//- Null constructor
|
||||
dimensioned();
|
||||
|
||||
//- Construct from dictionary, with default value.
|
||||
static dimensioned<Type> lookupOrDefault
|
||||
(
|
||||
|
||||
@ -163,6 +163,22 @@ public:
|
||||
return TableBase<Type>::integrate(x1, x2);
|
||||
}
|
||||
|
||||
//- Return dimensioned constant value
|
||||
virtual dimensioned<Type> dimValue(const scalar x) const
|
||||
{
|
||||
return TableBase<Type>::dimValue(x);
|
||||
}
|
||||
|
||||
//- Integrate between two values and return dimensioned type
|
||||
virtual dimensioned<Type> dimIntegrate
|
||||
(
|
||||
const scalar x1,
|
||||
const scalar x2
|
||||
) const
|
||||
{
|
||||
return TableBase<Type>::dimIntegrate(x1, x2);
|
||||
}
|
||||
|
||||
|
||||
// I/O
|
||||
|
||||
|
||||
@ -34,9 +34,27 @@ Foam::CompatibilityConstant<Type>::CompatibilityConstant
|
||||
)
|
||||
:
|
||||
DataEntry<Type>(entryName),
|
||||
value_(pTraits<Type>::zero)
|
||||
value_(pTraits<Type>::zero),
|
||||
dimensions_(dimless)
|
||||
{
|
||||
dict.lookup(entryName) >> value_;
|
||||
Istream& is(dict.lookup(entryName));
|
||||
|
||||
token firstToken(is);
|
||||
if (firstToken.isWord())
|
||||
{
|
||||
token nextToken(is);
|
||||
if (nextToken == token::BEGIN_SQR)
|
||||
{
|
||||
is.putBack(nextToken);
|
||||
is >> dimensions_;
|
||||
is >> value_;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
is.putBack(firstToken);
|
||||
is >> value_;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -47,10 +65,10 @@ Foam::CompatibilityConstant<Type>::CompatibilityConstant
|
||||
)
|
||||
:
|
||||
DataEntry<Type>(cnst),
|
||||
value_(cnst.value_)
|
||||
value_(cnst.value_),
|
||||
dimensions_(cnst.dimensions_)
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
@ -78,6 +96,23 @@ Type Foam::CompatibilityConstant<Type>::integrate
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::dimensioned<Type> Foam::CompatibilityConstant<Type>::
|
||||
dimValue(const scalar x) const
|
||||
{
|
||||
return dimensioned<Type>("dimensionedValue", dimensions_, value_);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::dimensioned<Type> Foam::CompatibilityConstant<Type>::dimIntegrate
|
||||
(
|
||||
const scalar x1, const scalar x2
|
||||
) const
|
||||
{
|
||||
return dimensioned<Type>("dimensionedValue", dimensions_, (x2-x1)*value_);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
|
||||
|
||||
#include "CompatibilityConstantIO.C"
|
||||
|
||||
@ -42,6 +42,7 @@ SourceFiles
|
||||
#define CompatibilityConstant_H
|
||||
|
||||
#include "DataEntry.H"
|
||||
#include "dimensionSet.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -68,6 +69,9 @@ class CompatibilityConstant
|
||||
//- Constant value
|
||||
Type value_;
|
||||
|
||||
//- The dimension set
|
||||
dimensionSet dimensions_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
@ -111,6 +115,16 @@ public:
|
||||
//- Integrate between two values
|
||||
Type integrate(const scalar x1, const scalar x2) const;
|
||||
|
||||
//- Return dimensioned constant value
|
||||
dimensioned<Type> dimValue(const scalar) const;
|
||||
|
||||
//- Integrate between two values and return dimensioned type
|
||||
dimensioned<Type> dimIntegrate
|
||||
(
|
||||
const scalar x1,
|
||||
const scalar x2
|
||||
) const;
|
||||
|
||||
|
||||
// I/O
|
||||
|
||||
|
||||
@ -31,12 +31,27 @@ template<class Type>
|
||||
Foam::Constant<Type>::Constant(const word& entryName, const dictionary& dict)
|
||||
:
|
||||
DataEntry<Type>(entryName),
|
||||
value_(pTraits<Type>::zero)
|
||||
value_(pTraits<Type>::zero),
|
||||
dimensions_(dimless)
|
||||
{
|
||||
Istream& is(dict.lookup(entryName));
|
||||
word entryType(is);
|
||||
|
||||
token firstToken(is);
|
||||
if (firstToken.isWord())
|
||||
{
|
||||
token nextToken(is);
|
||||
if (nextToken == token::BEGIN_SQR)
|
||||
{
|
||||
is.putBack(nextToken);
|
||||
is >> dimensions_;
|
||||
is >> value_;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
is.putBack(firstToken);
|
||||
is >> value_;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -44,7 +59,8 @@ template<class Type>
|
||||
Foam::Constant<Type>::Constant(const Constant<Type>& cnst)
|
||||
:
|
||||
DataEntry<Type>(cnst),
|
||||
value_(cnst.value_)
|
||||
value_(cnst.value_),
|
||||
dimensions_(cnst.dimensions_)
|
||||
{}
|
||||
|
||||
|
||||
@ -71,6 +87,22 @@ Type Foam::Constant<Type>::integrate(const scalar x1, const scalar x2) const
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::dimensioned<Type> Foam::Constant<Type>::dimValue(const scalar x) const
|
||||
{
|
||||
return dimensioned<Type>("dimensionedValue", dimensions_, value_);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::dimensioned<Type> Foam::Constant<Type>::dimIntegrate
|
||||
(
|
||||
const scalar x1, const scalar x2
|
||||
) const
|
||||
{
|
||||
return dimensioned<Type>("dimensionedValue", dimensions_, (x2-x1)*value_);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
|
||||
|
||||
#include "ConstantIO.C"
|
||||
|
||||
@ -41,6 +41,7 @@ SourceFiles
|
||||
#define Constant_H
|
||||
|
||||
#include "DataEntry.H"
|
||||
#include "dimensionSet.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -67,6 +68,9 @@ class Constant
|
||||
//- Constant value
|
||||
Type value_;
|
||||
|
||||
//- The dimension set
|
||||
dimensionSet dimensions_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
@ -107,6 +111,16 @@ public:
|
||||
//- Integrate between two values
|
||||
Type integrate(const scalar x1, const scalar x2) const;
|
||||
|
||||
//- Return dimensioned constant value
|
||||
dimensioned<Type> dimValue(const scalar) const;
|
||||
|
||||
//- Integrate between two values and return dimensioned type
|
||||
dimensioned<Type> dimIntegrate
|
||||
(
|
||||
const scalar x1,
|
||||
const scalar x2
|
||||
) const;
|
||||
|
||||
|
||||
// I/O
|
||||
|
||||
|
||||
@ -76,6 +76,22 @@ Type Foam::DataEntry<Type>::value(const scalar x) const
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::DataEntry<Type>::integrate(const scalar x1, const scalar x2) const
|
||||
{
|
||||
notImplemented
|
||||
(
|
||||
"Type Foam::DataEntry<Type>::integrate"
|
||||
"("
|
||||
"const scalar, "
|
||||
"const scalar"
|
||||
") const"
|
||||
);
|
||||
|
||||
return pTraits<Type>::zero;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type> > Foam::DataEntry<Type>::value
|
||||
(
|
||||
@ -93,22 +109,6 @@ Foam::tmp<Foam::Field<Type> > Foam::DataEntry<Type>::value
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::DataEntry<Type>::integrate(const scalar x1, const scalar x2) const
|
||||
{
|
||||
notImplemented
|
||||
(
|
||||
"Type Foam::DataEntry<Type>::integrate"
|
||||
"("
|
||||
"const scalar, "
|
||||
"const scalar"
|
||||
") const"
|
||||
);
|
||||
|
||||
return pTraits<Type>::zero;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Type> > Foam::DataEntry<Type>::integrate
|
||||
(
|
||||
@ -127,6 +127,90 @@ Foam::tmp<Foam::Field<Type> > Foam::DataEntry<Type>::integrate
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::dimensioned<Type> Foam::DataEntry<Type>::dimValue(const scalar x) const
|
||||
{
|
||||
notImplemented
|
||||
(
|
||||
"dimensioned<Type> Foam::DataEntry<dimensioned<Type> >::dimValue"
|
||||
"(const scalar) const"
|
||||
);
|
||||
|
||||
return dimensioned<Type>("zero", dimless, pTraits<Type>::zero);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::dimensioned<Type> Foam::DataEntry<Type>::dimIntegrate
|
||||
(
|
||||
const scalar x1,
|
||||
const scalar x2
|
||||
) const
|
||||
{
|
||||
notImplemented
|
||||
(
|
||||
"dimensioned<Type> Foam::DataEntry<Type>::dimIntegrate"
|
||||
"("
|
||||
"const scalar, "
|
||||
"const scalar"
|
||||
") const"
|
||||
);
|
||||
|
||||
return dimensioned<Type>("zero", dimless, pTraits<Type>::zero);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Foam::dimensioned<Type> > >
|
||||
Foam::DataEntry<Type>::dimValue
|
||||
(
|
||||
const scalarField& x
|
||||
) const
|
||||
{
|
||||
|
||||
tmp<Field<dimensioned<Type> > > tfld
|
||||
(
|
||||
new Field<dimensioned<Type> >
|
||||
(
|
||||
x.size(),
|
||||
dimensioned<Type>("zero", dimless, pTraits<Type>::zero)
|
||||
)
|
||||
);
|
||||
|
||||
Field<dimensioned<Type> >& fld = tfld();
|
||||
|
||||
forAll(x, i)
|
||||
{
|
||||
fld[i] = this->dimValue(x[i]);
|
||||
}
|
||||
return tfld;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::tmp<Foam::Field<Foam::dimensioned<Type> > >
|
||||
Foam::DataEntry<Type>::dimIntegrate
|
||||
(
|
||||
const scalarField& x1,
|
||||
const scalarField& x2
|
||||
) const
|
||||
{
|
||||
tmp<Field<dimensioned<Type> > > tfld
|
||||
(
|
||||
new Field<dimensioned<Type> >(x1.size())
|
||||
);
|
||||
|
||||
Field<dimensioned<Type> >& fld = tfld();
|
||||
|
||||
forAll(x1, i)
|
||||
{
|
||||
fld[i] = this->dimIntegrate(x1[i], x2[i]);
|
||||
}
|
||||
return tfld;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
|
||||
|
||||
#include "DataEntryIO.C"
|
||||
|
||||
@ -41,6 +41,7 @@ SourceFiles
|
||||
|
||||
#include "dictionary.H"
|
||||
#include "Field.H"
|
||||
#include "dimensionedType.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -141,6 +142,9 @@ public:
|
||||
virtual void convertTimeBase(const Time& t);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
|
||||
// Evaluation
|
||||
|
||||
//- Return value as a function of (scalar) independent variable
|
||||
@ -159,6 +163,29 @@ public:
|
||||
const scalarField& x2
|
||||
) const;
|
||||
|
||||
//- Return dimensioned type
|
||||
virtual dimensioned<Type> dimValue(const scalar x) const;
|
||||
|
||||
//- Return dimensioned type as a function of (scalar)
|
||||
virtual tmp<Field<dimensioned<Type> > > dimValue
|
||||
(
|
||||
const scalarField& x
|
||||
) const;
|
||||
|
||||
//- Integrate between two scalars and returns a dimensioned type
|
||||
virtual dimensioned<Type> dimIntegrate
|
||||
(
|
||||
const scalar x1,
|
||||
const scalar x2
|
||||
) const;
|
||||
|
||||
//- Integrate between two scalars and returns list of dimensioned type
|
||||
virtual tmp<Field<dimensioned<Type> > > dimIntegrate
|
||||
(
|
||||
const scalarField& x1,
|
||||
const scalarField& x2
|
||||
) const;
|
||||
|
||||
|
||||
// I/O
|
||||
|
||||
|
||||
@ -40,9 +40,17 @@ Foam::autoPtr<Foam::DataEntry<Type> > Foam::DataEntry<Type>::New
|
||||
|
||||
word DataEntryType;
|
||||
if (firstToken.isWord())
|
||||
{
|
||||
// Dimensioned type default compatibility
|
||||
if (firstToken.wordToken() == entryName)
|
||||
{
|
||||
DataEntryType = "CompatibilityConstant";
|
||||
}
|
||||
else
|
||||
{
|
||||
DataEntryType = firstToken.wordToken();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// DataEntryType = CompatibilityConstant<Type>::typeName;
|
||||
|
||||
@ -36,6 +36,12 @@ Foam::Table<Type>::Table(const word& entryName, const dictionary& dict)
|
||||
Istream& is(dict.lookup(entryName));
|
||||
word entryType(is);
|
||||
|
||||
token firstToken(is);
|
||||
is.putBack(firstToken);
|
||||
if (firstToken == token::BEGIN_SQR)
|
||||
{
|
||||
is >> this->dimensions_;
|
||||
}
|
||||
is >> this->table_;
|
||||
|
||||
TableBase<Type>::check();
|
||||
|
||||
@ -30,7 +30,7 @@ Description
|
||||
in the form, e.g. for an entry \<entryName\> that is (scalar, vector):
|
||||
|
||||
\verbatim
|
||||
<entryName> table
|
||||
<entryName> table [0 1 0 0 0] //dimension set optional
|
||||
(
|
||||
0.0 (1 2 3)
|
||||
1.0 (4 5 6)
|
||||
@ -129,6 +129,22 @@ public:
|
||||
return TableBase<Type>::integrate(x1, x2);
|
||||
}
|
||||
|
||||
//- Return dimensioned constant value
|
||||
virtual dimensioned<Type> dimValue(const scalar x) const
|
||||
{
|
||||
return TableBase<Type>::dimValue(x);
|
||||
}
|
||||
|
||||
//- Integrate between two values and return dimensioned type
|
||||
virtual dimensioned<Type> dimIntegrate
|
||||
(
|
||||
const scalar x1,
|
||||
const scalar x2
|
||||
)
|
||||
{
|
||||
return TableBase<Type>::dimIntegrate(x1, x2);
|
||||
}
|
||||
|
||||
|
||||
// I/O
|
||||
|
||||
|
||||
@ -39,7 +39,8 @@ Foam::TableBase<Type>::TableBase(const word& name, const dictionary& dict)
|
||||
dict.lookupOrDefault<word>("outOfBounds", "clamp")
|
||||
)
|
||||
),
|
||||
table_()
|
||||
table_(),
|
||||
dimensions_(dimless)
|
||||
{}
|
||||
|
||||
|
||||
@ -48,7 +49,8 @@ Foam::TableBase<Type>::TableBase(const TableBase<Type>& tbl)
|
||||
:
|
||||
name_(tbl.name_),
|
||||
boundsHandling_(tbl.boundsHandling_),
|
||||
table_(tbl.table_)
|
||||
table_(tbl.table_),
|
||||
dimensions_(tbl.dimensions_)
|
||||
{}
|
||||
|
||||
|
||||
@ -330,6 +332,11 @@ Type Foam::TableBase<Type>::value(const scalar x) const
|
||||
i++;
|
||||
}
|
||||
|
||||
Info <<
|
||||
(xDash - table_[i].first())/(table_[i+1].first() - table_[i].first())
|
||||
* (table_[i+1].second() - table_[i].second())
|
||||
+ table_[i].second() << endl;
|
||||
|
||||
// Linear interpolation to find value
|
||||
return Type
|
||||
(
|
||||
@ -403,6 +410,28 @@ Type Foam::TableBase<Type>::integrate(const scalar x1, const scalar x2) const
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::dimensioned<Type> Foam::TableBase<Type>::
|
||||
dimValue(const scalar x) const
|
||||
{
|
||||
return dimensioned<Type>("dimensionedValue", dimensions_, this->value(x));
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Foam::dimensioned<Type> Foam::TableBase<Type>::dimIntegrate
|
||||
(
|
||||
const scalar x1, const scalar x2
|
||||
) const
|
||||
{
|
||||
return dimensioned<Type>
|
||||
(
|
||||
"dimensionedValue",
|
||||
dimensions_,
|
||||
this->integrate(x2, x1)
|
||||
);
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
|
||||
|
||||
#include "TableBaseIO.C"
|
||||
|
||||
@ -37,6 +37,7 @@ SourceFiles
|
||||
|
||||
#include "DataEntry.H"
|
||||
#include "Tuple2.H"
|
||||
#include "dimensionSet.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -87,6 +88,9 @@ protected:
|
||||
//- Table data
|
||||
List<Tuple2<scalar, Type> > table_;
|
||||
|
||||
//- The dimension set
|
||||
dimensionSet dimensions_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
@ -138,6 +142,16 @@ public:
|
||||
//- Integrate between two (scalar) values
|
||||
virtual Type integrate(const scalar x1, const scalar x2) const;
|
||||
|
||||
//- Return dimensioned constant value
|
||||
virtual dimensioned<Type> dimValue(const scalar x) const;
|
||||
|
||||
//- Integrate between two values and return dimensioned type
|
||||
virtual dimensioned<Type> dimIntegrate
|
||||
(
|
||||
const scalar x1,
|
||||
const scalar x2
|
||||
) const;
|
||||
|
||||
|
||||
// I/O
|
||||
|
||||
|
||||
@ -37,6 +37,11 @@ Foam::TableFile<Type>::TableFile(const word& entryName, const dictionary& dict)
|
||||
const dictionary coeffs(dict.subDict(type() + "Coeffs"));
|
||||
coeffs.lookup("fileName") >> fName_;
|
||||
|
||||
if (coeffs.found("dimensions"))
|
||||
{
|
||||
coeffs.lookup("dimensions") >> this->dimensions_;
|
||||
}
|
||||
|
||||
fileName expandedFile(fName_);
|
||||
IFstream is(expandedFile.expand());
|
||||
|
||||
|
||||
@ -31,6 +31,7 @@ Description
|
||||
<entryName> tableFile;
|
||||
tableFileCoeffs
|
||||
{
|
||||
dimensions [0 0 1 0 0]; // optional dimensions
|
||||
fileName dataFile; // name of data file
|
||||
outOfBounds clamp; // optional out-of-bounds handling
|
||||
}
|
||||
@ -145,6 +146,22 @@ public:
|
||||
return TableBase<Type>::integrate(x1, x2);
|
||||
}
|
||||
|
||||
//- Return dimensioned constant value
|
||||
virtual dimensioned<Type> dimValue(const scalar x) const
|
||||
{
|
||||
return TableBase<Type>::dimValue(x);
|
||||
}
|
||||
|
||||
//- Integrate between two values and return dimensioned type
|
||||
virtual dimensioned<Type> dimIntegrate
|
||||
(
|
||||
const scalar x1,
|
||||
const scalar x2
|
||||
)
|
||||
{
|
||||
return TableBase<Type>::dimIntegrate(x1, x2);
|
||||
}
|
||||
|
||||
|
||||
// I/O
|
||||
|
||||
|
||||
@ -42,11 +42,19 @@ Foam::polynomial::polynomial(const word& entryName, const dictionary& dict)
|
||||
:
|
||||
DataEntry<scalar>(entryName),
|
||||
coeffs_(),
|
||||
canIntegrate_(true)
|
||||
canIntegrate_(true),
|
||||
dimensions_(dimless)
|
||||
{
|
||||
Istream& is(dict.lookup(entryName));
|
||||
word entryType(is);
|
||||
|
||||
token firstToken(is);
|
||||
is.putBack(firstToken);
|
||||
if (firstToken == token::BEGIN_SQR)
|
||||
{
|
||||
is >> this->dimensions_;
|
||||
}
|
||||
|
||||
is >> coeffs_;
|
||||
|
||||
if (!coeffs_.size())
|
||||
@ -85,7 +93,8 @@ Foam::polynomial::polynomial
|
||||
:
|
||||
DataEntry<scalar>(entryName),
|
||||
coeffs_(coeffs),
|
||||
canIntegrate_(true)
|
||||
canIntegrate_(true),
|
||||
dimensions_(dimless)
|
||||
{
|
||||
if (!coeffs_.size())
|
||||
{
|
||||
@ -125,7 +134,8 @@ Foam::polynomial::polynomial(const polynomial& poly)
|
||||
:
|
||||
DataEntry<scalar>(poly),
|
||||
coeffs_(poly.coeffs_),
|
||||
canIntegrate_(poly.canIntegrate_)
|
||||
canIntegrate_(poly.canIntegrate_),
|
||||
dimensions_(poly.dimensions_)
|
||||
{}
|
||||
|
||||
|
||||
@ -180,4 +190,26 @@ Foam::scalar Foam::polynomial::integrate(const scalar x1, const scalar x2) const
|
||||
}
|
||||
|
||||
|
||||
Foam::dimensioned<Foam::scalar> Foam::polynomial::dimValue
|
||||
(
|
||||
const scalar x
|
||||
) const
|
||||
{
|
||||
return dimensioned<scalar>("dimensionedValue", dimensions_, value(x));
|
||||
}
|
||||
|
||||
|
||||
Foam::dimensioned<Foam::scalar> Foam::polynomial::dimIntegrate
|
||||
(
|
||||
const scalar x1, const scalar x2
|
||||
) const
|
||||
{
|
||||
return dimensioned<scalar>
|
||||
(
|
||||
"dimensionedValue",
|
||||
dimensions_,
|
||||
integrate(x1, x2)
|
||||
);
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -30,7 +30,7 @@ Description
|
||||
describes y = x^2 + 2x^3
|
||||
|
||||
\verbatim
|
||||
<entryName> polynomial
|
||||
<entryName> polynomial [0 0 1 0 0] // optional dimensions
|
||||
(
|
||||
(1 2)
|
||||
(2 3)
|
||||
@ -47,6 +47,7 @@ SourceFiles
|
||||
|
||||
#include "DataEntry.H"
|
||||
#include "Tuple2.H"
|
||||
#include "dimensionSet.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -79,6 +80,9 @@ class polynomial
|
||||
//- Flag to indicate whether poly can be integrated
|
||||
bool canIntegrate_;
|
||||
|
||||
//- The dimension set
|
||||
dimensionSet dimensions_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
@ -129,6 +133,16 @@ public:
|
||||
//- Integrate between two (scalar) values
|
||||
scalar integrate(const scalar x1, const scalar x2) const;
|
||||
|
||||
//- Return dimensioned constant value
|
||||
dimensioned<scalar> dimValue(const scalar) const;
|
||||
|
||||
//- Integrate between two values and return dimensioned type
|
||||
dimensioned<scalar> dimIntegrate
|
||||
(
|
||||
const scalar x1,
|
||||
const scalar x2
|
||||
) const;
|
||||
|
||||
|
||||
// I/O
|
||||
|
||||
|
||||
@ -240,8 +240,7 @@ Foam::MRFZone::MRFZone(const fvMesh& mesh, Istream& is)
|
||||
),
|
||||
origin_(dict_.lookup("origin")),
|
||||
axis_(dict_.lookup("axis")),
|
||||
omega_(dict_.lookup("omega")),
|
||||
Omega_("Omega", omega_*axis_)
|
||||
omega_(DataEntry<scalar>::New("omega", dict_))
|
||||
{
|
||||
if (dict_.found("patches"))
|
||||
{
|
||||
@ -256,7 +255,6 @@ Foam::MRFZone::MRFZone(const fvMesh& mesh, Istream& is)
|
||||
const polyBoundaryMesh& patches = mesh_.boundaryMesh();
|
||||
|
||||
axis_ = axis_/mag(axis_);
|
||||
Omega_ = omega_*axis_;
|
||||
|
||||
excludedPatchLabels_.setSize(excludedPatchNames_.size());
|
||||
|
||||
@ -309,7 +307,9 @@ void Foam::MRFZone::addCoriolis
|
||||
vectorField& ddtUc = ddtU.internalField();
|
||||
const vectorField& Uc = U.internalField();
|
||||
|
||||
const vector& Omega = Omega_.value();
|
||||
const scalar t = mesh_.time().timeOutputValue();
|
||||
|
||||
const vector& Omega = omega_->value(t)*axis_;
|
||||
|
||||
forAll(cells, i)
|
||||
{
|
||||
@ -331,7 +331,9 @@ void Foam::MRFZone::addCoriolis(fvVectorMatrix& UEqn) const
|
||||
vectorField& Usource = UEqn.source();
|
||||
const vectorField& U = UEqn.psi();
|
||||
|
||||
const vector& Omega = Omega_.value();
|
||||
const scalar t = mesh_.time().timeOutputValue();
|
||||
|
||||
const vector& Omega = omega_->value(t)*axis_;
|
||||
|
||||
forAll(cells, i)
|
||||
{
|
||||
@ -357,7 +359,9 @@ void Foam::MRFZone::addCoriolis
|
||||
vectorField& Usource = UEqn.source();
|
||||
const vectorField& U = UEqn.psi();
|
||||
|
||||
const vector& Omega = Omega_.value();
|
||||
const scalar t = mesh_.time().timeOutputValue();
|
||||
|
||||
const vector& Omega = omega_->value(t)*axis_;
|
||||
|
||||
forAll(cells, i)
|
||||
{
|
||||
@ -371,9 +375,11 @@ void Foam::MRFZone::relativeVelocity(volVectorField& U) const
|
||||
{
|
||||
const volVectorField& C = mesh_.C();
|
||||
|
||||
const vector& origin = origin_.value();
|
||||
const vector& origin = origin_;
|
||||
|
||||
const vector& Omega = Omega_.value();
|
||||
const scalar t = mesh_.time().timeOutputValue();
|
||||
|
||||
const vector& Omega = omega_->value(t)*axis_;
|
||||
|
||||
const labelList& cells = mesh_.cellZones()[cellZoneID_];
|
||||
|
||||
@ -411,9 +417,11 @@ void Foam::MRFZone::absoluteVelocity(volVectorField& U) const
|
||||
{
|
||||
const volVectorField& C = mesh_.C();
|
||||
|
||||
const vector& origin = origin_.value();
|
||||
const vector& origin = origin_;
|
||||
|
||||
const vector& Omega = Omega_.value();
|
||||
const scalar t = mesh_.time().timeOutputValue();
|
||||
|
||||
const vector& Omega = omega_->value(t)*axis_;
|
||||
|
||||
const labelList& cells = mesh_.cellZones()[cellZoneID_];
|
||||
|
||||
@ -481,9 +489,12 @@ void Foam::MRFZone::absoluteFlux
|
||||
|
||||
void Foam::MRFZone::correctBoundaryVelocity(volVectorField& U) const
|
||||
{
|
||||
const vector& origin = origin_.value();
|
||||
const vector& origin = origin_;
|
||||
|
||||
const scalar t = mesh_.time().timeOutputValue();
|
||||
|
||||
const vector& Omega = omega_->value(t)*axis_;
|
||||
|
||||
const vector& Omega = Omega_.value();
|
||||
|
||||
// Included patches
|
||||
forAll(includedFaces_, patchi)
|
||||
@ -511,7 +522,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const MRFZone& MRF)
|
||||
os << token::BEGIN_BLOCK << incrIndent << nl;
|
||||
os.writeKeyword("origin") << MRF.origin_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("axis") << MRF.axis_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("omega") << MRF.omega_ << token::END_STATEMENT << nl;
|
||||
MRF.omega_->writeData(os);
|
||||
|
||||
if (MRF.excludedPatchNames_.size())
|
||||
{
|
||||
|
||||
@ -49,6 +49,7 @@ SourceFiles
|
||||
#include "fvMatricesFwd.H"
|
||||
#include "fvMatrices.H"
|
||||
#include "DataEntry.H"
|
||||
#include "autoPtr.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -86,10 +87,14 @@ class MRFZone
|
||||
//- Excluded faces (per patch) that do not move with the MRF
|
||||
labelListList excludedFaces_;
|
||||
|
||||
const dimensionedVector origin_;
|
||||
dimensionedVector axis_;
|
||||
dimensionedScalar omega_;
|
||||
dimensionedVector Omega_;
|
||||
//- Origin of the axis
|
||||
const vector origin_;
|
||||
|
||||
//- Axis vector
|
||||
vector axis_;
|
||||
|
||||
//- Angular velocty (rad/sec)
|
||||
autoPtr<DataEntry<scalar> > omega_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
@ -41,8 +41,10 @@ void Foam::MRFZone::relativeRhoFlux
|
||||
const surfaceVectorField& Cf = mesh_.Cf();
|
||||
const surfaceVectorField& Sf = mesh_.Sf();
|
||||
|
||||
const vector& origin = origin_.value();
|
||||
const vector& Omega = Omega_.value();
|
||||
const vector& origin = origin_;
|
||||
|
||||
const scalar t = mesh_.time().timeOutputValue();
|
||||
const vector& Omega = omega_->value(t)*axis_;
|
||||
|
||||
const vectorField& Cfi = Cf.internalField();
|
||||
const vectorField& Sfi = Sf.internalField();
|
||||
@ -92,8 +94,10 @@ void Foam::MRFZone::absoluteRhoFlux
|
||||
const surfaceVectorField& Cf = mesh_.Cf();
|
||||
const surfaceVectorField& Sf = mesh_.Sf();
|
||||
|
||||
const vector& origin = origin_.value();
|
||||
const vector& Omega = Omega_.value();
|
||||
const vector& origin = origin_;
|
||||
|
||||
const scalar t = mesh_.time().timeOutputValue();
|
||||
const vector& Omega = omega_->value(t)*axis_;
|
||||
|
||||
const vectorField& Cfi = Cf.internalField();
|
||||
const vectorField& Sfi = Sf.internalField();
|
||||
|
||||
@ -22,9 +22,9 @@ FoamFile
|
||||
// Fixed patches (by default they 'move' with the MRF zone)
|
||||
nonRotatingPatches ();
|
||||
|
||||
origin origin [0 1 0 0 0 0 0] (0 0 0);
|
||||
axis axis [0 0 0 0 0 0 0] (0 0 1);
|
||||
omega omega [0 0 -1 0 0 0 0] 1047.2;
|
||||
origin (0 0 0);
|
||||
axis (0 0 1);
|
||||
omega constant 1047.2;
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@ -22,9 +22,9 @@ FoamFile
|
||||
// Fixed patches (by default they 'move' with the MRF zone)
|
||||
nonRotatingPatches ();
|
||||
|
||||
origin origin [0 1 0 0 0 0 0] (0 0 0);
|
||||
axis axis [0 0 0 0 0 0 0] (0 0 1);
|
||||
omega omega [0 0 -1 0 0 0 0] 104.72;
|
||||
origin (0 0 0);
|
||||
axis (0 0 1);
|
||||
omega 104.72;
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@ -22,9 +22,9 @@ FoamFile
|
||||
// Fixed patches (by default they 'move' with the MRF zone)
|
||||
nonRotatingPatches ();
|
||||
|
||||
origin origin [0 1 0 0 0 0 0] (0 0 0);
|
||||
axis axis [0 0 0 0 0 0 0] (0 0 1);
|
||||
omega omega [0 0 -1 0 0 0 0] 104.72;
|
||||
origin (0 0 0);
|
||||
axis (0 0 1);
|
||||
omega constant 104.72;
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@ -22,9 +22,9 @@ FoamFile
|
||||
// Fixed patches (by default they 'move' with the MRF zone)
|
||||
nonRotatingPatches ();
|
||||
|
||||
origin origin [0 1 0 0 0 0 0] (0 0 0);
|
||||
axis axis [0 0 0 0 0 0 0] (0 0 1);
|
||||
omega omega [0 0 -1 0 0 0 0] 6.2831853;
|
||||
origin (0 0 0);
|
||||
axis (0 0 1);
|
||||
omega constant 6.2831853;
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@ -22,9 +22,9 @@ FoamFile
|
||||
// Fixed patches (by default they 'move' with the MRF zone)
|
||||
nonRotatingPatches ();
|
||||
|
||||
origin origin [0 1 0 0 0 0 0] (0 0 0);
|
||||
axis axis [0 0 0 0 0 0 0] (0 0 1);
|
||||
omega omega [0 0 -1 0 0 0 0] 6.2831853;
|
||||
origin (0 0 0);
|
||||
axis (0 0 1);
|
||||
omega constant 6.2831853;
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@ -22,9 +22,9 @@ FoamFile
|
||||
// Fixed patches (by default they 'move' with the MRF zone)
|
||||
nonRotatingPatches ();
|
||||
|
||||
origin origin [0 1 0 0 0 0 0] (0 0 0);
|
||||
axis axis [0 0 0 0 0 0 0] (0 0 1);
|
||||
omega omega [0 0 -1 0 0 0 0] 10.472;
|
||||
origin (0 0 0);
|
||||
axis (0 0 1);
|
||||
omega constant 10.472;
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@ -22,9 +22,9 @@ FoamFile
|
||||
// Fixed patches (by default they 'move' with the MRF zone)
|
||||
nonRotatingPatches ();
|
||||
|
||||
origin origin [0 1 0 0 0 0 0] (0 0 0);
|
||||
axis axis [0 0 0 0 0 0 0] (0 0 1);
|
||||
omega omega [0 0 -1 0 0 0 0] 10.472;
|
||||
origin (0 0 0);
|
||||
axis (0 0 1);
|
||||
omega constant 10.472;
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@ -22,9 +22,9 @@ FoamFile
|
||||
// Fixed patches (by default they 'move' with the MRF zone)
|
||||
nonRotatingPatches ();
|
||||
|
||||
origin origin [0 1 0 0 0 0 0] (0 0 0);
|
||||
axis axis [0 0 0 0 0 0 0] (0 0 1);
|
||||
omega omega [0 0 -1 0 0 0 0] 10.472;
|
||||
origin (0 0 0);
|
||||
axis (0 0 1);
|
||||
omega constant 10.472;
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user