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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2014-2016 OpenFOAM Foundation
9  Copyright (C) 2017-2020 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
31 #include "volFields.H"
32 #include "surfaceFields.H"
33 
34 
35 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
36 
39 (
40  const fvPatch& p,
42 )
43 :
44  directionMixedFvPatchVectorField(p, iF),
45  phiName_("phi"),
46  fixTangentialInflow_(true),
47  normalVelocity_
48  (
49  fvPatchVectorField::New("fixedValue", p, iF)
50  )
51 {
52  refValue() = Zero;
53  refGrad() = Zero;
54  valueFraction() = Zero;
55 }
56 
57 
60 (
61  const fvPatch& p,
63  const dictionary& dict
64 )
65 :
66  directionMixedFvPatchVectorField(p, iF),
67  phiName_(dict.getOrDefault<word>("phi", "phi")),
68  fixTangentialInflow_(dict.lookup("fixTangentialInflow")),
69  normalVelocity_
70  (
71  fvPatchVectorField::New(p, iF, dict.subDict("normalVelocity"))
72  )
73 {
74  patchType() = dict.getOrDefault<word>("patchType", word::null);
75  fvPatchVectorField::operator=(vectorField("value", dict, p.size()));
76  refValue() = normalVelocity();
77  refGrad() = Zero;
78  valueFraction() = Zero;
79 }
80 
81 
84 (
86  const fvPatch& p,
88  const fvPatchFieldMapper& mapper
89 )
90 :
91  directionMixedFvPatchVectorField(ptf, p, iF, mapper),
92  phiName_(ptf.phiName_),
93  fixTangentialInflow_(ptf.fixTangentialInflow_),
94  normalVelocity_
95  (
96  fvPatchVectorField::New(ptf.normalVelocity(), p, iF, mapper)
97  )
98 {}
99 
100 
103 (
105 )
106 :
107  directionMixedFvPatchVectorField(pivpvf),
108  phiName_(pivpvf.phiName_),
109  fixTangentialInflow_(pivpvf.fixTangentialInflow_),
110  normalVelocity_(pivpvf.normalVelocity().clone())
111 {}
112 
113 
116 (
119 )
120 :
121  directionMixedFvPatchVectorField(pivpvf, iF),
122  phiName_(pivpvf.phiName_),
123  fixTangentialInflow_(pivpvf.fixTangentialInflow_),
124  normalVelocity_(pivpvf.normalVelocity().clone())
125 {}
126 
127 
128 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
129 
131 (
132  const fvPatchFieldMapper& m
133 )
134 {
135  directionMixedFvPatchVectorField::autoMap(m);
136  normalVelocity_->autoMap(m);
137 }
138 
139 
141 (
142  const fvPatchVectorField& ptf,
143  const labelList& addr
144 )
145 {
146  directionMixedFvPatchVectorField::rmap(ptf, addr);
147 
149  refCast<const fixedNormalInletOutletVelocityFvPatchVectorField>(ptf);
150 
151  normalVelocity_->rmap(fniovptf.normalVelocity(), addr);
152 }
153 
154 
156 {
157  if (updated())
158  {
159  return;
160  }
161 
162  normalVelocity_->evaluate();
163  refValue() = normalVelocity();
164 
165  valueFraction() = sqr(patch().nf());
166 
168  {
169  const fvsPatchField<scalar>& phip =
170  patch().lookupPatchField<surfaceScalarField, scalar>(phiName_);
171 
172  valueFraction() += neg(phip)*(I - valueFraction());
173  }
174 
175  directionMixedFvPatchVectorField::updateCoeffs();
177 }
178 
179 
181 (
182  Ostream& os
183 )
184 const
185 {
187  os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
188  os.writeEntry("fixTangentialInflow", fixTangentialInflow_);
189 
190  os.beginBlock("normalVelocity");
191  normalVelocity_->write(os);
192  os.endBlock();
193 
194  writeEntry("value", os);
195 }
196 
197 
198 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
199 
200 void Foam::fixedNormalInletOutletVelocityFvPatchVectorField::operator=
201 (
202  const fvPatchField<vector>& pvf
203 )
204 {
205  tmp<vectorField> normalValue = transform(valueFraction(), refValue());
206  tmp<vectorField> transformGradValue = transform(I - valueFraction(), pvf);
207  fvPatchField<vector>::operator=(normalValue + transformGradValue);
208 }
209 
210 
211 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
212 
213 namespace Foam
214 {
216  (
219  );
220 }
221 
222 // ************************************************************************* //
Foam::fvPatchField< vector >
volFields.H
Foam::fvPatchField< vector >::write
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:384
Foam::Ostream::writeEntryIfDifferent
Ostream & writeEntryIfDifferent(const word &key, const T &value1, const T &value2)
Write a keyword/value entry only when the two values differ.
Definition: Ostream.H:248
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::fixedNormalInletOutletVelocityFvPatchVectorField::rmap
virtual void rmap(const fvPatchVectorField &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
Definition: fixedNormalInletOutletVelocityFvPatchVectorField.C:141
Foam::fvsPatchField
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:68
surfaceFields.H
Foam::surfaceFields.
Foam::Ostream::beginBlock
virtual Ostream & beginBlock(const keyType &kw)
Write begin block group with the given name.
Definition: Ostream.C:91
Foam::transform
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:521
Foam::vectorField
Field< vector > vectorField
Specialisation of Field<T> for vector.
Definition: primitiveFieldsFwd.H:54
Foam::fixedNormalInletOutletVelocityFvPatchVectorField::phiName_
word phiName_
Flux field name.
Definition: fixedNormalInletOutletVelocityFvPatchVectorField.H:133
Foam::fixedNormalInletOutletVelocityFvPatchVectorField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: fixedNormalInletOutletVelocityFvPatchVectorField.C:155
Foam::fixedNormalInletOutletVelocityFvPatchVectorField::fixTangentialInflow_
Switch fixTangentialInflow_
Set true to fix the tangential component for inflow.
Definition: fixedNormalInletOutletVelocityFvPatchVectorField.H:136
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
Foam::fixedNormalInletOutletVelocityFvPatchVectorField::normalVelocity_
tmp< fvPatchVectorField > normalVelocity_
BC which provided the normal component of the velocity.
Definition: fixedNormalInletOutletVelocityFvPatchVectorField.H:139
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::Ostream::endBlock
virtual Ostream & endBlock()
Write end block group.
Definition: Ostream.C:109
Foam::fixedNormalInletOutletVelocityFvPatchVectorField
This velocity inlet/outlet boundary condition combines a fixed normal component obtained from the "no...
Definition: fixedNormalInletOutletVelocityFvPatchVectorField.H:124
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::fixedNormalInletOutletVelocityFvPatchVectorField::write
virtual void write(Ostream &) const
Write.
Definition: fixedNormalInletOutletVelocityFvPatchVectorField.C:181
os
OBJstream os(runTime.globalPath()/outputName)
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::Ostream::write
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::fixedNormalInletOutletVelocityFvPatchVectorField::autoMap
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: fixedNormalInletOutletVelocityFvPatchVectorField.C:131
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:51
Foam::surfaceScalarField
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
Definition: surfaceFieldsFwd.H:54
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::fixedNormalInletOutletVelocityFvPatchVectorField::fixedNormalInletOutletVelocityFvPatchVectorField
fixedNormalInletOutletVelocityFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Construct from patch and internal field.
Definition: fixedNormalInletOutletVelocityFvPatchVectorField.C:39
Foam::List< label >
Foam::fvPatchField::clone
virtual tmp< fvPatchField< Type > > clone() const
Construct and return a clone.
Definition: fvPatchField.H:219
Foam::Ostream::writeEntry
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:236
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:47
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::makePatchTypeField
makePatchTypeField(fvPatchScalarField, atmBoundaryLayerInletEpsilonFvPatchScalarField)
fixedNormalInletOutletVelocityFvPatchVectorField.H
Foam::fvPatchField::operator=
virtual void operator=(const UList< Type > &)
Definition: fvPatchField.C:404
Foam::neg
dimensionedScalar neg(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:199
Foam::I
static const Identity< scalar > I
Definition: Identity.H:95
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54
Foam::fixedNormalInletOutletVelocityFvPatchVectorField::normalVelocity
const fvPatchVectorField & normalVelocity() const
Return the BC which provides the normal component of velocity.
Definition: fixedNormalInletOutletVelocityFvPatchVectorField.H:241
Foam::stringOps::evaluate
string evaluate(label fieldWidth, const std::string &s, size_t pos=0, size_t len=std::string::npos)
String evaluation with specified (positive, non-zero) field width.
Definition: stringOpsEvaluate.C:37