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:169
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
fvExprDriverWriter.H
Foam::expressions::defineTypeName
defineTypeName(fvExprDriverWriter)
Foam::Time::timeName
static word timeName(const scalar t, const int precision=precision_)
Definition: Time.C:780
Foam::expressions::fvExprDriver
Base driver for parsing value expressions associated with an fvMesh.
Definition: fvExprDriver.H:136
fvExprDriver.H
Foam::expressions::fvExprDriverWriter::writeData
virtual bool writeData(Ostream &os) const
Pure virtual writeData function.
Definition: fvExprDriverWriter.C:88
Foam::expressions::fvExprDriver::mesh
virtual const fvMesh & mesh() const =0
The mesh we are attached to.
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
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:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam::IOstream::bad
bool bad() const noexcept
True if stream is corrupted.
Definition: IOstream.H:251
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:73
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::fvMesh::time
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:280
Foam::expressions::fvExprDriver::getData
virtual void getData(const dictionary &dict)
Read data from dictionary, normally via the reader/writer.
Definition: fvExprDriver.C:715
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::expressions::fvExprDriverWriter::readData
virtual bool readData(Istream &is)
Virtual readData function.
Definition: fvExprDriverWriter.C:76