calcFvcGrad.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 "calcFvcGrad.H"
27 #include "volFields.H"
28 #include "dictionary.H"
29 #include "calcFvcGrad.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 defineTypeNameAndDebug(calcFvcGrad, 0);
36 }
37 
38 
39 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40 
41 Foam::calcFvcGrad::calcFvcGrad
42 (
43  const word& name,
44  const objectRegistry& obr,
45  const dictionary& dict,
46  const bool loadFromFiles
47 )
48 :
49  name_(name),
50  obr_(obr),
51  active_(true),
52  fieldName_("undefined-fieldName"),
53  resultName_("undefined-resultName")
54 {
55  // Check if the available mesh is an fvMesh, otherwise deactivate
56  if (!isA<fvMesh>(obr_))
57  {
58  active_ = false;
59  WarningIn
60  (
61  "calcFvcGrad::calcFvcGrad"
62  "("
63  "const word&, "
64  "const objectRegistry&, "
65  "const dictionary&, "
66  "const bool"
67  ")"
68  ) << "No fvMesh available, deactivating." << nl
69  << endl;
70  }
71 
72  read(dict);
73 }
74 
75 
76 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
77 
79 {}
80 
81 
82 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
83 
85 {
86  if (active_)
87  {
88  dict.lookup("fieldName") >> fieldName_;
89  dict.lookup("resultName") >> resultName_;
90 
91  if (resultName_ == "none")
92  {
93  resultName_ = "fvc::grad(" + fieldName_ + ")";
94  }
95  }
96 }
97 
98 
100 {
101  if (active_)
102  {
103  bool processed = false;
104 
105  calcGrad<scalar>(fieldName_, resultName_, processed);
106  calcGrad<vector>(fieldName_, resultName_, processed);
107 
108  if (!processed)
109  {
110  WarningIn("void Foam::calcFvcGrad::write()")
111  << "Unprocessed field " << fieldName_ << endl;
112  }
113  }
114 }
115 
116 
118 {
119  if (active_)
120  {
121  execute();
122  }
123 }
124 
125 
127 {
128  // Do nothing
129 }
130 
131 
133 {
134  if (active_)
135  {
136  if (obr_.foundObject<regIOobject>(resultName_))
137  {
138  const regIOobject& field =
139  obr_.lookupObject<regIOobject>(resultName_);
140 
141  Info<< type() << " " << name_ << " output:" << nl
142  << " writing field " << field.name() << nl << endl;
143 
144  field.write();
145  }
146  }
147 }
148 
149 
150 // ************************************************************************* //
virtual void end()
Execute at the final time-loop, currently does nothing.
Definition: calcFvcGrad.C:117
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
Namespace for OpenFOAM.
virtual void read(const dictionary &)
Read the calcFvcGrad data.
Definition: calcFvcGrad.C:84
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
#define WarningIn(functionName)
Report a warning using Foam::Warning.
virtual ~calcFvcGrad()
Destructor.
Definition: calcFvcGrad.C:78
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
Definition: calcFvcGrad.C:126
virtual void execute()
Execute, currently does nothing.
Definition: calcFvcGrad.C:99
virtual void write()
Calculate the calcFvcGrad and write.
Definition: calcFvcGrad.C:132
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
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:60
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:452
Registry of regIOobjects.
bool read(const char *, int32_t &)
Definition: int32IO.C:87
defineTypeNameAndDebug(combustionModel, 0)