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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2013-2016 OpenFOAM Foundation
9  Copyright (C) 2016-2020 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::blendingFactor
29 
30 Group
31  grpFieldFunctionObjects
32 
33 Description
34  Computes the blending coefficient employed by blended divergence schemes,
35  giving an indicator as to which of the schemes is active across the domain.
36 
37  Blended schemes combine contributions from two schemes, i.e. \f$\phi_1\f$
38  and \f$\phi_2\f$, using a weight field, i.e. \f$w\f$, such that the
39  effective scheme value, i.e. \f$\phi_{eff}\f$, is computed as follows:
40 
41  \f[
42  \phi_{eff} = w \phi_1 + (1 - w) \phi_2
43  \f]
44 
45  The weight field, i.e. \f$w\f$, is surface field and converted to a volume
46  field for easier post-processing by setting the cell value to one minus
47  the minimum of the face values.
48 
49  This conversion leads to blending indicator field whose values mean:
50  \verbatim
51  0 = scheme 0
52  1 = scheme 1
53  0-1 = a blend between scheme 0 and scheme 1
54  \endverbatim
55 
56  Operands:
57  \table
58  Operand | Type | Location
59  input | - | -
60  output file | dat | $FOAM_CASE/postProcessing/<FO>/<time>/<file>
61  output field | volScalarField | $FOAM_CASE/<time>/<outField>
62  \endtable
63 
64 Usage
65  Minimal example by using \c system/controlDict.functions:
66  \verbatim
67  blendingFactor1
68  {
69  // Mandatory entries (unmodifiable)
70  type blendingFactor;
71  libs (fieldFunctionObjects);
72 
73  // Mandatory (inherited) entry (runtime modifiable)
74  field <field>;
75 
76  // Optional entries (runtime modifiable)
77  phi phi;
78  tolerance 0.001;
79 
80  // Optional (inherited) entries
81  ...
82  }
83  \endverbatim
84 
85  where the entries mean:
86  \table
87  Property | Description | Type | Req'd | Deflt
88  type | Type name: blendingFactor | word | yes | -
89  libs | Library name: fieldFunctionObjects | word | yes | -
90  field | Name of the operand field | word | yes | -
91  phi | Name of flux field | word | no | phi
92  tolerance | Tolerance for number of blended cells | scalar | no | 0.001
93  \endtable
94 
95  The inherited entries are elaborated in:
96  - \link functionObject.H \endlink
97  - \link fieldExpression.H \endlink
98  - \link writeFile.H \endlink
99 
100  Usage by the \c postProcess utility is not available.
101 
102 See also
103  - Foam::functionObject
104  - Foam::functionObjects::fieldExpression
105  - Foam::functionObjects::fvMeshFunctionObject
106  - Foam::functionObjects::writeFile
107  - Foam::CoBlended
108  - ExtendedCodeGuide::functionObjects::field::blendingFactor
109 
110 SourceFiles
111  blendingFactor.C
112  blendingFactorTemplates.C
113 
114 \*---------------------------------------------------------------------------*/
115 
116 #ifndef functionObjects_blendingFactor_H
117 #define functionObjects_blendingFactor_H
118 
119 #include "fieldExpression.H"
120 #include "writeFile.H"
121 #include "convectionScheme.H"
122 
123 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
124 
125 namespace Foam
126 {
127 namespace functionObjects
128 {
129 
130 /*---------------------------------------------------------------------------*\
131  Class blendingFactor Declaration
132 \*---------------------------------------------------------------------------*/
133 
134 class blendingFactor
135 :
136  public fieldExpression,
137  public writeFile
138 {
139  // Private Data
140 
141  //- Name of flux field
142  word phiName_;
143 
144  //- Tolerance used when calculating the number of blended cells
145  scalar tolerance_;
146 
147 
148  // Private Member Functions
149 
150  //- Calculate the blending factor field
151  template<class Type>
152  void calcBlendingFactor
153  (
154  const GeometricField<Type, fvPatchField, volMesh>& field,
155  const typename fv::convectionScheme<Type>& cs
156  );
157 
158  //- Calculate the blending factor field
159  template<class Type>
160  bool calcScheme();
161 
162  //- Calculate the blending factor field and return true if successful
163  virtual bool calc();
164 
165 
166 protected:
167 
168  // Protected Member Functions
169 
170  //- Write the file header
171  virtual void writeFileHeader(Ostream& os) const;
172 
173 
174 public:
175 
176  //- Runtime type information
177  TypeName("blendingFactor");
178 
179 
180  // Constructors
181 
182  //- Construct from Time and dictionary
184  (
185  const word& name,
186  const Time& runTime,
187  const dictionary& dict
188  );
189 
190  //- No copy construct
191  blendingFactor(const blendingFactor&) = delete;
192 
193  //- No copy assignment
194  void operator=(const blendingFactor&) = delete;
195 
196 
197  //- Destructor
198  virtual ~blendingFactor() = default;
199 
200 
201  // Member Functions
202 
203  //- Read the blendingFactor data
204  virtual bool read(const dictionary&);
205 
206  //- Write the blendingFactor
207  virtual bool write();
208 };
209 
210 
211 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
212 
213 } // End namespace functionObjects
214 } // End namespace Foam
215 
216 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 
218 #ifdef NoRepository
219  #include "blendingFactorTemplates.C"
220 #endif
221 
222 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
223 
224 #endif
225 
226 // ************************************************************************* //
Foam::functionObjects::blendingFactor::~blendingFactor
virtual ~blendingFactor()=default
Destructor.
runTime
engineTime & runTime
Definition: createEngineTime.H:13
convectionScheme.H
writeFile.H
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
Foam::functionObjects::blendingFactor::blendingFactor
blendingFactor(const word &name, const Time &runTime, const dictionary &dict)
Construct from Time and dictionary.
Definition: blendingFactor.C:72
Foam::functionObjects::blendingFactor::write
virtual bool write()
Write the blendingFactor.
Definition: blendingFactor.C:129
blendingFactorTemplates.C
field
rDeltaTY field()
Foam::functionObjects::blendingFactor::operator=
void operator=(const blendingFactor &)=delete
No copy assignment.
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
os
OBJstream os(runTime.globalPath()/outputName)
Foam::functionObjects::blendingFactor::writeFileHeader
virtual void writeFileHeader(Ostream &os) const
Write the file header.
Definition: blendingFactor.C:47
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::functionObjects::blendingFactor
Computes the blending coefficient employed by blended divergence schemes, giving an indicator as to w...
Definition: blendingFactor.H:185
Foam::functionObjects::blendingFactor::read
virtual bool read(const dictionary &)
Read the blendingFactor data.
Definition: blendingFactor.C:108
Foam::fv::convectionScheme
Abstract base class for convection schemes.
Definition: convectionScheme.H:69
Foam::functionObject::name
const word & name() const noexcept
Return the name of this functionObject.
Definition: functionObject.C:143
Foam::functionObjects::fieldExpression
Intermediate class for handling field expression function objects (e.g. blendingFactor etc....
Definition: fieldExpression.H:120
Foam::functionObjects::blendingFactor::TypeName
TypeName("blendingFactor")
Runtime type information.
fieldExpression.H
Foam::functionObjects::writeFile
Base class for writing single files from the function objects.
Definition: writeFile.H:119
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::GeometricField< Type, fvPatchField, volMesh >