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/>.
24 \*---------------------------------------------------------------------------*/
26 #include "partialWrite.H"
27 #include "dictionary.H"
29 #include "IOobjectList.H"
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
37 defineTypeNameAndDebug(partialWrite, 0);
41 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
43 Foam::partialWrite::partialWrite
46 const objectRegistry& obr,
47 const dictionary& dict,
48 const bool loadFromFiles
58 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
60 Foam::partialWrite::~partialWrite()
64 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
66 void Foam::partialWrite::read(const dictionary& dict)
68 dict.lookup("objectNames") >> objectNames_;
69 dict.lookup("writeInterval") >> writeInterval_;
72 Info<< type() << " " << name() << ":" << nl
73 << " dumping every outputTime :";
74 forAllConstIter(HashSet<word>, objectNames_, iter)
76 Info<< ' ' << iter.key();
79 << " dumping all other fields every "
80 << writeInterval_ << "th outputTime" << nl
83 if (writeInterval_ < 1)
85 FatalIOErrorIn("partialWrite::read(const dictionary&)", dict)
86 << "Illegal value for writeInterval " << writeInterval_
87 << ". It should be >= 1."
88 << exit(FatalIOError);
93 void Foam::partialWrite::execute()
95 //Pout<< "execute at time " << obr_.time().timeName()
96 // << " index:" << obr_.time().timeIndex() << endl;
100 void Foam::partialWrite::end()
102 //Pout<< "end at time " << obr_.time().timeName() << endl;
103 // Do nothing - only valid on write
107 void Foam::partialWrite::write()
109 //Pout<< "write at time " << obr_.time().timeName() << endl;
110 if (obr_.time().outputTime())
112 // Above check so it can be used both with
113 // outputControl timeStep;
116 // outputControl outputTime;
120 if (writeInstance_ == writeInterval_)
127 // Delete all but marked objects
129 if (isA<polyMesh>(obr_))
131 dbDir = dynamic_cast<const polyMesh&>(obr_).dbDir();
134 IOobjectList objects(obr_, obr_.time().timeName());
138 Pout<< "For region:" << obr_.name() << endl;
141 forAllConstIter(IOobjectList, objects, iter)
143 if (!objectNames_.found(iter()->name()))
146 obr_.time().timePath()
151 Pout<< " rm " << f << endl;
157 // Do the lagrangian files as well.
158 fileNameList cloudDirs
162 obr_.time().timePath()/dbDir/cloud::prefix,
170 Pout<< "For cloud:" << cloudDirs[i] << endl;
173 IOobjectList sprayObjs
176 obr_.time().timeName(),
177 cloud::prefix/cloudDirs[i]
179 forAllConstIter(IOobjectList, sprayObjs, iter)
181 if (!objectNames_.found(iter()->name()))
184 obr_.time().timePath()
191 Pout<< " rm " << f << endl;
202 // ************************************************************************* //