BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / postProcessing / functionObjects / utilities / timeActivatedFileUpdate / timeActivatedFileUpdate.C
blob31a583624fac1a46e03b84bebde7726018a9db2a
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 "timeActivatedFileUpdate.H"
27 #include "objectRegistry.H"
28 #include "Time.H"
29 #include "dictionary.H"
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 defineTypeNameAndDebug(Foam::timeActivatedFileUpdate, 0);
36 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
38 void Foam::timeActivatedFileUpdate::updateFile()
40     label i = lastIndex_;
41     while
42     (
43         i < timeVsFile_.size()-1
44      && timeVsFile_[i+1].first() < obr_.time().value()
45     )
46     {
47         i++;
48     }
50     if (i > lastIndex_)
51     {
52         Info<< nl << type() << ": copying file" << nl << timeVsFile_[i].second()
53             << nl << "to:" << nl << fileToUpdate_ << nl << endl;
55         cp(timeVsFile_[i].second(), fileToUpdate_);
56         lastIndex_ = i;
57     }
61 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
63 Foam::timeActivatedFileUpdate::timeActivatedFileUpdate
65     const word& name,
66     const objectRegistry& obr,
67     const dictionary& dict,
68     const bool loadFromFiles
71     name_(name),
72     obr_(obr),
73     active_(true),
74     fileToUpdate_(dict.lookup("fileToUpdate")),
75     timeVsFile_(),
76     lastIndex_(-1)
78     read(dict);
82 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
84 Foam::timeActivatedFileUpdate::~timeActivatedFileUpdate()
88 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
90 void Foam::timeActivatedFileUpdate::read(const dictionary& dict)
92     if (active_)
93     {
94         dict.lookup("fileToUpdate") >> fileToUpdate_;
95         dict.lookup("timeVsFile") >> timeVsFile_;
97         lastIndex_ = -1;
98         fileToUpdate_.expand();
100         Info<< type() << ": time vs file list:" << nl;
101         forAll(timeVsFile_, i)
102         {
103             timeVsFile_[i].second() = timeVsFile_[i].second().expand();
104             if (!isFile(timeVsFile_[i].second()))
105             {
106                 FatalErrorIn("timeActivatedFileUpdate::read(const dictionary&)")
107                     << "File: " << timeVsFile_[i].second() << " not found"
108                     << nl << exit(FatalError);
109             }
111             Info<< "    " << timeVsFile_[i].first() << tab
112                 << timeVsFile_[i].second() << endl;
113         }
114         Info<< endl;
116         updateFile();
117     }
121 void Foam::timeActivatedFileUpdate::execute()
123     if (active_)
124     {
125         updateFile();
126     }
130 void Foam::timeActivatedFileUpdate::end()
132     // Do nothing
136 void Foam::timeActivatedFileUpdate::write()
138     // Do nothing
142 // ************************************************************************* //