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-2015 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_(pTraits<Type>::zero)
40 {}
41 
42 
43 template<class Type>
45 (
46  const fixedMeanFvPatchField<Type>& ptf,
47  const fvPatch& p,
49  const fvPatchFieldMapper& mapper
50 )
51 :
52  fixedValueFvPatchField<Type>(ptf, p, iF, mapper),
53  meanValue_(ptf.meanValue_)
54 {}
55 
56 
57 template<class Type>
59 (
60  const fvPatch& p,
62  const dictionary& dict
63 )
64 :
66  meanValue_(pTraits<Type>(dict.lookup("meanValue")))
67 {}
68 
69 
70 template<class Type>
72 (
74 )
75 :
77  meanValue_(ptf.meanValue_)
78 {}
79 
80 
81 template<class Type>
83 (
84  const fixedMeanFvPatchField<Type>& ptf,
86 )
87 :
89  meanValue_(ptf.meanValue_)
90 {}
91 
92 
93 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
94 
95 template<class Type>
97 {
98  if (this->updated())
99  {
100  return;
101  }
102 
103  Field<Type> newValues(this->patchInternalField());
104 
105  Type meanValuePsi =
106  gSum(this->patch().magSf()*newValues)
107  /gSum(this->patch().magSf());
108 
109  if (mag(meanValue_) > SMALL && mag(meanValuePsi)/mag(meanValue_) > 0.5)
110  {
111  newValues *= mag(meanValue_)/mag(meanValuePsi);
112  }
113  else
114  {
115  newValues += (meanValue_ - meanValuePsi);
116  }
117 
118  this->operator==(newValues);
119 
121 }
122 
123 
124 template<class Type>
126 {
128  os.writeKeyword("meanValue") << meanValue_ << token::END_STATEMENT << nl;
129  this->writeEntry("value", os);
130 }
131 
132 
133 // ************************************************************************* //
volFields.H
Foam::fixedMeanFvPatchField::meanValue_
Type meanValue_
MeanValue value the field is adjusted to maintain.
Definition: fixedMeanFvPatchField.H:92
p
p
Definition: pEqn.H:62
Foam::fixedMeanFvPatchField::fixedMeanFvPatchField
fixedMeanFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Definition: fixedMeanFvPatchField.C:33
Foam::operator==
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
Foam::gSum
Type gSum(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:564
Foam::mag
dimensioned< scalar > mag(const dimensioned< Type > &)
Foam::fixedValueFvPatchField
This boundary condition supplies a fixed value constraint, and is the base class for a number of othe...
Definition: fixedValueFvPatchField.H:79
Foam::Field< Type >
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::fixedMeanFvPatchField::write
virtual void write(Ostream &) const
Write.
Definition: fixedMeanFvPatchField.C:125
Foam::fixedMeanFvPatchField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: fixedMeanFvPatchField.C:96
Foam::pTraits
Traits class for primitives.
Definition: pTraits.H:50
Foam::Ostream::writeKeyword
Ostream & writeKeyword(const keyType &)
Write the keyword followed by an appropriate indentation.
Definition: Ostream.C:59
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:45
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::fixedMeanFvPatchField
This boundary condition extrapolates field to the patch using the near-cell values and adjusts the di...
Definition: fixedMeanFvPatchField.H:82
write
Tcoeff write()
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:51
fixedMeanFvPatchField.H