timeVaryingMappedFixedValueFvPatchField.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-2017 OpenFOAM Foundation
9  Copyright (C) 2015-2018 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 
30 #include "Time.H"
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
34 template<class Type>
37 (
38  const fvPatch& p,
40 )
41 :
42  fixedValueFvPatchField<Type>(p, iF),
43  uniformValue_()
44 {}
45 
46 
47 template<class Type>
50 (
51  const fvPatch& p,
53  const dictionary& dict
54 )
55 :
56  fixedValueFvPatchField<Type>(p, iF, dict, IOobjectOption::NO_READ),
57  uniformValue_
58  (
59  new PatchFunction1Types::MappedFile<Type>
60  (
61  p.patch(),
62  "uniformValue",
63  dict,
64  iF.name(), // field table name
65  true // face values
66  )
67  )
68 {
69  if (!this->readValueEntry(dict))
70  {
71  // Note: we use evaluate() here to trigger updateCoeffs followed
72  // by re-setting of fvatchfield::updated_ flag. This is
73  // so if first use is in the next time step it retriggers
74  // a new update.
76  }
77 }
78 
79 
80 template<class Type>
83 (
84  const timeVaryingMappedFixedValueFvPatchField<Type>& ptf,
85  const fvPatch& p,
86  const DimensionedField<Type, volMesh>& iF,
87  const fvPatchFieldMapper& mapper
88 )
89 :
90  fixedValueFvPatchField<Type>(ptf, p, iF, mapper),
91  uniformValue_
92  (
93  new PatchFunction1Types::MappedFile<Type>
94  (
95  ptf.uniformValue_(),
96  p.patch()
97  )
98  )
99 {}
100 
101 
102 template<class Type>
105 (
107 )
108 :
109  fixedValueFvPatchField<Type>(ptf),
110  uniformValue_
111  (
112  new PatchFunction1Types::MappedFile<Type>
113  (
114  ptf.uniformValue_(),
115  this->patch().patch()
116  )
117  )
118 {}
119 
120 
121 template<class Type>
124 (
127 )
128 :
129  fixedValueFvPatchField<Type>(ptf, iF),
130  uniformValue_
131  (
132  new PatchFunction1Types::MappedFile<Type>
133  (
134  ptf.uniformValue_(),
135  this->patch().patch()
136  )
137  )
138 {}
139 
140 
141 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
142 
143 template<class Type>
145 (
146  const fvPatchFieldMapper& m
147 )
148 {
150  uniformValue_().autoMap(m);
151 }
152 
153 
154 template<class Type>
156 (
157  const fvPatchField<Type>& ptf,
158  const labelList& addr
159 )
160 {
162 
164  refCast<const timeVaryingMappedFixedValueFvPatchField<Type>>(ptf);
165 
166  uniformValue_().rmap(tiptf.uniformValue_(), addr);
167 }
168 
169 
170 template<class Type>
172 {
173  if (this->updated())
174  {
175  return;
176  }
177 
178 
179  const scalar t = this->db().time().timeOutputValue();
180  fvPatchField<Type>::operator==(uniformValue_->value(t));
181 
182  if (debug)
183  {
184  Pout<< "updateCoeffs : set fixedValue to min:" << gMin(*this)
185  << " max:" << gMax(*this)
186  << " avg:" << gAverage(*this) << endl;
187  }
190 }
191 
192 
193 template<class Type>
195 (
196  Ostream& os
197 ) const
198 {
200  uniformValue_->writeData(os);
202 }
203 
204 
205 // ************************************************************************* //
bool readValueEntry(const dictionary &dict, IOobjectOption::readOption readOpt=IOobjectOption::LAZY_READ)
Read the "value" entry into *this.
Definition: fvPatchField.C:32
This boundary condition supplies a fixed value constraint, and is the base class for a number of othe...
dictionary dict
"blocking" : (MPI_Bsend, MPI_Recv)
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: fvPatchField.C:236
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
Type gMin(const FieldField< Field, Type > &f)
virtual void rmap(const fvPatchField< Type > &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:70
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
void writeValueEntry(Ostream &os) const
Write *this field as a "value" entry.
Definition: fvPatchField.H:375
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:372
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
virtual void operator==(const fvPatchField< Type > &)
Definition: fvPatchField.C:546
This boundary conditions interpolates the values from a set of supplied points in space and time...
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
A FieldMapper for finite-volume patch fields.
virtual void rmap(const fvPatchField< Type > &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
Definition: fvPatchField.C:299
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
int debug
Static debugging option.
Type gMax(const FieldField< Field, Type > &f)
OBJstream os(runTime.globalPath()/outputName)
timeVaryingMappedFixedValueFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field, sets updated() to false.
Definition: fvPatchField.C:329
Type gAverage(const FieldField< Field, Type > &f)
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: fvPatchField.C:309
A simple container of IOobject preferences. Can also be used for general handling of read/no-read/rea...
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: areaFieldsFwd.H:42
const std::string patch
OpenFOAM patch number as a std::string.
volScalarField & p
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.