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 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() = vector::zero;
50  refGrad() = vector::zero;
51  valueFraction() = symmTensor::zero;
52 }
53 
54 
57 (
59  const fvPatch& p,
61  const fvPatchFieldMapper& mapper
62 )
63 :
64  directionMixedFvPatchVectorField(ptf, p, iF, mapper),
65  phiName_(ptf.phiName_),
66  fixTangentialInflow_(ptf.fixTangentialInflow_),
67  normalVelocity_
68  (
69  fvPatchVectorField::New(ptf.normalVelocity(), p, iF, mapper)
70  )
71 {}
72 
73 
76 (
77  const fvPatch& p,
79  const dictionary& dict
80 )
81 :
82  directionMixedFvPatchVectorField(p, iF),
83  phiName_(dict.lookupOrDefault<word>("phi", "phi")),
84  fixTangentialInflow_(dict.lookup("fixTangentialInflow")),
85  normalVelocity_
86  (
87  fvPatchVectorField::New(p, iF, dict.subDict("normalVelocity"))
88  )
89 {
90  fvPatchVectorField::operator=(vectorField("value", dict, p.size()));
91  refValue() = normalVelocity();
92  refGrad() = vector::zero;
93  valueFraction() = symmTensor::zero;
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 // ************************************************************************* //
virtual void operator=(const UList< Type > &)
Definition: fvPatchField.C:387
fixedNormalInletOutletVelocityFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Construct from patch and internal field.
Foam::surfaceFields.
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
dimensionedScalar neg(const dimensionedScalar &ds)
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:221
static const sphericalTensor I(1)
A class for handling words, derived from string.
Definition: word.H:59
Foam::fvPatchFieldMapper.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:638
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:354
Namespace for OpenFOAM.
autoPtr< BasicCompressibleTurbulenceModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleTurbulenceModel::transportModel &transport, const word &propertiesName)
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:228
static const char nl
Definition: Ostream.H:260
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:235
volVectorField vectorField(fieldObject, mesh)
volScalarField & p
Definition: createFields.H:51
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:465
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
virtual void rmap(const fvPatchVectorField &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
const fvPatchVectorField & normalVelocity() const
Return the BC which provides the normal component of velocity.
Macros for easy insertion into run-time selection tables.
This velocity inlet/outlet boundary condition combines a fixed normal component obtained from the "no...
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:65
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:452
virtual tmp< fvPatchField< Type > > clone() const
Construct and return a clone.
Definition: fvPatchField.H:206
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
makePatchTypeField(fvPatchVectorField, SRFFreestreamVelocityFvPatchVectorField)
dimensionedSymmTensor sqr(const dimensionedVector &dv)
virtual label size() const
Return size.
Definition: fvPatch.H:161
A class for managing temporary objects.
Definition: PtrList.H:118
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:65