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-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 "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_ =
61  (
62  "gradient",
63  iF.dimensions()/dimLength,
64  dict,
65  p.size()
66  );
67  evaluate();
68  }
69  else
70  {
72  << "Essential entry 'gradient' missing"
73  << exit(FatalIOError);
74  }
75  }
76 }
77 
78 
79 template<class Type>
81 (
83  const fvPatch& p,
85  const fieldMapper& mapper,
86  const bool mappingRequired
87 )
88 :
89  fvPatchField<Type>(ptf, p, iF, mapper, mappingRequired),
90  gradient_(p.size())
91 {
92  if (mappingRequired)
93  {
94  mapper(gradient_, ptf.gradient_);
95  }
96 }
97 
98 
99 template<class Type>
101 (
104 )
105 :
106  fvPatchField<Type>(ptf, iF),
107  gradient_(ptf.gradient_)
108 {}
109 
110 
111 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
112 
113 template<class Type>
115 (
116  const fvPatchField<Type>& ptf,
117  const fieldMapper& mapper
118 )
119 {
120  fvPatchField<Type>::map(ptf, mapper);
121 
122  const fixedGradientFvPatchField<Type>& fgptf =
123  refCast<const fixedGradientFvPatchField<Type>>(ptf);
124 
125  mapper(gradient_, fgptf.gradient_);
126 }
127 
128 
129 template<class Type>
131 (
132  const fvPatchField<Type>& ptf
133 )
134 {
136 
137  const fixedGradientFvPatchField<Type>& fgptf =
138  refCast<const fixedGradientFvPatchField<Type>>(ptf);
139 
140  gradient_.reset(fgptf.gradient_);
141 }
142 
143 
144 template<class Type>
146 {
147  if (!this->updated())
148  {
149  this->updateCoeffs();
150  }
151 
153  (
154  this->patchInternalField() + gradient_/this->patch().deltaCoeffs()
155  );
156 
158 }
159 
160 
161 template<class Type>
164 (
165  const tmp<scalarField>&
166 ) const
167 {
168  return tmp<Field<Type>>(new Field<Type>(this->size(), pTraits<Type>::one));
169 }
170 
171 
172 template<class Type>
175 (
176  const tmp<scalarField>&
177 ) const
178 {
179  return gradient()/this->patch().deltaCoeffs();
180 }
181 
182 
183 template<class Type>
186 {
187  return tmp<Field<Type>>
188  (
189  new Field<Type>(this->size(), Zero)
190  );
191 }
192 
193 
194 template<class Type>
197 {
198  return gradient();
199 }
200 
201 
202 template<class Type>
204 {
206  writeEntry(os, "gradient", gradient_);
207 }
208 
209 
210 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const dimensionSet & dimensions() const
Return dimensions.
Pre-declare SubField and related Field type.
Definition: Field.H:83
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:162
Abstract base class for field mapping.
Definition: fieldMapper.H:48
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 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.
virtual void map(const fvPatchField< Type > &, const fieldMapper &)
Map the given fvPatchField onto this fvPatchField.
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:88
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field, sets Updated to false.
Definition: fvPatchField.C:209
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:229
virtual void reset(const fvPatchField< Type > &)
Reset the fvPatchField to the given fvPatchField.
Definition: fvPatchField.C:195
virtual void map(const fvPatchField< Type > &, const fieldMapper &)
Map the given fvPatchField onto this fvPatchField.
Definition: fvPatchField.C:185
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:346
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
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
IOerror FatalIOError
dictionary dict
volScalarField & p