fvExprDriverWriter.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) 2010-2018 Bernhard Gschaider
9  Copyright (C) 2019-2021 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 "fvExprDriverWriter.H"
30 #include "fvExprDriver.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 namespace expressions
37 {
38 
39 defineTypeName(fvExprDriverWriter);
40 
41 } // namespace expressions
42 } // namespace Foam
43 
44 
45 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
46 
47 Foam::expressions::fvExprDriverWriter::fvExprDriverWriter
48 (
49  const word& name,
50  fvExprDriver& driver
51 )
52 :
54  (
55  IOobject
56  (
57  name,
58  driver.mesh().time().timeName(),
59  "expressions",
60  driver.mesh().time(),
61  IOobject::READ_IF_PRESENT,
62  IOobject::AUTO_WRITE
63  )
64  ),
65  driver_(driver)
66 {
67  if (headerOk())
68  {
69  readData(readStream("fvExprDriverWriter", true));
70  }
71 }
72 
73 
74 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
75 
77 {
78  dictionary dict(is);
79 
80  // driver_.readDict(is);
81 
82  driver_.getData(dict);
83 
84  return !is.bad();
85 }
86 
87 
89 {
90  // driver_.writeDict(os);
91 
93  driver_.prepareData(dict);
94  dict.write(os, false);
95 
96  return os.good();
97 }
98 
99 
100 // ************************************************************************* //
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:165
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:63
fvExprDriverWriter.H
Foam::expressions::defineTypeName
defineTypeName(fvExprDriverWriter)
Foam::Time::timeName
static word timeName(const scalar t, const int precision=precision_)
Definition: Time.C:773
Foam::expressions::fvExprDriver
Base driver for parsing value expressions associated with an fvMesh.
Definition: fvExprDriver.H:132
fvExprDriver.H
Foam::expressions::fvExprDriverWriter::writeData
virtual bool writeData(Ostream &os) const
Definition: fvExprDriverWriter.C:81
Foam::expressions::fvExprDriver::mesh
virtual const fvMesh & mesh() const =0
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
timeName
word timeName
Definition: getTimeIndex.H:3
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:119
os
OBJstream os(runTime.globalPath()/outputName)
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::IOstream::bad
bool bad() const noexcept
Definition: IOstream.H:247
Foam
Definition: atmBoundaryLayer.C:26
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:69
Foam::name
word name(const expressions::valueTypeCode typeCode)
Definition: exprTraits.C:52
Foam::fvMesh::time
const Time & time() const
Definition: fvMesh.H:276
Foam::expressions::fvExprDriver::getData
virtual void getData(const dictionary &dict)
Definition: fvExprDriver.C:708
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:52
Foam::regIOobject::readStream
Istream & readStream(const word &, const bool valid=true)
Definition: regIOobjectRead.C:122
Foam::regIOobject::headerOk
bool headerOk()
Definition: regIOobject.C:429
Foam::expressions::fvExprDriverWriter::readData
virtual bool readData(Istream &is)
Definition: fvExprDriverWriter.C:69