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-2023 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 {
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  resultDict_(fileName("result"), dictionary::null)
57 {
58  read(dict);
59 }
60 
61 
63 (
64  const word& name,
65  const objectRegistry& obr,
66  const dictionary& dict,
67  const word& valueType
68 )
69 :
71  logFiles(obr_, name),
72  dict_(dict),
73  valueType_(valueType),
74  resultDict_(fileName("result"), dictionary::null)
75 {
76  read(dict);
77 }
78 
79 
80 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
81 
83 {}
84 
85 
86 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
87 
89 {
90  if (dict != dict_)
91  {
92  dict_ = dict;
93  }
94 
96 
97  dict.lookup("fields") >> fields_;
98  dict.lookup("writeFields") >> writeFields_;
99 
100  resetName(valueType_);
101 
102  return true;
103 }
104 
105 
107 {
108  return true;
109 }
110 
111 
113 {
114  logFiles::write();
115 
116  Log << type() << " " << name() << " write:" << nl;
117 
118  return true;
119 }
120 
121 
122 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
A class for handling file names.
Definition: fileName.H:82
Base class for field value -based function objects.
Definition: fieldValue.H:66
virtual ~fieldValue()
Destructor.
Definition: fieldValue.C:82
virtual bool read(const dictionary &dict)
Read from dictionary.
Definition: fieldValue.C:88
fieldValue(const word &name, const Time &runTime, const dictionary &dict, const word &valueType)
Construct from Time and dictionary.
Definition: fieldValue.C:45
const dictionary & dict() const
Return the reference to the construction dictionary.
Definition: fieldValueI.H:31
virtual bool execute()
Execute.
Definition: fieldValue.C:106
virtual bool write()
Write.
Definition: fieldValue.C:112
Specialisation of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
functionObject base class for creating, maintaining and writing log files e.g. integrated of averaged...
Definition: logFiles.H:60
virtual bool write()
Write function.
Definition: logFiles.C:173
virtual bool read(const dictionary &)
Read optional controls.
Registry of regIOobjects.
A class for handling words, derived from string.
Definition: word.H:62
#define valueType(Type, none)
The field's value.
Definition: uniform.H:71
#define Log
Report write to Foam::Info if the local log switch is true.
defineTypeNameAndDebug(adjustTimeStepToCombustion, 0)
defineRunTimeSelectionTable(fieldValue, dictionary)
Namespace for OpenFOAM.
word name(const bool)
Return a word representation of a bool.
Definition: boolIO.C:39
static const char nl
Definition: Ostream.H:266
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
dictionary dict