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-2021 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 )
39 :
40  fixedGradientFvPatchScalarField(p, iF),
41  curTimeIndex_(-1)
42 {}
43 
44 
46 (
47  const fvPatch& p,
49  const dictionary& dict
50 )
51 :
52  fixedGradientFvPatchScalarField(p, iF, dict, false),
53  curTimeIndex_(-1)
54 {
55  if (dict.found("value") && dict.found("gradient"))
56  {
58  gradient() = scalarField("gradient", dict, p.size());
59  }
60  else
61  {
62  fvPatchField<scalar>::operator=(patchInternalField());
63  gradient() = Zero;
64  }
65 }
66 
67 
69 (
71  const fvPatch& p,
73  const fvPatchFieldMapper& mapper
74 )
75 :
76  fixedGradientFvPatchScalarField(ptf, p, iF, mapper),
77  curTimeIndex_(-1)
78 {}
79 
80 
82 (
85 )
86 :
87  fixedGradientFvPatchScalarField(wbppsf, iF),
88  curTimeIndex_(-1)
89 {}
90 
91 
92 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
93 
95 (
96  const scalarField& snGradp
97 )
98 {
99  if (updated())
100  {
101  return;
102  }
103 
104  curTimeIndex_ = this->db().time().timeIndex();
105 
106  gradient() = snGradp;
107  fixedGradientFvPatchScalarField::updateCoeffs();
108 }
109 
110 
112 {
113  if (updated())
114  {
115  return;
116  }
117 
118  if (curTimeIndex_ != this->db().time().timeIndex())
119  {
121  << "updateCoeffs(const scalarField& snGradp) MUST be called before"
122  " updateCoeffs() or evaluate() to set the boundary gradient."
123  << exit(FatalError);
124  }
125 }
126 
127 
129 {
131  writeEntry(os, "value", *this);
132 }
133 
134 
135 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
136 
137 namespace Foam
138 {
140  (
143  );
144 }
145 
146 
147 // ************************************************************************* //
Foam::surfaceFields.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:663
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:63
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:66
Macros for easy insertion into run-time selection tables.
virtual void updateCoeffs()
Update the patch pressure gradient field.
Foam::fvPatchFieldMapper.
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
static const zero Zero
Definition: zero.H:97
This boundary condition sets the pressure gradient to the provided value such that the flux on the bo...
virtual label size() const
Return size.
Definition: fvPatch.H:157
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
volScalarField scalarField(fieldObject, mesh)
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
fixedFluxPressureFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
label timeIndex
Definition: getTimeIndex.H:4
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
makePatchTypeField(fvPatchScalarField, atmBoundaryLayerInletEpsilonFvPatchScalarField)
Namespace for OpenFOAM.