readFields.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2017-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "readFields.H"
30 #include "volFields.H"
31 #include "surfaceFields.H"
33 
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38 namespace functionObjects
39 {
41  addToRunTimeSelectionTable(functionObject, readFields, dictionary);
42 }
43 }
44 
45 
46 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
47 
49 (
50  const word& name,
51  const Time& runTime,
52  const dictionary& dict
53 )
54 :
56  readOnStart_(true),
57  fieldSet_()
58 {
59  read(dict);
60 
61  if (readOnStart_)
62  {
63  execute();
64  }
65 }
66 
67 
68 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
69 
71 {
73 
74  dict.readIfPresent("readOnStart", readOnStart_);
75  dict.readEntry("fields", fieldSet_);
76 
77  return true;
78 }
79 
80 
82 {
83  forAll(fieldSet_, fieldi)
84  {
85  const word& fieldName = fieldSet_[fieldi];
86 
87  // If necessary load field
88  loadField<scalar>(fieldName);
89  loadField<vector>(fieldName);
90  loadField<sphericalTensor>(fieldName);
91  loadField<symmTensor>(fieldName);
92  loadField<tensor>(fieldName);
93  }
94 
95  return true;
96 }
97 
98 
100 {
101  return true;
102 }
103 
104 
105 // ************************************************************************* //
volFields.H
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::functionObjects::readFields::readFields
readFields(const word &name, const Time &runTime, const dictionary &dict)
Construct for given objectRegistry and dictionary.
Definition: readFields.C:49
Foam::functionObjects::readFields::readOnStart_
bool readOnStart_
Flag to read on construction.
Definition: readFields.H:164
Foam::functionObjects::readFields::read
virtual bool read(const dictionary &)
Read the set of fields from dictionary.
Definition: readFields.C:70
surfaceFields.H
Foam::surfaceFields.
Foam::functionObjects::readFields::execute
virtual bool execute()
Read the fields.
Definition: readFields.C:81
Foam::functionObjects::fvMeshFunctionObject
Specialization of Foam::functionObject for an Foam::fvMesh, providing a reference to the Foam::fvMesh...
Definition: fvMeshFunctionObject.H:64
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
readFields.H
Foam::blockMeshTools::read
void read(Istream &, label &, const dictionary &)
In-place read with dictionary lookup.
Definition: blockMeshTools.C:33
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::functionObjects::regionFunctionObject::read
virtual bool read(const dictionary &dict)
Read optional controls.
Definition: regionFunctionObject.C:166
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::functionObjects::readFields::write
virtual bool write()
Do nothing.
Definition: readFields.C:99
Foam::readFields
void readFields(const typename GeoFieldType::Mesh &mesh, const IOobjectList &objects, const wordHashSet &selectedFields, LIFOStack< regIOobject * > &storedObjects)
Read the selected GeometricFields of the templated type.
Definition: ReadFieldsTemplates.C:312
Foam::functionObjects::readFields::fieldSet_
wordList fieldSet_
Fields to load.
Definition: readFields.H:167
Foam::functionObjects::addToRunTimeSelectionTable
addToRunTimeSelectionTable(functionObject, ObukhovLength, dictionary)
Foam::functionObjects::defineTypeNameAndDebug
defineTypeNameAndDebug(ObukhovLength, 0)