initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / postProcessing / functionObjects / utilities / staticPressure / staticPressure.C
blobb746987f3c17ed9ad2789622cc0ea2c56c29fd0b
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2009-2009 OpenCFD Ltd.
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 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
19     for more details.
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
25 \*---------------------------------------------------------------------------*/
27 #include "staticPressure.H"
28 #include "volFields.H"
29 #include "dictionary.H"
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 namespace Foam
35     defineTypeNameAndDebug(staticPressure, 0);
38 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
40 bool Foam::staticPressure::isKinematicPressure()
42     const volScalarField& p = obr_.lookupObject<volScalarField>(pName_);
44     return p.dimensions() == sqr(dimLength)/sqr(dimTime);
48 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
50 Foam::staticPressure::staticPressure
52     const word& name,
53     const objectRegistry& obr,
54     const dictionary& dict,
55     const bool loadFromFiles
58     name_(name),
59     obr_(obr),
60     active_(true),
61     pName_(dict.lookupOrDefault<word>("p", "p")),
62     rho_(readScalar(dict.lookup("rho")))
64     // Check if the available mesh is an fvMesh, otherwise deactivate
65     if (!isA<fvMesh>(obr_))
66     {
67         active_ = false;
68         WarningIn
69         (
70             "staticPressure::staticPressure"
71             "(const objectRegistry&, const dictionary&)"
72         )   << "No fvMesh available, deactivating." << nl
73             << endl;
74     }
75     else
76     {
77         // Check if the pressure is kinematic pressure, otherwise deactivate
78         if (!isKinematicPressure())
79         {
80             active_ = false;
81             WarningIn
82             (
83                 "staticPressure::staticPressure"
84                 "(const objectRegistry&, const dictionary&)"
85             )   << "Pressure is not kinematic pressure, deactivating." << nl
86                 << endl;
87         }
88     }
90     read(dict);
94 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
96 Foam::staticPressure::~staticPressure()
100 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
102 void Foam::staticPressure::read(const dictionary& dict)
104     if (active_)
105     {
106         dict.readIfPresent("p", pName_);
107         dict.lookup("rho") >> rho_;
108     }
112 void Foam::staticPressure::execute()
114     // Do nothing - only valid on write
118 void Foam::staticPressure::end()
120     // Do nothing - only valid on write
124 void Foam::staticPressure::write()
126     if (active_)
127     {
128         const volScalarField& p = obr_.lookupObject<volScalarField>(pName_);
130         volScalarField pStatic
131         (
132             IOobject
133             (
134                 "pStatic",
135                 obr_.time().timeName(),
136                 obr_,
137                 IOobject::NO_READ
138             ),
139             dimensionedScalar("rho", dimDensity, rho_)*p
140         );
142         pStatic.write();
143     }
147 // ************************************************************************* //