FreeFOAM The Cross-Platform CFD Toolkit
fluxCorrectedVelocityFvPatchVectorField.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 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
35 
38 (
39  const fvPatch& p,
41 )
42 :
43  zeroGradientFvPatchVectorField(p, iF),
44  phiName_("phi"),
45  rhoName_("rho")
46 {}
47 
48 
51 (
53  const fvPatch& p,
55  const fvPatchFieldMapper& mapper
56 )
57 :
58  zeroGradientFvPatchVectorField(ptf, p, iF, mapper),
59  phiName_(ptf.phiName_),
60  rhoName_(ptf.rhoName_)
61 {}
62 
63 
66 (
67  const fvPatch& p,
69  const dictionary& dict
70 )
71 :
72  zeroGradientFvPatchVectorField(p, iF),
73  phiName_(dict.lookupOrDefault<word>("phi", "phi")),
74  rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
75 {
76  fvPatchVectorField::operator=(patchInternalField());
77 }
78 
79 
82 (
85 )
86 :
87  zeroGradientFvPatchVectorField(fcvpvf, iF),
88  phiName_(fcvpvf.phiName_),
89  rhoName_(fcvpvf.rhoName_)
90 {}
91 
92 
93 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
94 
96 (
98 )
99 {
100  if (!updated())
101  {
102  updateCoeffs();
103  }
104 
105  zeroGradientFvPatchVectorField::evaluate();
106 
107  const surfaceScalarField& phi =
108  db().lookupObject<surfaceScalarField>(phiName_);
109 
110  const fvsPatchField<scalar>& phip =
111  patch().patchField<surfaceScalarField, scalar>(phi);
112 
113  vectorField n = patch().nf();
114  const Field<scalar>& magS = patch().magSf();
115 
116  if (phi.dimensions() == dimVelocity*dimArea)
117  {
118  operator==(*this - n*(n & *this) + n*phip/magS);
119  }
120  else if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
121  {
122  const fvPatchField<scalar>& rhop =
123  patch().lookupPatchField<volScalarField, scalar>(rhoName_);
124 
125  operator==(*this - n*(n & *this) + n*phip/(rhop*magS));
126  }
127  else
128  {
130  (
131  "fluxCorrectedVelocityFvPatchVectorField::evaluate()"
132  )
133  << "dimensions of phi are incorrect\n"
134  << " on patch " << this->patch().name()
135  << " of field " << this->dimensionedInternalField().name()
136  << " in file " << this->dimensionedInternalField().objectPath()
137  << exit(FatalError);
138  }
139 }
140 
141 
143 {
145  if (phiName_ != "phi")
146  {
147  os.writeKeyword("phi") << phiName_ << token::END_STATEMENT << nl;
148  }
149  if (rhoName_ != "rho")
150  {
151  os.writeKeyword("rho") << rhoName_ << token::END_STATEMENT << nl;
152  }
153  writeEntry("value", os);
154 }
155 
156 
157 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
158 
159 namespace Foam
160 {
162  (
165  );
166 }
167 
168 // ************************ vim: set sw=4 sts=4 et: ************************ //