fieldValue.C
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) 2011-2021 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 "fieldValue.H"
27 #include "Time.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 namespace functionObjects
35 {
36  defineTypeNameAndDebug(fieldValue, 0);
37  defineRunTimeSelectionTable(fieldValue, dictionary);
38 }
39 }
40 
41 
42 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
43 
45 (
46  const word& name,
47  const Time& runTime,
48  const dictionary& dict,
49  const word& valueType
50 )
51 :
52  fvMeshFunctionObject(name, runTime, dict),
53  logFiles(obr_, name),
54  dict_(dict),
55  valueType_(valueType),
56  regionName_(word::null),
57  resultDict_(fileName("name"), dictionary::null)
58 {
59  read(dict);
60 }
61 
62 
64 (
65  const word& name,
66  const objectRegistry& obr,
67  const dictionary& dict,
68  const word& valueType
69 )
70 :
71  fvMeshFunctionObject(name, obr, dict),
72  logFiles(obr_, name),
73  dict_(dict),
74  valueType_(valueType),
75  regionName_(word::null),
76  resultDict_(fileName("name"), dictionary::null)
77 {
78  read(dict);
79 }
80 
81 
82 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
83 
85 {}
86 
87 
88 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
89 
91 {
92  if (dict != dict_)
93  {
94  dict_ = dict;
95  }
96 
98 
99  dict.lookup("fields") >> fields_;
100  dict.lookup("writeFields") >> writeFields_;
101 
102  resetName(valueType_);
103 
104  return true;
105 }
106 
107 
109 {
110  return true;
111 }
112 
113 
115 {
116  logFiles::write();
117 
118  Log << type() << " " << name() << " write:" << nl;
119 
120  return true;
121 }
122 
123 
124 // ************************************************************************* //
dictionary dict
virtual bool execute()
Execute.
Definition: fieldValue.C:108
virtual bool write()
Write function.
Definition: logFiles.C:167
A class for handling file names.
Definition: fileName.H:79
virtual ~fieldValue()
Destructor.
Definition: fieldValue.C:84
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
virtual bool read(const dictionary &dict)
Read from dictionary.
Definition: fieldValue.C:90
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:68
Macros for easy insertion into run-time selection tables.
virtual bool read(const dictionary &)
Read optional controls.
bool read(const char *, int32_t &)
Definition: int32IO.C:85
fieldValue(const word &name, const Time &runTime, const dictionary &dict, const word &valueType)
Construct from Time and dictionary.
Definition: fieldValue.C:45
A class for handling words, derived from string.
Definition: word.H:59
static const dictionary null
Null dictionary.
Definition: dictionary.H:242
static const word null
An empty word.
Definition: word.H:77
static const char nl
Definition: Ostream.H:260
defineRunTimeSelectionTable(fieldValue, dictionary)
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
defineTypeNameAndDebug(Qdot, 0)
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
#define Log
Report write to Foam::Info if the local log switch is true.
Specialisation of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Registry of regIOobjects.
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:844
virtual bool write()
Write.
Definition: fieldValue.C:114
functionObject base class for creating, maintaining and writing log files e.g. integrated of averaged...
Definition: logFiles.H:57