fieldAverageItemI.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2017 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 
27 \*---------------------------------------------------------------------------*/
28 
29 
31 {
32  return active_;
33 }
34 
35 
37 {
38  return active_;
39 }
40 
41 
43 {
44  return fieldName_;
45 }
46 
47 
49 {
50  return mean_;
51 }
52 
53 
55 {
56  return mean_;
57 }
58 
59 
60 const Foam::word&
62 {
63  return meanFieldName_;
64 }
65 
66 
68 (
69  const word& name
70 )
71 {
72  meanFieldName_ = name;
73 }
74 
75 
77 {
78  return prime2Mean_;
79 }
80 
81 
83 {
84  return prime2Mean_;
85 }
86 
87 
88 const Foam::word&
90 {
91  return prime2MeanFieldName_;
92 }
93 
94 
96 (
97  const word& name
98 )
99 {
100  prime2MeanFieldName_ = name;
101 }
102 
105 {
106  return baseTypeNames_[base_];
107 }
108 
111 {
112  return totalIter_;
113 }
114 
117 {
118  return totalTime_;
119 }
120 
123 {
124  return window_;
125 }
126 
127 
129 {
130  return windowName_;
131 }
132 
133 
136 {
137  return windowTimes_;
138 }
139 
140 
143 {
144  return windowFieldNames_;
145 }
146 
147 
149 {
150  return allowRestart_;
151 }
152 
153 
155 (
156  const scalar deltaT
157 ) const
158 {
159  switch (base_)
160  {
161  case baseType::TIME:
162  {
163  return deltaT;
164  }
165  case baseType::ITER:
166  {
167  return scalar(1);
168  }
169  default:
170  {
172  << "Unhandled enumeration " << baseTypeNames_[base_]
173  << abort(FatalError);
174  }
175  }
176 
177  return 0.0;
178 }
179 
180 
182 {
183  switch (base_)
184  {
185  case baseType::TIME:
186  {
187  return totalTime_;
188  }
189  case baseType::ITER:
190  {
191  return scalar(totalIter_);
192  }
193  default:
194  {
196  << "Unhandled enumeration " << baseTypeNames_[base_]
197  << abort(FatalError);
198  }
199  }
200 
201  return 0.0;
202 }
203 
204 
206 (
207  const word& prefix
208 ) const
209 {
210  return prefix + ':' + fieldName_ + ':' + Foam::name(totalIter_);
211 }
212 
213 
214 bool Foam::functionObjects::fieldAverageItem::inWindow(const scalar t) const
215 {
216  switch (base_)
217  {
218  case baseType::ITER:
219  {
220  return round(t) <= round(window_) + 1;
221  }
222  case baseType::TIME:
223  {
224  return t <= window_;
225  }
226  default:
227  {
229  << "Unhandled baseType enumeration "
230  << baseTypeNames_[base_]
231  << abort(FatalError);
232  }
233  }
234 
235  return false;
236 }
237 
240 {
241  return windowType_ == windowType::EXACT;
242 }
243 
244 
246 {
247  return (allowRestart_ && window_ > 0);
248 }
249 
250 
251 // ************************************************************************* //
A FIFO stack based on a singly-linked list.
Definition: FIFOStack.H:45
const word & meanFieldName() const
Return const access to the mean field name.
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:598
void setMeanFieldName(const word &name)
Set the mean field name.
bool mean() const
Return const access to the mean flag.
scalar totalTime() const
Return the total time item has been evolved.
bool allowRestart() const
Return the allow restart flag.
word windowFieldName(const word &prefix) const
Helper function to construct a window field name.
const word & windowName() const
Return the (optional) window name.
scalar window() const
Return the window length (iterations or seconds)
const word & base() const
Return averaging base type name.
scalar dt(const scalar deltaT) const
Return the current time interval.
bool active() const
Return const access to the active flag.
scalar Dt() const
Return the total time interval.
const word & fieldName() const
Return const access to the field name.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
bool inWindow(const scalar t) const
Return true if time is inside window (including boundaries)
A class for handling words, derived from Foam::string.
Definition: word.H:63
const FIFOStack< scalar > & windowTimes() const
Return the list of window times (windowType = EXACT)
errorManip< error > abort(error &err)
Definition: errorManip.H:139
const FIFOStack< word > & windowFieldNames() const
Return the list of window field names (windowType = EXACT)
const word & prime2MeanFieldName() const
Return const access to the prime-squared mean field name.
void setPrime2MeanFieldName(const word &name)
Set the prime-squared mean field name.
bool storeWindowFields() const
Return true if we wish to store window fields.
label totalIter() const
Return the total number of iterations item has been evolved.
bool prime2Mean() const
Return const access to the prime-squared mean flag.
bool writeWindowFields() const
Return true if we wish to write window fields.