ENH: Adding dimensioSet to DataEntry and modify MRFZone entry types

This commit is contained in:
sergio
2012-04-13 16:31:07 +01:00
parent 8909ecc8bb
commit 48c70a91df
29 changed files with 488 additions and 92 deletions

View File

@ -154,6 +154,16 @@ dimensioned<Type>::dimensioned
} }
template <class Type>
dimensioned<Type>::dimensioned
()
:
name_("undefined"),
dimensions_(dimless),
value_(pTraits<Type>::zero)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template <class Type> template <class Type>

View File

@ -107,6 +107,9 @@ public:
//- Construct from an Istream with a given name and dimensions //- Construct from an Istream with a given name and dimensions
dimensioned(const word&, const dimensionSet&, Istream&); dimensioned(const word&, const dimensionSet&, Istream&);
//- Null constructor
dimensioned();
//- Construct from dictionary, with default value. //- Construct from dictionary, with default value.
static dimensioned<Type> lookupOrDefault static dimensioned<Type> lookupOrDefault
( (

View File

@ -163,6 +163,22 @@ public:
return TableBase<Type>::integrate(x1, x2); 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 // I/O

View File

@ -34,9 +34,27 @@ Foam::CompatibilityConstant<Type>::CompatibilityConstant
) )
: :
DataEntry<Type>(entryName), 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), DataEntry<Type>(cnst),
value_(cnst.value_) value_(cnst.value_),
dimensions_(cnst.dimensions_)
{} {}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type> 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 * * * * * * * * * * * * * // // * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
#include "CompatibilityConstantIO.C" #include "CompatibilityConstantIO.C"

View File

@ -42,6 +42,7 @@ SourceFiles
#define CompatibilityConstant_H #define CompatibilityConstant_H
#include "DataEntry.H" #include "DataEntry.H"
#include "dimensionSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -68,6 +69,9 @@ class CompatibilityConstant
//- Constant value //- Constant value
Type value_; Type value_;
//- The dimension set
dimensionSet dimensions_;
// Private Member Functions // Private Member Functions
@ -111,6 +115,16 @@ public:
//- Integrate between two values //- Integrate between two values
Type integrate(const scalar x1, const scalar x2) const; 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 // I/O

View File

