freestreamFvPatchField.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-2015 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 
29 #include "freestreamFvPatchField.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
33 template<class Type>
35 (
36  const fvPatch& p,
38 )
39 :
41  freestreamBCPtr_()
42 {}
43 
44 
45 template<class Type>
47 (
48  const fvPatch& p,
50  const dictionary& dict
51 )
52 :
54  freestreamBCPtr_()
55 {
56  this->patchType() = dict.getOrDefault<word>("patchType", word::null);
57 
58  this->phiName_ = dict.getOrDefault<word>("phi", "phi");
59 
60  if (dict.found("freestreamValue"))
61  {
62  freestreamValue() =
63  Field<Type>("freestreamValue", dict, p.size());
64 
65  if (dict.found("value"))
66  {
68  (
69  Field<Type>("value", dict, p.size())
70  );
71  }
72  else
73  {
74  fvPatchField<Type>::operator=(freestreamValue());
75  }
76  }
77  else
78  {
79  // Freestream value provided by another patch
80  freestreamBCPtr_ =
81  fvPatchField<Type>::New(p, iF, dict.subDict("freestreamBC"));
82 
83  // Force user to supply an initial value
84  // - we do not know if the supplied BC has all dependencies available
86  (
87  Field<Type>("value", dict, p.size())
88  );
89  }
90 }
91 
92 
93 template<class Type>
95 (
97  const fvPatch& p,
99  const fvPatchFieldMapper& mapper
100 )
101 :
102  inletOutletFvPatchField<Type>(ptf, p, iF, mapper),
103  freestreamBCPtr_()
104 {
105  if (ptf.freestreamBCPtr_)
106  {
107  freestreamBCPtr_ =
108  fvPatchField<Type>::New(ptf.freestreamBCPtr_(), p, iF, mapper);
109  }
110 }
111 
112 
113 template<class Type>
115 (
117 )
118 :
120  freestreamBCPtr_()
121 {
122  if (ptf.freestreamBCPtr_)
123  {
124  freestreamBCPtr_ = ptf.freestreamBCPtr_->clone();
125  }
126 }
127 
128 
129 template<class Type>
131 (
132  const freestreamFvPatchField<Type>& ptf,
134 )
135 :
137  freestreamBCPtr_()
138 {
139  if (ptf.freestreamBCPtr_)
140  {
141  freestreamBCPtr_ = ptf.freestreamBCPtr_->clone();
142  }
143 }
144 
145 
146 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
147 
148 template<class Type>
150 {
152  if (freestreamBCPtr_)
153  {
154  freestreamBCPtr_->autoMap(m);
155  }
156 }
157 
158 
159 template<class Type>
161 (
162  const fvPatchField<Type>& ptf,
163  const labelList& addr
164 )
165 {
167 
168  const auto& fsptf = refCast<const freestreamFvPatchField<Type>>(ptf);
169 
170  if (fsptf.freestreamBCPtr_)
171  {
172  freestreamBCPtr_->rmap(fsptf.freestreamBCPtr_(), addr);
173  }
174 }
175 
176 
177 template<class Type>
179 {
180  if (this->updated())
181  {
182  return;
183  }
184 
185  if (freestreamBCPtr_)
186  {
187  freestreamBCPtr_->evaluate();
188  freestreamValue() = freestreamBCPtr_();
189  }
190 
192 }
193 
194 
195 template<class Type>
197 {
199  os.writeEntryIfDifferent<word>("phi", "phi", this->phiName_);
200 
201  if (freestreamBCPtr_)
202  {
203  os.beginBlock("freestreamBC");
204  freestreamBCPtr_->write(os);
205  os.endBlock();
206  }
207  else
208  {
209  freestreamValue().writeEntry("freestreamValue", os);
210  }
211  this->writeEntry("value", os);
212 }
213 
214 
215 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:51
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::freestreamFvPatchField::freestreamFvPatchField
freestreamFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Definition: freestreamFvPatchField.C:35
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::freestreamFvPatchField
This boundary condition provides a free-stream condition. It is a 'mixed' condition derived from the ...
Definition: freestreamFvPatchField.H:120
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::inletOutletFvPatchField
This boundary condition provides a generic outflow condition, with specified inflow for the case of r...
Definition: inletOutletFvPatchField.H:101
Foam::freestreamFvPatchField::rmap
virtual void rmap(const fvPatchField< Type > &ptf, const labelList &addr)
Reverse map the given fvPatchField onto this fvPatchField.
Definition: freestreamFvPatchField.C:161
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
Foam::freestreamFvPatchField::write
virtual void write(Ostream &) const
Write.
Definition: freestreamFvPatchField.C:196
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:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam::freestreamFvPatchField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: freestreamFvPatchField.C:178
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
Foam::freestreamFvPatchField::autoMap
virtual void autoMap(const fvPatchFieldMapper &mapper)
Map (and resize as needed) from self given a mapping object.
Definition: freestreamFvPatchField.C:149
Foam::List< label >
Foam::vtk::write
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
Definition: foamVtkOutputTemplates.C:36
freestreamFvPatchField.H
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:47
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54