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 // ************************************************************************* //
dictionary dict
bool bad() const noexcept
True if stream is corrupted.
Definition: IOstream.H:305
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
virtual bool readData(Istream &is)
Virtual readData function.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
bool headerOk()
Read and check header info. Does not check the headerClassName.
Definition: regIOobject.C:505
defineTypeName(fvExprDriverWriter)
word timeName
Definition: getTimeIndex.H:3
dynamicFvMesh & mesh
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual bool writeData(Ostream &os) const
Pure virtual writeData function.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
OBJstream os(runTime.globalPath()/outputName)
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:66
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
Istream & readStream(const word &, const bool readOnProc=true)
Return Istream and check object type against that given.
Namespace for OpenFOAM.