blendingFactor.C
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-2014 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 \*---------------------------------------------------------------------------*/
25 
26 #include "blendingFactor.H"
27 #include "dictionary.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33  defineTypeNameAndDebug(blendingFactor, 0);
34 }
35 
36 
37 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
38 
39 Foam::blendingFactor::blendingFactor
40 (
41  const word& name,
42  const objectRegistry& obr,
43  const dictionary& dict,
44  const bool loadFromFiles
45 )
46 :
47  name_(name),
48  obr_(obr),
49  active_(true),
50  phiName_("unknown-phiName"),
51  fieldName_("unknown-fieldName")
52 {
53  // Check if the available mesh is an fvMesh, otherwise deactivate
54  if (!isA<fvMesh>(obr_))
55  {
56  active_ = false;
57  WarningIn
58  (
59  "blendingFactor::blendingFactor"
60  "("
61  "const word&, "
62  "const objectRegistry&, "
63  "const dictionary&, "
64  "const bool"
65  ")"
66  ) << "No fvMesh available, deactivating " << name_ << nl
67  << endl;
68  }
69 
70  read(dict);
71 }
72 
73 
74 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
75 
77 {}
78 
79 
80 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
81 
83 {
84  if (active_)
85  {
86  phiName_ = dict.lookupOrDefault<word>("phiName", "phi");
87  dict.lookup("fieldName") >> fieldName_;
88  }
89 }
90 
91 
93 {
94  if (active_)
95  {
96  calc<scalar>();
97  calc<vector>();
98  }
99 }
100 
101 
103 {
104  if (active_)
105  {
106  execute();
107  }
108 }
109 
111 {
112  // Do nothing
113 }
114 
115 
117 {
118  if (active_)
119  {
120  const word fieldName = "blendingFactor:" + fieldName_;
121 
123  obr_.lookupObject<volScalarField>(fieldName);
124 
125  Info<< type() << " " << name_ << " output:" << nl
126  << " writing field " << blendingFactor.name() << nl
127  << endl;
128 
129  blendingFactor.write();
130  }
131 }
132 
133 
134 // ************************************************************************* //
virtual void end()
Execute at the final time-loop, currently does nothing.
A class for handling words, derived from string.
Definition: word.H:59
messageStream Info
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
This function object calculates and outputs the blendingFactor as used by the bended convection schem...
Namespace for OpenFOAM.
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
virtual void read(const dictionary &)
Read the blendingFactor data.
virtual bool write() const
Write using setting from DB.
static const char nl
Definition: Ostream.H:260
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
virtual void execute()
Execute, currently does nothing.
#define WarningIn(functionName)
Report a warning using Foam::Warning.
const word & name() const
Return name.
Definition: IOobject.H:260
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:589
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:452
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
Registry of regIOobjects.
virtual ~blendingFactor()
Destructor.
bool read(const char *, int32_t &)
Definition: int32IO.C:87
defineTypeNameAndDebug(combustionModel, 0)
virtual void write()
Calculate the blendingFactor and write.