fixedFluxPressureFvPatchScalarField.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) 2011-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 "fvPatchFieldMapper.H"
28 #include "volFields.H"
29 #include "surfaceFields.H"
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
35 (
36  const fvPatch& p,
38  const dictionary& dict
39 )
40 :
41  fixedGradientFvPatchScalarField(p, iF, dict, false),
42  curTimeIndex_(-1)
43 {
44  if (dict.found("value") && dict.found("gradient"))
45  {
47  gradient() = scalarField("gradient", dict, p.size());
48  }
49  else
50  {
51  fvPatchField<scalar>::operator=(patchInternalField());
52  gradient() = Zero;
53  }
54 }
55 
56 
58 (
60  const fvPatch& p,
62  const fvPatchFieldMapper& mapper
63 )
64 :
65  fixedGradientFvPatchScalarField(ptf, p, iF, mapper),
66  curTimeIndex_(-1)
67 {}
68 
69 
71 (
74 )
75 :
76  fixedGradientFvPatchScalarField(wbppsf, iF),
77  curTimeIndex_(-1)
78 {}
79 
80 
81 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
82 
84 (
85  const scalarField& snGradp
86 )
87 {
88  if (updated())
89  {
90  return;
91  }
92 
93  curTimeIndex_ = this->db().time().timeIndex();
94 
95  gradient() = snGradp;
96  fixedGradientFvPatchScalarField::updateCoeffs();
97 }
98 
99 
101 {
102  if (updated())
103  {
104  return;
105  }
106 
107  if (curTimeIndex_ != this->db().time().timeIndex())
108  {
110  << "updateCoeffs(const scalarField& snGradp) MUST be called before"
111  " updateCoeffs() or evaluate() to set the boundary gradient."
112  << exit(FatalError);
113  }
114 }
115 
116 
118 {
120  writeEntry(os, "value", *this);
121 }
122 
123 
124 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
125 
126 namespace Foam
127 {
129  (
132  );
133 }
134 
135 
136 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
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 sets the pressure gradient to the provided value such that the flux on the bo...
virtual void updateCoeffs()
Update the patch pressure gradient field.
fixedFluxPressureFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &, const dictionary &)
Construct from patch, internal field and dictionary.
Foam::fvPatchFieldMapper.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:87
virtual void operator=(const UList< Type > &)
Definition: fvPatchField.C:251
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:64
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
static const zero Zero
Definition: zero.H:97
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
error FatalError
makePatchTypeField(fvPatchScalarField, atmBoundaryLayerInletEpsilonFvPatchScalarField)
label timeIndex
Definition: getTimeIndex.H:4
dictionary dict
volScalarField & p
Foam::surfaceFields.