FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "fieldMinMax.H"
00027 #include <finiteVolume/volFields.H>
00028 #include <OpenFOAM/dictionary.H>
00029 #include <OpenFOAM/Time.H>
00030 
00031 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00032 
00033 template<class Type>
00034 void Foam::fieldMinMax::calcMinMaxFields(const word& fieldName)
00035 {
00036     typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
00037 
00038     if (obr_.foundObject<fieldType>(fieldName))
00039     {
00040         const fieldType& field = obr_.lookupObject<fieldType>(fieldName);
00041         switch (mode_)
00042         {
00043             case mdMag:
00044             {
00045                 scalar minValue = min(mag(field)).value();
00046                 scalar maxValue = max(mag(field)).value();
00047 
00048                 if (Pstream::master())
00049                 {
00050                     fieldMinMaxFilePtr_() << obr_.time().value() << tab
00051                         << fieldName << tab << minValue << tab << maxValue
00052                         << endl;
00053 
00054                     if (log_)
00055                     {
00056                         Info<< "fieldMinMax output:" << nl
00057                             << "    min(mag(" << fieldName << ")) = "
00058                             << minValue << nl
00059                             << "    max(mag(" << fieldName << ")) = "
00060                             << maxValue << nl
00061                             << endl;
00062                     }
00063                 }
00064                 break;
00065             }
00066             case mdCmpt:
00067             {
00068                 Type minValue = min(field).value();
00069                 Type maxValue = max(field).value();
00070 
00071                 if (Pstream::master())
00072                 {
00073                     fieldMinMaxFilePtr_() << obr_.time().value() << tab
00074                         << fieldName << tab << minValue << tab << maxValue
00075                         << endl;
00076 
00077                     if (log_)
00078                     {
00079                         Info<< "fieldMinMax output:" << nl
00080                             << "    cmptMin(" << fieldName << ") = "
00081                             << minValue << nl
00082                             << "    cmptMax(" << fieldName << ") = "
00083                             << maxValue << nl
00084                             << endl;
00085                     }
00086                 }
00087                 break;
00088             }
00089             default:
00090             {
00091                 FatalErrorIn
00092                 (
00093                     "Foam::fieldMinMax::calcMinMaxFields"
00094                     "(const word& fieldName)"
00095                 )<< "Unknown min/max mode: " << modeTypeNames_[mode_]
00096                  << exit(FatalError);
00097             }
00098         }
00099     }
00100 }
00101 
00102 
00103 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines