fixedGradientFvPatchField.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 "dictionary.H"
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
31 template<class Type>
33 (
34  const fvPatch& p,
36 )
37 :
38  fvPatchField<Type>(p, iF),
39  gradient_(p.size(), Zero)
40 {}
41 
42 
43 template<class Type>
45 (
46  const fvPatch& p,
48  const dictionary& dict,
49  const bool gradientRequired
50 )
51 :
52  fvPatchField<Type>(p, iF, dict, false),
53  gradient_(p.size())
54 {
55  if (gradientRequired)
56  {
57  if (dict.found("gradient"))
58  {
59  gradient_ = Field<Type>("gradient", dict, p.size());
60  evaluate();
61  }
62  else
63  {
65  << "Essential entry 'gradient' missing"
66  << exit(FatalIOError);
67  }
68  }
69 }
70 
71 
72 template<class Type>
74 (
76  const fvPatch& p,
78  const fvPatchFieldMapper& mapper,
79  const bool mappingRequired
80 )
81 :
82  fvPatchField<Type>(ptf, p, iF, mapper, mappingRequired),
83  gradient_(p.size())
84 {
85  if (mappingRequired)
86  {
87  mapper(gradient_, ptf.gradient_);
88  }
89 }
90 
91 
92 template<class Type>
94 (
97 )
98 :
99  fvPatchField<Type>(ptf, iF),
100  gradient_(ptf.gradient_)
101 {}
102 
103 
104 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
105 
106 template<class Type>
108 (
109  const fvPatchField<Type>& ptf,
110  const fvPatchFieldMapper& mapper
111 )
112 {
113  fvPatchField<Type>::map(ptf, mapper);
114 
115  const fixedGradientFvPatchField<Type>& fgptf =
116  refCast<const fixedGradientFvPatchField<Type>>(ptf);
117 
118  mapper(gradient_, fgptf.gradient_);
119 }
120 
121 
122 template<class Type>
124 (
125  const fvPatchField<Type>& ptf
126 )
127 {
129 
130  const fixedGradientFvPatchField<Type>& fgptf =
131  refCast<const fixedGradientFvPatchField<Type>>(ptf);
132 
133  gradient_.reset(fgptf.gradient_);
134 }
135 
136 
137 template<class Type>
139 {
140  if (!this->updated())
141  {
142  this->updateCoeffs();
143  }
144 
146  (
147  this->patchInternalField() + gradient_/this->patch().deltaCoeffs()
148  );
149 
151 }
152 
153 
154 template<class Type>
157 (
158  const tmp<scalarField>&
159 ) const
160 {
161  return tmp<Field<Type>>(new Field<Type>(this->size(), pTraits<Type>::one));
162 }
163 
164 
165 template<class Type>
168 (
169  const tmp<scalarField>&
170 ) const
171 {
172  return gradient()/this->patch().deltaCoeffs();
173 }
174 
175 
176 template<class Type>
179 {
180  return tmp<Field<Type>>
181  (
182  new Field<Type>(this->size(), Zero)
183  );
184 }
185 
186 
187 template<class Type>
190 {
191  return gradient();
192 }
193 
194 
195 template<class Type>
197 {
199  writeEntry(os, "gradient", gradient_);
200 }
201 
202 
203 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Pre-declare SubField and related Field type.
Definition: Field.H:82
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
commsTypes
Types of communications.
Definition: UPstream.H:65
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 gradient condition, such that the patch values are calculate...
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field.
virtual void write(Ostream &) const
Write.
virtual tmp< Field< Type > > gradientInternalCoeffs() const
Return the matrix diagonal coefficients corresponding to the.
virtual tmp< Field< Type > > valueInternalCoeffs(const tmp< scalarField > &) const
Return the matrix diagonal coefficients corresponding to the.
virtual tmp< Field< Type > > gradientBoundaryCoeffs() const
Return the matrix source coefficients corresponding to the.
virtual void reset(const fvPatchField< Type > &)
Reset the fvPatchField to the given fvPatchField.
virtual void map(const fvPatchField< Type > &, const fvPatchFieldMapper &)
Map the given fvPatchField onto this fvPatchField.
virtual tmp< Field< Type > > valueBoundaryCoeffs(const tmp< scalarField > &) const
Return the matrix source coefficients corresponding to the.
fixedGradientFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
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 evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field, sets Updated to false.
Definition: fvPatchField.C:211
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:231
virtual void reset(const fvPatchField< Type > &)
Reset the fvPatchField to the given fvPatchField.
Definition: fvPatchField.C:197
virtual void map(const fvPatchField< Type > &, const fvPatchFieldMapper &)
Map the given fvPatchField onto this fvPatchField.
Definition: fvPatchField.C:187
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
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:318
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
static const zero Zero
Definition: zero.H:97
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
IOerror FatalIOError
dictionary dict
volScalarField & p