1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 write function for regIOobjects
28 \*---------------------------------------------------------------------------*/
30 #include "regIOobject.H"
32 #include "OSspecific.H"
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 bool Foam::regIOobject::writeObject
39 IOstream::streamFormat fmt,
40 IOstream::versionNumber ver,
41 IOstream::compressionType cmp
46 SeriousErrorIn("regIOobject::write()")
47 << "bad object " << name()
53 if (instance().empty())
55 SeriousErrorIn("regIOobject::write()")
56 << "instance undefined for object " << name()
64 instance() != time().timeName()
65 && instance() != time().system()
66 && instance() != time().caseSystem()
67 && instance() != time().constant()
68 && instance() != time().caseConstant()
71 const_cast<regIOobject&>(*this).instance() = time().timeName();
78 Info<< "regIOobject::write() : "
79 << "writing file " << objectPath();
86 // Try opening an OFstream for object
87 OFstream os(objectPath(), fmt, ver, cmp);
89 // If any of these fail, return (leave error handling to Ostream class)
100 // Write the data to the Ostream
113 Info<< " .... written" << endl;
116 // Only update the lastModified_ time if this object is re-readable,
117 // i.e. lastModified_ is already set
120 lastModified_ = lastModified(objectPath());
127 bool Foam::regIOobject::write() const
131 time().writeFormat(),
132 IOstream::currentVersion,
133 time().writeCompression()
137 // ************************************************************************* //