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 
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::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:65
volFields.H
Foam::fvPatchField::write
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:349
Foam::fvPatchField::operator=
virtual void operator=(const UList< Type > &)
Foam::token::END_STATEMENT
@ END_STATEMENT
Definition: token.H:99
p
p
Definition: pEqn.H:62
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::compressible::New
autoPtr< BasicCompressibleTurbulenceModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleTurbulenceModel::transportModel &transport, const word &propertiesName)
Definition: turbulentFluidThermoModel.C:36
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::fixedNormalInletOutletVelocityFvPatchVectorField::rmap
virtual void rmap(const fvPatchVectorField &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
Definition: fixedNormalInletOutletVelocityFvPatchVectorField.C:137
Foam::fvsPatchField
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:65
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
surfaceFields.H
Foam::surfaceFields.
Foam::incrIndent
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:228
Foam::transform
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:465
Foam::fixedNormalInletOutletVelocityFvPatchVectorField::phiName_
word phiName_
Flux field name.
Definition: fixedNormalInletOutletVelocityFvPatchVectorField.H:125
Foam::fixedNormalInletOutletVelocityFvPatchVectorField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: fixedNormalInletOutletVelocityFvPatchVectorField.C:151
Foam::fixedNormalInletOutletVelocityFvPatchVectorField::fixTangentialInflow_
Switch fixTangentialInflow_
Set true to fix the tangential component for inflow.
Definition: fixedNormalInletOutletVelocityFvPatchVectorField.H:128
Foam::Ostream::write
virtual Ostream & write(const token &)=0
Write next token to stream.
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
Foam::fixedNormalInletOutletVelocityFvPatchVectorField::normalVelocity_
tmp< fvPatchVectorField > normalVelocity_
BC which provided the normal component of the velocity.
Definition: fixedNormalInletOutletVelocityFvPatchVectorField.H:131
vectorField
volVectorField vectorField(fieldObject, mesh)
Foam::I
static const sphericalTensor I(1)
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::fixedNormalInletOutletVelocityFvPatchVectorField
This velocity inlet/outlet boundary condition combines a fixed normal component obtained from the "no...
Definition: fixedNormalInletOutletVelocityFvPatchVectorField.H:118
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::fixedNormalInletOutletVelocityFvPatchVectorField::write
virtual void write(Ostream &) const
Write.
Definition: fixedNormalInletOutletVelocityFvPatchVectorField.C:177
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::decrIndent
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:235
Foam::indent
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:221
Foam::makePatchTypeField
makePatchTypeField(fvPatchVectorField, SRFFreestreamVelocityFvPatchVectorField)
Foam::fixedNormalInletOutletVelocityFvPatchVectorField::autoMap
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: fixedNormalInletOutletVelocityFvPatchVectorField.C:127
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:49
Foam::surfaceScalarField
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
Definition: surfaceFieldsFwd.H:52
Foam::fixedNormalInletOutletVelocityFvPatchVectorField::fixedNormalInletOutletVelocityFvPatchVectorField
fixedNormalInletOutletVelocityFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Construct from patch and internal field.
Definition: fixedNormalInletOutletVelocityFvPatchVectorField.C:36
Foam::token::END_BLOCK
@ END_BLOCK
Definition: token.H:105
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::Ostream::writeKeyword
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:59
Foam::fvPatchField::clone
virtual tmp< fvPatchField< Type > > clone() const
Construct and return a clone.
Definition: fvPatchField.H:206
Foam::token::BEGIN_BLOCK
@ BEGIN_BLOCK
Definition: token.H:104
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:45
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
fixedNormalInletOutletVelocityFvPatchVectorField.H
Foam::neg
dimensionedScalar neg(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:201
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:51
Foam::fixedNormalInletOutletVelocityFvPatchVectorField::normalVelocity
const fvPatchVectorField & normalVelocity() const
Return the BC which provides the normal component of velocity.
Definition: fixedNormalInletOutletVelocityFvPatchVectorField.H:224