FreeFOAM The Cross-Platform CFD Toolkit
buoyantPressureFvPatchScalarField.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) 1991-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 
29 #include <finiteVolume/volFields.H>
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 
37 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
38 
41 (
42  const fvPatch& p,
44 )
45 :
46  fixedGradientFvPatchScalarField(p, iF),
47  rhoName_("rho")
48 {}
49 
50 
53 (
54  const fvPatch& p,
56  const dictionary& dict
57 )
58 :
59  fixedGradientFvPatchScalarField(p, iF),
60  rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
61 {
62  fvPatchField<scalar>::operator=(patchInternalField());
63  gradient() = 0.0;
64 }
65 
66 
69 (
71  const fvPatch& p,
73  const fvPatchFieldMapper& mapper
74 )
75 :
76  fixedGradientFvPatchScalarField(ptf, p, iF, mapper),
77  rhoName_(ptf.rhoName_)
78 {}
79 
80 
83 (
85 )
86 :
87  fixedGradientFvPatchScalarField(ptf),
88  rhoName_(ptf.rhoName_)
89 {}
90 
91 
94 (
97 )
98 :
99  fixedGradientFvPatchScalarField(ptf, iF),
100  rhoName_(ptf.rhoName_)
101 {}
102 
103 
104 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
105 
107 {
108  if (updated())
109  {
110  return;
111  }
112 
114  db().lookupObject<uniformDimensionedVectorField>("g");
115 
116  const fvPatchField<scalar>& rho =
117  patch().lookupPatchField<volScalarField, scalar>(rhoName_);
118 
119  // If the variable name is "p_rgh", "ph_rgh" or "pd"
120  // assume it is p? - rho*g.h and set the gradient appropriately.
121  // Otherwise assume the variable is the static pressure.
122  if
123  (
124  dimensionedInternalField().name() == "p_rgh"
125  || dimensionedInternalField().name() == "ph_rgh"
126  || dimensionedInternalField().name() == "pd"
127  )
128  {
129  gradient() = -rho.snGrad()*(g.value() & patch().Cf());
130  }
131  else
132  {
133  gradient() = rho*(g.value() & patch().nf());
134  }
135 
137 }
138 
139 
141 {
143  os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
144  writeEntry("value", os);
145 }
146 
147 
148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
149 
151 (
154 );
155 
156 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
157 
158 } // End namespace Foam
159 
160 // ************************ vim: set sw=4 sts=4 et: ************************ //