fieldValue.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) 2011-2015 OpenFOAM Foundation
6  \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
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 "fvMesh.H"
28 #include "Time.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35  defineTypeNameAndDebug(fieldValue, 0);
36  defineRunTimeSelectionTable(fieldValue, dictionary);
37 }
38 
39 
40 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
41 
43 {
44  if (active_)
45  {
47 
48  dict_ = dict;
49 
50  log_ = dict.lookupOrDefault<Switch>("log", true);
51  dict.lookup("fields") >> fields_;
52  dict.lookup("valueOutput") >> valueOutput_;
53  dict.readIfPresent("scaleFactor", scaleFactor_);
54  }
55 }
56 
57 
59 {
60  if (active_)
61  {
62  if (log_) Info << type() << " " << name_ << " output:" << nl;
63  }
64 }
65 
66 
67 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
68 
70 (
71  const word& name,
72  const objectRegistry& obr,
73  const dictionary& dict,
74  const word& valueType,
75  const bool loadFromFiles
76 )
77 :
79  functionObjectFile(obr, name, valueType, dict),
80  obr_(obr),
81  dict_(dict),
82  log_(true),
83  sourceName_(dict.lookupOrDefault<word>("sourceName", "sampledSurface")),
84  fields_(),
85  valueOutput_(false),
86  scaleFactor_(1.0)
87 {
88  // Only active if obr is an fvMesh
89  if (setActive<fvMesh>())
90  {
91  read(dict);
92  }
93 }
94 
95 
96 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
97 
99 {}
100 
101 
102 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
103 
105 {
106  // Do nothing
107 }
108 
109 
111 {
112  // Do nothing
113 }
114 
115 
117 {
118  // Do nothing
119 }
120 
121 
123 {
124  // Do nothing
125 }
126 
127 
129 {
130  // Do nothing
131 }
132 
133 
134 // ************************************************************************* //
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:60
Foam::fieldValue::dict_
dictionary dict_
Construction dictionary.
Definition: fieldValue.H:77
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::fieldValue::fieldValue
fieldValue(const word &name, const objectRegistry &obr, const dictionary &dict, const word &valueType, const bool loadFromFiles=false)
Construct from components.
Definition: fieldValue.C:70
Foam::functionObjectState
Base class for function objects, adding functionality to read/write state information (data required ...
Definition: functionObjectState.H:54
Foam::dictionary::readIfPresent
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
Definition: dictionaryTemplates.C:94
Foam::defineRunTimeSelectionTable
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Foam::read
bool read(const char *, int32_t &)
Definition: int32IO.C:87
Foam::fieldValue::log_
Switch log_
Switch to send output to Info as well as to file.
Definition: fieldValue.H:80
Foam::fieldValue::scaleFactor_
scalar scaleFactor_
Scale factor - optional.
Definition: fieldValue.H:92
Foam::dictionary::lookup
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:449
Foam::dictionary::lookupOrDefault
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
Definition: dictionaryTemplates.C:33
Foam::fieldValue::fields_
wordList fields_
List of field names to operate on.
Definition: fieldValue.H:86
Foam::functionObjectFile::read
void read(const dictionary &dict)
Read.
Definition: functionObjectFile.C:178
Foam::fieldValue::valueOutput_
Switch valueOutput_
Output field values flag.
Definition: fieldValue.H:89
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
Foam::fieldValue::read
virtual void read(const dictionary &dict)
Read from dictionary.
Definition: fieldValue.C:42
Foam::fieldValue::updateMesh
virtual void updateMesh(const mapPolyMesh &)
Update mesh.
Definition: fieldValue.C:122
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
Foam::fieldValue::~fieldValue
virtual ~fieldValue()
Destructor.
Definition: fieldValue.C:98
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::functionObjectState::active_
bool active_
Flag to indicate whether the object is active.
Definition: functionObjectState.H:75
Foam::fieldValue::execute
virtual void execute()
Execute.
Definition: fieldValue.C:104
Foam::fieldValue::dict
const dictionary & dict() const
Return the reference to the construction dictionary.
Definition: fieldValueI.H:43
fieldValue.H
Foam::functionObjectFile
Base class for output file data handling.
Definition: functionObjectFile.H:57
Foam::fieldValue::end
virtual void end()
Execute the at the final time-loop, currently does nothing.
Definition: fieldValue.C:110
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
Foam::fieldValue::timeSet
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
Definition: fieldValue.C:116
Foam::fieldValue::write
virtual void write()
Write to screen/file.
Definition: fieldValue.C:58
Foam::type
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:588
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
Foam::fieldValue::movePoints
virtual void movePoints(const polyMesh &)
Move points.
Definition: fieldValue.C:128