fixedMeanFvPatchField.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 | Copyright (C) 2012-2016 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 
26 #include "fixedMeanFvPatchField.H"
27 #include "volFields.H"
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
31 template<class Type>
33 (
34  const fvPatch& p,
36 )
37 :
39  meanValue_()
40 {}
41 
42 
43 template<class Type>
45 (
46  const fvPatch& p,
48  const dictionary& dict
49 )
50 :
52  meanValue_(Function1<Type>::New("meanValue", dict))
53 {}
54 
55 
56 template<class Type>
58 (
59  const fixedMeanFvPatchField<Type>& ptf,
60  const fvPatch& p,
62  const fvPatchFieldMapper& mapper
63 )
64 :
65  fixedValueFvPatchField<Type>(ptf, p, iF, mapper),
66  meanValue_(ptf.meanValue_, false)
67 {}
68 
69 
70 template<class Type>
72 (
74 )
75 :
77  meanValue_(ptf.meanValue_, false)
78 {}
79 
80 
81 template<class Type>
83 (
84  const fixedMeanFvPatchField<Type>& ptf,
86 )
87 :
89  meanValue_(ptf.meanValue_, false)
90 {}
91 
92 
93 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
94 
95 template<class Type>
97 {
98  if (this->updated())
99  {
100  return;
101  }
102 
103  const scalar t = this->db().time().timeOutputValue();
104  Type meanValue = meanValue_->value(t);
105 
106  Field<Type> newValues(this->patchInternalField());
107 
108  Type meanValuePsi =
109  gSum(this->patch().magSf()*newValues)
110  /gSum(this->patch().magSf());
111 
112  if (mag(meanValue) > SMALL && mag(meanValuePsi)/mag(meanValue) > 0.5)
113  {
114  newValues *= mag(meanValue)/mag(meanValuePsi);
115  }
116  else
117  {
118  newValues += (meanValue - meanValuePsi);
119  }
120 
121  this->operator==(newValues);
122 
124 }
125 
126 
127 template<class Type>
129 {
131  meanValue_->writeData(os);
132  this->writeEntry("value", os);
133 }
134 
135 
136 // ************************************************************************* //
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: Function1.H:53
This boundary condition supplies a fixed value constraint, and is the base class for a number of othe...
dictionary dict
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
This boundary condition extrapolates field to the patch using the near-cell values and adjusts the di...
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
virtual void write(Ostream &) const
Write.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Type gSum(const FieldField< Field, Type > &f)
Pre-declare SubField and related Field type.
Definition: Field.H:57
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
Foam::fvPatchFieldMapper.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
dimensioned< scalar > mag(const dimensioned< Type > &)
fixedMeanFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
volScalarField & p
runTime write()