freestreamVelocityFvPatchVectorField.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) 2018-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 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
32 (
33  const fvPatch& p,
35  const dictionary& dict
36 )
37 :
38  mixedFvPatchVectorField(p, iF, dict, false),
39  dimensionedFreestreamValue_
40  (
41  iF.name(),
42  "freestreamValue",
43  p,
44  iF.dimensions(),
45  freestreamValue(),
46  dict
47  )
48 {
49  if (dict.found("value"))
50  {
52  (
53  vectorField("value", iF.dimensions(), dict, p.size())
54  );
55  }
56  else if (p.time().completeCase())
57  {
59  }
60  else
61  {
63  << "Unable to evaluate function for incomplete case "
64  "and 'value' entry not provided."
65  << exit(FatalIOError);
66  }
67 
68  refGrad() = Zero;
69  valueFraction() = 1;
70 }
71 
72 
74 (
76  const fvPatch& p,
78  const fieldMapper& mapper
79 )
80 :
81  mixedFvPatchVectorField(ptf, p, iF, mapper),
82  dimensionedFreestreamValue_
83  (
84  ptf.dimensionedFreestreamValue_,
85  p,
86  freestreamValue()
87  )
88 {}
89 
90 
92 (
95 )
96 :
97  mixedFvPatchVectorField(ptf, iF),
98  dimensionedFreestreamValue_
99  (
100  ptf.dimensionedFreestreamValue_,
101  freestreamValue()
102  )
103 {}
104 
105 
106 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
107 
109 (
110  const fvPatchVectorField& ptf,
111  const fieldMapper& mapper
112 )
113 {
114  mixedFvPatchField<vector>::map(ptf, mapper);
115  dimensionedFreestreamValue_.map(!mapper.direct());
116 }
117 
118 
120 (
121  const fvPatchVectorField& ptf
122 )
123 {
125  dimensionedFreestreamValue_.reset();
126 }
127 
128 
130 {
131  if (updated())
132  {
133  return;
134  }
135 
136  dimensionedFreestreamValue_.update();
137 
138  const Field<vector> Up(0.5*(patchInternalField() + *this));
139  const Field<scalar> magUp(mag(Up));
140 
141  const Field<vector> nf(patch().nf());
142 
143  Field<scalar>& vf = valueFraction();
144 
145  forAll(vf, i)
146  {
147  if (magUp[i] > vSmall)
148  {
149  vf[i] = 0.5 - 0.5*(Up[i] & nf[i])/magUp[i];
150  }
151  else
152  {
153  vf[i] = 0.5;
154  }
155  }
156 
158 }
159 
160 
162 {
164  writeEntry(os, dimensionedFreestreamValue_);
165  writeEntry(os, "value", *this);
166 }
167 
168 
169 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
170 
171 namespace Foam
172 {
174  (
177  );
178 }
179 
180 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:449
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
This boundary condition provides a free-stream condition for velocity.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
virtual void reset(const fvPatchVectorField &)
Reset the fvPatchField to the given fvPatchField.
virtual void map(const fvPatchVectorField &, const fieldMapper &)
Map the given fvPatchField onto this fvPatchField.
freestreamVelocityFvPatchVectorField(const fvPatch &, const DimensionedField< vector, fvMesh > &, const dictionary &)
Construct from patch, internal field and dictionary.
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
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: fvPatchField.C:208
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:58
virtual void reset(const fvPatchField< Type > &)
Reset the fvPatchField to the given fvPatchField.
virtual void map(const fvPatchField< Type > &, const fieldMapper &)
Map the given fvPatchField onto this fvPatchField.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:346
const scalar magUp
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
makePatchTypeField(fvPatchScalarField, atmosphericBoundaryLayerTurbulentEpsilonFvPatchScalarField)
Field< vector > vectorField
Specialisation of Field<T> for vector.
IOerror FatalIOError
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
tmp< DimensionedField< scalar, GeoMesh, Field > > mag(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
void writeEntry(Ostream &os, const word &key, const DimensionedFieldFunction< DimensionedFieldType > &f)
dictionary dict
volScalarField & p