ENH: autoLayerDriver: better layering information message
[OpenFOAM-2.0.x.git] / src / postProcessing / functionObjects / IO / writeRegisteredObject / writeRegisteredObject.C
blobbee009a1bb5f5f57e0a8a0a37483f82da22b72f2
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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/>.
24 \*---------------------------------------------------------------------------*/
26 #include "writeRegisteredObject.H"
27 #include "dictionary.H"
28 #include "Time.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 defineTypeNameAndDebug(Foam::writeRegisteredObject, 0);
35 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
37 Foam::writeRegisteredObject::writeRegisteredObject
39     const word& name,
40     const objectRegistry& obr,
41     const dictionary& dict,
42     const bool loadFromFiles
45     name_(name),
46     obr_(obr),
47     objectNames_()
49     read(dict);
53 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
55 Foam::writeRegisteredObject::~writeRegisteredObject()
59 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
61 void Foam::writeRegisteredObject::read(const dictionary& dict)
63     dict.lookup("objectNames") >> objectNames_;
67 void Foam::writeRegisteredObject::execute()
69     // Do nothing - only valid on write
73 void Foam::writeRegisteredObject::end()
75     // Do nothing - only valid on write
79 void Foam::writeRegisteredObject::write()
81     forAll(objectNames_, i)
82     {
83         if (obr_.foundObject<regIOobject>(objectNames_[i]))
84         {
85             regIOobject& obj =
86                 const_cast<regIOobject&>
87                 (
88                     obr_.lookupObject<regIOobject>(objectNames_[i])
89                 );
90             // Switch off automatic writing to prevent double write
91             obj.writeOpt() = IOobject::NO_WRITE;
92             obj.write();
93         }
94         else
95         {
96             WarningIn
97             (
98                 "Foam::writeRegisteredObject::read(const dictionary&)"
99             )   << "Object " << objectNames_[i] << " not found in "
100                 << "database. Available objects:" << nl << obr_.sortedToc()
101                 << endl;
102         }
104     }
108 // ************************************************************************* //