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

staticPressure.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) 2009-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 "staticPressure.H"
00027 #include <finiteVolume/volFields.H>
00028 #include <OpenFOAM/dictionary.H>
00029 
00030 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
00031 
00032 namespace Foam
00033 {
00034     defineTypeNameAndDebug(staticPressure, 0);
00035 }
00036 
00037 // * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
00038 
00039 bool Foam::staticPressure::isKinematicPressure()
00040 {
00041     const volScalarField& p = obr_.lookupObject<volScalarField>(pName_);
00042 
00043     return p.dimensions() == sqr(dimLength)/sqr(dimTime);
00044 }
00045 
00046 
00047 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00048 
00049 Foam::staticPressure::staticPressure
00050 (
00051     const word& name,
00052     const objectRegistry& obr,
00053     const dictionary& dict,
00054     const bool loadFromFiles
00055 )
00056 :
00057     name_(name),
00058     obr_(obr),
00059     active_(true),
00060     pName_(dict.lookupOrDefault<word>("p", "p")),
00061     rho_(readScalar(dict.lookup("rho")))
00062 {
00063     // Check if the available mesh is an fvMesh, otherwise deactivate
00064     if (!isA<fvMesh>(obr_))
00065     {
00066         active_ = false;
00067         WarningIn
00068         (
00069             "staticPressure::staticPressure"
00070             "(const objectRegistry&, const dictionary&)"
00071         )   << "No fvMesh available, deactivating." << nl
00072             << endl;
00073     }
00074     else
00075     {
00076         // Check if the pressure is kinematic pressure, otherwise deactivate
00077         if (!isKinematicPressure())
00078         {
00079             active_ = false;
00080             WarningIn
00081             (
00082                 "staticPressure::staticPressure"
00083                 "(const objectRegistry&, const dictionary&)"
00084             )   << "Pressure is not kinematic pressure, deactivating." << nl
00085                 << endl;
00086         }
00087     }
00088 
00089     read(dict);
00090 }
00091 
00092 
00093 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00094 
00095 Foam::staticPressure::~staticPressure()
00096 {}
00097 
00098 
00099 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00100 
00101 void Foam::staticPressure::read(const dictionary& dict)
00102 {
00103     if (active_)
00104     {
00105         dict.readIfPresent("p", pName_);
00106         dict.lookup("rho") >> rho_;
00107     }
00108 }
00109 
00110 
00111 void Foam::staticPressure::execute()
00112 {
00113     // Do nothing - only valid on write
00114 }
00115 
00116 
00117 void Foam::staticPressure::end()
00118 {
00119     // Do nothing - only valid on write
00120 }
00121 
00122 
00123 void Foam::staticPressure::write()
00124 {
00125     if (active_)
00126     {
00127         const volScalarField& p = obr_.lookupObject<volScalarField>(pName_);
00128 
00129         volScalarField pStatic
00130         (
00131             IOobject
00132             (
00133                 "pStatic",
00134                 obr_.time().timeName(),
00135                 obr_,
00136                 IOobject::NO_READ
00137             ),
00138             dimensionedScalar("rho", dimDensity, rho_)*p
00139         );
00140 
00141         pStatic.write();
00142     }
00143 }
00144 
00145 
00146 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines