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-2014 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  {
62  WarningIn
63  (
64  "fixedGradientFvPatchField<Type>::fixedGradientFvPatchField\n"
65  "(\n"
66  " const fixedGradientFvPatchField<Type>&,\n"
67  " const fvPatch&,\n"
68  " const DimensionedField<Type, volMesh>&,\n"
69  " const fvPatchFieldMapper&\n"
70  ")\n"
71  ) << "On field " << iF.name() << " patch " << p.name()
72  << " patchField " << this->type()
73  << " : mapper does not map all values." << nl
74  << " To avoid this warning fully specify the mapping in derived"
75  << " patch fields." << endl;
76  }
77 }
78 
79 
80 template<class Type>
82 (
83  const fvPatch& p,
85  const dictionary& dict
86 )
87 :
89  gradient_("gradient", dict, p.size())
90 {
91  evaluate();
92 }
93 
94 
95 template<class Type>
97 (
99 )
100 :
101  fvPatchField<Type>(ptf),
102  gradient_(ptf.gradient_)
103 {}
104 
105 
106 template<class Type>
108 (
111 )
112 :
113  fvPatchField<Type>(ptf, iF),
114  gradient_(ptf.gradient_)
115 {}
116 
117 
118 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
119 
120 template<class Type>
122 (
123  const fvPatchFieldMapper& m
124 )
125 {
127  gradient_.autoMap(m);
128 }
129 
130 
131 template<class Type>
133 (
134  const fvPatchField<Type>& ptf,
135  const labelList& addr
136 )
137 {
138  fvPatchField<Type>::rmap(ptf, addr);
139 
140  const fixedGradientFvPatchField<Type>& fgptf =
141  refCast<const fixedGradientFvPatchField<Type> >(ptf);
142 
143  gradient_.rmap(fgptf.gradient_, addr);
144 }
145 
146 
147 template<class Type>
149 {
150  if (!this->updated())
151  {
152  this->updateCoeffs();
153  }
154 
156  (
157  this->patchInternalField() + gradient_/this->patch().deltaCoeffs()
158  );
159 
161 }
162 
163 
164 template<class Type>
166 (
167  const tmp<scalarField>&
168 ) const
169 {
170  return tmp<Field<Type> >(new Field<Type>(this->size(), pTraits<Type>::one));
171 }
172 
173 
174 template<class Type>
176 (
177  const tmp<scalarField>&
178 ) const
179 {
180  return gradient()/this->patch().deltaCoeffs();
181 }
182 
183 
184 template<class Type>
187 {
188  return tmp<Field<Type> >
189  (
190  new Field<Type>(this->size(), pTraits<Type>::zero)
191  );
192 }
193 
194 
195 template<class Type>
198 {
199  return gradient();
200 }
201 
202 
203 template<class Type>
205 {
207  gradient_.writeEntry("gradient", os);
208 }
209 
210 
211 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
212 
213 } // End namespace Foam
214 
215 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::fvPatchFieldMapper.
bool notNull(const T &t)
Return true if t is not a reference to the nullObject of type T.
Definition: nullObjectI.H:46
virtual void rmap(const fvPatchField< Type > &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
fixedGradientFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:354
virtual tmp< Field< Type > > gradientInternalCoeffs() const
Return the matrix diagonal coefficients corresponding to the.
Namespace for OpenFOAM.
dictionary dict
static const char nl
Definition: Ostream.H:260
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
This boundary condition supplies a fixed gradient condition, such that the patch values are calculate...
virtual void rmap(const fvPatchField< Type > &, const labelList &)
Reverse map the given fvPatchField onto this fvPatchField.
Definition: fvPatchField.C:291
#define WarningIn(functionName)
Report a warning using Foam::Warning.
volScalarField & p
Definition: createFields.H:51
virtual tmp< Field< Type > > valueBoundaryCoeffs(const tmp< scalarField > &) const
Return the matrix source coefficients corresponding to the.
commsTypes
Types of communications.
Definition: UPstream.H:64
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:65
Pre-declare SubField and related Field type.
Definition: Field.H:57
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::blocking)
Evaluate the patch field, sets Updated to false.
Definition: fvPatchField.C:323
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:589
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
Definition: fvPatchField.C:230
Traits class for primitives.
Definition: pTraits.H:50
virtual void autoMap(const fvPatchFieldMapper &)
Map (and resize as needed) from self given a mapping object.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
virtual void write(Ostream &) const
Write.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::blocking)
Evaluate the patch field.
virtual bool hasUnmapped() const =0
Are there unmapped values? I.e. do all size() elements get.
virtual tmp< Field< Type > > gradientBoundaryCoeffs() const
Return the matrix source coefficients corresponding to the.
A class for managing temporary objects.
Definition: PtrList.H:118
virtual tmp< Field< Type > > valueInternalCoeffs(const tmp< scalarField > &) const
Return the matrix diagonal coefficients corresponding to the.