FreeFOAM The Cross-Platform CFD Toolkit
staticPressure.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
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.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "staticPressure.H"
27 #include <finiteVolume/volFields.H>
28 #include <OpenFOAM/dictionary.H>
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34  defineTypeNameAndDebug(staticPressure, 0);
35 }
36 
37 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
38 
39 bool Foam::staticPressure::isKinematicPressure()
40 {
41  const volScalarField& p = obr_.lookupObject<volScalarField>(pName_);
42 
43  return p.dimensions() == sqr(dimLength)/sqr(dimTime);
44 }
45 
46 
47 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48 
49 Foam::staticPressure::staticPressure
50 (
51  const word& name,
52  const objectRegistry& obr,
53  const dictionary& dict,
54  const bool loadFromFiles
55 )
56 :
57  name_(name),
58  obr_(obr),
59  active_(true),
60  pName_(dict.lookupOrDefault<word>("p", "p")),
61  rho_(readScalar(dict.lookup("rho")))
62 {
63  // Check if the available mesh is an fvMesh, otherwise deactivate
64  if (!isA<fvMesh>(obr_))
65  {
66  active_ = false;
67  WarningIn
68  (
69  "staticPressure::staticPressure"
70  "(const objectRegistry&, const dictionary&)"
71  ) << "No fvMesh available, deactivating." << nl
72  << endl;
73  }
74  else
75  {
76  // Check if the pressure is kinematic pressure, otherwise deactivate
77  if (!isKinematicPressure())
78  {
79  active_ = false;
80  WarningIn
81  (
82  "staticPressure::staticPressure"
83  "(const objectRegistry&, const dictionary&)"
84  ) << "Pressure is not kinematic pressure, deactivating." << nl
85  << endl;
86  }
87  }
88 
89  read(dict);
90 }
91 
92 
93 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
94 
96 {}
97 
98 
99 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
100 
102 {
103  if (active_)
104  {
105  dict.readIfPresent("p", pName_);
106  dict.lookup("rho") >> rho_;
107  }
108 }
109 
110 
112 {
113  // Do nothing - only valid on write
114 }
115 
116 
118 {
119  // Do nothing - only valid on write
120 }
121 
122 
124 {
125  if (active_)
126  {
127  const volScalarField& p = obr_.lookupObject<volScalarField>(pName_);
128 
129  volScalarField pStatic
130  (
131  IOobject
132  (
133  "pStatic",
134  obr_.time().timeName(),
135  obr_,
137  ),
138  dimensionedScalar("rho", dimDensity, rho_)*p
139  );
140 
141  pStatic.write();
142  }
143 }
144 
145 
146 // ************************ vim: set sw=4 sts=4 et: ************************ //