pressureInletOutletVelocityFvPatchVectorField.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) 2011-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 {
47  refValue() = Zero;
48  refGrad() = Zero;
49  valueFraction() = Zero;
50 }
51 
52 
55 (
57  const fvPatch& p,
59  const fvPatchFieldMapper& mapper
60 )
61 :
62  directionMixedFvPatchVectorField(ptf, p, iF, mapper),
63  phiName_(ptf.phiName_)
64 {
65  if (ptf.tangentialVelocity_.size())
66  {
67  tangentialVelocity_ = mapper(ptf.tangentialVelocity_);
68  }
69 }
70 
71 
74 (
75  const fvPatch& p,
76  const DimensionedField<vector, volMesh>& iF,
77  const dictionary& dict
78 )
79 :
80  directionMixedFvPatchVectorField(p, iF),
81  phiName_(dict.getOrDefault<word>("phi", "phi"))
82 {
83  patchType() = dict.getOrDefault<word>("patchType", word::null);
85 
86  if (dict.found("tangentialVelocity"))
87  {
89  (
90  vectorField("tangentialVelocity", dict, p.size())
91  );
92  }
93  else
94  {
95  refValue() = Zero;
96  }
97 
98  refGrad() = Zero;
99  valueFraction() = Zero;
100 }
101 
102 
105 (
107 )
108 :
109  directionMixedFvPatchVectorField(pivpvf),
110  phiName_(pivpvf.phiName_),
111  tangentialVelocity_(pivpvf.tangentialVelocity_)
112 {}
113 
114 
117 (
120 )
121 :
122  directionMixedFvPatchVectorField(pivpvf, iF),
123  phiName_(pivpvf.phiName_),
124  tangentialVelocity_(pivpvf.tangentialVelocity_)
125 {}
126 
127 
128 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
129 
131 setTangentialVelocity(const vectorField& tangentialVelocity)
132 {
133  tangentialVelocity_ = tangentialVelocity;
134  const vectorField n(patch().nf());
135  refValue() = tangentialVelocity_ - n*(n & tangentialVelocity_);
136 }
137 
138 
140 (
141  const fvPatchFieldMapper& m
142 )
143 {
144  directionMixedFvPatchVectorField::autoMap(m);
145  if (tangentialVelocity_.size())
146  {
147  tangentialVelocity_.autoMap(m);
148  }
149 }
150 
151 
153 (
154  const fvPatchVectorField& ptf,
155  const labelList& addr
156 )
157 {
158  directionMixedFvPatchVectorField::rmap(ptf, addr);
159 
160  if (tangentialVelocity_.size())
161  {
162  const pressureInletOutletVelocityFvPatchVectorField& tiptf =
163  refCast<const pressureInletOutletVelocityFvPatchVectorField>(ptf);
164 
165  tangentialVelocity_.rmap(tiptf.tangentialVelocity_, addr);
166  }
167 }
168 
169 
171 {
172  if (updated())
173  {
174  return;
175  }
176 
177  const fvsPatchField<scalar>& phip =
178  patch().lookupPatchField<surfaceScalarField, scalar>(phiName_);
179 
180  valueFraction() = neg(phip)*(I - sqr(patch().nf()));
181 
182  directionMixedFvPatchVectorField::updateCoeffs();
184 }
185 
186 
188 (
189  Ostream& os
190 )
191 const
192 {
194  os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
195  if (tangentialVelocity_.size())
196  {
197  tangentialVelocity_.writeEntry("tangentialVelocity", os);
198  }
199  writeEntry("value", os);
200 }
201 
202 
203 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
204 
205 void Foam::pressureInletOutletVelocityFvPatchVectorField::operator=
206 (
207  const fvPatchField<vector>& pvf
208 )
209 {
210  tmp<vectorField> normalValue = transform(valueFraction(), refValue());
211  tmp<vectorField> transformGradValue = transform(I - valueFraction(), pvf);
212  fvPatchField<vector>::operator=(normalValue + transformGradValue);
213 }
214 
215 
216 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 
218 namespace Foam
219 {
221  (
223  pressureInletOutletVelocityFvPatchVectorField
224  );
225 }
226 
227 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:47
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:63
volFields.H
Foam::fvPatchField::write
virtual void write(Ostream &) const
Definition: fvPatchField.C:377
Foam::fvPatchField::operator=
virtual void operator=(const UList< Type > &)
Foam::Ostream::writeEntryIfDifferent
Ostream & writeEntryIfDifferent(const word &key, const T &value1, const T &value2)
Definition: Ostream.H:244
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:63
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:57
Foam::Zero
static constexpr const zero Zero
Definition: zero.H:131
Foam::fvsPatchField
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:64
surfaceFields.H
Foam::surfaceFields.
Foam::pressureInletOutletVelocityFvPatchVectorField::write
virtual void write(Ostream &) const
Definition: pressureInletOutletVelocityFvPatchVectorField.C:181
Foam::pressureInletOutletVelocityFvPatchVectorField::tangentialVelocity
const vectorField & tangentialVelocity() const
Definition: pressureInletOutletVelocityFvPatchVectorField.H:201
Foam::pressureInletOutletVelocityFvPatchVectorField::pressureInletOutletVelocityFvPatchVectorField
pressureInletOutletVelocityFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Definition: pressureInletOutletVelocityFvPatchVectorField.C:32
Foam::transform
dimensionSet transform(const dimensionSet &ds)
Definition: dimensionSet.C:514
Foam::pressureInletOutletVelocityFvPatchVectorField::updateCoeffs
virtual void updateCoeffs()
Definition: pressureInletOutletVelocityFvPatchVectorField.C:163
Foam::vectorField
Field< vector > vectorField
Specialisation of Field<T> for vector.
Definition: primitiveFieldsFwd.H:48
n
label n
Definition: TABSMDCalcMethod2.H:31
Foam::Field
Generic templated field type.
Definition: Field.H:59
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:119
os
OBJstream os(runTime.globalPath()/outputName)
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::pressureInletOutletVelocityFvPatchVectorField::rmap
virtual void rmap(const fvPatchVectorField &, const labelList &)
Definition: pressureInletOutletVelocityFvPatchVectorField.C:146
Foam
Definition: atmBoundaryLayer.C:26
pressureInletOutletVelocityFvPatchVectorField.H
Foam::fvPatchVectorField
fvPatchField< vector > fvPatchVectorField
Definition: fvPatchFieldsFwd.H:36
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:44
Foam::surfaceScalarField
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
Definition: surfaceFieldsFwd.H:50
Foam::foamVersion::patch
const std::string patch
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:58
Foam::word::null
static const word null
Definition: word.H:78
Foam::pressureInletOutletVelocityFvPatchVectorField::autoMap
virtual void autoMap(const fvPatchFieldMapper &)
Definition: pressureInletOutletVelocityFvPatchVectorField.C:133
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:41
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:52
Foam::pressureInletOutletVelocityFvPatchVectorField::setTangentialVelocity
void setTangentialVelocity(const vectorField &tangentialVelocity)
Definition: pressureInletOutletVelocityFvPatchVectorField.C:124
Foam::makePatchTypeField
makePatchTypeField(fvPatchScalarField, atmBoundaryLayerInletEpsilonFvPatchScalarField)
Foam::neg
dimensionedScalar neg(const dimensionedScalar &ds)
Definition: dimensionedScalar.C:192
Foam::I
static const Identity< scalar > I
Definition: Identity.H:89
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:50
Foam::pressureInletOutletVelocityFvPatchVectorField
This velocity inlet/outlet boundary condition is applied to velocity boundaries where the pressure is...
Definition: pressureInletOutletVelocityFvPatchVectorField.H:94
Foam::stringOps::evaluate
string evaluate(label fieldWidth, const std::string &s, size_t pos=0, size_t len=std::string::npos)
Definition: stringOpsEvaluate.C:30