blendingFactor.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 | Copyright (C) 2013-2015 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::blendingFactor
26 
27 Group
28  grpUtilitiesFunctionObjects
29 
30 Description
31  This function object provides information on the mode of operation of
32  blended convection schemes.
33 
34  The weight of a blended scheme is given by a function of the blending
35  factor, f:
36 
37  weight = f*scheme1 + (1 - f)*scheme2
38 
39  The factor is a face-based quantity, which is converted to a cell-based
40  quantity by assigning the minimum blending factor for any cell face.
41 
42  An indicator (volume) field, named <functionObjectName>:<fieldName>, is
43  generated that is set to (1 - f), i.e. values of:
44  - 0 represent scheme1 as active, and
45  - 1 represent scheme2 as active.
46  - intermediate values show the contribution to scheme2
47 
48  Additional reporting is written to the standard output, providing
49  statistics as to the number of cells used by each scheme.
50 
51  Example of function object specification to calculate the blending factor:
52  \verbatim
53  blendingFactor1
54  {
55  type blendingFactor;
56  functionObjectLibs ("libutilityFunctionObjects.so");
57 
58  ...
59 
60  // Name of field
61  fieldName U;
62  }
63  \endverbatim
64 
65  \heading Function object usage
66  \table
67  Property | Description | Required | Default value
68  type | Type name: blendingFactor | yes |
69  phiName | Name of flux field | no | phi
70  fieldName | Name of field to evaluate | yes |
71  tolerance | Tolerance for number of blended cells | no | 0.001
72  log | Log to standard output | no | yes
73  \endtable
74 
75 SourceFiles
76  blendingFactor.C
77  IOblendingFactor.H
78 
79 \*---------------------------------------------------------------------------*/
80 
81 #ifndef blendingFactor_H
82 #define blendingFactor_H
83 
84 #include "functionObjectState.H"
85 #include "functionObjectFile.H"
86 #include "volFieldsFwd.H"
87 #include "surfaceFieldsFwd.H"
88 #include "OFstream.H"
89 #include "Switch.H"
90 
91 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
92 
93 namespace Foam
94 {
95 
96 // Forward declaration of classes
97 class objectRegistry;
98 class dictionary;
99 class polyMesh;
100 class mapPolyMesh;
101 
102 /*---------------------------------------------------------------------------*\
103  Class blendingFactor Declaration
104 \*---------------------------------------------------------------------------*/
105 
106 class blendingFactor
107 :
108  public functionObjectState,
109  public functionObjectFile
110 {
111  // Private data
112 
113  //- Name
114  const word name_;
115 
116  //- Reference to the database
117  const objectRegistry& obr_;
118 
119  //- Name of flux field, default is "phi"
120  word phiName_;
121 
122  //- Field name
123  word fieldName_;
124 
125  //- Result field name
126  word resultName_;
127 
128  //- Tolerance used when calculating the number of blended cells
129  scalar tolerance_;
130 
131  //- Switch to send output to Info as well as to file
132  Switch log_;
133 
134 
135  // Private Member Functions
136 
137  //- Disallow default bitwise copy construct
139 
140  //- Disallow default bitwise assignment
141  void operator=(const blendingFactor&);
142 
143  //- Calculate the blending factor
144  template<class Type>
145  void calc();
146 
147 
148 protected:
149 
150  // Protected Member Functions
151 
152  //- Write the file header
153  virtual void writeFileHeader(Ostream& os) const;
154 
155 
156 public:
157 
158  //- Runtime type information
159  TypeName("blendingFactor");
160 
161 
162  // Constructors
163 
164  //- Construct for given objectRegistry and dictionary.
165  // Allow the possibility to load fields from files
167  (
168  const word& name,
169  const objectRegistry&,
170  const dictionary&,
171  const bool loadFromFiles = false
172  );
173 
174 
175  //- Destructor
176  virtual ~blendingFactor();
177 
178 
179  // Member Functions
180 
181  //- Return name of the set of blendingFactor
182  virtual const word& name() const
183  {
184  return name_;
185  }
186 
187  //- Read the blendingFactor data
188  virtual void read(const dictionary&);
189 
190  //- Execute, currently does nothing
191  virtual void execute();
192 
193  //- Execute at the final time-loop, currently does nothing
194  virtual void end();
195 
196  //- Called when time was set at the end of the Time::operator++
197  virtual void timeSet();
198 
199  //- Calculate the blendingFactor and write
200  virtual void write();
201 
202  //- Update for changes of mesh
203  virtual void updateMesh(const mapPolyMesh&)
204  {}
205 
206  //- Update for changes of mesh
207  virtual void movePoints(const polyMesh&)
208  {}
209 };
210 
211 
212 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
213 
214 } // End namespace Foam
215 
216 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 
218 #ifdef NoRepository
219  #include "blendingFactorTemplates.C"
220 #endif
221 
222 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
223 
224 #endif
225 
226 // ************************************************************************* //
Foam::blendingFactor::timeSet
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
Definition: blendingFactor.C:153
volFieldsFwd.H
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:60
Foam::blendingFactor::movePoints
virtual void movePoints(const polyMesh &)
Update for changes of mesh.
Definition: blendingFactor.H:236
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::blendingFactor::log_
Switch log_
Switch to send output to Info as well as to file.
Definition: blendingFactor.H:161
Foam::blendingFactor::tolerance_
scalar tolerance_
Tolerance used when calculating the number of blended cells.
Definition: blendingFactor.H:158
Foam::functionObjectState
Base class for function objects, adding functionality to read/write state information (data required ...
Definition: functionObjectState.H:54
Foam::blendingFactor::operator=
void operator=(const blendingFactor &)
Disallow default bitwise assignment.
Foam::blendingFactor::write
virtual void write()
Calculate the blendingFactor and write.
Definition: blendingFactor.C:159
functionObjectState.H
Foam::blendingFactor::name
virtual const word & name() const
Return name of the set of blendingFactor.
Definition: blendingFactor.H:211
Foam::blendingFactor::resultName_
word resultName_
Result field name.
Definition: blendingFactor.H:155
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
OFstream.H
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
blendingFactorTemplates.C
Foam::blendingFactor::name_
const word name_
Name.
Definition: blendingFactor.H:143
Switch.H
Foam::blendingFactor::blendingFactor
blendingFactor(const blendingFactor &)
Disallow default bitwise copy construct.
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::blendingFactor::obr_
const objectRegistry & obr_
Reference to the database.
Definition: blendingFactor.H:146
Foam::blendingFactor::read
virtual void read(const dictionary &)
Read the blendingFactor data.
Definition: blendingFactor.C:109
Foam::blendingFactor::end
virtual void end()
Execute at the final time-loop, currently does nothing.
Definition: blendingFactor.C:147
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::blendingFactor::fieldName_
word fieldName_
Field name.
Definition: blendingFactor.H:152
functionObjectFile.H
Foam::blendingFactor
This function object provides information on the mode of operation of blended convection schemes.
Definition: blendingFactor.H:135
Foam::blendingFactor::~blendingFactor
virtual ~blendingFactor()
Destructor.
Definition: blendingFactor.C:103
Foam::blendingFactor::execute
virtual void execute()
Execute, currently does nothing.
Definition: blendingFactor.C:137
Foam::functionObjectFile
Base class for output file data handling.
Definition: functionObjectFile.H:57
surfaceFieldsFwd.H
Foam::blendingFactor::updateMesh
virtual void updateMesh(const mapPolyMesh &)
Update for changes of mesh.
Definition: blendingFactor.H:232
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
Foam::blendingFactor::phiName_
word phiName_
Name of flux field, default is "phi".
Definition: blendingFactor.H:149
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::blendingFactor::calc
void calc()
Calculate the blending factor.
Definition: blendingFactorTemplates.C:33
Foam::blendingFactor::writeFileHeader
virtual void writeFileHeader(Ostream &os) const
Write the file header.
Definition: blendingFactor.C:39
Foam::blendingFactor::TypeName
TypeName("blendingFactor")
Runtime type information.