1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2009-2009 OpenCFD Ltd.
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
25 \*---------------------------------------------------------------------------*/
27 #include "staticPressure.H"
28 #include "volFields.H"
29 #include "dictionary.H"
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
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
53 const objectRegistry& obr,
54 const dictionary& dict,
55 const bool loadFromFiles
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_))
70 "staticPressure::staticPressure"
71 "(const objectRegistry&, const dictionary&)"
72 ) << "No fvMesh available, deactivating." << nl
77 // Check if the pressure is kinematic pressure, otherwise deactivate
78 if (!isKinematicPressure())
83 "staticPressure::staticPressure"
84 "(const objectRegistry&, const dictionary&)"
85 ) << "Pressure is not kinematic pressure, deactivating." << nl
94 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
96 Foam::staticPressure::~staticPressure()
100 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
102 void Foam::staticPressure::read(const dictionary& dict)
106 dict.readIfPresent("p", pName_);
107 dict.lookup("rho") >> rho_;
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()
128 const volScalarField& p = obr_.lookupObject<volScalarField>(pName_);
130 volScalarField pStatic
135 obr_.time().timeName(),
139 dimensionedScalar("rho", dimDensity, rho_)*p
147 // ************************************************************************* //