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 | Copyright (C) 2011-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 \*---------------------------------------------------------------------------*/
25 
26 #include "readFields.H"
27 #include "dictionary.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
34 }
35 
36 
37 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
38 
40 (
41  const word& name,
42  const objectRegistry& obr,
43  const dictionary& dict,
44  const bool loadFromFiles
45 )
46 :
47  name_(name),
48  obr_(obr),
49  active_(true),
50  fieldSet_()
51 {
52  // Check if the available mesh is an fvMesh otherise deactivate
53  if (isA<fvMesh>(obr_))
54  {
55  read(dict);
56  }
57  else
58  {
59  active_ = false;
60  WarningIn
61  (
62  "readFields::readFields"
63  "("
64  "const word&, "
65  "const objectRegistry&, "
66  "const dictionary&, "
67  "const bool"
68  ")"
69  ) << "No fvMesh available, deactivating " << name_
70  << endl;
71  }
72 }
73 
74 
75 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
76 
78 {}
79 
80 
81 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
82 
84 {
85  if (active_)
86  {
87  dict.lookup("fields") >> fieldSet_;
88  }
89 }
90 
91 
93 {
94  if (active_)
95  {
96  // Clear out any previously loaded fields
97  vsf_.clear();
98  vvf_.clear();
99  vSpheretf_.clear();
100  vSymmtf_.clear();
101  vtf_.clear();
102 
103  ssf_.clear();
104  svf_.clear();
105  sSpheretf_.clear();
106  sSymmtf_.clear();
107  stf_.clear();
108 
109  forAll(fieldSet_, fieldI)
110  {
111  const word& fieldName = fieldSet_[fieldI];
112 
113  // If necessary load field
114  loadField<scalar>(fieldName, vsf_, ssf_);
115  loadField<vector>(fieldName, vvf_, svf_);
116  loadField<sphericalTensor>(fieldName, vSpheretf_, sSpheretf_);
117  loadField<symmTensor>(fieldName, vSymmtf_, sSymmtf_);
118  loadField<tensor>(fieldName, vtf_, stf_);
119  }
120  }
121 }
122 
123 
125 {
126  if (active_)
127  {
128  execute();
129  }
130 }
131 
132 
134 {
135  // Do nothing
136 }
137 
138 
140 {
141  // Do nothing
142 }
143 
144 
145 // ************************************************************************* //
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
Definition: readFields.C:133
virtual void write()
Write.
Definition: readFields.C:139
A class for handling words, derived from string.
Definition: word.H:59
virtual ~readFields()
Destructor.
Definition: readFields.C:77
virtual void end()
Execute at the final time-loop, currently does nothing.
Definition: readFields.C:124
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
Namespace for OpenFOAM.
virtual void read(const dictionary &)
Read the field min/max data.
Definition: readFields.C:83
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
#define WarningIn(functionName)
Report a warning using Foam::Warning.
readFields(const readFields &)
Disallow default bitwise copy construct.
void readFields(const Mesh &mesh, const IOobjectList &objects, PtrList< GeoField > &fields)
#define forAll(list, i)
Definition: UList.H:421
virtual void execute()
Execute, currently does nothing.
Definition: readFields.C:92
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:452
Registry of regIOobjects.
bool read(const char *, int32_t &)
Definition: int32IO.C:87
defineTypeNameAndDebug(combustionModel, 0)