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-2022 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 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
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  // For unmapped faces set to internal field value (zero-gradient)
88  if (mapper.hasUnmapped())
89  {
90  gradient_ = Zero;
91  }
92  mapper(gradient_, ptf.gradient_);
93  }
94 }
95 
96 
97 template<class Type>
99 (
102 )
103 :
104  fvPatchField<Type>(ptf, iF),
105  gradient_(ptf.gradient_)
106 {}
107 
108 
109 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
110 
111 template<class Type>
113 (
114  const fvPatchFieldMapper& m
115 )
116 {
118  m(gradient_, gradient_);
119 }
120 
121 
122 template<class Type>
124 (
125  const fvPatchField<Type>& ptf,
126  const labelList& addr
127 )
128 {
129  fvPatchField<Type>::rmap(ptf, addr);
130 
131  const fixedGradientFvPatchField<Type>& fgptf =
132  refCast<const fixedGradientFvPatchField<Type>>(ptf);
133 
134  gradient_.rmap(fgptf.gradient_, addr);
135 }
136 
137 
138 template<class Type>
140 (
141  const fvPatchField<Type>& ptf
142 )
143 {
145 
146  const fixedGradientFvPatchField<Type>& fgptf =
147  refCast<const fixedGradientFvPatchField<Type>>(ptf);
148 
149  gradient_.reset(fgptf.gradient_);
150 }
151 
152 
153 template<class Type>
155 {
156  if (!this->updated())
157  {
158  this->updateCoeffs();
159  }
160 
162  (
163  this->patchInternalField() + gradient_/this->patch().deltaCoeffs()
164  );
165 
167 }
168 
169 
170 template<class Type>
173 (
174  const tmp<scalarField>&
175 ) const
176 {
177  return tmp<Field<Type>>(new Field<Type>(this->size(), pTraits<Type>::one));
178 }
179 
180 
181 template<class Type>
184 (
185  const tmp<scalarField>&
186 ) const
187 {
188  return gradient()/this->patch().deltaCoeffs();
189 }
190 
191 
192 template<class Type>
195 {
196  return tmp<Field<Type>>
197  (
198  new Field<Type>(this->size(), Zero)
199  );
200 }
201 
202 
203 template<class Type>
206 {
207  return gradient();
208 }
209 
210 
211 template<class Type>
213 {
215  writeEntry(os, "gradient", gradient_);
216 }
217 
218 
219 // ************************************************************************* //
dictionary dict
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
void evaluate(GeometricField< Type, PatchField, GeoMesh > &result, const Function1< Type > &func, const GeometricField< Type, PatchField, GeoMesh > &x)
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
commsTypes
Types of communications.
Definition: UPstream.H:64
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:63
Traits class for primitives.
Definition: pTraits.H:50
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:66
virtual void rmap(const fvPatchField< Type > &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
virtual tmp< Field< Type > > gradientBoundaryCoeffs() const
Return the matrix source coefficients corresponding to the.
virtual void write(Ostream &) const
Write.
virtual tmp< Field< Type > > valueInternalCoeffs(const tmp< scalarField > &) const
Return the matrix diagonal coefficients corresponding to the.
fixedGradientFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Pre-declare SubField and related Field type.
Definition: Field.H:56
Foam::fvPatchFieldMapper.
virtual tmp< Field< Type > > valueBoundaryCoeffs(const tmp< scalarField > &) const
Return the matrix source coefficients corresponding to the.
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
virtual tmp< Field< Type > > gradientInternalCoeffs() const
Return the matrix diagonal coefficients corresponding to the.
static const zero Zero
Definition: zero.H:97
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
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.
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
virtual void reset(const fvPatchField< Type > &)
Reset the fvPatchField to the given fvPatchField.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:318
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
volScalarField & p
A class for managing temporary objects.
Definition: PtrList.H:53
IOerror FatalIOError