ENH: Added optional naming of averaging window

This commit is contained in:
andy
2013-01-10 12:19:40 +00:00
parent 939a617414
commit 2130f63fe4
5 changed files with 50 additions and 10 deletions

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-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -77,6 +77,8 @@ Description
mean on; mean on;
prime2Mean on; prime2Mean on;
base time; base time;
window 10.0;
windowName w1;
} }
p p
{ {

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-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -42,7 +42,15 @@ void Foam::fieldAverage::addMeanField
const word& fieldName = faItems_[fieldI].fieldName(); const word& fieldName = faItems_[fieldI].fieldName();
const word meanFieldName = fieldName + EXT_MEAN; word meanFieldName = fieldName + EXT_MEAN;
if
(
(faItems_[fieldI].window() > 0)
&& (faItems_[fieldI].windowName() != "")
)
{
meanFieldName = meanFieldName + "_" + faItems_[fieldI].windowName();
}
Info<< "Reading/calculating field " << meanFieldName << nl << endl; Info<< "Reading/calculating field " << meanFieldName << nl << endl;
@ -100,7 +108,16 @@ void Foam::fieldAverage::addPrime2MeanField
const word& fieldName = faItems_[fieldI].fieldName(); const word& fieldName = faItems_[fieldI].fieldName();
const word meanFieldName = fieldName + EXT_PRIME2MEAN; word meanFieldName = fieldName + EXT_PRIME2MEAN;
if
(
(faItems_[fieldI].window() > 0)
&& (faItems_[fieldI].windowName() != "")
)
{
meanFieldName = meanFieldName + "_" + faItems_[fieldI].windowName();
}
Info<< "Reading/calculating field " << meanFieldName << nl << endl; Info<< "Reading/calculating field " << meanFieldName << nl << endl;
if (obr_.foundObject<fieldType2>(meanFieldName)) if (obr_.foundObject<fieldType2>(meanFieldName))

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-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -54,7 +54,8 @@ Foam::fieldAverageItem::fieldAverageItem()
mean_(0), mean_(0),
prime2Mean_(0), prime2Mean_(0),
base_(ITER), base_(ITER),
window_(-1.0) window_(-1.0),
windowName_("")
{} {}
@ -64,7 +65,8 @@ Foam::fieldAverageItem::fieldAverageItem(const fieldAverageItem& faItem)
mean_(faItem.mean_), mean_(faItem.mean_),
prime2Mean_(faItem.prime2Mean_), prime2Mean_(faItem.prime2Mean_),
base_(faItem.base_), base_(faItem.base_),
window_(faItem.window_) window_(faItem.window_),
windowName_(faItem.windowName_)
{} {}
@ -94,6 +96,7 @@ void Foam::fieldAverageItem::operator=(const fieldAverageItem& rhs)
prime2Mean_ = rhs.prime2Mean_; prime2Mean_ = rhs.prime2Mean_;
base_ = rhs.base_; base_ = rhs.base_;
window_ = rhs.window_; window_ = rhs.window_;
windowName_ = rhs.windowName_;
} }

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-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -34,6 +34,7 @@ Description
prime2Mean on; prime2Mean on;
base time; // iteration base time; // iteration
window 200; // optional averaging window window 200; // optional averaging window
windowName w1; // optional window name (default = "")
} }
\endverbatim \endverbatim
@ -107,6 +108,9 @@ private:
//- Averaging window - defaults to -1 for 'all iters/time' //- Averaging window - defaults to -1 for 'all iters/time'
scalar window_; scalar window_;
//- Averaging window name - defaults to 'window'
word windowName_;
public: public:
@ -171,6 +175,11 @@ public:
return window_; return window_;
} }
const word& windowName() const
{
return windowName_;
}
// Member Operators // Member Operators
@ -190,7 +199,8 @@ public:
&& a.mean_ == b.mean_ && a.mean_ == b.mean_
&& a.prime2Mean_ == b.prime2Mean_ && a.prime2Mean_ == b.prime2Mean_
&& a.base_ == b.base_ && a.base_ == b.base_
&& a.window_ == b.window_; && a.window_ == b.window_
&& a.windowName_ == b.windowName_;
} }
friend bool operator!= friend bool operator!=

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-2013 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -46,6 +46,7 @@ Foam::fieldAverageItem::fieldAverageItem(Istream& is)
entry.lookup("prime2Mean") >> prime2Mean_; entry.lookup("prime2Mean") >> prime2Mean_;
base_ = baseTypeNames_[entry.lookup("base")]; base_ = baseTypeNames_[entry.lookup("base")];
window_ = entry.lookupOrDefault<scalar>("window", -1.0); window_ = entry.lookupOrDefault<scalar>("window", -1.0);
windowName_ = entry.lookupOrDefault<word>("windowName", "");
} }
@ -66,6 +67,7 @@ Foam::Istream& Foam::operator>>(Istream& is, fieldAverageItem& faItem)
entry.lookup("prime2Mean") >> faItem.prime2Mean_; entry.lookup("prime2Mean") >> faItem.prime2Mean_;
faItem.base_ = faItem.baseTypeNames_[entry.lookup("base")]; faItem.base_ = faItem.baseTypeNames_[entry.lookup("base")];
faItem.window_ = entry.lookupOrDefault<scalar>("window", -1.0); faItem.window_ = entry.lookupOrDefault<scalar>("window", -1.0);
faItem.windowName_ = entry.lookupOrDefault<word>("windowName", "");
return is; return is;
} }
@ -90,6 +92,12 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const fieldAverageItem& faItem)
{ {
os.writeKeyword("window") << faItem.window_ os.writeKeyword("window") << faItem.window_
<< token::END_STATEMENT << nl; << token::END_STATEMENT << nl;
if (faItem.windowName_ != "")
{
os.writeKeyword("windowName") << faItem.windowName_
<< token::END_STATEMENT << nl;
}
} }
os << token::END_BLOCK << nl; os << token::END_BLOCK << nl;