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-2015 OpenFOAM Foundation
6  \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
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  log_(true)
52 {
53  // Check if the available mesh is an fvMesh otherise deactivate
54  if (isA<fvMesh>(obr_))
55  {
56  read(dict);
57  }
58  else
59  {
60  active_ = false;
62  << "No fvMesh available, deactivating " << name_
63  << endl;
64  }
65 }
66 
67 
68 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
69 
71 {}
72 
73 
74 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
75 
77 {
78  if (active_)
79  {
80  log_.readIfPresent("log", dict);
81  dict.lookup("fields") >> fieldSet_;
82  }
83 }
84 
85 
87 {
88  if (active_)
89  {
90  forAll(fieldSet_, fieldI)
91  {
92  const word& fieldName = fieldSet_[fieldI];
93 
94  // If necessary load field
95  loadField<scalar>(fieldName);
96  loadField<vector>(fieldName);
97  loadField<sphericalTensor>(fieldName);
98  loadField<symmTensor>(fieldName);
99  loadField<tensor>(fieldName);
100  }
101  }
102 }
103 
104 
106 {
107  // Do nothing
108 }
109 
110 
112 {
113  // Do nothing
114 }
115 
116 
118 {
119  // Do nothing
120 }
121 
122 
123 // ************************************************************************* //
readFields.H
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::readFields::readFields
readFields(const readFields &)
Disallow default bitwise copy construct.
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::read
bool read(const char *, int32_t &)
Definition: int32IO.C:87
Foam::dictionary::lookup
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:449
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::readFields::timeSet
virtual void timeSet()
Called when time was set at the end of the Time::operator++.
Definition: readFields.C:111
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:50
Foam::readFields::read
virtual void read(const dictionary &)
Read the field min/max data.
Definition: readFields.C:76
dict
dictionary dict
Definition: searchingEngine.H:14
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
Foam::readFields::~readFields
virtual ~readFields()
Destructor.
Definition: readFields.C:70
Foam::readFields::write
virtual void write()
Write.
Definition: readFields.C:117
dictionary.H
Foam::readFields::execute
virtual void execute()
Execute, currently does nothing.
Definition: readFields.C:86
Foam::readFields::end
virtual void end()
Execute at the final time-loop, currently does nothing.
Definition: readFields.C:105
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:259
Foam::readFields
void readFields(const typename GeoMesh::Mesh &mesh, const IOobjectList &objects, PtrList< GeometricField< Type, PatchField, GeoMesh > > &fields, const bool readOldTime)
Definition: readFields.C:33
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47