Transferred copyright to the OpenFOAM Foundation
[OpenFOAM-2.0.x.git] / src / turbulenceModels / compressible / turbulenceModel / derivedFvPatchFields / temperatureCoupledBase / temperatureCoupledBase.C
blobc3562426e36c447421364c21acb86762f7c288b3
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 2011 OpenFOAM Foundation
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 "temperatureCoupledBase.H"
27 #include "volFields.H"
28 #include "basicSolidThermo.H"
29 #include "turbulenceModel.H"
30 #include "basicThermo.H"
32 // * * * * * * * * * * * * * Static Member Data  * * * * * * * * * * * * * * //
34 namespace Foam
36     template<>
37     const char* Foam::NamedEnum
38     <
39         Foam::temperatureCoupledBase::KMethodType,
40         4
41     >::names[] =
42     {
43         "basicThermo",
44         "solidThermo",
45         "directionalSolidThermo",
46         "lookup"
47     };
51 const Foam::NamedEnum<Foam::temperatureCoupledBase::KMethodType, 4>
52     Foam::temperatureCoupledBase::KMethodTypeNames_;
55 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
57 Foam::temperatureCoupledBase::temperatureCoupledBase
59     const fvPatch& patch,
60     const word& calculationType,
61     const word& KName
64     patch_(patch),
65     method_(KMethodTypeNames_[calculationType]),
66     KName_(KName)
70 Foam::temperatureCoupledBase::temperatureCoupledBase
72     const fvPatch& patch,
73     const dictionary& dict
76     patch_(patch),
77     method_(KMethodTypeNames_.read(dict.lookup("K"))),
78     KName_(dict.lookup("KName"))
82 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
84 Foam::tmp<Foam::scalarField> Foam::temperatureCoupledBase::K
86     const scalarField& Tp
87 ) const
89     const fvMesh& mesh = patch_.boundaryMesh().mesh();
91     switch (method_)
92     {
93         case BASICTHERMO:
94         {
95             const compressible::turbulenceModel& model =
96                 mesh.lookupObject<compressible::turbulenceModel>
97                 (
98                     "turbulenceModel"
99                 );
101             return
102                 model.alphaEff()().boundaryField()[patch_.index()]
103                *model.thermo().Cp(Tp, patch_.index());
104         }
105         break;
107         case SOLIDTHERMO:
108         {
109             const basicSolidThermo& thermo =
110                 mesh.lookupObject<basicSolidThermo>
111                 (
112                     "solidThermophysicalProperties"
113                 );
114             return thermo.K(patch_.index());
115         }
116         break;
118         case DIRECTIONALSOLIDTHERMO:
119         {
120             const vectorField n(patch_.nf());
122             const basicSolidThermo& thermo =
123                 mesh.lookupObject<basicSolidThermo>
124                 (
125                     "solidThermophysicalProperties"
126                 );
127             return n & thermo.directionalK(patch_.index()) & n;
128         }
129         break;
131         case LOOKUP:
132         {
133             if (mesh.objectRegistry::foundObject<volScalarField>(KName_))
134             {
135                 return patch_.lookupPatchField<volScalarField, scalar>(KName_);
136             }
137             else if
138             (
139                 mesh.objectRegistry::foundObject<volSymmTensorField>(KName_)
140             )
141             {
142                 const symmTensorField& KWall =
143                     patch_.lookupPatchField<volSymmTensorField, scalar>(KName_);
145                 const vectorField n(patch_.nf());
147                 return n & KWall & n;
148             }
149             else
150             {
151                 FatalErrorIn("temperatureCoupledBase::K() const")
152                     << "Did not find field " << KName_
153                     << " on mesh " << mesh.name() << " patch " << patch_.name()
154                     << endl
155                     << "Please set 'K' to one of " << KMethodTypeNames_.toc()
156                     << " and 'KName' to the name of the volScalar"
157                     << " or volSymmTensor field (if K=lookup)"
158                     << exit(FatalError);
160                 return scalarField(0);
161             }
162         }
164         default:
165         {
166             FatalErrorIn("temperatureCoupledBase::K() const")
167                 << "Unimplemented method " << method_ << endl
168                 << "Please set 'K' to one of " << KMethodTypeNames_.toc()
169                 << " and 'KName' to the name of the volScalar"
170                 << " or volSymmTensor field (if K=lookup)"
171                 << exit(FatalError);
172         }
173         break;
174     }
175     return scalarField(0);
179 void Foam::temperatureCoupledBase::write(Ostream& os) const
181     os.writeKeyword("K") << KMethodTypeNames_[method_]
182         << token::END_STATEMENT << nl;
183     os.writeKeyword("KName") << KName_ << token::END_STATEMENT << nl;
187 // ************************************************************************* //