calcMag.H
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) 2012-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 Class
25  Foam::calcMag
26 
27 Group
28  grpFVFunctionObjects
29 
30 Description
31  This function object calculates the magnitude of a field. The operation
32  can be applied to any volume or surface fieldsm and the output is a
33  volume or surface scalar field.
34 
35  Example of function object specification:
36  \verbatim
37  calcMag1
38  {
39  type calcMag;
40  functionObjectLibs ("libFVFunctionObjects.so");
41  ...
42  fieldName U;
43  }
44  \endverbatim
45 
46  \heading Function object usage
47  \table
48  Property | Description | Required | Default value
49  type | type name: calcMag | yes |
50  fieldName | Name of field to process | yes |
51  resultName | Name of magnitude field | no | mag(fieldName)
52  log | Log to standard output | no | yes
53  \endtable
54 SourceFiles
55  calcMag.C
56  IOcalcMag.H
57 
58 \*---------------------------------------------------------------------------*/
59 
60 #ifndef calcMag_H
61 #define calcMag_H
62 
63 #include "volFieldsFwd.H"
64 #include "surfaceFieldsFwd.H"
65 #include "pointFieldFwd.H"
66 #include "OFstream.H"
67 #include "Switch.H"
68 
69 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
70 
71 namespace Foam
72 {
73 
74 // Forward declaration of classes
75 class objectRegistry;
76 class dictionary;
77 class polyMesh;
78 class mapPolyMesh;
79 class dimensionSet;
80 
81 /*---------------------------------------------------------------------------*\
82  Class calcMag Declaration
83 \*---------------------------------------------------------------------------*/
84 
85 class calcMag
86 {
87  // Private data
88 
89  //- Name of this calcMag object
90  word name_;
91 
92  //- Reference to the database
93  const objectRegistry& obr_;
94 
95  //- On/off switch
96  bool active_;
97 
98  //- Name of field to process
99  word fieldName_;
100 
101  //- Name of result field
102  word resultName_;
103 
104  //- Switch to send output to Info as well as to file
105  Switch log_;
106 
107 
108  // Private Member Functions
109 
110  //- Helper function to create/store/return the mag field
111  template<class FieldType>
112  FieldType& magField(const word& magName, const dimensionSet& dims);
113 
114  //- Helper function to calculate the magnitude of different field types
115  template<class Type>
116  void calc
117  (
118  const word& fieldName,
119  const word& resultName,
120  bool& processed
121  );
122 
123  //- Disallow default bitwise copy construct
124  calcMag(const calcMag&);
125 
126  //- Disallow default bitwise assignment
127  void operator=(const calcMag&);
128 
129 
130 public:
131 
132  //- Runtime type information
133  TypeName("calcMag");
134 
135 
136  // Constructors
137 
138  //- Construct for given objectRegistry and dictionary.
139  // Allow the possibility to load fields from files
140  calcMag
141  (
142  const word& name,
143  const objectRegistry&,
144  const dictionary&,
145  const bool loadFromFiles = false
146  );
147 
148 
149  //- Destructor
150  virtual ~calcMag();
151 
152 
153  // Member Functions
154 
155  //- Return name of the set of calcMag
156  virtual const word& name() const
157  {
158  return name_;
159  }
160 
161  //- Read the calcMag data
162  virtual void read(const dictionary&);
163 
164  //- Execute, currently does nothing
165  virtual void execute();
166 
167  //- Execute at the final time-loop, currently does nothing
168  virtual void end();
169 
170  //- Called when time was set at the end of the Time::operator++
171  virtual void timeSet();
172 
173  //- Calculate the calcMag and write
174  virtual void write();
175 
176  //- Update for changes of mesh
177  virtual void updateMesh(const mapPolyMesh&)
178  {}
179 
180  //- Update for changes of mesh
181  virtual void movePoints(const polyMesh&)
182  {}
183 };
184 
185 
186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187 
188 } // End namespace Foam
189 
190 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
191 
192 #ifdef NoRepository
193  #include "calcMagTemplates.C"
194 #endif
195 
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
197 
198 #endif
199 
200 // ************************************************************************* //
volFieldsFwd.H
Foam::calcMag::operator=
void operator=(const calcMag &)
Disallow default bitwise assignment.
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::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::calcMag::calc
void calc(const word &fieldName, const word &resultName, bool &processed)
Helper function to calculate the magnitude of different field types.
Definition: calcMagTemplates.C:72
Foam::dimensionSet
Dimension set for the base types.
Definition: dimensionSet.H:116
Foam::calcMag::fieldName_
word fieldName_
Name of field to process.
Definition: calcMag.H:123
Foam::calcMag::name
virtual const word & name() const
Return name of the set of calcMag.
Definition: calcMag.H:180
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
OFstream.H
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
Foam::calcMag::end
virtual void end()
Execute at the final time-loop, currently does nothing.
Definition: calcMag.C:115
Foam::calcMag::log_
Switch log_
Switch to send output to Info as well as to file.
Definition: calcMag.H:129
Foam::calcMag::obr_
const objectRegistry & obr_
Reference to the database.
Definition: calcMag.H:117
Foam::calcMag::movePoints
virtual void movePoints(const polyMesh &)
Update for changes of mesh.
Definition: calcMag.H:205
pointFieldFwd.H
Foam::calcMag::write
virtual void write()
Calculate the calcMag and write.
Definition: calcMag.C:127
Switch.H
Foam::calcMag::name_
word name_
Name of this calcMag object.
Definition: calcMag.H:114
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
calcMagTemplates.C
Foam::calcMag::active_
bool active_
On/off switch.
Definition: calcMag.H:120
Foam::calcMag::resultName_
word resultName_
Name of result field.
Definition: calcMag.H:126
Foam::calcMag::updateMesh
virtual void updateMesh(const mapPolyMesh &)
Update for changes of mesh.
Definition: calcMag.H:201
Foam::calcMag::TypeName
TypeName("calcMag")
Runtime type information.
Foam::calcMag
This function object calculates the magnitude of a field. The operation can be applied to any volume ...
Definition: calcMag.H:109
Foam::calcMag::read
virtual void read(const dictionary &)
Read the calcMag data.
Definition: calcMag.C:77
surfaceFieldsFwd.H
Foam::calcMag::timeSet
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
Definition: calcMag.C:121
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
Foam::calcMag::calcMag
calcMag(const calcMag &)
Disallow default bitwise copy construct.
Foam::calcMag::~calcMag
virtual ~calcMag()
Destructor.
Definition: calcMag.C:71
Foam::calcMag::magField
FieldType & magField(const word &magName, const dimensionSet &dims)
Helper function to create/store/return the mag field.
Definition: calcMagTemplates.C:33
Foam::calcMag::execute
virtual void execute()
Execute, currently does nothing.
Definition: calcMag.C:94