age.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) 2018-2021 OpenFOAM Foundation
9  Copyright (C) 2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::functionObjects::age
29 
30 Description
31  Calculates and writes out the time taken for a particle to travel from an
32  inlet to the location. Solves the following equation when incompressible:
33 
34  \f[
35  \div (\phi t) = 1
36  \f]
37 
38  where
39  \vartable
40  t | Age [s]
41  \phi | Volumetric flux [m^3/s]
42  \endvartable
43 
44  Boundary conditions are generated automatically as \c zeroGradient
45  on all walls and \c inletOutlet everywhere else.
46 
47 Usage
48  Minimal example by using \c system/controlDict.functions:
49  \verbatim
50  age1
51  {
52  // Mandatory entries
53  type age;
54  libs (fieldFunctionObjects);
55 
56  // Optional entries
57  phi <word>;
58  rho <word>;
59  schemesField <word>;
60  tolerance <scalar>;
61  nCorr <int>;
62  diffusion <bool>;
63 
64  // Inherited entries
65  ...
66  }
67  \endverbatim
68 
69  where the entries mean:
70  \table
71  Property | Description | Type | Reqd | Deflt
72  type | Type name: age | word | yes | -
73  libs | Library name: fieldFunctionObjects | word | yes | -
74  phi | Name of flux field | word | no | phi
75  rho | Name of density field | word | no | rho
76  schemesField | Name of the field from which schemes are taken <!--
77  --> | word | no | age
78  tolerance | Solver residual control | scalar | no | 1e-5
79  nCorr | Maximum number of correctors | int | no | 5
80  diffusion | Flag to turn on/off the diffusion term | bool | no | false
81  \endtable
82 
83  The inherited entries are elaborated in:
84  - \link functionObject.H \endlink
85 
86 See also
87  - Foam::functionObjects::comfort
88 
89 SourceFiles
90  age.C
91 
92 \*---------------------------------------------------------------------------*/
93 
94 #ifndef functionObjects_age_H
95 #define functionObjects_age_H
96 
97 #include "fvMeshFunctionObject.H"
98 #include "volFields.H"
99 
100 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
101 
102 namespace Foam
103 {
104 namespace functionObjects
105 {
106 
107 /*---------------------------------------------------------------------------*\
108  Class age Declaration
109 \*---------------------------------------------------------------------------*/
110 
111 class age
112 :
113  public fvMeshFunctionObject
114 {
115  // Private Data
116 
117  //- The name of the flux field
118  word phiName_;
119 
120  //- The name of the density field
121  word rhoName_;
122 
123  //- Name of field from which schemes are taken
124  word schemesField_;
125 
126  //- Convergence tolerance
127  scalar tolerance_;
128 
129  //- Number of corrections
130  int nCorr_;
131 
132  //- Flag to turn on/off the diffusion term
133  bool diffusion_;
134 
135 
136  // Private Member Functions
137 
138  //- The list of patch types for the age field
139  wordList patchTypes() const;
140 
141  //- Return true if convergence is reached
142  bool converged(const int nCorr, const scalar initialResidual) const;
143 
144  //- Create and allocate a new zero geometric field
145  template<class GeoField>
146  autoPtr<GeoField> newField
147  (
148  const word& baseName,
149  const wordList
150  ) const;
151 
152 
153 public:
154 
155  //- Runtime type information
156  TypeName("age");
157 
158 
159  // Constructors
160 
161  //- Construct from Time and dictionary
162  age
163  (
164  const word& name,
165  const Time& runTime,
166  const dictionary& dict
167  );
168 
169 
170  //- Destructor
171  virtual ~age() = default;
172 
173 
174  // Member Functions
175 
176  //- Read the data
177  virtual bool read(const dictionary&);
178 
179  //- Execute
180  virtual bool execute();
181 
182  //- Write
183  virtual bool write();
184 };
185 
186 
187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
188 
189 } // End namespace functionObjects
190 } // End namespace Foam
191 
192 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
193 
194 #endif
195 
196 // ************************************************************************* //
volFields.H
runTime
engineTime & runTime
Definition: createEngineTime.H:13
nCorr
const int nCorr
Definition: readFluidMultiRegionPIMPLEControls.H:3
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
fvMeshFunctionObject.H
Foam::functionObjects::fvMeshFunctionObject
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Definition: fvMeshFunctionObject.H:64
Foam::functionObjects::age::~age
virtual ~age()=default
Destructor.
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:62
Foam::functionObjects::age::read
virtual bool read(const dictionary &)
Read the data.
Definition: age.C:135
Foam::functionObjects::age::write
virtual bool write()
Write.
Definition: age.C:290
Foam::functionObjects::age::age
age(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: age.C:121
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::functionObjects::age::TypeName
TypeName("age")
Runtime type information.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::functionObjects::age
Calculates and writes out the time taken for a particle to travel from an inlet to the location....
Definition: age.H:174
Foam::functionObjects::age::execute
virtual bool execute()
Execute.
Definition: age.C:153
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::functionObject::name
const word & name() const noexcept
Return the name of this functionObject.
Definition: functionObject.C:143
Foam::List< word >