FreeFOAM The Cross-Platform CFD Toolkit
solidWallHeatFluxTemperatureFvPatchScalarField.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) 1991-2010 OpenCFD Ltd.
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 
29 #include <finiteVolume/volFields.H>
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
35 (
36  const fvPatch& p,
37  const DimensionedField<scalar, volMesh>& iF
38 )
39 :
40  fixedGradientFvPatchScalarField(p, iF),
41  q_(p.size(), 0.0),
42  KName_("undefined-K")
43 {}
44 
45 
48 (
50  const fvPatch& p,
51  const DimensionedField<scalar, volMesh>& iF,
52  const fvPatchFieldMapper& mapper
53 )
54 :
55  fixedGradientFvPatchScalarField(ptf, p, iF, mapper),
56  q_(ptf.q_, mapper),
57  KName_(ptf.KName_)
58 {}
59 
60 
63 (
64  const fvPatch& p,
65  const DimensionedField<scalar, volMesh>& iF,
66  const dictionary& dict
67 )
68 :
69  fixedGradientFvPatchScalarField(p, iF, dict),
70  q_("q", dict, p.size()),
71  KName_(dict.lookup("Kcond"))
72 {}
73 
74 
77 (
79 )
80 :
81  fixedGradientFvPatchScalarField(tppsf),
82  q_(tppsf.q_),
83  KName_(tppsf.KName_)
84 {}
85 
86 
89 (
91  const DimensionedField<scalar, volMesh>& iF
92 )
93 :
94  fixedGradientFvPatchScalarField(tppsf, iF),
95  q_(tppsf.q_),
96  KName_(tppsf.KName_)
97 {}
98 
99 
100 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
101 
103 (
104  const fvPatchFieldMapper& m
105 )
106 {
108  q_.autoMap(m);
109 }
110 
111 
113 (
114  const fvPatchScalarField& ptf,
115  const labelList& addr
116 )
117 {
118  fixedGradientFvPatchScalarField::rmap(ptf, addr);
119 
121  refCast<const solidWallHeatFluxTemperatureFvPatchScalarField>(ptf);
122 
123  q_.rmap(hfptf.q_, addr);
124 }
125 
126 
129 {
130  const fvMesh& mesh = patch().boundaryMesh().mesh();
131 
132  if (mesh.objectRegistry::foundObject<volScalarField>(KName_))
133  {
134  return patch().lookupPatchField<volScalarField, scalar>(KName_);
135  }
136  else if (mesh.objectRegistry::foundObject<volSymmTensorField>(KName_))
137  {
138  const symmTensorField& KWall =
139  patch().lookupPatchField<volSymmTensorField, scalar>(KName_);
140 
141  vectorField n = patch().nf();
142 
143  return n & KWall & n;
144  }
145  else
146  {
148  (
149  "solidWallHeatFluxTemperatureFvPatchScalarField::K()"
150  " const"
151  ) << "Did not find field " << KName_
152  << " on mesh " << mesh.name() << " patch " << patch().name()
153  << endl
154  << "Please set 'K' to a valid volScalarField"
155  << " or a valid volSymmTensorField." << exit(FatalError);
156 
157  return scalarField(0);
158  }
159 }
160 
161 
163 {
164  if (updated())
165  {
166  return;
167  }
168 
169  gradient() = q_/K();
170 
171  fixedGradientFvPatchScalarField::updateCoeffs();
172 
173  if (debug)
174  {
175  scalar Q = gSum(K()*patch().magSf()*snGrad());
176 
177  Info<< patch().boundaryMesh().mesh().name() << ':'
178  << patch().name() << ':'
179  << this->dimensionedInternalField().name() << " :"
180  << " heatFlux:" << Q
181  << " walltemperature "
182  << " min:" << gMin(*this)
183  << " max:" << gMax(*this)
184  << " avg:" << gAverage(*this)
185  << endl;
186  }
187 }
188 
189 
191 (
192  Ostream& os
193 ) const
194 {
195  fixedGradientFvPatchScalarField::write(os);
196  q_.writeEntry("q", os);
197  os.writeKeyword("Kcond") << KName_ << token::END_STATEMENT << nl;
198  this->writeEntry("value", os);
199 }
200 
201 
202 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
203 
204 namespace Foam
205 {
207  (
210  );
211 }
212 
213 // ************************ vim: set sw=4 sts=4 et: ************************ //