@ -31,12 +31,27 @@ template<class Type>
Foam::Constant<Type>::Constant(const word& entryName, const dictionary& dict) Foam::Constant<Type>::Constant(const word& entryName, const dictionary& dict)
: :
DataEntry<Type>(entryName), DataEntry<Type>(entryName),
value_(pTraits<Type>::zero) value_(pTraits<Type>::zero),
dimensions_(dimless)
{ {
Istream& is(dict.lookup(entryName)); Istream& is(dict.lookup(entryName));
word entryType(is); word entryType(is);
token firstToken(is);
is >> value_; 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) Foam::Constant<Type>::Constant(const Constant<Type>& cnst)
: :
DataEntry<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 * * * * * * * * * * * * * // // * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
#include "ConstantIO.C" #include "ConstantIO.C"

View File

@ -41,6 +41,7 @@ SourceFiles
#define Constant_H #define Constant_H
#include "DataEntry.H" #include "DataEntry.H"
#include "dimensionSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -67,6 +68,9 @@ class Constant
//- Constant value //- Constant value
Type value_; Type value_;
//- The dimension set
dimensionSet dimensions_;
// Private Member Functions // Private Member Functions
@ -107,6 +111,16 @@ public:
//- Integrate between two values //- Integrate between two values
Type integrate(const scalar x1, const scalar x2) const; 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 // I/O

View File

@ -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> template<class Type>
Foam::tmp<Foam::Field<Type> > Foam::DataEntry<Type>::value 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> template<class Type>
Foam::tmp<Foam::Field<Type> > Foam::DataEntry<Type>::integrate 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 * * * * * * * * * * * * * // // * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
#include "DataEntryIO.C" #include "DataEntryIO.C"

View File

@ -41,6 +41,7 @@ SourceFiles
#include "dictionary.H" #include "dictionary.H"
#include "Field.H" #include "Field.H"
#include "dimensionedType.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -141,23 +142,49 @@ public:
virtual void convertTimeBase(const Time& t); virtual void convertTimeBase(const Time& t);
// Evaluation public:
//- Return value as a function of (scalar) independent variable
virtual Type value(const scalar x) const;
//- Return value as a function of (scalar) independent variable // Evaluation
virtual tmp<Field<Type> > value(const scalarField& x) const;
//- Integrate between two (scalar) values //- Return value as a function of (scalar) independent variable
virtual Type integrate(const scalar x1, const scalar x2) const; virtual Type value(const scalar x) const;
//- Integrate between two (scalar) values //- Return value as a function of (scalar) independent variable
virtual tmp<Field<Type> > integrate virtual tmp<Field<Type> > value(const scalarField& x) const;
(
const scalarField& x1, //- Integrate between two (scalar) values
const scalarField& x2 virtual Type integrate(const scalar x1, const scalar x2) const;
) const;
//- Integrate between two (scalar) values
virtual tmp<Field<Type> > integrate
(
const scalarField& x1,
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 // I/O

View File

@ -41,7 +41,15 @@ Foam::autoPtr<Foam::DataEntry<Type> > Foam::DataEntry<Type>::New
word DataEntryType; word DataEntryType;
if (firstToken.isWord()) if (firstToken.isWord())
{ {
DataEntryType = firstToken.wordToken(); // Dimensioned type default compatibility
if (firstToken.wordToken() == entryName)
{
DataEntryType = "CompatibilityConstant";
}
else
{
DataEntryType = firstToken.wordToken();
}
} }
else else
{ {

View File

@ -36,6 +36,12 @@ Foam::Table<Type>::Table(const word& entryName, const dictionary& dict)
Istream& is(dict.lookup(entryName)); Istream& is(dict.lookup(entryName));
word entryType(is); word entryType(is);
token firstToken(is);
is.putBack(firstToken);
if (firstToken == token::BEGIN_SQR)
{
is >> this->dimensions_;
}
is >> this->table_; is >> this->table_;
TableBase<Type>::check(); TableBase<Type>::check();

View File

@ -30,7 +30,7 @@ Description
in the form, e.g. for an entry \<entryName\> that is (scalar, vector): in the form, e.g. for an entry \<entryName\> that is (scalar, vector):
\verbatim \verbatim
<entryName> table <entryName> table [0 1 0 0 0] //dimension set optional
( (
0.0 (1 2 3) 0.0 (1 2 3)
1.0 (4 5 6) 1.0 (4 5 6)
@ -129,6 +129,22 @@ public:
return TableBase<Type>::integrate(x1, x2); 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 // I/O

View File

@ -39,7 +39,8 @@ Foam::TableBase<Type>::TableBase(const word& name, const dictionary& dict)
dict.lookupOrDefault<word>("outOfBounds", "clamp") dict.lookupOrDefault<word>("outOfBounds", "clamp")
) )
), ),
table_() table_(),
dimensions_(dimless)
{} {}
@ -48,7 +49,8 @@ Foam::TableBase<Type>::TableBase(const TableBase<Type>& tbl)
: :
name_(tbl.name_), name_(tbl.name_),
boundsHandling_(tbl.boundsHandling_), 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++; 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 // Linear interpolation to find value
return Type 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 * * * * * * * * * * * * * // // * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
#include "TableBaseIO.C" #include "TableBaseIO.C"

View File

@ -37,6 +37,7 @@ SourceFiles
#include "DataEntry.H" #include "DataEntry.H"
#include "Tuple2.H" #include "Tuple2.H"
#include "dimensionSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -87,6 +88,9 @@ protected:
//- Table data //- Table data
List<Tuple2<scalar, Type> > table_; List<Tuple2<scalar, Type> > table_;
//- The dimension set
dimensionSet dimensions_;
// Protected Member Functions // Protected Member Functions
@ -138,6 +142,16 @@ public:
//- Integrate between two (scalar) values //- Integrate between two (scalar) values
virtual Type integrate(const scalar x1, const scalar x2) const; 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 // I/O

View File

@ -37,6 +37,11 @@ Foam::TableFile<Type>::TableFile(const word& entryName, const dictionary& dict)
const dictionary coeffs(dict.subDict(type() + "Coeffs")); const dictionary coeffs(dict.subDict(type() + "Coeffs"));
coeffs.lookup("fileName") >> fName_; coeffs.lookup("fileName") >> fName_;
if (coeffs.found("dimensions"))
{
coeffs.lookup("dimensions") >> this->dimensions_;
}
fileName expandedFile(fName_); fileName expandedFile(fName_);
IFstream is(expandedFile.expand()); IFstream is(expandedFile.expand());

View File

@ -31,8 +31,9 @@ Description
<entryName> tableFile; <entryName> tableFile;
tableFileCoeffs tableFileCoeffs
{ {
fileName dataFile; // name of data file dimensions [0 0 1 0 0]; // optional dimensions
outOfBounds clamp; // optional out-of-bounds handling fileName dataFile; // name of data file
outOfBounds clamp; // optional out-of-bounds handling
} }
\endverbatim \endverbatim
@ -145,6 +146,22 @@ public:
return TableBase<Type>::integrate(x1, x2); 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 // I/O

View File

@ -42,11 +42,19 @@ Foam::polynomial::polynomial(const word& entryName, const dictionary& dict)
: :
DataEntry<scalar>(entryName), DataEntry<scalar>(entryName),
coeffs_(), coeffs_(),
canIntegrate_(true) canIntegrate_(true),
dimensions_(dimless)
{ {
Istream& is(dict.lookup(entryName)); Istream& is(dict.lookup(entryName));
word entryType(is); word entryType(is);
token firstToken(is);
is.putBack(firstToken);
if (firstToken == token::BEGIN_SQR)
{
is >> this->dimensions_;
}
is >> coeffs_; is >> coeffs_;
if (!coeffs_.size()) if (!coeffs_.size())
@ -85,7 +93,8 @@ Foam::polynomial::polynomial
: :
DataEntry<scalar>(entryName), DataEntry<scalar>(entryName),
coeffs_(coeffs), coeffs_(coeffs),
canIntegrate_(true) canIntegrate_(true),
dimensions_(dimless)
{ {
if (!coeffs_.size()) if (!coeffs_.size())
{ {
@ -125,7 +134,8 @@ Foam::polynomial::polynomial(const polynomial& poly)
: :
DataEntry<scalar>(poly), DataEntry<scalar>(poly),
coeffs_(poly.coeffs_), 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)
);
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -30,7 +30,7 @@ Description
describes y = x^2 + 2x^3 describes y = x^2 + 2x^3
\verbatim \verbatim
<entryName> polynomial <entryName> polynomial [0 0 1 0 0] // optional dimensions
( (
(1 2) (1 2)
(2 3) (2 3)
@ -47,6 +47,7 @@ SourceFiles
#include "DataEntry.H" #include "DataEntry.H"
#include "Tuple2.H" #include "Tuple2.H"
#include "dimensionSet.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -79,6 +80,9 @@ class polynomial
//- Flag to indicate whether poly can be integrated //- Flag to indicate whether poly can be integrated
bool canIntegrate_; bool canIntegrate_;
//- The dimension set
dimensionSet dimensions_;
// Private Member Functions // Private Member Functions
@ -129,6 +133,16 @@ public:
//- Integrate between two (scalar) values //- Integrate between two (scalar) values
scalar integrate(const scalar x1, const scalar x2) const; 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 // I/O

View File

@ -240,8 +240,7 @@ Foam::MRFZone::MRFZone(const fvMesh& mesh, Istream& is)
), ),
origin_(dict_.lookup("origin")), origin_(dict_.lookup("origin")),
axis_(dict_.lookup("axis")), axis_(dict_.lookup("axis")),
omega_(dict_.lookup("omega")), omega_(DataEntry<scalar>::New("omega", dict_))
Omega_("Omega", omega_*axis_)
{ {
if (dict_.found("patches")) if (dict_.found("patches"))
{ {
@ -256,7 +255,6 @@ Foam::MRFZone::MRFZone(const fvMesh& mesh, Istream& is)
const polyBoundaryMesh& patches = mesh_.boundaryMesh(); const polyBoundaryMesh& patches = mesh_.boundaryMesh();
axis_ = axis_/mag(axis_); axis_ = axis_/mag(axis_);
Omega_ = omega_*axis_;
excludedPatchLabels_.setSize(excludedPatchNames_.size()); excludedPatchLabels_.setSize(excludedPatchNames_.size());
@ -309,7 +307,9 @@ void Foam::MRFZone::addCoriolis
vectorField& ddtUc = ddtU.internalField(); vectorField& ddtUc = ddtU.internalField();
const vectorField& Uc = U.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) forAll(cells, i)
{ {
@ -331,7 +331,9 @@ void Foam::MRFZone::addCoriolis(fvVectorMatrix& UEqn) const
vectorField& Usource = UEqn.source(); vectorField& Usource = UEqn.source();
const vectorField& U = UEqn.psi(); 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) forAll(cells, i)
{ {
@ -357,7 +359,9 @@ void Foam::MRFZone::addCoriolis
vectorField& Usource = UEqn.source(); vectorField& Usource = UEqn.source();
const vectorField& U = UEqn.psi(); 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) forAll(cells, i)
{ {
@ -371,9 +375,11 @@ void Foam::MRFZone::relativeVelocity(volVectorField& U) const
{ {
const volVectorField& C = mesh_.C(); 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_]; const labelList& cells = mesh_.cellZones()[cellZoneID_];
@ -411,9 +417,11 @@ void Foam::MRFZone::absoluteVelocity(volVectorField& U) const
{ {
const volVectorField& C = mesh_.C(); 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_]; const labelList& cells = mesh_.cellZones()[cellZoneID_];
@ -481,9 +489,12 @@ void Foam::MRFZone::absoluteFlux
void Foam::MRFZone::correctBoundaryVelocity(volVectorField& U) const 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 // Included patches
forAll(includedFaces_, patchi) forAll(includedFaces_, patchi)
@ -511,7 +522,7 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const MRFZone& MRF)
os << token::BEGIN_BLOCK << incrIndent << nl; os << token::BEGIN_BLOCK << incrIndent << nl;
os.writeKeyword("origin") << MRF.origin_ << token::END_STATEMENT << nl; os.writeKeyword("origin") << MRF.origin_ << token::END_STATEMENT << nl;
os.writeKeyword("axis") << MRF.axis_ << 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()) if (MRF.excludedPatchNames_.size())
{ {

View File

@ -49,6 +49,7 @@ SourceFiles
#include "fvMatricesFwd.H" #include "fvMatricesFwd.H"
#include "fvMatrices.H" #include "fvMatrices.H"
#include "DataEntry.H" #include "DataEntry.H"
#include "autoPtr.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -86,10 +87,14 @@ class MRFZone
//- Excluded faces (per patch) that do not move with the MRF //- Excluded faces (per patch) that do not move with the MRF
labelListList excludedFaces_; labelListList excludedFaces_;
const dimensionedVector origin_; //- Origin of the axis
dimensionedVector axis_; const vector origin_;
dimensionedScalar omega_;
dimensionedVector Omega_; //- Axis vector
vector axis_;
//- Angular velocty (rad/sec)
autoPtr<DataEntry<scalar> > omega_;
// Private Member Functions // Private Member Functions

View File

@ -41,8 +41,10 @@ void Foam::MRFZone::relativeRhoFlux
const surfaceVectorField& Cf = mesh_.Cf(); const surfaceVectorField& Cf = mesh_.Cf();
const surfaceVectorField& Sf = mesh_.Sf(); const surfaceVectorField& Sf = mesh_.Sf();
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 vectorField& Cfi = Cf.internalField(); const vectorField& Cfi = Cf.internalField();
const vectorField& Sfi = Sf.internalField(); const vectorField& Sfi = Sf.internalField();
@ -92,8 +94,10 @@ void Foam::MRFZone::absoluteRhoFlux
const surfaceVectorField& Cf = mesh_.Cf(); const surfaceVectorField& Cf = mesh_.Cf();
const surfaceVectorField& Sf = mesh_.Sf(); const surfaceVectorField& Sf = mesh_.Sf();
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 vectorField& Cfi = Cf.internalField(); const vectorField& Cfi = Cf.internalField();
const vectorField& Sfi = Sf.internalField(); const vectorField& Sfi = Sf.internalField();

View File

@ -22,9 +22,9 @@ FoamFile
// Fixed patches (by default they 'move' with the MRF zone) // Fixed patches (by default they 'move' with the MRF zone)
nonRotatingPatches (); nonRotatingPatches ();
origin origin [0 1 0 0 0 0 0] (0 0 0); origin (0 0 0);
axis axis [0 0 0 0 0 0 0] (0 0 1); axis (0 0 1);
omega omega [0 0 -1 0 0 0 0] 1047.2; omega constant 1047.2;
} }
) )

View File

@ -22,9 +22,9 @@ FoamFile
// Fixed patches (by default they 'move' with the MRF zone) // Fixed patches (by default they 'move' with the MRF zone)
nonRotatingPatches (); nonRotatingPatches ();
origin origin [0 1 0 0 0 0 0] (0 0 0); origin (0 0 0);
axis axis [0 0 0 0 0 0 0] (0 0 1); axis (0 0 1);
omega omega [0 0 -1 0 0 0 0] 104.72; omega 104.72;
} }
) )

View File

@ -22,9 +22,9 @@ FoamFile
// Fixed patches (by default they 'move' with the MRF zone) // Fixed patches (by default they 'move' with the MRF zone)
nonRotatingPatches (); nonRotatingPatches ();
origin origin [0 1 0 0 0 0 0] (0 0 0); origin (0 0 0);
axis axis [0 0 0 0 0 0 0] (0 0 1); axis (0 0 1);
omega omega [0 0 -1 0 0 0 0] 104.72; omega constant 104.72;
} }
) )

View File

@ -22,9 +22,9 @@ FoamFile
// Fixed patches (by default they 'move' with the MRF zone) // Fixed patches (by default they 'move' with the MRF zone)
nonRotatingPatches (); nonRotatingPatches ();
origin origin [0 1 0 0 0 0 0] (0 0 0); origin (0 0 0);
axis axis [0 0 0 0 0 0 0] (0 0 1); axis (0 0 1);
omega omega [0 0 -1 0 0 0 0] 6.2831853; omega constant 6.2831853;
} }
) )

