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-2020 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 #include "fvOptionList.H"
77 
78 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
79 
80 namespace Foam
81 {
82 namespace functionObjects
83 {
84 
85 /*---------------------------------------------------------------------------*\
86  Class age Declaration
87 \*---------------------------------------------------------------------------*/
88 
89 class age
90 :
91  public fvMeshFunctionObject
92 {
93  // Private Data
94 
95  //- The name of the flux field
96  word phiName_;
97 
98  //- The name of the density field
99  word rhoName_;
100 
101  //- Number of corrections
102  int nCorr_;
103 
104  //- Name of field from which schemes are taken
105  word schemesField_;
106 
107  //- Switch to turn on/off the diffusion term
108  Switch diffusion_;
109 
110  //- Convergence tolerance
111  scalar tolerance_;
112 
113  //- Run-time selectable finite volume options, e.g. sources, constraints
114  fv::optionList fvOptions_;
115 
116 
117  // Private Member Functions
118 
119  //- The list of patch types for the age field
120  wordList patchTypes() const;
121 
122  //- Check convergence
123  bool converged(const int nCorr, const scalar initialResidual) const;
124 
125 
126 public:
127 
128  //- Runtime type information
129  TypeName("age");
131 
132  // Constructors
133 
134  //- Construct from Time and dictionary
135  age
136  (
137  const word& name,
138  const Time& runTime,
139  const dictionary& dict
140  );
141 
142 
143  //- Destructor
144  virtual ~age();
145 
146 
147  // Member Functions
148 
149  //- Read the data
150  virtual bool read(const dictionary&);
151 
152  //- Execute
153  virtual bool execute();
154 
155  //- Write
156  virtual bool write();
157 };
158 
159 
160 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
161 
162 } // End namespace functionObjects
163 } // End namespace Foam
164 
165 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
166 
167 #endif
168 
169 // ************************************************************************* //
virtual bool execute()
Execute.
Definition: age.C:131
virtual bool read(const dictionary &)
Read the data.
Definition: age.C:113
dictionary dict
const word & name() const
Return the name of this functionObject.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
age(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: age.C:92
TypeName("age")
Runtime type information.
engineTime & runTime
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
A class for handling words, derived from string.
Definition: word.H:59
List< word > wordList
A List of words.
Definition: fileName.H:54
virtual ~age()
Destructor.
Definition: age.C:107
int nCorr
Definition: createControls.H:3
virtual bool write()
Write.
Definition: age.C:261
Namespace for OpenFOAM.