Merge branch 'master' of /home/dm4/OpenFOAM/OpenFOAM-dev

This commit is contained in:
laurence
2012-02-03 14:36:04 +00:00
49 changed files with 1123 additions and 242 deletions

View File

@ -2525,7 +2525,10 @@ Foam::labelBits Foam::dynamicIndexedOctree<Type>::findNode
template <class Type> template <class Type>
Foam::label Foam::dynamicIndexedOctree<Type>::findInside(const point& sample) const Foam::label Foam::dynamicIndexedOctree<Type>::findInside
(
const point& sample
) const
{ {
labelBits index = findNode(0, sample); labelBits index = findNode(0, sample);
@ -2873,7 +2876,8 @@ Foam::label Foam::dynamicIndexedOctree<Type>::removeIndex
if (newContent.size() == 0) if (newContent.size() == 0)
{ {
// Set to empty. // Set to empty.
nodes_[nodIndex].subNodes_[octant] = emptyPlusOctant(octant); nodes_[nodIndex].subNodes_[octant]
= emptyPlusOctant(octant);
} }
contentList.transfer(newContent); contentList.transfer(newContent);
@ -3002,7 +3006,8 @@ bool Foam::dynamicIndexedOctree<Type>::write(Ostream& os) const
template <class Type> template <class Type>
Foam::Ostream& Foam::operator<<(Ostream& os, const dynamicIndexedOctree<Type>& t) Foam::Ostream&
Foam::operator<<(Ostream& os, const dynamicIndexedOctree<Type>& t)
{ {
os << t.bb() << token::SPACE << t.nodes() << endl; os << t.bb() << token::SPACE << t.nodes() << endl;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -150,8 +150,8 @@ public:
{ {
notImplemented notImplemented
( (
"dynamicTreeDataPoint::intersects(const label, const point&," "dynamicTreeDataPoint::intersects
"const point&, point&)" "(const label, const point&, const point&, point&)"
); );
return false; return false;
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -139,17 +139,28 @@ public:
// Member Functions // Member Functions
//- Return Table value // Manipulation
virtual Type value(const scalar x) const
{
return TableBase<Type>::value(x);
}
//- Integrate between two (scalar) values //- Convert time
virtual Type integrate(const scalar x1, const scalar x2) const virtual void convertTimeBase(const Time& t)
{ {
return TableBase<Type>::integrate(x1, x2); TableBase<Type>::convertTimeBase(t);
} }
// Evaluation
//- Return Table value
virtual Type value(const scalar x) const
{
return TableBase<Type>::value(x);
}
//- Integrate between two (scalar) values
virtual Type integrate(const scalar x1, const scalar x2) const
{
return TableBase<Type>::integrate(x1, x2);
}
// I/O // I/O

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "DataEntry.H" #include "DataEntry.H"
#include "Time.H"
// * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * //
@ -59,6 +60,13 @@ const Foam::word& Foam::DataEntry<Type>::name() const
} }
template<class Type>
void Foam::DataEntry<Type>::convertTimeBase(const Time&)
{
// do nothing
}
template<class Type> template<class Type>
Type Foam::DataEntry<Type>::value(const scalar x) const Type Foam::DataEntry<Type>::value(const scalar x) const
{ {

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -45,6 +45,7 @@ SourceFiles
namespace Foam namespace Foam
{ {
class Time;
template<class Type> template<class Type>
class DataEntry; class DataEntry;
@ -133,6 +134,12 @@ public:
const word& name() const; const word& name() const;
// Manipulation
//- Convert time
virtual void convertTimeBase(const Time& t);
// Evaluation // Evaluation
//- Return value as a function of (scalar) independent variable //- Return value as a function of (scalar) independent variable

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -106,17 +106,28 @@ public:
// Member Functions // Member Functions
//- Return Table value // Manipulation
virtual Type value(const scalar x) const
{
return TableBase<Type>::value(x);
}
//- Integrate between two (scalar) values //- Convert time
virtual Type integrate(const scalar x1, const scalar x2) const virtual void convertTimeBase(const Time& t)
{ {
return TableBase<Type>::integrate(x1, x2); TableBase<Type>::convertTimeBase(t);
} }
// Evaluation
//- Return Table value
virtual Type value(const scalar x) const
{
return TableBase<Type>::value(x);
}
//- Integrate between two (scalar) values
virtual Type integrate(const scalar x1, const scalar x2) const
{
return TableBase<Type>::integrate(x1, x2);
}
// I/O // I/O

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "TableBase.H" #include "TableBase.H"
#include "Time.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -296,6 +297,17 @@ bool Foam::TableBase<Type>::checkMaxBounds
} }
template<class Type>
void Foam::TableBase<Type>::convertTimeBase(const Time& t)
{
forAll(table_, i)
{
scalar value = table_[i].first();
table_[i].first() = t.userTimeToTime(value);
}
}
template<class Type> template<class Type>
Type Foam::TableBase<Type>::value(const scalar x) const Type Foam::TableBase<Type>::value(const scalar x) const
{ {

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -129,6 +129,9 @@ public:
//- Check maximum table bounds //- Check maximum table bounds
bool checkMaxBounds(const scalar x, scalar& xDash) const; bool checkMaxBounds(const scalar x, scalar& xDash) const;
//- Convert time
virtual void convertTimeBase(const Time& t);
//- Return Table value //- Return Table value
virtual Type value(const scalar x) const; virtual Type value(const scalar x) const;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -122,17 +122,28 @@ public:
// Member Functions // Member Functions
//- Return TableFile value // Manipulation
virtual Type value(const scalar x) const
{
return TableBase<Type>::value(x);
}
//- Integrate between two (scalar) values //- Convert time
virtual Type integrate(const scalar x1, const scalar x2) const virtual void convertTimeBase(const Time& t)
{ {
return TableBase<Type>::integrate(x1, x2); TableBase<Type>::convertTimeBase(t);
} }
// Evaluation
//- Return TableFile value
virtual Type value(const scalar x) const
{
return TableBase<Type>::value(x);
}
//- Integrate between two (scalar) values
virtual Type integrate(const scalar x1, const scalar x2) const
{
return TableBase<Type>::integrate(x1, x2);
}
// I/O // I/O

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -24,6 +24,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "polynomial.H" #include "polynomial.H"
#include "Time.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -89,6 +90,16 @@ Foam::polynomial::~polynomial()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::polynomial::convertTimeBase(const Time& t)
{
forAll(coeffs_, i)
{
scalar value = coeffs_[i].first();
coeffs_[i].first() = t.userTimeToTime(value);
}
}
Foam::scalar Foam::polynomial::value(const scalar x) const Foam::scalar Foam::polynomial::value(const scalar x) const
{ {
scalar y = 0.0; scalar y = 0.0;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -112,11 +112,19 @@ public:
// Member Functions // Member Functions
//- Return polynomial value // Manipulation
scalar value(const scalar x) const;
//- Integrate between two (scalar) values //- Convert time
scalar integrate(const scalar x1, const scalar x2) const; virtual void convertTimeBase(const Time& t);
// Evaluation
//- Return polynomial value
scalar value(const scalar x) const;
//- Integrate between two (scalar) values
scalar integrate(const scalar x1, const scalar x2) const;
// I/O // I/O

View File

@ -0,0 +1,137 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "TimeDataEntry.H"
// * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * //
template<class Type>
Foam::TimeDataEntry<Type>::TimeDataEntry
(
const Time& t,
const word& name,
const dictionary& dict
)
:
time_(t),
name_(name),
entry_(DataEntry<Type>::New(name, dict))
{
entry_->convertTimeBase(t);
}
template<class Type>
Foam::TimeDataEntry<Type>::TimeDataEntry(const Time& t, const word& name)
:
time_(t),
name_(name),
entry_(NULL)
{}
template<class Type>
Foam::TimeDataEntry<Type>::TimeDataEntry
(
const TimeDataEntry<Type>& tde
)
:
time_(tde.time_),
name_(tde.name_),
entry_(tde.entry_->clone().ptr())
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
template<class Type>
Foam::TimeDataEntry<Type>::~TimeDataEntry()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<class Type>
void Foam::TimeDataEntry<Type>::reset(const dictionary& dict)
{
entry_.reset
(
DataEntry<Type>::New
(
name_,
dict
).ptr()
);
entry_->convertTimeBase(time_);
}
template<class Type>
const Foam::word& Foam::TimeDataEntry<Type>::name() const
{
return entry_->name();
}
template<class Type>
Type Foam::TimeDataEntry<Type>::value(const scalar x) const
{
return entry_->value(x);
}
template<class Type>
Type Foam::TimeDataEntry<Type>::integrate
(
const scalar x1,
const scalar x2
) const
{
return entry_->integrate(x1, x2);
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template<class Type>
Foam::Ostream& Foam::operator<<
(
Ostream& os,
const TimeDataEntry<Type>& de
)
{
return de.entry_->operator<<(os, de);
}
template<class Type>
void Foam::TimeDataEntry<Type>::writeData(Ostream& os) const
{
entry_->writeData(os);
}
// ************************************************************************* //

View File

@ -0,0 +1,153 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2012 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
Class
Foam::TimeDataEntry
Description
Light wrapper around DataEntry to provide a mechanism to update time-based
entries.
SourceFiles
TimeDataEntry.C
\*---------------------------------------------------------------------------*/
#ifndef TimeDataEntry_H
#define TimeDataEntry_H
#include "DataEntry.H"
#include "Time.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
template<class Type>
class TimeDataEntry;
template<class Type>
Ostream& operator<<
(
Ostream&,
const TimeDataEntry<Type>&
);
/*---------------------------------------------------------------------------*\
Class TimeDataEntry Declaration
\*---------------------------------------------------------------------------*/
template<class Type>
class TimeDataEntry
{
protected:
// Protected data
//- Reference to the time database
const Time& time_;
//- Name of the data entry
const word name_;
//- The underlying DataEntry
autoPtr<DataEntry<Type> > entry_;
public:
// Constructor
//- Construct from entry name
TimeDataEntry
(
const Time& t,
const word& name,
const dictionary& dict
);
//- Construct null from entry name
TimeDataEntry
(
const Time& t,
const word& entryName
);
//- Copy constructor
TimeDataEntry(const TimeDataEntry<Type>& tde);
//- Destructor
virtual ~TimeDataEntry();
// Member Functions
// Access
//- Reset entry by re-reading from dictionary
void reset(const dictionary& dict);
//- Return the name of the entry
const word& name() const;
// Evaluation
//- Return value as a function of (scalar) independent variable
virtual Type value(const scalar x) const;
//- Integrate between two (scalar) values
virtual Type integrate(const scalar x1, const scalar x2) const;
// I/O
//- Ostream Operator
friend Ostream& operator<< <Type>
(
Ostream& os,
const TimeDataEntry<Type>& de
);
//- Write in dictionary format
virtual void writeData(Ostream& os) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "TimeDataEntry.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -66,6 +66,12 @@ void Foam::actuationDiskSource::checkData() const
<< "disk direction vector is approximately zero" << "disk direction vector is approximately zero"
<< exit(FatalIOError); << exit(FatalIOError);
} }
if (returnReduce(upstreamCellId_, maxOp<label>()) == -1)
{
FatalErrorIn("Foam::actuationDiskSource::checkData()")
<< "upstream location " << upstreamPoint_ << " not found in mesh"
<< exit(FatalIOError);
}
} }
@ -83,7 +89,9 @@ Foam::actuationDiskSource::actuationDiskSource
diskDir_(coeffs_.lookup("diskDir")), diskDir_(coeffs_.lookup("diskDir")),
Cp_(readScalar(coeffs_.lookup("Cp"))), Cp_(readScalar(coeffs_.lookup("Cp"))),
Ct_(readScalar(coeffs_.lookup("Ct"))), Ct_(readScalar(coeffs_.lookup("Ct"))),
diskArea_(readScalar(coeffs_.lookup("diskArea"))) diskArea_(readScalar(coeffs_.lookup("diskArea"))),
upstreamPoint_(coeffs_.lookup("upstreamPoint")),
upstreamCellId_(-1)
{ {
coeffs_.lookup("fieldNames") >> fieldNames_; coeffs_.lookup("fieldNames") >> fieldNames_;
applied_.setSize(fieldNames_.size(), false); applied_.setSize(fieldNames_.size(), false);
@ -91,6 +99,8 @@ Foam::actuationDiskSource::actuationDiskSource
Info<< " - creating actuation disk zone: " Info<< " - creating actuation disk zone: "
<< this->name() << endl; << this->name() << endl;
upstreamCellId_ = mesh.findCell(upstreamPoint_);
checkData(); checkData();
} }

View File

@ -48,6 +48,7 @@ Description
Cp 0.1; // power coefficient Cp 0.1; // power coefficient
Ct 0.5; // thrust coefficient Ct 0.5; // thrust coefficient
diskArea 5.0; // disk area diskArea 5.0; // disk area
upstreamPoint (0 0 0); // upstream point
} }
@ -92,6 +93,12 @@ protected:
//- Disk area //- Disk area
scalar diskArea_; scalar diskArea_;
//- Upstream point sample
point upstreamPoint_;
//- Upstream cell ID
label upstreamCellId_;
private: private:

View File

@ -42,20 +42,27 @@ void Foam::actuationDiskSource::addActuationDiskAxialInertialResistance
) const ) const
{ {
scalar a = 1.0 - Cp_/Ct_; scalar a = 1.0 - Cp_/Ct_;
scalarField T(cells.size());
vector uniDiskDir = diskDir_/mag(diskDir_); vector uniDiskDir = diskDir_/mag(diskDir_);
tensor E(tensor::zero); tensor E(tensor::zero);
E.xx() = uniDiskDir.x(); E.xx() = uniDiskDir.x();
E.yy() = uniDiskDir.y(); E.yy() = uniDiskDir.y();
E.zz() = uniDiskDir.z(); E.zz() = uniDiskDir.z();
forAll(cells, i) vector upU = vector(VGREAT, VGREAT, VGREAT);
scalar upRho = VGREAT;
if (upstreamCellId_ != -1)
{ {
T[i] = 2.0*rho[cells[i]]*diskArea_*mag(U[cells[i]])*a/(1.0 - a); upU = U[upstreamCellId_];
upRho = rho[upstreamCellId_];
} }
reduce(upU, minOp<vector>());
reduce(upRho, minOp<scalar>());
scalar T = 2.0*upRho*diskArea_*mag(upU)*a*(1 - a);
forAll(cells, i) forAll(cells, i)
{ {
Usource[cells[i]] -= ((Vcells[cells[i]]/V())*T[i]*E) & U[cells[i]]; Usource[cells[i]] += ((Vcells[cells[i]]/V())*T*E) & upU;
} }
} }

View File

@ -53,6 +53,7 @@ Description
Ct 0.5; // thrust coefficient Ct 0.5; // thrust coefficient
diskArea 5.0; // disk area diskArea 5.0; // disk area
coeffs (0.1 0.5 0.01); // radial distribution coefficients coeffs (0.1 0.5 0.01); // radial distribution coefficients
upstreamPoint (0 0 0); // upstream point
} }

View File

@ -44,11 +44,9 @@ addRadialActuationDiskAxialInertialResistance
) const ) const
{ {
scalar a = 1.0 - Cp_/Ct_; scalar a = 1.0 - Cp_/Ct_;
scalarField T(cells.size());
scalarField Tr(cells.size()); scalarField Tr(cells.size());
const vector uniDiskDir = diskDir_/mag(diskDir_); const vector uniDiskDir = diskDir_/mag(diskDir_);
tensor E(tensor::zero); tensor E(tensor::zero);
E.xx() = uniDiskDir.x(); E.xx() = uniDiskDir.x();
E.yy() = uniDiskDir.y(); E.yy() = uniDiskDir.y();
@ -65,21 +63,27 @@ addRadialActuationDiskAxialInertialResistance
+ radialCoeffs_[1]*sqr(maxR)/2.0 + radialCoeffs_[1]*sqr(maxR)/2.0
+ radialCoeffs_[2]*pow4(maxR)/3.0; + radialCoeffs_[2]*pow4(maxR)/3.0;
vector upU = vector(VGREAT, VGREAT, VGREAT);
scalar upRho = VGREAT;
if (upstreamCellId_ != -1)
{
upU = U[upstreamCellId_];
upRho = rho[upstreamCellId_];
}
reduce(upU, minOp<vector>());
reduce(upRho, minOp<scalar>());
scalar T = 2.0*upRho*diskArea_*mag(upU)*a*(1.0 - a);
forAll(cells, i) forAll(cells, i)
{ {
T[i] = 2.0*rho[cells[i]]*diskArea_*mag(U[cells[i]])*a/(1.0 - a);
scalar r2 = magSqr(mesh().cellCentres()[cells[i]] - avgCentre); scalar r2 = magSqr(mesh().cellCentres()[cells[i]] - avgCentre);
Tr[i] = Tr[i] =
T[i] T
*(radialCoeffs_[0] + radialCoeffs_[1]*r2 + radialCoeffs_[2]*sqr(r2)) *(radialCoeffs_[0] + radialCoeffs_[1]*r2 + radialCoeffs_[2]*sqr(r2))
/intCoeffs; /intCoeffs;
}
forAll(cells, i) Usource[cells[i]] += ((Vcells[cells[i]]/V_)*Tr[i]*E) & upU;
{
Usource[cells[i]] -= ((Vcells[cells[i]]/V_)*Tr[i]*E) & U[cells[i]];
} }
if (debug) if (debug)

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "ConeInjection.H" #include "ConeInjection.H"
#include "DataEntry.H" #include "TimeDataEntry.H"
#include "mathematicalConstants.H" #include "mathematicalConstants.H"
#include "unitConversion.H" #include "unitConversion.H"
@ -51,11 +51,40 @@ Foam::ConeInjection<CloudType>::ConeInjection
), ),
flowRateProfile_ flowRateProfile_
( (
DataEntry<scalar>::New("flowRateProfile", this->coeffDict()) TimeDataEntry<scalar>
(
owner.db().time(),
"flowRateProfile",
this->coeffDict()
)
),
Umag_
(
TimeDataEntry<scalar>
(
owner.db().time(),
"Umag",
this->coeffDict()
)
),
thetaInner_
(
TimeDataEntry<scalar>
(
owner.db().time(),
"thetaInner",
this->coeffDict()
)
),
thetaOuter_
(
TimeDataEntry<scalar>
(
owner.db().time(),
"thetaOuter",
this->coeffDict()
)
), ),
Umag_(DataEntry<scalar>::New("Umag", this->coeffDict())),
thetaInner_(DataEntry<scalar>::New("thetaInner", this->coeffDict())),
thetaOuter_(DataEntry<scalar>::New("thetaOuter", this->coeffDict())),
sizeDistribution_ sizeDistribution_
( (
distributionModels::distributionModel::New distributionModels::distributionModel::New
@ -67,6 +96,8 @@ Foam::ConeInjection<CloudType>::ConeInjection
tanVec1_(positionAxis_.size()), tanVec1_(positionAxis_.size()),
tanVec2_(positionAxis_.size()) tanVec2_(positionAxis_.size())
{ {
duration_ = owner.db().time().userTimeToTime(duration_);
// Normalise direction vector and determine direction vectors // Normalise direction vector and determine direction vectors
// tangential to injector axis direction // tangential to injector axis direction
forAll(positionAxis_, i) forAll(positionAxis_, i)
@ -92,7 +123,7 @@ Foam::ConeInjection<CloudType>::ConeInjection
} }
// Set total volume to inject // Set total volume to inject
this->volumeTotal_ = flowRateProfile_().integrate(0.0, duration_); this->volumeTotal_ = flowRateProfile_.integrate(0.0, duration_);
// Set/cache the injector cells // Set/cache the injector cells
forAll(positionAxis_, i) forAll(positionAxis_, i)
@ -121,10 +152,10 @@ Foam::ConeInjection<CloudType>::ConeInjection
injectorTetPts_(im.injectorTetPts_), injectorTetPts_(im.injectorTetPts_),
duration_(im.duration_), duration_(im.duration_),
parcelsPerInjector_(im.parcelsPerInjector_), parcelsPerInjector_(im.parcelsPerInjector_),
flowRateProfile_(im.flowRateProfile_().clone().ptr()), flowRateProfile_(im.flowRateProfile_),
Umag_(im.Umag_().clone().ptr()), Umag_(im.Umag_),
thetaInner_(im.thetaInner_().clone().ptr()), thetaInner_(im.thetaInner_),
thetaOuter_(im.thetaOuter_().clone().ptr()), thetaOuter_(im.thetaOuter_),
sizeDistribution_(im.sizeDistribution_().clone().ptr()), sizeDistribution_(im.sizeDistribution_().clone().ptr()),
nInjected_(im.nInjected_), nInjected_(im.nInjected_),
tanVec1_(im.tanVec1_), tanVec1_(im.tanVec1_),
@ -157,7 +188,7 @@ Foam::label Foam::ConeInjection<CloudType>::parcelsToInject
{ {
if ((time0 >= 0.0) && (time0 < duration_)) if ((time0 >= 0.0) && (time0 < duration_))
{ {
const scalar targetVolume = flowRateProfile_().integrate(0, time1); const scalar targetVolume = flowRateProfile_.integrate(0, time1);
const label targetParcels = const label targetParcels =
parcelsPerInjector_*targetVolume/this->volumeTotal_; parcelsPerInjector_*targetVolume/this->volumeTotal_;
@ -184,7 +215,7 @@ Foam::scalar Foam::ConeInjection<CloudType>::volumeToInject
{ {
if ((time0 >= 0.0) && (time0 < duration_)) if ((time0 >= 0.0) && (time0 < duration_))
{ {
return flowRateProfile_().integrate(time0, time1); return flowRateProfile_.integrate(time0, time1);
} }
else else
{ {
@ -229,8 +260,8 @@ void Foam::ConeInjection<CloudType>::setProperties
const label i = parcelI % positionAxis_.size(); const label i = parcelI % positionAxis_.size();
scalar t = time - this->SOI_; scalar t = time - this->SOI_;
scalar ti = thetaInner_().value(t); scalar ti = thetaInner_.value(t);
scalar to = thetaOuter_().value(t); scalar to = thetaOuter_.value(t);
scalar coneAngle = degToRad(rnd.position<scalar>(ti, to)); scalar coneAngle = degToRad(rnd.position<scalar>(ti, to));
scalar alpha = sin(coneAngle); scalar alpha = sin(coneAngle);
@ -242,7 +273,7 @@ void Foam::ConeInjection<CloudType>::setProperties
dirVec += normal; dirVec += normal;
dirVec /= mag(dirVec); dirVec /= mag(dirVec);
parcel.U() = Umag_().value(t)*dirVec; parcel.U() = Umag_.value(t)*dirVec;
// set particle diameter // set particle diameter
parcel.d() = sizeDistribution_().sample(); parcel.d() = sizeDistribution_().sample();

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -45,17 +45,13 @@ SourceFiles
#include "InjectionModel.H" #include "InjectionModel.H"
#include "distributionModel.H" #include "distributionModel.H"
#include "vectorList.H" #include "vectorList.H"
#include "TimeDataEntry.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam namespace Foam
{ {
// Forward declaration of classes
template<class Type>
class DataEntry;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Class ConeInjection Declaration Class ConeInjection Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -80,22 +76,22 @@ class ConeInjection
labelList injectorTetPts_; labelList injectorTetPts_;
//- Injection duration [s] //- Injection duration [s]
const scalar duration_; scalar duration_;
//- Number of parcels to introduce per injector //- Number of parcels to introduce per injector
const label parcelsPerInjector_; const label parcelsPerInjector_;
//- Flow rate profile relative to SOI [] //- Flow rate profile relative to SOI []
const autoPtr<DataEntry<scalar> > flowRateProfile_; const TimeDataEntry<scalar> flowRateProfile_;
//- Parcel velocity magnitude relative to SOI [m/s] //- Parcel velocity magnitude relative to SOI [m/s]
const autoPtr<DataEntry<scalar> > Umag_; const TimeDataEntry<scalar> Umag_;
//- Inner cone angle relative to SOI [deg] //- Inner cone angle relative to SOI [deg]
const autoPtr<DataEntry<scalar> > thetaInner_; const TimeDataEntry<scalar> thetaInner_;
//- Outer cone angle relative to SOI [deg] //- Outer cone angle relative to SOI [deg]
const autoPtr<DataEntry<scalar> > thetaOuter_; const TimeDataEntry<scalar> thetaOuter_;
//- Parcel size distribution model //- Parcel size distribution model
const autoPtr<distributionModels::distributionModel> sizeDistribution_; const autoPtr<distributionModels::distributionModel> sizeDistribution_;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "ConeNozzleInjection.H" #include "ConeNozzleInjection.H"
#include "DataEntry.H" #include "TimeDataEntry.H"
#include "mathematicalConstants.H" #include "mathematicalConstants.H"
#include "distributionModel.H" #include "distributionModel.H"
@ -74,26 +74,12 @@ void Foam::ConeNozzleInjection<CloudType>::setFlowType()
} }
else if (flowType == "pressureDrivenVelocity") else if (flowType == "pressureDrivenVelocity")
{ {
Pinj_.reset Pinj_.reset(this->coeffDict());
(
DataEntry<scalar>::New
(
"Pinj",
this->coeffDict()
).ptr()
);
flowType_ = ftPressureDrivenVelocity; flowType_ = ftPressureDrivenVelocity;
} }
else if (flowType == "flowRateAndDischarge") else if (flowType == "flowRateAndDischarge")
{ {
Cd_.reset Cd_.reset(this->coeffDict());
(
DataEntry<scalar>::New
(
"Cd",
this->coeffDict()
).ptr()
);
flowType_ = ftFlowRateAndDischarge; flowType_ = ftFlowRateAndDischarge;
} }
else else
@ -132,24 +118,27 @@ Foam::ConeNozzleInjection<CloudType>::ConeNozzleInjection
), ),
flowRateProfile_ flowRateProfile_
( (
DataEntry<scalar>::New TimeDataEntry<scalar>
( (
owner.db().time(),
"flowRateProfile", "flowRateProfile",
this->coeffDict() this->coeffDict()
) )
), ),
thetaInner_ thetaInner_
( (
DataEntry<scalar>::New TimeDataEntry<scalar>
( (
owner.db().time(),
"thetaInner", "thetaInner",
this->coeffDict() this->coeffDict()
) )
), ),
thetaOuter_ thetaOuter_
( (
DataEntry<scalar>::New TimeDataEntry<scalar>
( (
owner.db().time(),
"thetaOuter", "thetaOuter",
this->coeffDict() this->coeffDict()
) )
@ -167,8 +156,8 @@ Foam::ConeNozzleInjection<CloudType>::ConeNozzleInjection
normal_(vector::zero), normal_(vector::zero),
UMag_(0.0), UMag_(0.0),
Cd_(NULL), Cd_(owner.db().time(), "Cd"),
Pinj_(NULL) Pinj_(owner.db().time(), "Pinj")
{ {
if (innerDiameter_ >= outerDiameter_) if (innerDiameter_ >= outerDiameter_)
{ {
@ -183,6 +172,8 @@ Foam::ConeNozzleInjection<CloudType>::ConeNozzleInjection
<< exit(FatalError); << exit(FatalError);
} }
duration_ = owner.db().time().userTimeToTime(duration_);
setInjectionMethod(); setInjectionMethod();
setFlowType(); setFlowType();
@ -208,7 +199,7 @@ Foam::ConeNozzleInjection<CloudType>::ConeNozzleInjection
tanVec2_ = direction_^tanVec1_; tanVec2_ = direction_^tanVec1_;
// Set total volume to inject // Set total volume to inject
this->volumeTotal_ = flowRateProfile_().integrate(0.0, duration_); this->volumeTotal_ = flowRateProfile_.integrate(0.0, duration_);
} }
@ -230,26 +221,17 @@ Foam::ConeNozzleInjection<CloudType>::ConeNozzleInjection
tetPtI_(im.tetPtI_), tetPtI_(im.tetPtI_),
direction_(im.direction_), direction_(im.direction_),
parcelsPerSecond_(im.parcelsPerSecond_), parcelsPerSecond_(im.parcelsPerSecond_),
flowRateProfile_(im.flowRateProfile_().clone().ptr()), flowRateProfile_(im.flowRateProfile_),
thetaInner_(im.thetaInner_().clone().ptr()), thetaInner_(im.thetaInner_),
thetaOuter_(im.thetaOuter_().clone().ptr()), thetaOuter_(im.thetaOuter_),
sizeDistribution_(im.sizeDistribution_().clone().ptr()), sizeDistribution_(im.sizeDistribution_().clone().ptr()),
tanVec1_(im.tanVec1_), tanVec1_(im.tanVec1_),
tanVec2_(im.tanVec1_), tanVec2_(im.tanVec1_),
normal_(im.normal_), normal_(im.normal_),
UMag_(im.UMag_), UMag_(im.UMag_),
Cd_(NULL), Cd_(im.Cd_),
Pinj_(NULL) Pinj_(im.Pinj_)
{ {}
if (im.Cd_.valid())
{
Cd_.reset(im.Cd_().clone().ptr());
}
if (im.Pinj_.valid())
{
Pinj_.reset(im.Pinj_().clone().ptr());
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
@ -295,7 +277,7 @@ Foam::scalar Foam::ConeNozzleInjection<CloudType>::volumeToInject
{ {
if ((time0 >= 0.0) && (time0 < duration_)) if ((time0 >= 0.0) && (time0 < duration_))
{ {
return flowRateProfile_().integrate(time0, time1); return flowRateProfile_.integrate(time0, time1);
} }
else else
{ {
@ -383,8 +365,8 @@ void Foam::ConeNozzleInjection<CloudType>::setProperties
const scalar deg2Rad = mathematical::pi/180.0; const scalar deg2Rad = mathematical::pi/180.0;
scalar t = time - this->SOI_; scalar t = time - this->SOI_;
scalar ti = thetaInner_().value(t); scalar ti = thetaInner_.value(t);
scalar to = thetaOuter_().value(t); scalar to = thetaOuter_.value(t);
scalar coneAngle = rndGen.sample01<scalar>()*(to - ti) + ti; scalar coneAngle = rndGen.sample01<scalar>()*(to - ti) + ti;
coneAngle *= deg2Rad; coneAngle *= deg2Rad;
@ -407,7 +389,7 @@ void Foam::ConeNozzleInjection<CloudType>::setProperties
{ {
scalar pAmbient = this->owner().pAmbient(); scalar pAmbient = this->owner().pAmbient();
scalar rho = parcel.rho(); scalar rho = parcel.rho();
scalar UMag = ::sqrt(2.0*(Pinj_().value(t) - pAmbient)/rho); scalar UMag = ::sqrt(2.0*(Pinj_.value(t) - pAmbient)/rho);
parcel.U() = UMag*dirVec; parcel.U() = UMag*dirVec;
break; break;
} }
@ -417,10 +399,10 @@ void Foam::ConeNozzleInjection<CloudType>::setProperties
scalar Ai = 0.25*mathematical::pi*innerDiameter_*innerDiameter_; scalar Ai = 0.25*mathematical::pi*innerDiameter_*innerDiameter_;
scalar massFlowRate = scalar massFlowRate =
this->massTotal() this->massTotal()
*flowRateProfile_().value(t) *flowRateProfile_.value(t)
/this->volumeTotal(); /this->volumeTotal();
scalar Umag = massFlowRate/(parcel.rho()*Cd_().value(t)*(Ao - Ai)); scalar Umag = massFlowRate/(parcel.rho()*Cd_.value(t)*(Ao - Ai));
parcel.U() = Umag*dirVec; parcel.U() = Umag*dirVec;
break; break;
} }

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -63,7 +63,7 @@ namespace Foam
// Forward declaration of classes // Forward declaration of classes
template<class Type> template<class Type>
class DataEntry; class TimeDataEntry;
class distributionModel; class distributionModel;
@ -111,7 +111,7 @@ private:
const scalar innerDiameter_; const scalar innerDiameter_;
//- Injection duration [s] //- Injection duration [s]
const scalar duration_; scalar duration_;
//- Injector position [m] //- Injector position [m]
vector position_; vector position_;
@ -132,13 +132,13 @@ private:
const label parcelsPerSecond_; const label parcelsPerSecond_;
//- Flow rate profile relative to SOI [] //- Flow rate profile relative to SOI []
const autoPtr<DataEntry<scalar> > flowRateProfile_; const TimeDataEntry<scalar> flowRateProfile_;
//- Inner cone angle relative to SOI [deg] //- Inner cone angle relative to SOI [deg]
const autoPtr<DataEntry<scalar> > thetaInner_; const TimeDataEntry<scalar> thetaInner_;
//- Outer cone angle relative to SOI [deg] //- Outer cone angle relative to SOI [deg]
const autoPtr<DataEntry<scalar> > thetaOuter_; const TimeDataEntry<scalar> thetaOuter_;
//- Parcel size PDF model //- Parcel size PDF model
const autoPtr<distributionModels::distributionModel> sizeDistribution_; const autoPtr<distributionModels::distributionModel> sizeDistribution_;
@ -162,10 +162,10 @@ private:
scalar UMag_; scalar UMag_;
//- Discharge coefficient, relative to SOI [m/s] //- Discharge coefficient, relative to SOI [m/s]
autoPtr<DataEntry<scalar> > Cd_; TimeDataEntry<scalar> Cd_;
//- Injection pressure [Pa] //- Injection pressure [Pa]
autoPtr<DataEntry<scalar> > Pinj_; TimeDataEntry<scalar> Pinj_;
// Private Member Functions // Private Member Functions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -48,16 +48,18 @@ Foam::InflationInjection<CloudType>::InflationInjection
duration_(readScalar(this->coeffDict().lookup("duration"))), duration_(readScalar(this->coeffDict().lookup("duration"))),
flowRateProfile_ flowRateProfile_
( (
DataEntry<scalar>::New TimeDataEntry<scalar>
( (
owner.db().time(),
"flowRateProfile", "flowRateProfile",
this->coeffDict() this->coeffDict()
) )
), ),
growthRate_ growthRate_
( (
DataEntry<scalar>::New TimeDataEntry<scalar>
( (
owner.db().time(),
"growthRate", "growthRate",
this->coeffDict() this->coeffDict()
) )
@ -76,6 +78,8 @@ Foam::InflationInjection<CloudType>::InflationInjection
) )
) )
{ {
duration_ = owner.db().time().userTimeToTime(duration_);
if (selfSeed_) if (selfSeed_)
{ {
dSeed_ = readScalar(this->coeffDict().lookup("dSeed")); dSeed_ = readScalar(this->coeffDict().lookup("dSeed"));
@ -111,7 +115,7 @@ Foam::InflationInjection<CloudType>::InflationInjection
} }
// Set total volume/mass to inject // Set total volume/mass to inject
this->volumeTotal_ = fraction_*flowRateProfile_().integrate(0.0, duration_); this->volumeTotal_ = fraction_*flowRateProfile_.integrate(0.0, duration_);
this->massTotal_ *= fraction_; this->massTotal_ *= fraction_;
} }
@ -128,8 +132,8 @@ Foam::InflationInjection<CloudType>::InflationInjection
generationCells_(im.generationCells_), generationCells_(im.generationCells_),
inflationCells_(im.inflationCells_), inflationCells_(im.inflationCells_),
duration_(im.duration_), duration_(im.duration_),
flowRateProfile_(im.flowRateProfile_().clone().ptr()), flowRateProfile_(im.flowRateProfile_),
growthRate_(im.growthRate_().clone().ptr()), growthRate_(im.growthRate_),
newParticles_(im.newParticles_), newParticles_(im.newParticles_),
volumeAccumulator_(im.volumeAccumulator_), volumeAccumulator_(im.volumeAccumulator_),
fraction_(im.fraction_), fraction_(im.fraction_),
@ -167,7 +171,7 @@ Foam::label Foam::InflationInjection<CloudType>::parcelsToInject
List<DynamicList<typename CloudType::parcelType*> >& cellOccupancy = List<DynamicList<typename CloudType::parcelType*> >& cellOccupancy =
this->owner().cellOccupancy(); this->owner().cellOccupancy();
scalar gR = growthRate_().value(time1); scalar gR = growthRate_.value(time1);
scalar dT = time1 - time0; scalar dT = time1 - time0;
@ -202,7 +206,7 @@ Foam::label Foam::InflationInjection<CloudType>::parcelsToInject
if ((time0 >= 0.0) && (time0 < duration_)) if ((time0 >= 0.0) && (time0 < duration_))
{ {
volumeAccumulator_ += volumeAccumulator_ +=
fraction_*flowRateProfile_().integrate(time0, time1); fraction_*flowRateProfile_.integrate(time0, time1);
} }
labelHashSet cellCentresUsed; labelHashSet cellCentresUsed;
@ -424,7 +428,7 @@ Foam::scalar Foam::InflationInjection<CloudType>::volumeToInject
{ {
if ((time0 >= 0.0) && (time0 < duration_)) if ((time0 >= 0.0) && (time0 < duration_))
{ {
return fraction_*flowRateProfile_().integrate(time0, time1); return fraction_*flowRateProfile_.integrate(time0, time1);
} }
else else
{ {

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -81,13 +81,13 @@ class InflationInjection
labelList inflationCells_; labelList inflationCells_;
//- Injection duration [s] //- Injection duration [s]
const scalar duration_; scalar duration_;
//- Flow rate profile relative to SOI [m3/s] //- Flow rate profile relative to SOI [m3/s]
const autoPtr<DataEntry<scalar> > flowRateProfile_; TimeDataEntry<scalar> flowRateProfile_;
//- Growth rate of particle diameters towards target [m/s] //- Growth rate of particle diameters towards target [m/s]
const autoPtr<DataEntry<scalar> > growthRate_; TimeDataEntry<scalar> growthRate_;
//- Positions, velocities, diameters and target diameters of //- Positions, velocities, diameters and target diameters of
// new particles after splitting // new particles after splitting

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -316,6 +316,7 @@ Foam::InjectionModel<CloudType>::InjectionModel
{ {
this->coeffDict().lookup("massTotal") >> massTotal_; this->coeffDict().lookup("massTotal") >> massTotal_;
this->coeffDict().lookup("SOI") >> SOI_; this->coeffDict().lookup("SOI") >> SOI_;
SOI_ = owner.db().time().userTimeToTime(SOI_);
} }
else else
{ {

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -57,6 +57,8 @@ Foam::KinematicLookupTableInjection<CloudType>::KinematicLookupTableInjection
injectorTetFaces_(0), injectorTetFaces_(0),
injectorTetPts_(0) injectorTetPts_(0)
{ {
duration_ = owner.db().time().userTimeToTime(duration_);
// Set/cache the injector cells // Set/cache the injector cells
injectorCells_.setSize(injectors_.size()); injectorCells_.setSize(injectors_.size());
injectorTetFaces_.setSize(injectors_.size()); injectorTetFaces_.setSize(injectors_.size());

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -73,7 +73,7 @@ class KinematicLookupTableInjection
const word inputFileName_; const word inputFileName_;
//- Injection duration - common to all injection sources //- Injection duration - common to all injection sources
const scalar duration_; scalar duration_;
//- Number of parcels per injector - common to all injection sources //- Number of parcels per injector - common to all injection sources
const scalar parcelsPerSecond_; const scalar parcelsPerSecond_;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -24,7 +24,7 @@ License
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
#include "PatchInjection.H" #include "PatchInjection.H"
#include "DataEntry.H" #include "TimeDataEntry.H"
#include "distributionModel.H" #include "distributionModel.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
@ -47,7 +47,12 @@ Foam::PatchInjection<CloudType>::PatchInjection
U0_(this->coeffDict().lookup("U0")), U0_(this->coeffDict().lookup("U0")),
flowRateProfile_ flowRateProfile_
( (
DataEntry<scalar>::New("flowRateProfile", this->coeffDict()) TimeDataEntry<scalar>
(
owner.db().time(),
"flowRateProfile",
this->coeffDict()
)
), ),
sizeDistribution_ sizeDistribution_
( (
@ -76,6 +81,8 @@ Foam::PatchInjection<CloudType>::PatchInjection
const polyPatch& patch = owner.mesh().boundaryMesh()[patchId_]; const polyPatch& patch = owner.mesh().boundaryMesh()[patchId_];
duration_ = owner.db().time().userTimeToTime(duration_);
cellOwners_ = patch.faceCells(); cellOwners_ = patch.faceCells();
label patchSize = cellOwners_.size(); label patchSize = cellOwners_.size();
@ -84,7 +91,7 @@ Foam::PatchInjection<CloudType>::PatchInjection
fraction_ = scalar(patchSize)/totalPatchSize; fraction_ = scalar(patchSize)/totalPatchSize;
// Set total volume/mass to inject // Set total volume/mass to inject
this->volumeTotal_ = fraction_*flowRateProfile_().integrate(0.0, duration_); this->volumeTotal_ = fraction_*flowRateProfile_.integrate(0.0, duration_);
this->massTotal_ *= fraction_; this->massTotal_ *= fraction_;
} }
@ -101,7 +108,7 @@ Foam::PatchInjection<CloudType>::PatchInjection
duration_(im.duration_), duration_(im.duration_),
parcelsPerSecond_(im.parcelsPerSecond_), parcelsPerSecond_(im.parcelsPerSecond_),
U0_(im.U0_), U0_(im.U0_),
flowRateProfile_(im.flowRateProfile_().clone().ptr()), flowRateProfile_(im.flowRateProfile_),
sizeDistribution_(im.sizeDistribution_().clone().ptr()), sizeDistribution_(im.sizeDistribution_().clone().ptr()),
cellOwners_(im.cellOwners_), cellOwners_(im.cellOwners_),
fraction_(im.fraction_) fraction_(im.fraction_)
@ -171,7 +178,7 @@ Foam::scalar Foam::PatchInjection<CloudType>::volumeToInject
{ {
if ((time0 >= 0.0) && (time0 < duration_)) if ((time0 >= 0.0) && (time0 < duration_))
{ {
return fraction_*flowRateProfile_().integrate(time0, time1); return fraction_*flowRateProfile_.integrate(time0, time1);
} }
else else
{ {

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -51,7 +51,7 @@ namespace Foam
{ {
template<class Type> template<class Type>
class DataEntry; class TimeDataEntry;
class distributionModel; class distributionModel;
@ -73,7 +73,7 @@ class PatchInjection
const label patchId_; const label patchId_;
//- Injection duration [s] //- Injection duration [s]
const scalar duration_; scalar duration_;
//- Number of parcels to introduce per second [] //- Number of parcels to introduce per second []
const label parcelsPerSecond_; const label parcelsPerSecond_;
@ -82,7 +82,7 @@ class PatchInjection
const vector U0_; const vector U0_;
//- Flow rate profile relative to SOI [] //- Flow rate profile relative to SOI []
const autoPtr<DataEntry<scalar> > flowRateProfile_; const TimeDataEntry<scalar> flowRateProfile_;
//- Parcel size distribution model //- Parcel size distribution model
const autoPtr<distributionModels::distributionModel> sizeDistribution_; const autoPtr<distributionModels::distributionModel> sizeDistribution_;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -56,6 +56,8 @@ Foam::ReactingLookupTableInjection<CloudType>::ReactingLookupTableInjection
injectorTetFaces_(0), injectorTetFaces_(0),
injectorTetPts_(0) injectorTetPts_(0)
{ {
duration_ = owner.db().time().userTimeToTime(duration_);
// Set/cache the injector cells // Set/cache the injector cells
injectorCells_.setSize(injectors_.size()); injectorCells_.setSize(injectors_.size());
injectorTetFaces_.setSize(injectors_.size()); injectorTetFaces_.setSize(injectors_.size());

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -76,7 +76,7 @@ class ReactingLookupTableInjection
const word inputFileName_; const word inputFileName_;
//- Injection duration - common to all injection sources //- Injection duration - common to all injection sources
const scalar duration_; scalar duration_;
//- Number of parcels per injector - common to all injection sources //- Number of parcels per injector - common to all injection sources
const scalar parcelsPerSecond_; const scalar parcelsPerSecond_;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -57,6 +57,8 @@ ReactingMultiphaseLookupTableInjection
injectorTetFaces_(0), injectorTetFaces_(0),
injectorTetPts_(0) injectorTetPts_(0)
{ {
duration_ = owner.db().time().userTimeToTime(duration_);
// Set/cache the injector cells // Set/cache the injector cells
injectorCells_.setSize(injectors_.size()); injectorCells_.setSize(injectors_.size());
injectorTetFaces_.setSize(injectors_.size()); injectorTetFaces_.setSize(injectors_.size());

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -79,7 +79,7 @@ class ReactingMultiphaseLookupTableInjection
const word inputFileName_; const word inputFileName_;
//- Injection duration - common to all injection sources //- Injection duration - common to all injection sources
const scalar duration_; scalar duration_;
//- Number of parcels per injector - common to all injection sources //- Number of parcels per injector - common to all injection sources
const scalar parcelsPerSecond_; const scalar parcelsPerSecond_;

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -57,6 +57,8 @@ Foam::ThermoLookupTableInjection<CloudType>::ThermoLookupTableInjection
injectorTetFaces_(0), injectorTetFaces_(0),
injectorTetPts_(0) injectorTetPts_(0)
{ {
duration_ = owner.db().time().userTimeToTime(duration_);
// Set/cache the injector cells // Set/cache the injector cells
injectorCells_.setSize(injectors_.size()); injectorCells_.setSize(injectors_.size());
injectorTetFaces_.setSize(injectors_.size()); injectorTetFaces_.setSize(injectors_.size());

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -75,7 +75,7 @@ class ThermoLookupTableInjection
const word inputFileName_; const word inputFileName_;
//- Injection duration - common to all injection sources //- Injection duration - common to all injection sources
const scalar duration_; scalar duration_;
//- Number of parcels per injector - common to all injection sources //- Number of parcels per injector - common to all injection sources
const scalar parcelsPerSecond_; const scalar parcelsPerSecond_;

View File

@ -215,7 +215,7 @@ void Foam::externalWallHeatFluxTemperatureFvPatchScalarField::updateCoeffs()
( (
"externalWallHeatFluxTemperatureFvPatchScalarField" "externalWallHeatFluxTemperatureFvPatchScalarField"
"::updateCoeffs()" "::updateCoeffs()"
) << "Illegal mode " << operationModeNames[oldMode_] ) << "Illegal heat flux mode " << operationModeNames[oldMode_]
<< exit(FatalError); << exit(FatalError);
} }
@ -261,10 +261,31 @@ void Foam::externalWallHeatFluxTemperatureFvPatchScalarField::write
{ {
mixedFvPatchScalarField::write(os); mixedFvPatchScalarField::write(os);
temperatureCoupledBase::write(os); temperatureCoupledBase::write(os);
q_.writeEntry("q", os); switch (oldMode_)
h_.writeEntry("h", os); {
Ta_.writeEntry("Ta", os); case fixedHeatFlux:
this->writeEntry("value", os); {
q_.writeEntry("q", os);
break;
}
case fixedHeatTransferCoeff:
{
h_.writeEntry("h", os);
Ta_.writeEntry("Ta", os);
break;
}
default:
{
FatalErrorIn
(
"void externalWallHeatFluxTemperatureFvPatchScalarField::write"
"("
"Ostream& os"
") const"
) << "Illegal heat flux mode " << operationModeNames[oldMode_]
<< abort(FatalError);
}
}
} }

View File

@ -29,6 +29,7 @@ $(nutWallFunctions)/nutUSpaldingWallFunction/nutUSpaldingWallFunctionFvPatchScal
$(nutWallFunctions)/nutUWallFunction/nutUWallFunctionFvPatchScalarField.C $(nutWallFunctions)/nutUWallFunction/nutUWallFunctionFvPatchScalarField.C
$(nutWallFunctions)/nutUTabulatedWallFunction/nutUTabulatedWallFunctionFvPatchScalarField.C $(nutWallFunctions)/nutUTabulatedWallFunction/nutUTabulatedWallFunctionFvPatchScalarField.C
$(nutWallFunctions)/nutLowReWallFunction/nutLowReWallFunctionFvPatchScalarField.C $(nutWallFunctions)/nutLowReWallFunction/nutLowReWallFunctionFvPatchScalarField.C
$(nutWallFunctions)/nutkAtmRoughWallFunction/nutkAtmRoughWallFunctionFvPatchScalarField.C
epsilonWallFunctions = $(wallFunctions)/epsilonWallFunctions epsilonWallFunctions = $(wallFunctions)/epsilonWallFunctions
$(epsilonWallFunctions)/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C $(epsilonWallFunctions)/epsilonWallFunction/epsilonWallFunctionFvPatchScalarField.C

View File

@ -51,6 +51,8 @@ atmBoundaryLayerInletEpsilonFvPatchScalarField
z_(pTraits<vector>::zero), z_(pTraits<vector>::zero),
z0_(0), z0_(0),
kappa_(0.41), kappa_(0.41),
Uref_(0),
Href_(0),
zGround_(0) zGround_(0)
{} {}
@ -69,6 +71,8 @@ atmBoundaryLayerInletEpsilonFvPatchScalarField
z_(ptf.z_), z_(ptf.z_),
z0_(ptf.z0_), z0_(ptf.z0_),
kappa_(ptf.kappa_), kappa_(ptf.kappa_),
Uref_(ptf.Uref_),
Href_(ptf.Href_),
zGround_(ptf.zGround_) zGround_(ptf.zGround_)
{} {}
@ -82,10 +86,12 @@ atmBoundaryLayerInletEpsilonFvPatchScalarField
) )
: :
fixedValueFvPatchScalarField(p, iF), fixedValueFvPatchScalarField(p, iF),
Ustar_(readScalar(dict.lookup("Ustar"))), Ustar_(p.size()),
z_(dict.lookup("z")), z_(dict.lookup("z")),
z0_(readScalar(dict.lookup("z0"))), z0_(readScalar(dict.lookup("z0"))),
kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)), kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
Uref_(readScalar(dict.lookup("Uref"))),
Href_(readScalar(dict.lookup("Href"))),
zGround_("zGround", dict, p.size()) zGround_("zGround", dict, p.size())
{ {
if (mag(z_) < SMALL) if (mag(z_) < SMALL)
@ -103,6 +109,11 @@ atmBoundaryLayerInletEpsilonFvPatchScalarField
<< abort(FatalError); << abort(FatalError);
} }
forAll (Ustar_, i)
{
Ustar_[i] = kappa_*Uref_/(log((Href_ + z0_[i])/max(z0_[i] , 0.001)));
}
z_ /= mag(z_); z_ /= mag(z_);
evaluate(); evaluate();
@ -121,6 +132,8 @@ atmBoundaryLayerInletEpsilonFvPatchScalarField
z_(blpsf.z_), z_(blpsf.z_),
z0_(blpsf.z0_), z0_(blpsf.z0_),
kappa_(blpsf.kappa_), kappa_(blpsf.kappa_),
Uref_(blpsf.Uref_),
Href_(blpsf.Href_),
zGround_(blpsf.zGround_) zGround_(blpsf.zGround_)
{} {}
@ -138,14 +151,16 @@ void atmBoundaryLayerInletEpsilonFvPatchScalarField::updateCoeffs()
void atmBoundaryLayerInletEpsilonFvPatchScalarField::write(Ostream& os) const void atmBoundaryLayerInletEpsilonFvPatchScalarField::write(Ostream& os) const
{ {
fvPatchScalarField::write(os); fvPatchScalarField::write(os);
os.writeKeyword("Ustar")
<< Ustar_ << token::END_STATEMENT << nl;
os.writeKeyword("z") os.writeKeyword("z")
<< z_ << token::END_STATEMENT << nl; << z_ << token::END_STATEMENT << nl;
os.writeKeyword("z0") os.writeKeyword("z0")
<< z0_ << token::END_STATEMENT << nl; << z0_ << token::END_STATEMENT << nl;
os.writeKeyword("kappa") os.writeKeyword("kappa")
<< kappa_ << token::END_STATEMENT << nl; << kappa_ << token::END_STATEMENT << nl;
os.writeKeyword("Uref")
<< Uref_ << token::END_STATEMENT << nl;
os.writeKeyword("Href")
<< Href_ << token::END_STATEMENT << nl;
os.writeKeyword("zGround") os.writeKeyword("zGround")
<< zGround_ << token::END_STATEMENT << nl; << zGround_ << token::END_STATEMENT << nl;
writeEntry("value", os); writeEntry("value", os);

View File

@ -41,6 +41,16 @@ Description
z0 is the surface roughness lenght z0 is the surface roughness lenght
zGround minium vlaue in z direction zGround minium vlaue in z direction
and:
Ustar = K Uref/ln((Zref + z0)/z0)
where:
Uref is the reference velocity at Zref
Zref is the reference height.
\endverbatim \endverbatim
Reference: Reference:
@ -78,17 +88,23 @@ class atmBoundaryLayerInletEpsilonFvPatchScalarField
// Private data // Private data
//- Frictional velocity //- Frictional velocity
const scalar Ustar_; scalarField Ustar_;
//- Direction of the z-coordinate //- Direction of the z-coordinate
vector z_; vector z_;
//- Surface roughness lenght //- Surface roughness lenght
const scalar z0_; scalarField z0_;
//- Von Karman constant //- Von Karman constant
const scalar kappa_; const scalar kappa_;
//- Reference velocity
const scalar Uref_;
//- Reference hight
const scalar Href_;
//- Minimum corrdinate value in z direction //- Minimum corrdinate value in z direction
const scalarField zGround_; const scalarField zGround_;
@ -158,7 +174,7 @@ public:
// Member functions // Member functions
//- Return max value //- Return max value
scalar Ustar() const scalarField Ustar() const
{ {
return Ustar_; return Ustar_;
} }

View File

@ -88,16 +88,16 @@ atmBoundaryLayerInletVelocityFvPatchVectorField
) )
: :
fixedValueFvPatchVectorField(p, iF), fixedValueFvPatchVectorField(p, iF),
Ustar_(0), Ustar_(p.size()),
n_(dict.lookup("n")), n_(dict.lookup("n")),
z_(dict.lookup("z")), z_(dict.lookup("z")),
z0_(readScalar(dict.lookup("z0"))), z0_("z0", dict, p.size()),
kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)), kappa_(dict.lookupOrDefault<scalar>("kappa", 0.41)),
Uref_(readScalar(dict.lookup("Uref"))), Uref_(readScalar(dict.lookup("Uref"))),
Href_(readScalar(dict.lookup("Href"))), Href_(readScalar(dict.lookup("Href"))),
zGround_("zGround", dict, p.size()) zGround_("zGround", dict, p.size())
{ {
if (mag(n_) < SMALL || mag(z_) < SMALL || mag(z0_) < SMALL) if (mag(n_) < SMALL || mag(z_) < SMALL)
{ {
FatalErrorIn FatalErrorIn
( (
@ -108,14 +108,17 @@ atmBoundaryLayerInletVelocityFvPatchVectorField
"onst dictionary&" "onst dictionary&"
")" ")"
) )
<< "magnitude of n, z and z0 vectors must be greater than zero" << "magnitude of n or z must be greater than zero"
<< abort(FatalError); << abort(FatalError);
} }
n_ /= mag(n_); n_ /= mag(n_);
z_ /= mag(z_); z_ /= mag(z_);
Ustar_ = kappa_*Uref_/(log((Href_ + z0_)/max(z0_ , 0.001))); forAll (Ustar_, i)
{
Ustar_[i] = kappa_*Uref_/(log((Href_ + z0_[i])/max(z0_[i] , 0.001)));
}
evaluate(); evaluate();
} }
@ -153,12 +156,12 @@ void atmBoundaryLayerInletVelocityFvPatchVectorField::updateCoeffs()
if ((coord[i] - zGround_[i]) < Href_) if ((coord[i] - zGround_[i]) < Href_)
{ {
Un[i] = Un[i] =
(Ustar_/kappa_) (Ustar_[i]/kappa_)
* log((coord[i] - zGround_[i] + z0_)/max(z0_, 0.001)); * log((coord[i] - zGround_[i] + z0_[i])/max(z0_[i], 0.001));
} }
else else
{ {
Un[i] = (Uref_); Un[i] = Uref_;
} }
} }
@ -171,8 +174,7 @@ void atmBoundaryLayerInletVelocityFvPatchVectorField::updateCoeffs()
void atmBoundaryLayerInletVelocityFvPatchVectorField::write(Ostream& os) const void atmBoundaryLayerInletVelocityFvPatchVectorField::write(Ostream& os) const
{ {
fvPatchVectorField::write(os); fvPatchVectorField::write(os);
os.writeKeyword("z0") zGround_.writeEntry("z0", os) ;
<< z0_ << token::END_STATEMENT << nl;
os.writeKeyword("n") os.writeKeyword("n")
<< n_ << token::END_STATEMENT << nl; << n_ << token::END_STATEMENT << nl;
os.writeKeyword("z") os.writeKeyword("z")

View File

@ -92,7 +92,7 @@ class atmBoundaryLayerInletVelocityFvPatchVectorField
// Private data // Private data
//- Frictional velocity //- Frictional velocity
scalar Ustar_; scalarField Ustar_;
//- Flow direction //- Flow direction
vector n_; vector n_;
@ -101,7 +101,7 @@ class atmBoundaryLayerInletVelocityFvPatchVectorField
vector z_; vector z_;
//- Surface roughness lenght //- Surface roughness lenght
const scalar z0_; scalarField z0_;
//- Von Karman constant //- Von Karman constant
const scalar kappa_; const scalar kappa_;
@ -181,7 +181,7 @@ public:
// Member functions // Member functions
//- Return Ustar //- Return Ustar
scalar& Ustar() scalarField& Ustar()
{ {
return Ustar_; return Ustar_;
} }

View File

@ -0,0 +1,200 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "nutkAtmRoughWallFunctionFvPatchScalarField.H"
#include "RASModel.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace incompressible
{
namespace RASModels
{
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
tmp<scalarField> nutkAtmRoughWallFunctionFvPatchScalarField::calcNut() const
{
const label patchI = patch().index();
const RASModel& rasModel = db().lookupObject<RASModel>("RASProperties");
const scalarField& y = rasModel.y()[patchI];
const tmp<volScalarField> tk = rasModel.k();
const volScalarField& k = tk();
const tmp<volScalarField> tnu = rasModel.nu();
const volScalarField& nu = tnu();
const scalarField& nuw = nu.boundaryField()[patchI];
const scalar Cmu25 = pow025(Cmu_);
tmp<scalarField> tnutw(new scalarField(*this));
scalarField& nutw = tnutw();
forAll(nutw, faceI)
{
label faceCellI = patch().faceCells()[faceI];
scalar uStar = Cmu25*sqrt(k[faceCellI]);
scalar yPlus = uStar*y[faceI]/nuw[faceI];
scalar Edash = (y[faceI] + z0_[faceI])/z0_[faceI];
nutw[faceI] =
nuw[faceI]*(yPlus*kappa_/log(max(Edash, 1+1e-4)) - 1);
if (debug)
{
Info<< "yPlus = " << yPlus
<< ", Edash = " << Edash
<< ", nutw = " << nutw[faceI]
<< endl;
}
}
return tnutw;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
nutkAtmRoughWallFunctionFvPatchScalarField::
nutkAtmRoughWallFunctionFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
)
:
nutkWallFunctionFvPatchScalarField(p, iF),
z0_(p.size(), 0.0)
{}
nutkAtmRoughWallFunctionFvPatchScalarField::
nutkAtmRoughWallFunctionFvPatchScalarField
(
const nutkAtmRoughWallFunctionFvPatchScalarField& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
nutkWallFunctionFvPatchScalarField(ptf, p, iF, mapper),
z0_(ptf.z0_, mapper)
{}
nutkAtmRoughWallFunctionFvPatchScalarField::
nutkAtmRoughWallFunctionFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
nutkWallFunctionFvPatchScalarField(p, iF, dict),
z0_("z0", dict, p.size())
{}
nutkAtmRoughWallFunctionFvPatchScalarField::
nutkAtmRoughWallFunctionFvPatchScalarField
(
const nutkAtmRoughWallFunctionFvPatchScalarField& rwfpsf
)
:
nutkWallFunctionFvPatchScalarField(rwfpsf),
z0_(rwfpsf.z0_)
{}
nutkAtmRoughWallFunctionFvPatchScalarField::
nutkAtmRoughWallFunctionFvPatchScalarField
(
const nutkAtmRoughWallFunctionFvPatchScalarField& rwfpsf,
const DimensionedField<scalar, volMesh>& iF
)
:
nutkWallFunctionFvPatchScalarField(rwfpsf, iF),
z0_(rwfpsf.z0_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void nutkAtmRoughWallFunctionFvPatchScalarField::autoMap
(
const fvPatchFieldMapper& m
)
{
nutkWallFunctionFvPatchScalarField::autoMap(m);
z0_.autoMap(m);
}
void nutkAtmRoughWallFunctionFvPatchScalarField::rmap
(
const fvPatchScalarField& ptf,
const labelList& addr
)
{
nutkWallFunctionFvPatchScalarField::rmap(ptf, addr);
const nutkAtmRoughWallFunctionFvPatchScalarField& nrwfpsf =
refCast<const nutkAtmRoughWallFunctionFvPatchScalarField>(ptf);
z0_.rmap(nrwfpsf.z0_, addr);
}
void nutkAtmRoughWallFunctionFvPatchScalarField::write(Ostream& os) const
{
fvPatchField<scalar>::write(os);
writeLocalEntries(os);
z0_.writeEntry("z0", os);
writeEntry("value", os);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
makePatchTypeField
(
fvPatchScalarField,
nutkAtmRoughWallFunctionFvPatchScalarField
);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace RASModels
} // End namespace incompressible
} // End namespace Foam
// ************************************************************************* //

View File

@ -0,0 +1,195 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\/ 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 3 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, see <http://www.gnu.org/licenses/>.
Class
Foam::incompressible::RASModels::
nutkAtmRoughWallFunctionFvPatchScalarField
Description
Boundary condition for turbulent (kinematic) viscosity for atmospheric
velocity profiles.
Desinged to be used togheter with atmBoundaryLayerInletVelocity.
It follows U = (Ustar/K) ln((z - zGround + z0)/z0)
where:
Ustar is the frictional velocity
K is karman's constant
z0 is the surface roughness lenght
z is the verical coordinate
zGround is the minumum coordinate value in z direction.
SourceFiles
nutkAtmRoughWallFunctionFvPatchScalarField.C
\*---------------------------------------------------------------------------*/
#ifndef nutkAtmRoughWallFunctionFvPatchScalarField_H
#define nutkAtmRoughWallFunctionFvPatchScalarField_H
#include "nutkWallFunctionFvPatchScalarField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace incompressible
{
namespace RASModels
{
/*---------------------------------------------------------------------------*\
Class nutkAtmRoughWallFunctionFvPatchScalarField Declaration
\*---------------------------------------------------------------------------*/
class nutkAtmRoughWallFunctionFvPatchScalarField
:
public nutkWallFunctionFvPatchScalarField
{
protected:
// Protected data
//- Surface roughness lenght
scalarField z0_;
// Protected Member Functions
//- Calculate the turbulence viscosity
virtual tmp<scalarField> calcNut() const;
public:
//- Runtime type information
TypeName("nutkAtmRoughWallFunction");
// Constructors
//- Construct from patch and internal field
nutkAtmRoughWallFunctionFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&
);
//- Construct from patch, internal field and dictionary
nutkAtmRoughWallFunctionFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const dictionary&
);
//- Construct by mapping given
// nutkAtmRoughWallFunctionFvPatchScalarField
// onto a new patch
nutkAtmRoughWallFunctionFvPatchScalarField
(
const nutkAtmRoughWallFunctionFvPatchScalarField&,
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct as copy
nutkAtmRoughWallFunctionFvPatchScalarField
(
const nutkAtmRoughWallFunctionFvPatchScalarField&
);
//- Construct and return a clone
virtual tmp<fvPatchScalarField> clone() const
{
return tmp<fvPatchScalarField>
(
new nutkAtmRoughWallFunctionFvPatchScalarField(*this)
);
}
//- Construct as copy setting internal field reference
nutkAtmRoughWallFunctionFvPatchScalarField
(
const nutkAtmRoughWallFunctionFvPatchScalarField&,
const DimensionedField<scalar, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchScalarField> clone
(
const DimensionedField<scalar, volMesh>& iF
) const
{
return tmp<fvPatchScalarField>
(
new nutkAtmRoughWallFunctionFvPatchScalarField(*this, iF)
);
}
// Member functions
// Acces functions
// Return z0
scalarField& z0()
{
return z0_;
}
// Mapping functions
//- Map (and resize as needed) from self given a mapping object
virtual void autoMap(const fvPatchFieldMapper&);
//- Reverse map the given fvPatchField onto this fvPatchField
virtual void rmap
(
const fvPatchScalarField&,
const labelList&
);
// I-O
//- Write
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace RASModels
} // End namespace incompressible
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -40,7 +40,8 @@ boundaryField
inlet inlet
{ {
type atmBoundaryLayerInletEpsilon; type atmBoundaryLayerInletEpsilon;
Ustar $Ustar; Uref $Uref;
Href $Href;
z $zDirection; z $zDirection;
z0 $z0; z0 $z0;
value $internalField; value $internalField;

View File

@ -6,10 +6,9 @@
| \\/ M anipulation | | | \\/ M anipulation | |
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
Ustar 0.82;
Uref 10.0; Uref 10.0;
Href 20; Href 20;
z0 0.1; z0 uniform 0.1;
turbulentKE 1.3; turbulentKE 1.3;
windDirection (1 0 0); windDirection (1 0 0);
zDirection (0 0 1); zDirection (0 0 1);

View File

@ -36,9 +36,8 @@ boundaryField
"terrain_.*" "terrain_.*"
{ {
type nutkRoughWallFunction; type nutkAtmRoughWallFunction;
Ks uniform 0.2; //Ks = 20 Z0 z0 $Z0;
Cs uniform 0.5;
value uniform 0.0; value uniform 0.0;
} }

View File

@ -15,43 +15,37 @@ FoamFile
} }
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
6 5
( (
outlet outlet
{ {
type patch; type patch;
nFaces 922; nFaces 600;
startFace 364825; startFace 51900;
} }
sides sides
{ {
type patch; type patch;
nFaces 1834; nFaces 1200;
startFace 365747; startFace 52500;
} }
inlet inlet
{ {
type patch; type patch;
nFaces 923; nFaces 600;
startFace 367581; startFace 53700;
} }
ground ground
{ {
type wall; type wall;
nFaces 0; nFaces 900;
startFace 368504; startFace 54300;
} }
top top
{ {
type patch; type patch;
nFaces 900; nFaces 900;
startFace 368504; startFace 55200;
}
terrain_patch0
{
type wall;
nFaces 16037;
startFace 369404;
} }
) )

View File

@ -27,10 +27,11 @@ disk1
actuationDiskSourceCoeffs actuationDiskSourceCoeffs
{ {
fieldNames (U); fieldNames (U);
diskDir (-1 0 0); // orientation of the disk diskDir (-1 0 0); // orientation of the disk
Cp 0.53; // Cp Cp 0.386; // Cp
Ct 0.58; // Ct Ct 0.58; // Ct
diskArea 40; // disk area diskArea 40; // disk area
upstreamPoint (581849 4785810 1065);
} }
} }
@ -50,6 +51,7 @@ disk2
Cp 0.53; Cp 0.53;
Ct 0.58; Ct 0.58;
diskArea 40; diskArea 40;
upstreamPoint (581753 4785663 1070);
} }
} }

View File

@ -15,6 +15,7 @@ FoamFile
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#include "$FOAM_CASE/0/include/initialConditions" #include "$FOAM_CASE/0/include/initialConditions"
#include "$FOAM_CASE/0/include/ABLConditions"
dictionaryReplacement dictionaryReplacement
{ {
@ -99,12 +100,12 @@ dictionaryReplacement
inlet inlet
{ {
type atmBoundaryLayerInletVelocity; type atmBoundaryLayerInletVelocity;
Uref 10.0; Uref $Uref;
Href 20; Href $Href;
n (1 0 0); n $windDirection;
z (0 0 1); z $zDirection;
z0 0.1; z0 $z0;
zGround 935.0; zGround $zGround;
value uniform $flowVelocity; value uniform $flowVelocity;
} }
"terrain_.*" "terrain_.*"
@ -141,9 +142,8 @@ dictionaryReplacement
} }
"terrain_.*" "terrain_.*"
{ {
type nutkRoughWallFunction; type nutkAtmRoughWallFunction;
Ks uniform 0.2; //Ks = 20 Z0 z0 $z0;
Cs uniform 0.5;
value uniform 0.0; value uniform 0.0;
} }
ground ground
@ -170,11 +170,12 @@ dictionaryReplacement
inlet inlet
{ {
type atmBoundaryLayerInletEpsilon; type atmBoundaryLayerInletEpsilon;
Ustar 0.82; z $zDirection;
z (0 0 1); z0 $z0;
z0 0.1; zGround $zGround;
Uref $Uref;
Href $Href;
value uniform $turbulentEpsilon; value uniform $turbulentEpsilon;
zGround 935.0;
} }
"terrain_.*" "terrain_.*"
{ {