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-2024 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 "fieldMapper.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  (
48  scalarField("value", iF.dimensions(), dict, p.size())
49  );
50  gradient() =
51  scalarField("gradient", iF.dimensions()/dimLength, dict, p.size());
52  }
53  else
54  {
55  fvPatchField<scalar>::operator=(patchInternalField());
56  gradient() = Zero;
57  }
58 }
59 
60 
62 (
64  const fvPatch& p,
66  const fieldMapper& mapper
67 )
68 :
69  fixedGradientFvPatchScalarField(ptf, p, iF, mapper, false),
70  curTimeIndex_(-1)
71 {
72  map(refCast<const fixedFluxPressureFvPatchScalarField>(ptf), mapper);
73 }
74 
75 
77 (
80 )
81 :
82  fixedGradientFvPatchScalarField(wbppsf, iF),
83  curTimeIndex_(-1)
84 {}
85 
86 
87 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
88 
90 (
92  const fieldMapper& mapper
93 )
94 {
95  mapper(*this, ptf, [&](){ return patchInternalField(); });
96  mapper(gradient(), ptf.gradient(), scalar(0));
97 }
98 
99 
101 (
102  const fvPatchScalarField& ptf,
103  const fieldMapper& mapper
104 )
105 {
106  map(refCast<const fixedFluxPressureFvPatchScalarField>(ptf), mapper);
107 }
108 
109 
111 (
112  const scalarField& snGradp
113 )
114 {
115  if (updated())
116  {
117  return;
118  }
119 
120  curTimeIndex_ = this->db().time().timeIndex();
121 
122  gradient() = snGradp;
123  fixedGradientFvPatchScalarField::updateCoeffs();
124 }
125 
126 
128 {
129  if (updated())
130  {
131  return;
132  }
133 
134  if (curTimeIndex_ != this->db().time().timeIndex())
135  {
137  << "updateCoeffs(const scalarField& snGradp) MUST be called before"
138  " updateCoeffs() or evaluate() to set the boundary gradient."
139  << exit(FatalError);
140  }
141 }
142 
143 
145 {
147  writeEntry(os, "value", *this);
148 }
149 
150 
151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152 
153 namespace Foam
154 {
156  (
159  );
160 }
161 
162 
163 // ************************************************************************* //
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...
const dimensionSet & dimensions() const
Return dimensions.
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:162
Abstract base class for field mapping.
Definition: fieldMapper.H:48
This boundary condition sets the pressure gradient to the provided value such that the flux on the bo...
void map(const fixedFluxPressureFvPatchScalarField &, const fieldMapper &)
Map the given fvPatchField onto this fvPatchField.
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.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:88
virtual void operator=(const UList< Type > &)
Definition: fvPatchField.C:249
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:334
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
const dimensionSet dimLength
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.