fixedGradientFvPatchField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
29 #include "dictionary.H"
30 
31 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
32 
33 template<class Type>
35 (
36  const fvPatch& p,
38 )
39 :
40  fvPatchField<Type>(p, iF),
41  gradient_(p.size(), Zero)
42 {}
43 
44 
45 template<class Type>
47 (
48  const fvPatch& p,
50  const dictionary& dict
51 )
52 :
53  fvPatchField<Type>(p, iF, dict, false),
54  gradient_("gradient", dict, p.size())
55 {
56  evaluate();
57 }
58 
59 
60 template<class Type>
62 (
64  const fvPatch& p,
66  const fvPatchFieldMapper& mapper
67 )
68 :
69  fvPatchField<Type>(ptf, p, iF, mapper),
70  gradient_(ptf.gradient_, mapper)
71 {
72  if (notNull(iF) && mapper.hasUnmapped())
73  {
75  << "On field " << iF.name() << " patch " << p.name()
76  << " patchField " << this->type()
77  << " : mapper does not map all values." << nl
78  << " To avoid this warning fully specify the mapping in derived"
79  << " patch fields." << endl;
80  }
81 }
82 
83 
84 template<class Type>
86 (
88 )
89 :
90  fvPatchField<Type>(ptf),
91  gradient_(ptf.gradient_)
92 {}
93 
94 
95 template<class Type>
97 (
100 )
101 :
102  fvPatchField<Type>(ptf, iF),
103  gradient_(ptf.gradient_)
104 {}
105 
106 
107 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
108 
109 template<class Type>
111 (
112  const fvPatchFieldMapper& m
113 )
114 {
116  gradient_.autoMap(m);
117 }
118 
119 
120 template<class Type>
122 (
123  const fvPatchField<Type>& ptf,
124  const labelList& addr
125 )
126 {
127  fvPatchField<Type>::rmap(ptf, addr);
128 
129  const fixedGradientFvPatchField<Type>& fgptf =
130  refCast<const fixedGradientFvPatchField<Type>>(ptf);
131 
132  gradient_.rmap(fgptf.gradient_, addr);
133 }
134 
135 
136 template<class Type>
138 {
139  if (!this->updated())
140  {
141  this->updateCoeffs();
142  }
143 
145  (
146  this->patchInternalField() + gradient_/this->patch().deltaCoeffs()
147  );
148 
150 }
151 
152 
153 template<class Type>
156 (
157  const tmp<scalarField>&
158 ) const
159 {
160  return tmp<Field<Type>>::New(this->size(), pTraits<Type>::one);
161 }
162 
163 
164 template<class Type>
167 (
168  const tmp<scalarField>&
169 ) const
170 {
171  return gradient()/this->patch().deltaCoeffs();
172 }
173 
174 
175 template<class Type>
178 {
179  return tmp<Field<Type>>::New(this->size(), Zero);
180 }
181 
182 
183 template<class Type>
186 {
187  return gradient();
188 }
189 
190 
191 template<class Type>
193 {
195  gradient_.writeEntry("gradient", os);
196 }
197 
198 
199 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:51
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::Zero
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
Foam::fixedGradientFvPatchField::write
virtual void write(Ostream &) const
Write.
Definition: fixedGradientFvPatchField.C:192
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::FieldMapper::hasUnmapped
virtual bool hasUnmapped() const =0
Are there unmapped values? I.e. do all size() elements get.
fixedGradientFvPatchField.H
Foam::fixedGradientFvPatchField::evaluate
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field.
Definition: fixedGradientFvPatchField.C:137
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::fixedGradientFvPatchField::valueBoundaryCoeffs
virtual tmp< Field< Type > > valueBoundaryCoeffs(const tmp< scalarField > &) const
Return the matrix source coefficients corresponding to the.
Definition: fixedGradientFvPatchField.C:167
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
Foam::fixedGradientFvPatchField::autoMap
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: fixedGradientFvPatchField.C:111
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::notNull
bool notNull(const T *ptr)
True if ptr is not a pointer (of type T) to the nullObject.
Definition: nullObject.H:207
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam::fixedGradientFvPatchField::valueInternalCoeffs
virtual tmp< Field< Type > > valueInternalCoeffs(const tmp< scalarField > &) const
Return the matrix diagonal coefficients corresponding to the.
Definition: fixedGradientFvPatchField.C:156
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:69
Foam::fixedGradientFvPatchField::fixedGradientFvPatchField
fixedGradientFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Definition: fixedGradientFvPatchField.C:35
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::List< label >
Foam::pTraits
A traits class, which is primarily used for primitives.
Definition: pTraits.H:56
dictionary.H
Foam::vtk::write
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
Definition: foamVtkOutputTemplates.C:36
Foam::roots::type
type
Types of root.
Definition: Roots.H:54
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:47
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::fixedGradientFvPatchField
This boundary condition supplies a fixed gradient condition, such that the patch values are calculate...
Definition: fixedGradientFvPatchField.H:108
Foam::fixedGradientFvPatchField::rmap
virtual void rmap(const fvPatchField< Type > &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
Definition: fixedGradientFvPatchField.C:122
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:328
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54
Foam::fixedGradientFvPatchField::gradientBoundaryCoeffs
virtual tmp< Field< Type > > gradientBoundaryCoeffs() const
Return the matrix source coefficients corresponding to the.
Definition: fixedGradientFvPatchField.C:185
Foam::stringOps::evaluate
string evaluate(label fieldWidth, const std::string &s, size_t pos=0, size_t len=std::string::npos)
String evaluation with specified (positive, non-zero) field width.
Definition: stringOpsEvaluate.C:37
Foam::fixedGradientFvPatchField::gradientInternalCoeffs
virtual tmp< Field< Type > > gradientInternalCoeffs() const
Return the matrix diagonal coefficients corresponding to the.
Definition: fixedGradientFvPatchField.C:177