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-2018 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 {
38  addToRunTimeSelectionTable(functionObject, readFields, dictionary);
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  fieldSet_()
54 {
55  read(dict);
56 }
57 
58 
59 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
60 
62 {}
63 
64 
65 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
66 
68 {
70 
71  dict.lookup("fields") >> fieldSet_;
72 
73  return true;
74 }
75 
76 
78 {
79  // Clear out any previously loaded fields
80  vsf_.clear();
81  vvf_.clear();
82  vSpheretf_.clear();
83  vSymmtf_.clear();
84  vtf_.clear();
85 
86  ssf_.clear();
87  svf_.clear();
88  sSpheretf_.clear();
89  sSymmtf_.clear();
90  stf_.clear();
91 
92  forAll(fieldSet_, fieldi)
93  {
94  const word& fieldName = fieldSet_[fieldi];
95 
96  // If necessary load field
97  loadField<scalar>(fieldName, vsf_, ssf_);
98  loadField<vector>(fieldName, vvf_, svf_);
99  loadField<sphericalTensor>(fieldName, vSpheretf_, sSpheretf_);
100  loadField<symmTensor>(fieldName, vSymmtf_, sSymmtf_);
101  loadField<tensor>(fieldName, vtf_, stf_);
102  }
103 
104  return true;
105 }
106 
107 
109 {
110  return true;
111 }
112 
113 
114 // ************************************************************************* //
Foam::surfaceFields.
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const HashSet< word > &selectedFields, LIFOStack< regIOobject *> &storedObjects)
Read the selected GeometricFields of the specified type.
Definition: ReadFields.C:244
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
addToRunTimeSelectionTable(functionObject, Qdot, dictionary)
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 the set of fields from dictionary.
Definition: readFields.C:67
virtual bool execute()
Read the fields.
Definition: readFields.C:77
virtual bool read(const dictionary &)
Read optional controls.
bool read(const char *, int32_t &)
Definition: int32IO.C:85
readFields(const word &name, const Time &runTime, const dictionary &dict)
Construct for given objectRegistry and dictionary.
Definition: readFields.C:46
A class for handling words, derived from string.
Definition: word.H:59
virtual bool write()
Do nothing.
Definition: readFields.C:108
defineTypeNameAndDebug(Qdot, 0)
virtual ~readFields()
Destructor.
Definition: readFields.C:61
Specialisation of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
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