FreeFOAM The Cross-Platform CFD Toolkit
fixedFluxPressureFvPatchScalarField.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 
28 #include <finiteVolume/volFields.H>
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
35 (
36  const fvPatch& p,
38 )
39 :
40  fixedGradientFvPatchScalarField(p, iF),
41  UName_("U"),
42  phiName_("phi"),
43  rhoName_("rho"),
44  adjoint_(false)
45 {}
46 
47 
49 (
51  const fvPatch& p,
53  const fvPatchFieldMapper& mapper
54 )
55 :
56  fixedGradientFvPatchScalarField(ptf, p, iF, mapper),
57  UName_(ptf.UName_),
58  phiName_(ptf.phiName_),
59  rhoName_(ptf.rhoName_),
60  adjoint_(ptf.adjoint_)
61 {}
62 
63 
65 (
66  const fvPatch& p,
68  const dictionary& dict
69 )
70 :
71  fixedGradientFvPatchScalarField(p, iF),
72  UName_(dict.lookupOrDefault<word>("U", "U")),
73  phiName_(dict.lookupOrDefault<word>("phi", "phi")),
74  rhoName_(dict.lookupOrDefault<word>("rho", "rho")),
75  adjoint_(dict.lookup("adjoint"))
76 {
77  if (dict.found("gradient"))
78  {
79  gradient() = scalarField("gradient", dict, p.size());
80  fixedGradientFvPatchScalarField::updateCoeffs();
81  fixedGradientFvPatchScalarField::evaluate();
82  }
83  else
84  {
85  fvPatchField<scalar>::operator=(patchInternalField());
86  gradient() = 0.0;
87  }
88 }
89 
90 
92 (
94 )
95 :
96  fixedGradientFvPatchScalarField(wbppsf),
97  UName_(wbppsf.UName_),
98  phiName_(wbppsf.phiName_),
99  rhoName_(wbppsf.rhoName_),
100  adjoint_(wbppsf.adjoint_)
101 {}
102 
103 
105 (
108 )
109 :
110  fixedGradientFvPatchScalarField(wbppsf, iF),
111  UName_(wbppsf.UName_),
112  phiName_(wbppsf.phiName_),
113  rhoName_(wbppsf.rhoName_),
114  adjoint_(wbppsf.adjoint_)
115 {}
116 
117 
118 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
119 
121 {
122  if (updated())
123  {
124  return;
125  }
126 
127  const fvPatchField<vector>& Up =
128  patch().lookupPatchField<volVectorField, vector>(UName_);
129 
130  const surfaceScalarField& phi =
131  db().lookupObject<surfaceScalarField>(phiName_);
132 
133  fvsPatchField<scalar> phip =
134  patch().patchField<surfaceScalarField, scalar>(phi);
135 
136  if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
137  {
138  const fvPatchField<scalar>& rhop =
139  patch().lookupPatchField<volScalarField, scalar>(rhoName_);
140 
141  phip /= rhop;
142  }
143 
144  const fvPatchField<scalar>& rAp =
145  patch().lookupPatchField<volScalarField, scalar>("(1|A("+UName_+"))");
146 
147  if (adjoint_)
148  {
149  gradient() = ((patch().Sf() & Up) - phip)/patch().magSf()/rAp;
150  }
151  else
152  {
153  gradient() = (phip - (patch().Sf() & Up))/patch().magSf()/rAp;
154  }
155 
157 }
158 
159 
161 {
163  if (UName_ != "U")
164  {
165  os.writeKeyword("U") << UName_ << token::END_STATEMENT << nl;
166  }
167  if (phiName_ != "phi")
168  {
169  os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
170  }
171  if (rhoName_ != "rho")
172  {
173  os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
174  }
175  os.writeKeyword("adjoint") << adjoint_ << token::END_STATEMENT << nl;
176  gradient().writeEntry("gradient", os);
177 }
178 
179 
180 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
181 
182 namespace Foam
183 {
185  (
188  );
189 }
190 
191 // ************************ vim: set sw=4 sts=4 et: ************************ //