readFields.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 "readFields.H"
27 #include "volFields.H"
28 #include "surfaceFields.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 namespace functionObjects
36 {
39 }
40 }
41 
42 
43 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
44 
46 (
47  const word& name,
48  const Time& runTime,
49  const dictionary& dict
50 )
51 :
52  fvMeshFunctionObject(name, runTime, dict),
53  fields_()
54 {
55  read(dict);
56 }
57 
58 
59 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
60 
62 {}
63 
64 
65 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
66 
68 {
70 
71  dict.lookup("fields") >> fields_;
72 
73  return true;
74 }
75 
76 
78 {
79  return fields_;
80 }
81 
82 
84 {
85  // Clear out any previously loaded fields
86  vsf_.clear();
87  vvf_.clear();
88  vSpheretf_.clear();
89  vSymmtf_.clear();
90  vtf_.clear();
91 
92  ssf_.clear();
93  svf_.clear();
94  sSpheretf_.clear();
95  sSymmtf_.clear();
96  stf_.clear();
97 
98  forAll(fields_, fieldi)
99  {
100  const word& fieldName = fields_[fieldi];
101 
102  // If necessary load field
103  loadField<scalar>(fieldName, vsf_, ssf_);
104  loadField<vector>(fieldName, vvf_, svf_);
105  loadField<sphericalTensor>(fieldName, vSpheretf_, sSpheretf_);
106  loadField<symmTensor>(fieldName, vSymmtf_, sSymmtf_);
107  loadField<tensor>(fieldName, vtf_, stf_);
108  }
109 
110  return true;
111 }
112 
113 
115 {
116  return true;
117 }
118 
119 
120 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
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:160
Abstract base-class for Time/database functionObjects.
Specialisation of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Reads fields from the time directories and adds them to the mesh database for further post-processing...
Definition: readFields.H:96
virtual wordList fields() const
Return the list of fields required.
Definition: readFields.C:77
readFields(const word &name, const Time &runTime, const dictionary &dict)
Construct for given objectRegistry and dictionary.
Definition: readFields.C:46
virtual ~readFields()
Destructor.
Definition: readFields.C:61
virtual bool execute()
Read the fields.
Definition: readFields.C:83
virtual bool write()
Do nothing.
Definition: readFields.C:114
virtual bool read(const dictionary &)
Read the set of fields from dictionary.
Definition: readFields.C:67
virtual bool read(const dictionary &)
Read optional controls.
A class for handling words, derived from string.
Definition: word.H:62
defineTypeNameAndDebug(adjustTimeStepToCombustion, 0)
addToRunTimeSelectionTable(functionObject, adjustTimeStepToCombustion, dictionary)
Namespace for OpenFOAM.
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
dictionary dict
Foam::surfaceFields.