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 | Copyright (C) 2011-2015 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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 
34 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
35 
36 template<class Type>
38 (
39  const fvPatch& p,
41 )
42 :
43  fvPatchField<Type>(p, iF),
44  gradient_(p.size(), pTraits<Type>::zero)
45 {}
46 
47 
48 template<class Type>
50 (
52  const fvPatch& p,
54  const fvPatchFieldMapper& mapper
55 )
56 :
57  fvPatchField<Type>(ptf, p, iF, mapper),
58  gradient_(ptf.gradient_, mapper)
59 {
60  if (notNull(iF) && mapper.hasUnmapped())
61  {
63  << "On field " << iF.name() << " patch " << p.name()
64  << " patchField " << this->type()
65  << " : mapper does not map all values." << nl
66  << " To avoid this warning fully specify the mapping in derived"
67  << " patch fields." << endl;
68  }
69 }
70 
71 
72 template<class Type>
74 (
75  const fvPatch& p,
77  const dictionary& dict
78 )
79 :
81  gradient_("gradient", dict, p.size())
82 {
83  evaluate();
84 }
85 
86 
87 template<class Type>
89 (
91 )
92 :
93  fvPatchField<Type>(ptf),
94  gradient_(ptf.gradient_)
95 {}
96 
97 
98 template<class Type>
100 (
103 )
104 :
105  fvPatchField<Type>(ptf, iF),
106  gradient_(ptf.gradient_)
107 {}
108 
109 
110 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
111 
112 template<class Type>
114 (
115  const fvPatchFieldMapper& m
116 )
117 {
119  gradient_.autoMap(m);
120 }
121 
122 
123 template<class Type>
125 (
126  const fvPatchField<Type>& ptf,
127  const labelList& addr
128 )
129 {
130  fvPatchField<Type>::rmap(ptf, addr);
131 
132  const fixedGradientFvPatchField<Type>& fgptf =
133  refCast<const fixedGradientFvPatchField<Type> >(ptf);
134 
135  gradient_.rmap(fgptf.gradient_, addr);
136 }
137 
138 
139 template<class Type>
141 {
142  if (!this->updated())
143  {
144  this->updateCoeffs();
145  }
146 
148  (
149  this->patchInternalField() + gradient_/this->patch().deltaCoeffs()
150  );
151 
153 }
154 
155 
156 template<class Type>
158 (
159  const tmp<scalarField>&
160 ) const
161 {
162  return tmp<Field<Type> >(new Field<Type>(this->size(), pTraits<Type>::one));
163 }
164 
165 
166 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(), pTraits<Type>::zero)
183  );
184 }
185 
186 
187 template<class Type>
190 {
191  return gradient();
192 }
193 
194 
195 template<class Type>
197 {
199  gradient_.writeEntry("gradient", os);
200 }
201 
202 
203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204 
205 } // End namespace Foam
206 
207 // ************************************************************************* //
Foam::fvPatchField< Type >
Foam::fixedGradientFvPatchField::evaluate
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::blocking)
Evaluate the patch field.
Definition: fixedGradientFvPatchField.C:140
Foam::fvPatchField::write
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:349
Foam::fvPatchField::evaluate
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::blocking)
Evaluate the patch field, sets Updated to false.
Definition: fvPatchField.C:318
p
p
Definition: pEqn.H:62
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::notNull
bool notNull(const T &t)
Return true if t is not a reference to the nullObject of type T.
Definition: nullObjectI.H:46
Foam::fixedGradientFvPatchField::write
virtual void write(Ostream &) const
Write.
Definition: fixedGradientFvPatchField.C:196
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::fixedGradientFvPatchField::valueBoundaryCoeffs
virtual tmp< Field< Type > > valueBoundaryCoeffs(const tmp< scalarField > &) const
Return the matrix source coefficients corresponding to the.
Definition: fixedGradientFvPatchField.C:168
Foam::FieldMapper::hasUnmapped
virtual bool hasUnmapped() const =0
Are there unmapped values? I.e. do all size() elements get.
fixedGradientFvPatchField.H
Foam::fixedGradientFvPatchField::gradientBoundaryCoeffs
virtual tmp< Field< Type > > gradientBoundaryCoeffs() const
Return the matrix source coefficients corresponding to the.
Definition: fixedGradientFvPatchField.C:189
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
Foam::fixedGradientFvPatchField::autoMap
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: fixedGradientFvPatchField.C:114
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::fvPatchField::rmap
virtual void rmap(const fvPatchField< Type > &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
Definition: fvPatchField.C:286
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::fixedGradientFvPatchField::gradientInternalCoeffs
virtual tmp< Field< Type > > gradientInternalCoeffs() const
Return the matrix diagonal coefficients corresponding to the.
Definition: fixedGradientFvPatchField.C:178
Foam::fixedGradientFvPatchField::fixedGradientFvPatchField
fixedGradientFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Definition: fixedGradientFvPatchField.C:38
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:64
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::pTraits
Traits class for primitives.
Definition: pTraits.H:50
dictionary.H
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:45
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:53
Foam::type
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:588
Foam::fixedGradientFvPatchField
This boundary condition supplies a fixed gradient condition, such that the patch values are calculate...
Definition: fixedGradientFvPatchField.H:107
Foam::fixedGradientFvPatchField::rmap
virtual void rmap(const fvPatchField< Type > &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
Definition: fixedGradientFvPatchField.C:125
Foam::fixedGradientFvPatchField::valueInternalCoeffs
virtual tmp< Field< Type > > valueInternalCoeffs(const tmp< scalarField > &) const
Return the matrix diagonal coefficients corresponding to the.
Definition: fixedGradientFvPatchField.C:158
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:259
Foam::fvPatchField::autoMap
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: fvPatchField.C:223
Foam::fixedGradientFvPatchField::gradient_
Field< Type > gradient_
Definition: fixedGradientFvPatchField.H:113
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:51