1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
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
13 the Free Software Foundation, either version 3 of the License, or
14 (at your 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, see <http://www.gnu.org/licenses/>.
25 write function for regIOobjects
27 \*---------------------------------------------------------------------------*/
29 #include "regIOobject.H"
31 #include "OSspecific.H"
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36 bool Foam::regIOobject::writeObject
38 IOstream::streamFormat fmt,
39 IOstream::versionNumber ver,
40 IOstream::compressionType cmp
45 SeriousErrorIn("regIOobject::write()")
46 << "bad object " << name()
52 if (instance().empty())
54 SeriousErrorIn("regIOobject::write()")
55 << "instance undefined for object " << name()
63 instance() != time().timeName()
64 && instance() != time().system()
65 && instance() != time().caseSystem()
66 && instance() != time().constant()
67 && instance() != time().caseConstant()
70 const_cast<regIOobject&>(*this).instance() = time().timeName();
77 Info<< "regIOobject::write() : "
78 << "writing file " << objectPath();
85 // Try opening an OFstream for object
86 OFstream os(objectPath(), fmt, ver, cmp);
88 // If any of these fail, return (leave error handling to Ostream class)
99 // Write the data to the Ostream
112 Info<< " .... written" << endl;
115 // Only update the lastModified_ time if this object is re-readable,
116 // i.e. lastModified_ is already set
117 if (watchIndex_ != -1)
119 time().setUnmodified(watchIndex_);
126 bool Foam::regIOobject::write() const
130 time().writeFormat(),
131 IOstream::currentVersion,
132 time().writeCompression()
136 // ************************************************************************* //