View File

@ -22,9 +22,9 @@ FoamFile
// Fixed patches (by default they 'move' with the MRF zone) // Fixed patches (by default they 'move' with the MRF zone)
nonRotatingPatches (); nonRotatingPatches ();
origin origin [0 1 0 0 0 0 0] (0 0 0); origin (0 0 0);
axis axis [0 0 0 0 0 0 0] (0 0 1); axis (0 0 1);
omega omega [0 0 -1 0 0 0 0] 6.2831853; omega constant 6.2831853;
} }
) )

View File

@ -22,9 +22,9 @@ FoamFile
// Fixed patches (by default they 'move' with the MRF zone) // Fixed patches (by default they 'move' with the MRF zone)
nonRotatingPatches (); nonRotatingPatches ();
origin origin [0 1 0 0 0 0 0] (0 0 0); origin (0 0 0);
axis axis [0 0 0 0 0 0 0] (0 0 1); axis (0 0 1);
omega omega [0 0 -1 0 0 0 0] 10.472; omega constant 10.472;
} }
) )

View File

@ -22,9 +22,9 @@ FoamFile
// Fixed patches (by default they 'move' with the MRF zone) // Fixed patches (by default they 'move' with the MRF zone)
nonRotatingPatches (); nonRotatingPatches ();
origin origin [0 1 0 0 0 0 0] (0 0 0); origin (0 0 0);
axis axis [0 0 0 0 0 0 0] (0 0 1); axis (0 0 1);
omega omega [0 0 -1 0 0 0 0] 10.472; omega constant 10.472;
} }
) )

View File

@ -22,9 +22,9 @@ FoamFile
// Fixed patches (by default they 'move' with the MRF zone) // Fixed patches (by default they 'move' with the MRF zone)
nonRotatingPatches (); nonRotatingPatches ();
origin origin [0 1 0 0 0 0 0] (0 0 0); origin (0 0 0);
axis axis [0 0 0 0 0 0 0] (0 0 1); axis (0 0 1);
omega omega [0 0 -1 0 0 0 0] 10.472; omega constant 10.472;
} }
) )