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-2021 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 from which schemes are taken | \\
48  no | age
49  diffusion | Switch to turn on/off the diffusion term | no | off
50  tolerance | Solver residual control | no | 1e-5
51  \endtable
52 
53  \verbatim
54  age1
55  {
56  type age;
57  libs ("libsolverFunctionObjects.so");
58 
59  executeControl writeTime;
60  writeControl writeTime;
61 
62  schemesField k;
63  }
64  \endverbatim
65 
66 SourceFiles
67  age.C
68 
69 \*---------------------------------------------------------------------------*/
70 
71 #ifndef functionObjects_age_H
72 #define functionObjects_age_H
73 
74 #include "fvMeshFunctionObject.H"
75 #include "volFields.H"
76 
77 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
78 
79 namespace Foam
80 {
81 namespace functionObjects
82 {
83 
84 /*---------------------------------------------------------------------------*\
85  Class age Declaration
86 \*---------------------------------------------------------------------------*/
87 
88 class age
89 :
90  public fvMeshFunctionObject
91 {
92  // Private Data
93 
94  //- The name of the flux field
95  word phiName_;
96 
97  //- The name of the density field
98  word rhoName_;
99 
100  //- Number of corrections
101  int nCorr_;
102 
103  //- Name of field from which schemes are taken
104  word schemesField_;
105 
106  //- Switch to turn on/off the diffusion term
107  Switch diffusion_;
108 
109  //- Convergence tolerance
110  scalar tolerance_;
111 
112 
113  // Private Member Functions
114 
115  //- The list of patch types for the age field
116  wordList patchTypes() const;
117 
118  //- Check convergence
119  bool converged(const int nCorr, const scalar initialResidual) const;
120 
121 
122 public:
123 
124  //- Runtime type information
125  TypeName("age");
126 
127 
128  // Constructors
129 
130  //- Construct from Time and dictionary
131  age
132  (
133  const word& name,
134  const Time& runTime,
135  const dictionary& dict
136  );
137 
138 
139  //- Destructor
140  virtual ~age();
141 
142 
143  // Member Functions
144 
145  //- Read the data
146  virtual bool read(const dictionary&);
147 
148  //- Return the list of fields required
149  virtual wordList fields() const;
150 
151  //- Execute
152  virtual bool execute();
153 
154  //- Write
155  virtual bool write();
156 };
157 
158 
159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
160 
161 } // End namespace functionObjects
162 } // End namespace Foam
163 
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
165 
166 #endif
167 
168 // ************************************************************************* //
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
A list of keyword definitions, which are a keyword followed by any number of values (e....
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 execute()
Execute.
Definition: age.C:133
virtual bool write()
Write.
Definition: age.C:256
virtual bool read(const dictionary &)
Read the data.
Definition: age.C:114
A class for handling words, derived from string.
Definition: word.H:62
Namespace for OpenFOAM.
List< word > wordList
A List of words.
Definition: fileName.H:54
dictionary dict