pressureInletOutletVelocityFvPatchVectorField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2021 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 {
44  refValue() = Zero;
45  refGrad() = Zero;
46  valueFraction() = Zero;
47 }
48 
49 
52 (
54  const fvPatch& p,
56  const fvPatchFieldMapper& mapper
57 )
58 :
59  directionMixedFvPatchVectorField(ptf, p, iF, mapper),
60  phiName_(ptf.phiName_),
61  tangentialVelocity_(ptf.tangentialVelocity_, false)
62 {}
63 
64 
67 (
68  const fvPatch& p,
70  const dictionary& dict
71 )
72 :
73  directionMixedFvPatchVectorField(p, iF),
74  phiName_(dict.lookupOrDefault<word>("phi", "phi"))
75 {
76  fvPatchVectorField::operator=(vectorField("value", dict, p.size()));
77 
78  if (dict.found("tangentialVelocity"))
79  {
80  tangentialVelocity_ =
81  Function1<vector>::New("tangentialVelocity", dict);
82  }
83 
84  refValue() = Zero;
85  refGrad() = Zero;
86  valueFraction() = Zero;
87 }
88 
89 
92 (
95 )
96 :
97  directionMixedFvPatchVectorField(pivpvf, iF),
98  phiName_(pivpvf.phiName_),
99  tangentialVelocity_(pivpvf.tangentialVelocity_, false)
100 {}
101 
102 
103 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
104 
106 {
107  if (updated())
108  {
109  return;
110  }
111 
112  if (tangentialVelocity_.valid())
113  {
114  const scalar t = this->db().time().timeOutputValue();
115  const vector tangentialVelocity = tangentialVelocity_->value(t);
116  const vectorField n(patch().nf());
117  refValue() = tangentialVelocity - n*(n & tangentialVelocity);
118  }
119 
120  const fvsPatchField<scalar>& phip =
121  patch().lookupPatchField<surfaceScalarField, scalar>(phiName_);
122 
123  valueFraction() = neg(phip)*(I - sqr(patch().nf()));
124 
125  directionMixedFvPatchVectorField::updateCoeffs();
127 }
128 
129 
131 (
132  Ostream& os
133 )
134 const
135 {
137  writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
138  if (tangentialVelocity_.valid())
139  {
140  writeEntry(os, tangentialVelocity_());
141  }
142  writeEntry(os, "value", *this);
143 }
144 
145 
146 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
147 
148 void Foam::pressureInletOutletVelocityFvPatchVectorField::operator=
149 (
150  const fvPatchField<vector>& pvf
151 )
152 {
153  tmp<vectorField> normalValue = transform(valueFraction(), refValue());
154  tmp<vectorField> transformGradValue = transform(I - valueFraction(), pvf);
155  fvPatchField<vector>::operator=(normalValue + transformGradValue);
156 }
157 
158 
159 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
160 
161 namespace Foam
162 {
164  (
167  );
168 }
169 
170 // ************************************************************************* //
Foam::surfaceFields.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:643
void evaluate(GeometricField< Type, PatchField, GeoMesh > &result, const Function1< Type > &func, const GeometricField< Type, PatchField, GeoMesh > &x)
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
dimensionedSymmTensor sqr(const dimensionedVector &dv)
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:62
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 write(Ostream &) const
Write.
Definition: fvPatchField.C:260
dimensionedScalar neg(const dimensionedScalar &ds)
Macros for easy insertion into run-time selection tables.
pressureInletOutletVelocityFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Construct from patch and internal field.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
virtual Type value(const scalar x) const =0
Return value as a function of scalar x.
static const Identity< scalar > I
Definition: Identity.H:93
This velocity inlet/outlet boundary condition is applied to pressure boundaries where the pressure is...
autoPtr< BasicCompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleMomentumTransportModel::transportModel &transport)
A class for handling words, derived from string.
Definition: word.H:59
Foam::fvPatchFieldMapper.
static const zero Zero
Definition: zero.H:97
bool valid() const
Return true if the autoPtr valid (ie, the pointer is set)
Definition: autoPtrI.H:83
virtual label size() const
Return size.
Definition: fvPatch.H:156
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
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:275
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
label n
A class for managing temporary objects.
Definition: PtrList.H:53
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
makePatchTypeField(fvPatchScalarField, atmBoundaryLayerInletEpsilonFvPatchScalarField)
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