fixedNormalInletOutletVelocityFvPatchVectorField.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) 2014-2016 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 
28 #include "volFields.H"
29 #include "surfaceFields.H"
30 
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
36 (
37  const fvPatch& p,
39 )
40 :
41  directionMixedFvPatchVectorField(p, iF),
42  phiName_("phi"),
43  fixTangentialInflow_(true),
44  normalVelocity_
45  (
46  fvPatchVectorField::New("fixedValue", p, iF)
47  )
48 {
49  refValue() = Zero;
50  refGrad() = Zero;
51  valueFraction() = Zero;
52 }
53 
54 
57 (
58  const fvPatch& p,
60  const dictionary& dict
61 )
62 :
63  directionMixedFvPatchVectorField(p, iF),
64  phiName_(dict.lookupOrDefault<word>("phi", "phi")),
65  fixTangentialInflow_(dict.lookup("fixTangentialInflow")),
66  normalVelocity_
67  (
68  fvPatchVectorField::New(p, iF, dict.subDict("normalVelocity"))
69  )
70 {
71  fvPatchVectorField::operator=(vectorField("value", dict, p.size()));
72  refValue() = normalVelocity();
73  refGrad() = Zero;
74  valueFraction() = Zero;
75 }
76 
77 
80 (
82  const fvPatch& p,
84  const fvPatchFieldMapper& mapper
85 )
86 :
87  directionMixedFvPatchVectorField(ptf, p, iF, mapper),
88  phiName_(ptf.phiName_),
89  fixTangentialInflow_(ptf.fixTangentialInflow_),
90  normalVelocity_
91  (
92  fvPatchVectorField::New(ptf.normalVelocity(), p, iF, mapper)
93  )
94 {}
95 
96 
99 (
101 )
102 :
103  directionMixedFvPatchVectorField(pivpvf),
104  phiName_(pivpvf.phiName_),
105  fixTangentialInflow_(pivpvf.fixTangentialInflow_),
106  normalVelocity_(pivpvf.normalVelocity().clone())
107 {}
108 
109 
112 (
115 )
116 :
117  directionMixedFvPatchVectorField(pivpvf, iF),
118  phiName_(pivpvf.phiName_),
119  fixTangentialInflow_(pivpvf.fixTangentialInflow_),
120  normalVelocity_(pivpvf.normalVelocity().clone())
121 {}
122 
123 
124 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
125 
127 (
128  const fvPatchFieldMapper& m
129 )
130 {
131  directionMixedFvPatchVectorField::autoMap(m);
132  normalVelocity_->autoMap(m);
133 }
134 
135 
137 (
138  const fvPatchVectorField& ptf,
139  const labelList& addr
140 )
141 {
142  directionMixedFvPatchVectorField::rmap(ptf, addr);
143 
145  refCast<const fixedNormalInletOutletVelocityFvPatchVectorField>(ptf);
146 
147  normalVelocity_->rmap(fniovptf.normalVelocity(), addr);
148 }
149 
150 
152 {
153  if (updated())
154  {
155  return;
156  }
157 
158  normalVelocity_->evaluate();
159  refValue() = normalVelocity();
160 
161  valueFraction() = sqr(patch().nf());
162 
163  if (fixTangentialInflow_)
164  {
165  const fvsPatchField<scalar>& phip =
166  patch().lookupPatchField<surfaceScalarField, scalar>(phiName_);
167 
168  valueFraction() += neg(phip)*(I - valueFraction());
169  }
170 
171  directionMixedFvPatchVectorField::updateCoeffs();
172  directionMixedFvPatchVectorField::evaluate();
173 }
174 
175 
177 (
178  Ostream& os
179 )
180 const
181 {
183  writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
184  os.writeKeyword("fixTangentialInflow")
185  << fixTangentialInflow_ << token::END_STATEMENT << nl;
186  os.writeKeyword("normalVelocity")
187  << nl << indent << token::BEGIN_BLOCK << nl << incrIndent;
188  normalVelocity_->write(os);
189  os << decrIndent << indent << token::END_BLOCK << endl;
190  writeEntry("value", os);
191 }
192 
193 
194 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
195 
196 void Foam::fixedNormalInletOutletVelocityFvPatchVectorField::operator=
197 (
198  const fvPatchField<vector>& pvf
199 )
200 {
201  tmp<vectorField> normalValue = transform(valueFraction(), refValue());
202  tmp<vectorField> transformGradValue = transform(I - valueFraction(), pvf);
203  fvPatchField<vector>::operator=(normalValue + transformGradValue);
204 }
205 
206 
207 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
208 
209 namespace Foam
210 {
212  (
215  );
216 }
217 
218 // ************************************************************************* //
Foam::surfaceFields.
virtual void rmap(const fvPatchVectorField &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
const fvPatchVectorField & normalVelocity() const
Return the BC which provides the normal component of velocity.
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:223
This velocity inlet/outlet boundary condition combines a fixed normal component obtained from the "no...
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:66
volVectorField vectorField(fieldObject, mesh)
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:362
dimensionedScalar neg(const dimensionedScalar &ds)
Macros for easy insertion into run-time selection tables.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:692
makePatchTypeField(fvPatchVectorField, SRFFreestreamVelocityFvPatchVectorField)
static const Identity< scalar > I
Definition: Identity.H:93
A class for handling words, derived from string.
Definition: word.H:59
fixedNormalInletOutletVelocityFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Construct from patch and internal field.
Foam::fvPatchFieldMapper.
static const zero Zero
Definition: zero.H:91
virtual label size() const
Return size.
Definition: fvPatch.H:161
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
static const char nl
Definition: Ostream.H:262
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:237
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
virtual void operator=(const UList< Type > &)
Definition: fvPatchField.C:395
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
volScalarField & p
A class for managing temporary objects.
Definition: PtrList.H:53
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:230
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:65
Namespace for OpenFOAM.
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:477
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:576
virtual tmp< fvPatchField< Type > > clone() const
Construct and return a clone.
Definition: fvPatchField.H:219