Initial commit for version 2.0.x patch release
[OpenFOAM-2.0.x.git] / src / thermophysicalModels / basic / derivedFvPatchFields / wallHeatTransfer / wallHeatTransferFvPatchScalarField.C
blob250106b7a6abe0de2e0232df7f22feab61b27b24
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2004-2010 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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.
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.
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/>.
24 \*---------------------------------------------------------------------------*/
26 #include "wallHeatTransferFvPatchScalarField.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "fvPatchFieldMapper.H"
29 #include "volFields.H"
30 #include "basicThermo.H"
32 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
34 Foam::wallHeatTransferFvPatchScalarField::wallHeatTransferFvPatchScalarField
36     const fvPatch& p,
37     const DimensionedField<scalar, volMesh>& iF
40     mixedFvPatchScalarField(p, iF),
41     Tinf_(p.size(), 0.0),
42     alphaWall_(p.size(), 0.0)
44     refValue() = 0.0;
45     refGrad() = 0.0;
46     valueFraction() = 0.0;
50 Foam::wallHeatTransferFvPatchScalarField::wallHeatTransferFvPatchScalarField
52     const wallHeatTransferFvPatchScalarField& ptf,
53     const fvPatch& p,
54     const DimensionedField<scalar, volMesh>& iF,
55     const fvPatchFieldMapper& mapper
58     mixedFvPatchScalarField(ptf, p, iF, mapper),
59     Tinf_(ptf.Tinf_, mapper),
60     alphaWall_(ptf.alphaWall_, mapper)
64 Foam::wallHeatTransferFvPatchScalarField::wallHeatTransferFvPatchScalarField
66     const fvPatch& p,
67     const DimensionedField<scalar, volMesh>& iF,
68     const dictionary& dict
71     mixedFvPatchScalarField(p, iF),
72     Tinf_("Tinf", dict, p.size()),
73     alphaWall_("alphaWall", dict, p.size())
75     refValue() = Tinf_;
76     refGrad() = 0.0;
77     valueFraction() = 0.0;
79     if (dict.found("value"))
80     {
81         fvPatchField<scalar>::operator=
82         (
83             scalarField("value", dict, p.size())
84         );
85     }
86     else
87     {
88         evaluate();
89     }
93 Foam::wallHeatTransferFvPatchScalarField::wallHeatTransferFvPatchScalarField
95     const wallHeatTransferFvPatchScalarField& tppsf
98     mixedFvPatchScalarField(tppsf),
99     Tinf_(tppsf.Tinf_),
100     alphaWall_(tppsf.alphaWall_)
104 Foam::wallHeatTransferFvPatchScalarField::wallHeatTransferFvPatchScalarField
106     const wallHeatTransferFvPatchScalarField& tppsf,
107     const DimensionedField<scalar, volMesh>& iF
110     mixedFvPatchScalarField(tppsf, iF),
111     Tinf_(tppsf.Tinf_),
112     alphaWall_(tppsf.alphaWall_)
116 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
118 void Foam::wallHeatTransferFvPatchScalarField::autoMap
120     const fvPatchFieldMapper& m
123     scalarField::autoMap(m);
124     Tinf_.autoMap(m);
125     alphaWall_.autoMap(m);
129 void Foam::wallHeatTransferFvPatchScalarField::rmap
131     const fvPatchScalarField& ptf,
132     const labelList& addr
135     mixedFvPatchScalarField::rmap(ptf, addr);
137     const wallHeatTransferFvPatchScalarField& tiptf =
138         refCast<const wallHeatTransferFvPatchScalarField>(ptf);
140     Tinf_.rmap(tiptf.Tinf_, addr);
141     alphaWall_.rmap(tiptf.alphaWall_, addr);
145 void Foam::wallHeatTransferFvPatchScalarField::updateCoeffs()
147     if (updated())
148     {
149         return;
150     }
152     const basicThermo& thermo = db().lookupObject<basicThermo>
153     (
154         "thermophysicalProperties"
155     );
157     const label patchi = patch().index();
159     const scalarField& Tw = thermo.T().boundaryField()[patchi];
160     const scalarField Cpw(thermo.Cp(Tw, patchi));
162     valueFraction() =
163         1.0/
164         (
165             1.0
166           + Cpw*thermo.alpha().boundaryField()[patchi]
167            *patch().deltaCoeffs()/alphaWall_
168         );
170     mixedFvPatchScalarField::updateCoeffs();
174 void Foam::wallHeatTransferFvPatchScalarField::write(Ostream& os) const
176     fvPatchScalarField::write(os);
177     Tinf_.writeEntry("Tinf", os);
178     alphaWall_.writeEntry("alphaWall", os);
179     writeEntry("value", os);
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185 namespace Foam
187     makePatchTypeField
188     (
189         fvPatchScalarField,
190         wallHeatTransferFvPatchScalarField
191     );
194 // ************************************************************************* //