fanFvPatchFields.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) 2011-2015 OpenFOAM Foundation
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 "fanFvPatchFields.H"
28 #include "volFields.H"
29 #include "surfaceFields.H"
30 #include "Tuple2.H"
31 #include "PolynomialEntry.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
38  (
40  fanFvPatchScalarField
41  );
42 }
43 
44 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
45 
46 template<>
48 {
49  if (this->cyclicPatch().owner())
50  {
51  const surfaceScalarField& phi =
52  db().lookupObject<surfaceScalarField>(phiName_);
53 
54  const fvsPatchField<scalar>& phip =
55  patch().patchField<surfaceScalarField, scalar>(phi);
56 
57  scalarField Un(max(phip/patch().magSf(), scalar(0)));
58 
59  if (phi.dimensions() == dimDensity*dimVelocity*dimArea)
60  {
61  Un /= patch().lookupPatchField<volScalarField, scalar>(rhoName_);
62  }
63 
64  this->jump_ = max(this->jumpTable_->value(Un), scalar(0));
65  }
66 }
67 
68 
69 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
70 
71 template<>
73 (
74  const fvPatch& p,
76  const dictionary& dict
77 )
78 :
80  phiName_(dict.lookupOrDefault<word>("phi", "phi")),
81  rhoName_(dict.lookupOrDefault<word>("rho", "rho"))
82 {
83  if (this->cyclicPatch().owner())
84  {
85  if (dict.found("f"))
86  {
87  // Backwards compatibility
88  Istream& is = dict.lookup("f");
90  scalarList f(is);
91 
92  label nPows = 0;
93  forAll(f, powI)
94  {
95  if (mag(f[powI]) > VSMALL)
96  {
97  nPows++;
98  }
99  }
100  List<Tuple2<scalar, scalar> > coeffs(nPows);
101  nPows = 0;
102  forAll(f, powI)
103  {
104  if (mag(f[powI]) > VSMALL)
105  {
106  coeffs[nPows++] = Tuple2<scalar, scalar>(f[powI], powI);
107  }
108  }
109 
110  this->jumpTable_.reset
111  (
112  new PolynomialEntry<scalar>("jumpTable", coeffs)
113  );
114  }
115  else
116  {
117  // Generic input constructed from dictionary
118  this->jumpTable_ = DataEntry<scalar>::New("jumpTable", dict);
119  }
120  }
121 
122  if (dict.found("value"))
123  {
125  (
126  scalarField("value", dict, p.size())
127  );
128  }
129  else
130  {
131  this->evaluate(Pstream::blocking);
132  }
133 }
134 
135 
136 // ************************************************************************* //
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:306
A 2-tuple for storing two objects of different types.
Definition: Tuple2.H:47
Foam::surfaceFields.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
fanFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
dimensioned< scalar > mag(const dimensioned< Type > &)
labelList f(nPoints)
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
const dimensionSet dimArea(sqr(dimLength))
Definition: dimensionSets.H:57
A class for handling words, derived from string.
Definition: word.H:59
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
void size(const label)
Override size to be inconsistent with allocated storage.
const dimensionSet dimDensity
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
This boundary condition provides a jump condition, using the cyclic condition as a base...
Namespace for OpenFOAM.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
makeTemplatePatchTypeField(fvPatchScalarField, fanFvPatchScalarField)
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:52
volScalarField & p
Definition: createFields.H:51
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define forAll(list, i)
Definition: UList.H:421
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
streamFormat format() const
Return current stream format.
Definition: IOstream.H:377
Macros for easy insertion into run-time selection tables.
fvPatchField< scalar > fvPatchScalarField
surfaceScalarField & phi
PolynomialEntry container data entry for scalars. Items are stored in a list of Tuple2&#39;s. Data is input in the form, e.g. for an entry <entryName> that describes y = x^2 + 2x^3.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:452
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
static autoPtr< DataEntry< Type > > New(const word &entryName, const dictionary &dict)
Selector.
Definition: DataEntryNew.C:32
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
This boundary condition provides a jump condition, using the cyclic condition as a base...
const dimensionSet dimVelocity
friend Ostream & operator(Ostream &, const fvPatchField< Type > &)