fixedMeanOutletInletFvPatchField.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) 2018 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
29 #include "volFields.H"
30 #include "surfaceFields.H"
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
34 template<class Type>
36 (
37  const fvPatch& p,
39 )
40 :
42  meanValue_()
43 {}
44 
45 
46 template<class Type>
48 (
49  const fvPatch& p,
51  const dictionary& dict
52 )
53 :
55  meanValue_(Function1<Type>::New("meanValue", dict))
56 {
57  this->phiName_ = dict.lookupOrDefault<word>("phi", "phi");
58 
60  (
61  Field<Type>("value", dict, p.size())
62  );
63 
64  this->refValue() = *this;
65  this->refGrad() = Zero;
66  this->valueFraction() = 0.0;
67 }
68 
69 
70 template<class Type>
72 (
74  const fvPatch& p,
76  const fvPatchFieldMapper& mapper
77 )
78 :
79  outletInletFvPatchField<Type>(ptf, p, iF, mapper),
80  meanValue_(ptf.meanValue_.clone())
81 {}
82 
83 
84 template<class Type>
86 (
88 )
89 :
91  meanValue_(ptf.meanValue_.clone())
92 {}
93 
94 
95 template<class Type>
97 (
100 )
101 :
103  meanValue_(ptf.meanValue_.clone())
104 {}
105 
106 
107 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
108 
109 template<class Type>
111 {
112  if (this->updated())
113  {
114  return;
115  }
116 
117  const scalar t = this->db().time().timeOutputValue();
118  Type meanValue = meanValue_->value(t);
119 
120  Field<Type> newValues(this->patchInternalField());
121 
122  Type meanValuePsi =
123  gSum(this->patch().magSf()*newValues)
124  /gSum(this->patch().magSf());
125 
126  if (mag(meanValue) > SMALL && mag(meanValuePsi)/mag(meanValue) > 0.5)
127  {
128  newValues *= mag(meanValue)/mag(meanValuePsi);
129  }
130  else
131  {
132  newValues += (meanValue - meanValuePsi);
133  }
134 
135  this->refValue() = newValues;
136 
138 }
139 
140 
141 template<class Type>
143 {
145  meanValue_->writeData(os);
146  this->writeEntry("value", os);
147 }
148 
149 
150 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:50
volFields.H
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::outletInletFvPatchField
This boundary condition provides a generic inflow condition, with specified outflow for the case of r...
Definition: outletInletFvPatchField.H:101
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::fixedMeanOutletInletFvPatchField::write
virtual void write(Ostream &) const
Write.
Definition: fixedMeanOutletInletFvPatchField.C:142
Foam::Zero
static constexpr const zero Zero
Global zero.
Definition: zero.H:128
surfaceFields.H
Foam::surfaceFields.
Foam::gSum
Type gSum(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:594
Foam::fixedMeanOutletInletFvPatchField::updateCoeffs
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
Definition: fixedMeanOutletInletFvPatchField.C:110
Foam::Function1
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: Function1.H:56
fixedMeanOutletInletFvPatchField.H
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:63
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
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::fixedMeanOutletInletFvPatchField::fixedMeanOutletInletFvPatchField
fixedMeanOutletInletFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Definition: fixedMeanOutletInletFvPatchField.C:36
Foam::fixedMeanOutletInletFvPatchField
This boundary condition extrapolates field to the patch using the near-cell values and adjusts the di...
Definition: fixedMeanOutletInletFvPatchField.H:99
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::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54