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-2019 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 )
50 :
51  fvPatchField<Type>(p, iF, dict, false),
52  gradient_("gradient", dict, p.size())
53 {
54  evaluate();
55 }
56 
57 
58 template<class Type>
60 (
62  const fvPatch& p,
64  const fvPatchFieldMapper& mapper
65 )
66 :
67  fvPatchField<Type>(ptf, p, iF, mapper),
68  gradient_(mapper(ptf.gradient_))
69 {
70  if (notNull(iF) && mapper.hasUnmapped())
71  {
73  << "On field " << iF.name() << " patch " << p.name()
74  << " patchField " << this->type()
75  << " : mapper does not map all values." << nl
76  << " To avoid this warning fully specify the mapping in derived"
77  << " patch fields." << endl;
78  }
79 }
80 
81 
82 template<class Type>
84 (
86 )
87 :
88  fvPatchField<Type>(ptf),
89  gradient_(ptf.gradient_)
90 {}
91 
92 
93 template<class Type>
95 (
98 )
99 :
100  fvPatchField<Type>(ptf, iF),
101  gradient_(ptf.gradient_)
102 {}
103 
104 
105 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
106 
107 template<class Type>
109 (
110  const fvPatchFieldMapper& m
111 )
112 {
114  m(gradient_, gradient_);
115 }
116 
117 
118 template<class Type>
120 (
121  const fvPatchField<Type>& ptf,
122  const labelList& addr
123 )
124 {
125  fvPatchField<Type>::rmap(ptf, addr);
126 
127  const fixedGradientFvPatchField<Type>& fgptf =
128  refCast<const fixedGradientFvPatchField<Type>>(ptf);
129 
130  gradient_.rmap(fgptf.gradient_, addr);
131 }
132 
133 
134 template<class Type>
136 {
137  if (!this->updated())
138  {
139  this->updateCoeffs();
140  }
141 
143  (
144  this->patchInternalField() + gradient_/this->patch().deltaCoeffs()
145  );
146 
148 }
149 
150 
151 template<class Type>
154 (
155  const tmp<scalarField>&
156 ) const
157 {
158  return tmp<Field<Type>>(new Field<Type>(this->size(), pTraits<Type>::one));
159 }
160 
161 
162 template<class Type>
165 (
166  const tmp<scalarField>&
167 ) const
168 {
169  return gradient()/this->patch().deltaCoeffs();
170 }
171 
172 
173 template<class Type>
176 {
177  return tmp<Field<Type>>
178  (
179  new Field<Type>(this->size(), Zero)
180  );
181 }
182 
183 
184 template<class Type>
187 {
188  return gradient();
189 }
190 
191 
192 template<class Type>
194 {
196  writeEntry(os, "gradient", gradient_);
197 }
198 
199 
200 // ************************************************************************* //
dictionary dict
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:158
commsTypes
Types of communications.
Definition: UPstream.H:64
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
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 bool hasUnmapped() const =0
Are there unmapped values? I.e. do all size() elements get.
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
static const char nl
Definition: Ostream.H:260
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
bool notNull(const T &t)
Return true if t is not a reference to the nullObject of type T.
Definition: nullObjectI.H:52
#define WarningInFunction
Report a warning using Foam::Warning.
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
Definition: POSIX.C:488
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