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

fieldMinMaxTemplates.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) 2008-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 "fieldMinMax.H"
00028 #include "volFields.H"
00029 #include "dictionary.H"
00030 #include "Time.H"
00031 
00032 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00033 
00034 template<class Type>
00035 void Foam::fieldMinMax::calcMinMaxFields(const word& fieldName)
00036 {
00037     typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
00038 
00039     if (obr_.foundObject<fieldType>(fieldName))
00040     {
00041         if (Pstream::master())
00042         {
00043             const fieldType& field = obr_.lookupObject<fieldType>(fieldName);
00044             switch (mode_)
00045             {
00046                 case mdMag:
00047                 {
00048                     scalar minValue = min(mag(field)).value();
00049                     scalar maxValue = max(mag(field)).value();
00050 
00051                     fieldMinMaxFilePtr_() << obr_.time().value() << tab
00052                         << fieldName << tab << minValue << tab << maxValue
00053                         << endl;
00054 
00055                     if (log_)
00056                     {
00057                         Info<< "fieldMinMax output:" << nl
00058                             << "    min(mag(" << fieldName << ")) = "
00059                             << minValue << nl
00060                             << "    max(mag(" << fieldName << ")) = "
00061                             << maxValue << nl
00062                             << endl;
00063                     }
00064                     break;
00065                 }
00066                 case mdCmpt:
00067                 {
00068                     Type minValue = min(field).value();
00069                     Type maxValue = max(field).value();
00070 
00071                     fieldMinMaxFilePtr_() << obr_.time().value() << tab
00072                         << fieldName << tab << minValue << tab << maxValue
00073                         << endl;
00074 
00075                     if (log_)
00076                     {
00077                         Info<< "fieldMinMax output:" << nl
00078                             << "    cmptMin(" << fieldName << ") = "
00079                             << minValue << nl
00080                             << "    cmptMax(" << fieldName << ") = "
00081                             << maxValue << nl
00082                             << endl;
00083                     }
00084                     break;
00085                 }
00086                 default:
00087                 {
00088                     FatalErrorIn
00089                     (
00090                         "Foam::fieldMinMax::calcMinMaxFields"
00091                         "(const word& fieldName)"
00092                     )<< "Unknown min/max mode: " << modeTypeNames_[mode_]
00093                      << exit(FatalError);
00094                 }
00095             }
00096         }
00097     }
00098 }
00099 
00100 
00101 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd