age.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2018-2026 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::functionObjects::age
26 
27 Description
28  Calculates and writes out the time taken for a particle to travel from an
29  inlet to the location. Solves the following equation when incompressible:
30  \f[
31  \div (\phi t) = 1
32  \f]
33  where:
34  \vartable
35  t | Age [s]
36  \phi | Volumetric flux [m^3/s]
37  \endvartable
38  Boundary conditions are generated automatically as zeroGradient on all
39  walls and inletOutlet everywhere else.
40 
41 Usage
42  \table
43  Property | Description | Required | Default value
44  phi | The name of the flux field | no | phi
45  rho | The name of the density field | no | rho
46  nCorr | The maximum number of correctors | no | 5
47  schemesField | The name of the field for the schemes | \\
48  no | age
49  solverField | The name of the field for the solver setting | \\
50  no | age
51  diffusion | Switch to turn on/off the diffusion term | no | off
52  tolerance | Solver residual control | no | 1e-5
53  \endtable
54 
55  \verbatim
56  age1
57  {
58  type age;
59  libs ("libsolverFunctionObjects.so");
60 
61  executeControl writeTime;
62  writeControl writeTime;
63 
64  schemesField k;
65  solverField k;
66  }
67  \endverbatim
68 
69 SourceFiles
70  age.C
71 
72 \*---------------------------------------------------------------------------*/
73 
74 #ifndef age_functionObject_H
75 #define age_functionObject_H
76 
77 #include "fvMeshFunctionObject.H"
78 #include "volFields.H"
79 
80 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
81 
82 namespace Foam
83 {
84 namespace functionObjects
85 {
86 
87 /*---------------------------------------------------------------------------*\
88  Class age Declaration
89 \*---------------------------------------------------------------------------*/
90 
91 class age
92 :
93  public fvMeshFunctionObject
94 {
95  // Private Data
96 
97  //- The name of the flux field
98  word phiName_;
99 
100  //- The name of the density field
101  word rhoName_;
102 
103  //- Name of field from which schemes are taken
104  word schemesField_;
105 
106  //- Name of field whose solver is used (optional)
107  word solverField_;
108 
109  //- Switch to turn on/off the diffusion term
110  Switch diffusion_;
111 
112  //- Convergence tolerance
113  scalar tolerance_;
114 
115 
116  // Private Member Functions
117 
118  //- The list of patch types for the age field
119  wordList patchTypes() const;
120 
121  //- Check convergence
122  bool converged(const int nCorr, const scalar initialResidual) const;
123 
124 
125 public:
126 
127  //- Runtime type information
128  TypeName("age");
129 
130 
131  // Constructors
132 
133  //- Construct from Time and dictionary
134  age
135  (
136  const word& name,
137  const Time& runTime,
138  const dictionary& dict
139  );
140 
141 
142  //- Destructor
143  virtual ~age();
144 
145 
146  // Member Functions
147 
148  //- Read the data
149  virtual bool read(const dictionary&);
150 
151  //- Return the list of fields required
152  virtual wordList fields() const;
153 
154  //- Do not execute at the start of the run
155  virtual bool executeAtStart() const
156  {
157  return false;
158  }
159 
160  //- Execute
161  virtual bool execute();
162 
163  //- Write
164  virtual bool write();
165 };
166 
167 
168 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
169 
170 } // End namespace functionObjects
171 } // End namespace Foam
172 
173 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
174 
175 #endif
176 
177 // ************************************************************************* //
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
const word & name() const
Return the name of this functionObject.
age(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: age.C:94
virtual wordList fields() const
Return the list of fields required.
Definition: age.C:127
TypeName("age")
Runtime type information.
virtual ~age()
Destructor.
Definition: age.C:108
virtual bool executeAtStart() const
Do not execute at the start of the run.
Definition: age.H:200
virtual bool execute()
Execute.
Definition: age.C:133
virtual bool write()
Write.
Definition: age.C:266
virtual bool read(const dictionary &)
Read the data.
Definition: age.C:114
A class for handling words, derived from string.
Definition: word.H:63
Namespace for OpenFOAM.
List< word > wordList
A List of words.
Definition: fileName.H:54
dictionary dict