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  Copyright (C) 2020-2021 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 "volFields.H"
31 #include "surfaceFields.H"
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
35 template<class Type>
37 (
38  const fvPatch& p,
40 )
41 :
43  meanValue_()
44 {}
45 
46 
47 template<class Type>
49 (
50  const fvPatch& p,
52  const dictionary& dict
53 )
54 :
56  meanValue_(Function1<Type>::New("meanValue", dict, &this->db()))
57 {
58  this->phiName_ = dict.getOrDefault<word>("phi", "phi");
59 
61  (
62  Field<Type>("value", dict, p.size())
63  );
64 
65  this->refValue() = *this;
66  this->refGrad() = Zero;
67  this->valueFraction() = 0.0;
68 }
69 
70 
71 template<class Type>
73 (
75  const fvPatch& p,
77  const fvPatchFieldMapper& mapper
78 )
79 :
80  outletInletFvPatchField<Type>(ptf, p, iF, mapper),
81  meanValue_(ptf.meanValue_.clone())
82 {}
83 
84 
85 template<class Type>
87 (
89 )
90 :
92  meanValue_(ptf.meanValue_.clone())
93 {}
94 
95 
96 template<class Type>
98 (
101 )
102 :
104  meanValue_(ptf.meanValue_.clone())
105 {}
106 
107 
108 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
109 
110 template<class Type>
112 {
113  if (this->updated())
114  {
115  return;
116  }
117 
118  const scalar t = this->db().time().timeOutputValue();
119  Type meanValue = meanValue_->value(t);
120 
121  Field<Type> newValues(this->patchInternalField());
122 
123  Type meanValuePsi =
124  gSum(this->patch().magSf()*newValues)
125  /gSum(this->patch().magSf());
126 
127  if (mag(meanValue) > SMALL && mag(meanValuePsi) > 0.5*mag(meanValue))
128  {
129  newValues *= mag(meanValue)/mag(meanValuePsi);
130  }
131  else
132  {
133  newValues += (meanValue - meanValuePsi);
134  }
135 
136  this->refValue() = newValues;
137 
139 }
140 
141 
142 template<class Type>
144 {
146  meanValue_->writeData(os);
147  this->writeEntry("value", os);
148 }
149 
150 
151 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:51
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:65
Foam::fixedMeanOutletInletFvPatchField::write
virtual void write(Ostream &) const
Write.
Definition: fixedMeanOutletInletFvPatchField.C:143
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
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:111
Foam::Function1
Top level data entry class for use in dictionaries. Provides a mechanism to specify a variable as a c...
Definition: propellerInfo.H:291
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:65
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:123
os
OBJstream os(runTime.globalPath()/outputName)
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:37
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:36
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