OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

outputFilterOutputControl.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "outputFilterOutputControl.H"
00028 
00029 // * * * * * * * * * * * * * Static Member Data  * * * * * * * * * * * * * * //
00030 
00031 template<>
00032 const char* Foam::NamedEnum
00033 <
00034     Foam::outputFilterOutputControl::outputControls,
00035     2
00036 >::names[] =
00037 {
00038     "timeStep",
00039     "outputTime"
00040 };
00041 
00042 const Foam::NamedEnum<Foam::outputFilterOutputControl::outputControls, 2>
00043     Foam::outputFilterOutputControl::outputControlNames_;
00044 
00045 
00046 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00047 
00048 Foam::outputFilterOutputControl::outputFilterOutputControl
00049 (
00050     const Time& t,
00051     const dictionary& dict
00052 )
00053 :
00054     time_(t),
00055     outputControl_(ocTimeStep),
00056     outputInterval_(0)
00057 {
00058     read(dict);
00059 }
00060 
00061 
00062 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00063 
00064 Foam::outputFilterOutputControl::~outputFilterOutputControl()
00065 {}
00066 
00067 
00068 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00069 
00070 void Foam::outputFilterOutputControl::read(const dictionary& dict)
00071 {
00072     outputControl_ = outputControlNames_.read(dict.lookup("outputControl"));
00073 
00074     switch (outputControl_)
00075     {
00076         case ocTimeStep:
00077         {
00078             dict.lookup("outputInterval") >> outputInterval_;
00079         }
00080         default:
00081         {
00082             // do nothing
00083         }
00084     }
00085 }
00086 
00087 
00088 bool Foam::outputFilterOutputControl::output() const
00089 {
00090     switch (outputControl_)
00091     {
00092         case ocTimeStep:
00093         {
00094             return
00095             (
00096                 (outputInterval_ <= 1)
00097              || !(time_.timeIndex() % outputInterval_)
00098             );
00099             break;
00100         }
00101         case ocOutputTime:
00102         {
00103             return time_.outputTime();
00104             break;
00105         }
00106         default:
00107         {
00108             FatalErrorIn("bool Foam::outputFilterOutputControl::output()")
00109                 << "Unknown output control: "
00110                 << outputControlNames_[outputControl_] << nl
00111                 << abort(FatalError);
00112         }
00113     }
00114 
00115     return false;
00116 }
00117 
00118 
00119 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd