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-2026 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  const dictionary& dict
40 )
41 :
42  directionMixedFvPatchVectorField(p, iF),
43  tangentialVelocity_
44  (
45  iF.name(),
46  "tangentialVelocity",
47  p,
48  iF.dimensions(),
49  refValue(),
50  dict,
51  Zero
52  ),
53  phiName_(dict.lookupOrDefault<word>("phi", "phi"))
54 {
55  const vectorField n(patch().nf());
56 
57  refValue() -= n*(n & refValue());
58  refGrad() = Zero;
59  valueFraction() = Zero;
60 
61  if (dict.found("value"))
62  {
64  (
65  vectorField("value", iF.dimensions(), dict, p.size())
66  );
67  }
68  else if (p.time().completeCase())
69  {
70  const scalarField phip(patchInternalField() & n);
71  valueFraction() = neg(phip)*(I - sqr(n));
72 
73  directionMixedFvPatchVectorField::updateCoeffs();
75  }
76  else
77  {
79  << "Unable to evaluate function for incomplete case "
80  "and 'value' entry not provided."
81  << exit(FatalIOError);
82  }
83 }
84 
85 
88 (
90  const fvPatch& p,
92  const fieldMapper& mapper
93 )
94 :
95  directionMixedFvPatchVectorField(ptf, p, iF, mapper),
96  tangentialVelocity_
97  (
98  ptf.tangentialVelocity_,
99  p,
100  refValue()
101  ),
102  phiName_(ptf.phiName_)
103 {}
104 
105 
108 (
111 )
112 :
113  directionMixedFvPatchVectorField(ptf, iF),
114  tangentialVelocity_
115  (
116  ptf.tangentialVelocity_,
117  refValue()
118  ),
119  phiName_(ptf.phiName_)
120 {}
121 
122 
123 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
124 
126 (
127  const fvPatchField<vector>& ptf,
128  const fieldMapper& mapper
129 )
130 {
131  directionMixedFvPatchVectorField::map(ptf, mapper);
132  tangentialVelocity_.map(!mapper.direct());
133 }
134 
135 
137 (
138  const fvPatchField<vector>& ptf
139 )
140 {
141  directionMixedFvPatchVectorField::reset(ptf);
142  tangentialVelocity_.reset();
143 }
144 
145 
147 {
148  if (updated())
149  {
150  return;
151  }
152 
153  const vectorField n(patch().nf());
154 
155  if (tangentialVelocity_.update())
156  {
157  refValue() -= n*(n & refValue());
158  }
159 
160  const fvsPatchField<scalar>& phip =
161  patch().lookupPatchField<surfaceScalarField, scalar>(phiName_);
162 
163  valueFraction() = neg(phip)*(I - sqr(n));
164 
165  directionMixedFvPatchVectorField::updateCoeffs();
167 }
168 
169 
171 (
172  Ostream& os
173 )
174 const
175 {
177  writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
178  writeEntry(os, tangentialVelocity_);
179  writeEntry(os, "value", *this);
180 }
181 
182 
183 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
184 
185 void Foam::pressureInletOutletVelocityFvPatchVectorField::operator=
186 (
187  const fvPatchField<vector>& pvf
188 )
189 {
190  tmp<vectorField> normalValue = transform(valueFraction(), refValue());
191  tmp<vectorField> transformGradValue = transform(I - valueFraction(), pvf);
192  fvPatchField<vector>::operator=(normalValue + transformGradValue);
193 }
194 
195 
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
197 
198 namespace Foam
199 {
201  (
204  );
205 }
206 
207 // ************************************************************************* //
label n
Macros for easy insertion into run-time selection tables.
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const dimensionSet & dimensions() const
Return dimensions.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Abstract base class for field mapping.
Definition: fieldMapper.H:48
virtual bool direct() const
Is the mapper direct?
Definition: fieldMapper.H:132
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:90
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:235
friend Ostream & operator(Ostream &, const fvPatchField< Type > &)
virtual void operator=(const UList< Type > &)
Definition: fvPatchField.C:255
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:58
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:86
Velocity inlet/outlet boundary condition for patches where the pressure is specified in some manner,...
virtual void map(const fvPatchField< vector > &, const fieldMapper &)
Map the given fvPatchField onto this fvPatchField.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
virtual void reset(const fvPatchField< vector > &)
Reset the fvPatchField to the given fvPatchField.
pressureInletOutletVelocityFvPatchVectorField(const fvPatch &, const DimensionedField< vector, fvMesh > &, const dictionary &)
Construct from patch, internal field and dictionary.
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:63
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:346
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
static const zero Zero
Definition: zero.H:97
void transform(GeometricField< Type, GeoMesh > &rtf, const GeometricField< tensor, GeoMesh > &trf, const GeometricField< Type, GeoMesh > &tf)
makePatchTypeField(fvPatchScalarField, atmosphericBoundaryLayerTurbulentEpsilonFvPatchScalarField)
SurfaceField< scalar > surfaceScalarField
static const Identity< scalar > I
Definition: Identity.H:93
tmp< DimensionedField< typename outerProduct< Type, Type >::type, GeoMesh, Field >> sqr(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
void evaluate(GeometricField< Type, GeoMesh > &result, const Function1< Type > &func, const GeometricField< Type, GeoMesh > &x)
Field< vector > vectorField
Specialisation of Field<T> for vector.
IOerror FatalIOError
dimensionedScalar neg(const dimensionedScalar &ds)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
void writeEntry(Ostream &os, const word &key, const DimensionedFieldFunction< DimensionedFieldType > &f)
dictionary dict
volScalarField & p
Foam::surfaceFields.