velocityFilmShellFvPatchVectorField.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) 2020-2022 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
29 #include "dictionaryContent.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 
37 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
38 
40 (
41  const fvPatch& p,
43 )
44 :
46  baffle_(nullptr),
47  dict_(),
48  curTimeIndex_(-1),
49  zeroWallVelocity_(true)
50 {
51  refValue() = Zero;
52  refGrad() = Zero;
53  valueFraction() = 1;
54 }
55 
56 
58 (
60  const fvPatch& p,
62  const fvPatchFieldMapper& mapper
63 )
64 :
66  (
67  ptf,
68  p,
69  iF,
70  mapper
71  ),
72  baffle_(nullptr),
73  dict_(ptf.dict_),
74  curTimeIndex_(-1),
75  zeroWallVelocity_(true)
76 {}
77 
78 
80 (
81  const fvPatch& p,
83  const dictionary& dict
84 )
85 :
87  baffle_(nullptr),
88  dict_
89  (
90  // Copy dictionary, but without "heavy" data chunks
91  dictionaryContent::copyDict
92  (
93  dict,
94  wordList(), // allow
95  wordList // deny
96  ({
97  "type", // redundant
98  "value", "refValue", "refGradient", "valueFraction"
99  })
100  )
101  ),
102  curTimeIndex_(-1),
103  zeroWallVelocity_(dict.getOrDefault<bool>("zeroWallVelocity", true))
104 {
106 
107  if (dict.found("refValue"))
108  {
109  // Full restart
110  refValue() = vectorField("refValue", dict, p.size());
111  refGrad() = vectorField("refGradient", dict, p.size());
112  valueFraction() = scalarField("valueFraction", dict, p.size());
113  }
114  else
115  {
116  // Start from user entered data. Assume fixedValue.
117  refValue() = *this;
118  refGrad() = Zero;
119  valueFraction() = 1;
120  }
121 
122  if (!baffle_)
123  {
124  baffle_.reset(baffleType::New(p.boundaryMesh().mesh(), dict_));
125  }
126 }
127 
128 
130 (
133 )
134 :
135  mixedFvPatchField<vector>(ptf, iF),
136  baffle_(nullptr),
137  dict_(ptf.dict_),
138  curTimeIndex_(-1),
139  zeroWallVelocity_(true)
140 {}
141 
142 
143 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
144 
145 
147 {
148  if (this->updated())
149  {
150  return;
151  }
152 
153  // Execute the change to the openFraction only once per time-step
154  if (curTimeIndex_ != this->db().time().timeIndex())
155  {
156  baffle_->evolve();
157 
158  vectorField& pfld = *this;
159 
160  baffle_->vsm().mapToVolumePatch(baffle_->Us(), pfld, patch().index());
161 
162  refGrad() = Zero;
163  valueFraction() = 1;
164 
165  if (zeroWallVelocity_)
166  {
167  refValue() = Zero;
168  }
169  else
170  {
171  refValue() = pfld;
172  }
173 
174  curTimeIndex_ = this->db().time().timeIndex();
175  }
176 
178 }
179 
180 
182 {
184  dict_.write(os, false);
185 }
186 
187 
188 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
189 
191 (
194 );
195 
196 
197 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
198 
199 } // End namespace Foam
200 
201 
202 // ************************************************************************* //
dictionary dict
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:118
const objectRegistry & db() const
The associated objectRegistry.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:120
const fvPatch & patch() const noexcept
Return the patch.
Definition: fvPatchField.H:199
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:68
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Macros for easy insertion into run-time selection tables.
velocityFilmShellFvPatchVectorField(const fvPatch &, const DimensionedField< vector, volMesh > &)
Construct from patch and internal field.
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry (const access) with the given keyword.
Definition: dictionaryI.H:100
virtual Field< vector > & refValue()
bool updated() const noexcept
True if the boundary condition has already been updated.
Definition: fvPatchField.H:226
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const Time & time() const noexcept
Return time registry.
virtual scalarField & valueFraction()
A FieldMapper for finite-volume patch fields.
label timeIndex() const noexcept
Return current time index.
Definition: TimeStateI.H:30
A wrapper for dictionary content, without operators that could affect inheritance patterns...
const Mesh & mesh() const noexcept
Return mesh.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:55
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
OBJstream os(runTime.globalPath()/outputName)
void write(Ostream &os, const bool subDict=true) const
Write dictionary, normally with sub-dictionary formatting.
Definition: dictionaryIO.C:199
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: fvPatchField.C:270
virtual void operator=(const UList< Type > &)
Definition: fvPatchField.C:352
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: areaFieldsFwd.H:42
Field< vector > vectorField
Specialisation of Field<T> for vector.
virtual void write(Ostream &) const
Write.
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
volScalarField & p
label index() const noexcept
Return the index of this patch in the fvBoundaryMesh.
Definition: fvPatch.H:250
makePatchTypeField(fvPatchScalarField, atmBoundaryLayerInletEpsilonFvPatchScalarField)
virtual Field< vector > & refGrad()
Namespace for OpenFOAM.
label timeIndex
Definition: getTimeIndex.H:24
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:157