fixedValueInletOutletFvPatchField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2021-2023 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 
27 #include "volFields.H"
28 #include "surfaceFields.H"
29 
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 
32 template<class Type>
34 (
35  const fvPatch& p,
37  const dictionary& dict,
38  const bool valueRequired
39 )
40 :
41  fixedValueFvPatchField<Type>(p, iF, dict, valueRequired),
42  phiName_(dict.lookupOrDefault<word>("phi", "phi"))
43 {}
44 
45 
46 template<class Type>
48 (
50  const fvPatch& p,
52  const fvPatchFieldMapper& mapper,
53  const bool mappingRequired
54 )
55 :
56  fixedValueFvPatchField<Type>(ptf, p, iF, mapper, mappingRequired),
57  phiName_(ptf.phiName_)
58 {}
59 
60 
61 template<class Type>
63 (
66 )
67 :
68  fixedValueFvPatchField<Type>(ptf, iF),
69  phiName_(ptf.phiName_)
70 {}
71 
72 
73 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
74 
75 template<class Type>
78 (
79  const tmp<scalarField>&
80 ) const
81 {
82  // Behave as a fixed value patch where there is inflow, and fixed gradient
83  // patch where there is outflow
84  const scalarField& phi =
85  this->patch().template
86  lookupPatchField<surfaceScalarField, scalar>(phiName_);
87  return (1 - pos0(phi))*Zero + pos0(phi)*pTraits<Type>::one;
88 }
89 
90 
91 template<class Type>
94 (
95  const tmp<scalarField>&
96 ) const
97 {
98  // Behave as a fixed value patch where there is inflow, and fixed gradient
99  // patch where there is outflow
100  const scalarField& phi =
101  this->patch().template
102  lookupPatchField<surfaceScalarField, scalar>(phiName_);
103  const Field<Type> pif(this->patchInternalField());
104  return (1 - pos0(phi))**this + pos0(phi)*(*this - pif);
105 }
106 
107 
108 template<class Type>
110 {
112  writeEntryIfDifferent<word>(os, "phi", "phi", phiName_);
113 }
114 
115 
116 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
This boundary condition supplies a fixed value constraint, and is the base class for a number of othe...
virtual void write(Ostream &) const
Write.
This boundary condition sets a fixed value. When the flow direction is inwards this acts exactly like...
virtual tmp< Field< Type > > valueInternalCoeffs(const tmp< scalarField > &) const
Return the matrix diagonal coefficients corresponding to the.
virtual tmp< Field< Type > > valueBoundaryCoeffs(const tmp< scalarField > &) const
Return the matrix source coefficients corresponding to the.
fixedValueInletOutletFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &, const dictionary &, const bool valueRequired=true)
Construct from patch, internal field and dictionary.
Foam::fvPatchFieldMapper.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:64
Traits class for primitives.
Definition: pTraits.H:53
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:62
static const zero Zero
Definition: zero.H:97
dimensionedScalar pos0(const dimensionedScalar &ds)
dictionary dict
volScalarField & p
Foam::surfaceFields.