1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 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, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 Hrvoje Jasak, Wikki Ltd. All rights reserved
28 \*---------------------------------------------------------------------------*/
30 #include "minMaxField.H"
31 #include "addToRunTimeSelectionTable.H"
32 #include "volFields.H"
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
38 defineTypeNameAndDebug(minMaxField, 0);
40 addToRunTimeSelectionTable
49 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
52 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
54 Foam::minMaxField::minMaxField
58 const dictionary& dict
63 regionName_(polyMesh::defaultRegion),
64 fieldName_(dict.lookup("name"))
66 if (dict.found("region"))
68 dict.lookup("region") >> regionName_;
71 Info<< "Creating minMaxField for field "
72 << fieldName_ << endl;
76 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
78 bool Foam::minMaxField::start()
84 bool Foam::minMaxField::execute()
87 time_.lookupObject<fvMesh>(regionName_);
89 if (mesh.foundObject<volScalarField>(fieldName_))
91 const volScalarField& f = mesh.lookupObject<volScalarField>
96 Info<< "Field " << fieldName_ << " min = " << Foam::min(f).value()
97 << " max = " << Foam::max(f).value() << endl;
101 else if (mesh.foundObject<volVectorField>(fieldName_))
103 const volVectorField& f = mesh.lookupObject<volVectorField>(fieldName_);
105 volScalarField magF = mag(f);
107 Info<< "Field " << fieldName_ << " magnitude min = "
108 << Foam::min(magF).value()
109 << " max = " << Foam::max(magF).value() << endl;
115 Info<< "Field " << fieldName_ << " not found. Skipping." << endl;
122 bool Foam::minMaxField::read(const dictionary& dict)
124 fieldName_ = word(dict.lookup("name"));
126 if (dict.found("region"))
128 dict.lookup("region") >> regionName_;
134 // ************************************************************************* //