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 #include "AverageField.H"
32 #include "IFstream.H"
33 
34 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
35 
36 template<class Type>
39 (
40  const fvPatch& p,
42 )
43 :
45  uniformValue_()
46 {}
47 
48 
49 template<class Type>
52 (
53  const fvPatch& p,
55  const dictionary& dict
56 )
57 :
58  fixedValueFvPatchField<Type>(p, iF, dict, false),
59  uniformValue_
60  (
62  (
63  p.patch(),
64  "uniformValue",
65  dict,
66  iF.name(), // field table name
67  true // face values
68  )
69  )
70 {
71  if (dict.found("value"))
72  {
74  }
75  else
76  {
77  // Note: we use evaluate() here to trigger updateCoeffs followed
78  // by re-setting of fvatchfield::updated_ flag. This is
79  // so if first use is in the next time step it retriggers
80  // a new update.
81  this->evaluate(Pstream::commsTypes::blocking);
82  }
83 }
84 
85 
86 template<class Type>
89 (
91  const fvPatch& p,
93  const fvPatchFieldMapper& mapper
94 )
95 :
96  fixedValueFvPatchField<Type>(ptf, p, iF, mapper),
97  uniformValue_
98  (
100  (
101  ptf.uniformValue_(),
102  p.patch()
103  )
104  )
105 {}
106 
107 
108 template<class Type>
111 (
113 )
114 :
116  uniformValue_
117  (
119  (
120  ptf.uniformValue_(),
121  this->patch().patch()
122  )
123  )
124 {}
125 
126 
127 template<class Type>
130 (
133 )
134 :
136  uniformValue_
137  (
139  (
140  ptf.uniformValue_(),
141  this->patch().patch()
142  )
143  )
144 {}
145 
146 
147 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
148 
149 template<class Type>
151 (
152  const fvPatchFieldMapper& m
153 )
154 {
156  uniformValue_().autoMap(m);
157 }
158 
159 
160 template<class Type>
162 (
163  const fvPatchField<Type>& ptf,
164  const labelList& addr
165 )
166 {
168 
170  refCast<const timeVaryingMappedFixedValueFvPatchField<Type>>(ptf);
171 
172  uniformValue_().rmap(tiptf.uniformValue_(), addr);
173 }
174 
175 
176 template<class Type>
178 {
179  if (this->updated())
180  {
181  return;
182  }
183 
184 
185  const scalar t = this->db().time().timeOutputValue();
186  fvPatchField<Type>::operator==(uniformValue_->value(t));
187 
188  if (debug)
189  {
190  Pout<< "updateCoeffs : set fixedValue to min:" << gMin(*this)
191  << " max:" << gMax(*this)
192  << " avg:" << gAverage(*this) << endl;
193  }
194 
196 }
197 
198 
199 template<class Type>
201 (
202  Ostream& os
203 ) const
204 {
206  uniformValue_->writeData(os);
207  this->writeEntry("value", os);
208 }
209 
210 
211 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
Foam::timeVaryingMappedFixedValueFvPatchField::rmap
virtual void rmap(const fvPatchField< Type > &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
Definition: timeVaryingMappedFixedValueFvPatchField.C:162
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:50
AverageField.H
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::gAverage
Type gAverage(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:604
Foam::timeVaryingMappedFixedValueFvPatchField
This boundary conditions interpolates the values from a set of supplied points in space and time.
Definition: timeVaryingMappedFixedValueFvPatchField.H:127
Foam::timeVaryingMappedFixedValueFvPatchField::write
virtual void write(Ostream &) const
Write.
Definition: timeVaryingMappedFixedValueFvPatchField.C:201
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:337
Foam::Pout
prefixOSstream Pout
An Ostream wrapper for parallel output to std::cout.
Foam::fixedValueFvPatchField
This boundary condition supplies a fixed value constraint, and is the base class for a number of othe...
Definition: fixedValueFvPatchField.H:80
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::operator==
tmp< faMatrix< Type > > operator==(const faMatrix< Type > &, const faMatrix< Type > &)
Foam::timeVaryingMappedFixedValueFvPatchField::timeVaryingMappedFixedValueFvPatchField
timeVaryingMappedFixedValueFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Definition: timeVaryingMappedFixedValueFvPatchField.C:39
Foam::timeVaryingMappedFixedValueFvPatchField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: timeVaryingMappedFixedValueFvPatchField.C:177
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:63
IFstream.H
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:121
timeVaryingMappedFixedValueFvPatchField.H
Foam::PatchFunction1Types::MappedFile
Definition: MappedFile.H:54
Time.H
Foam::timeVaryingMappedFixedValueFvPatchField::autoMap
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: timeVaryingMappedFixedValueFvPatchField.C:151
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
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:35
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::gMin
Type gMin(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:593
Foam::gMax
Type gMax(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:592
Foam::stringOps::evaluate
string evaluate(const std::string &s, size_t pos=0, size_t len=std::string::npos)
Definition: stringOpsEvaluate.C:37
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54