BUG: UListIO: byteSize overflowing on really big faceLists
[OpenFOAM-2.0.x.git] / src / thermophysicalModels / basicSolidThermo / constSolidThermo / constSolidThermo.C
blob2434d959c3ffcda671e66719a53d8becf77fcc3a
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 "constSolidThermo.H"
27 #include "addToRunTimeSelectionTable.H"
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 namespace Foam
33     defineTypeNameAndDebug(constSolidThermo, 0);
34     addToRunTimeSelectionTable(basicSolidThermo, constSolidThermo, mesh);
35     addToRunTimeSelectionTable(basicSolidThermo, constSolidThermo, dictionary);
39 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
41 Foam::constSolidThermo::constSolidThermo
43     const fvMesh& mesh,
44     const dictionary& dict
47     basicSolidThermo(mesh, dict),
48     dict_(dict.subDict(typeName + "Coeffs")),
49     constK_(dimensionedScalar(dict_.lookup("K"))),
50     K_
51     (
52         IOobject
53         (
54             "K",
55             mesh.time().timeName(),
56             mesh,
57             IOobject::NO_READ,
58             IOobject::NO_WRITE
59         ),
60         mesh,
61         constK_
62     ),
63     constRho_(dimensionedScalar(dict_.lookup("rho"))),
64     constCp_(dimensionedScalar(dict_.lookup("Cp"))),
65     constHf_(dimensionedScalar(dict_.lookup("Hf"))),
66     constEmissivity_(dimensionedScalar(dict_.lookup("emissivity"))),
67     constKappa_(dimensionedScalar(dict_.lookup("kappa"))),
68     constSigmaS_(dimensionedScalar(dict_.lookup("sigmaS")))
70     read();
72     K_ = constK_;
74     rho_ = constRho_;
76     emissivity_ = constEmissivity_;
78     kappa_ = constKappa_;
80     sigmaS_ = constSigmaS_;
84 Foam::constSolidThermo::constSolidThermo(const fvMesh& mesh)
86     basicSolidThermo(mesh),
87     dict_(subDict(typeName + "Coeffs")),
88     constK_(dimensionedScalar(dict_.lookup("K"))),
89     K_
90     (
91         IOobject
92         (
93             "K",
94             mesh.time().timeName(),
95             mesh,
96             IOobject::NO_READ,
97             IOobject::NO_WRITE
98         ),
99         mesh,
100         constK_
101     ),
102     constRho_(dimensionedScalar(dict_.lookup("rho"))),
103     constCp_(dimensionedScalar(dict_.lookup("Cp"))),
104     constHf_(dimensionedScalar(dict_.lookup("Hf"))),
105     constEmissivity_(dimensionedScalar(dict_.lookup("emissivity"))),
106     constKappa_(dimensionedScalar(dict_.lookup("kappa"))),
107     constSigmaS_(dimensionedScalar(dict_.lookup("sigmaS")))
109     read();
111     K_ = constK_;
113     rho_ = constRho_;
115     emissivity_ = constEmissivity_;
117     kappa_ = constKappa_;
119     sigmaS_ = constSigmaS_;
123 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
125 Foam::constSolidThermo::~constSolidThermo()
129 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
131 void Foam::constSolidThermo::correct()
135 Foam::tmp<Foam::volScalarField> Foam::constSolidThermo::Cp() const
137     return tmp<volScalarField>
138     (
139         new volScalarField
140         (
141             IOobject
142             (
143                 "Cp",
144                 mesh_.time().timeName(),
145                 mesh_,
146                 IOobject::NO_READ,
147                 IOobject::NO_WRITE
148             ),
149             mesh_,
150             constCp_
151         )
152     );
156 const Foam::volScalarField& Foam::constSolidThermo::K() const
158     return K_;
162 const Foam::volSymmTensorField& Foam::constSolidThermo::directionalK() const
164     dimensionedSymmTensor t
165     (
166         constK_.name(),
167         constK_.dimensions(),
168         symmTensor
169         (
170             constK_.value(),
171             0.0,
172             0.0,
173             constK_.value(),
174             0.0,
175             constK_.value()
176         )
177     );
178     return tmp<volSymmTensorField>
179     (
180         new volSymmTensorField
181         (
182             IOobject
183             (
184                 "K",
185                 mesh_.time().timeName(),
186                 mesh_,
187                 IOobject::NO_READ,
188                 IOobject::NO_WRITE
189             ),
190             mesh_,
191             t
192         )
193     );
197 Foam::tmp<Foam::volScalarField> Foam::constSolidThermo::Hf() const
199     return tmp<volScalarField>
200     (
201         new volScalarField
202         (
203             IOobject
204             (
205                 "Hf",
206                 mesh_.time().timeName(),
207                 mesh_,
208                 IOobject::NO_READ,
209                 IOobject::NO_WRITE
210             ),
211             mesh_,
212             constHf_
213         )
214     );
218 Foam::tmp<Foam::scalarField> Foam::constSolidThermo::rho
220     const label patchI
221 ) const
223     return tmp<scalarField>
224     (
225         new scalarField
226         (
227             T_.boundaryField()[patchI].size(),
228             constRho_.value()
229         )
230     );
234 Foam::tmp<Foam::scalarField> Foam::constSolidThermo::Cp
236     const label patchI
237 ) const
239     return tmp<scalarField>
240     (
241         new scalarField
242         (
243             T_.boundaryField()[patchI].size(),
244             constCp_.value()
245         )
246     );
250 Foam::tmp<Foam::scalarField> Foam::constSolidThermo::K
252     const label patchI
253 ) const
255     return (K_.boundaryField()[patchI]);
259 Foam::tmp<Foam::symmTensorField> Foam::constSolidThermo::directionalK
261     const label patchI
262 ) const
264     symmTensor t
265     (
266         constK_.value(),
267         0.0,
268         0.0,
269         constK_.value(),
270         0.0,
271         constK_.value()
272     );
273     return tmp<symmTensorField>
274     (
275         new symmTensorField
276         (
277             T_.boundaryField()[patchI].size(),
278             t
279         )
280     );
284 Foam::tmp<Foam::scalarField> Foam::constSolidThermo::Hf
286     const label patchI
287 ) const
289     return tmp<scalarField>
290     (
291         new scalarField
292         (
293             T_.boundaryField()[patchI].size(),
294             constHf_.value()
295         )
296     );
300 Foam::tmp<Foam::scalarField> Foam::constSolidThermo::emissivity
302     const label patchI
303 ) const
305     return tmp<scalarField>
306     (
307         new scalarField
308         (
309             T_.boundaryField()[patchI].size(),
310             constEmissivity_.value()
311         )
312     );
316 Foam::tmp<Foam::scalarField> Foam::constSolidThermo::kappa
318     const label patchI
319 ) const
321     return tmp<scalarField>
322     (
323         new scalarField
324         (
325             T_.boundaryField()[patchI].size(),
326             constKappa_.value()
327         )
328     );
332 Foam::tmp<Foam::scalarField> Foam::constSolidThermo::sigmaS
334     const label patchI
335 ) const
337     return tmp<scalarField>
338     (
339         new scalarField
340         (
341             T_.boundaryField()[patchI].size(),
342             constSigmaS_.value()
343         )
344     );
348 bool Foam::constSolidThermo::read()
350     return read(subDict(typeName + "Coeffs"));
354 bool Foam::constSolidThermo::read(const dictionary& dict)
356     constRho_ = dimensionedScalar(dict.lookup("rho"));
357     constCp_ = dimensionedScalar(dict.lookup("Cp"));
358     constK_ = dimensionedScalar(dict.lookup("K"));
359     constHf_ = dimensionedScalar(dict.lookup("Hf"));
360     constEmissivity_ = dimensionedScalar(dict.lookup("emissivity"));
361     constKappa_ = dimensionedScalar(dict_.lookup("kappa"));
362     constSigmaS_ = dimensionedScalar(dict_.lookup("sigmaS"));
364     Info<< "Constructed constSolidThermo with" << nl
365         << "    rho        : " << constRho_ << nl
366         << "    Cp         : " << constCp_ << nl
367         << "    K          : " << constK_ << nl
368         << "    Hf         : " << constHf_ << nl
369         << "    emissivity : " << constEmissivity_ << nl
370         << "    kappa      : " << constKappa_ << nl
371         << "    sigmaS     : " << constSigmaS_ << nl
372         << endl;
374     return true;
378 bool Foam::constSolidThermo::writeData(Ostream& os) const
380     bool ok = basicSolidThermo::writeData(os);
381     os.writeKeyword("rho") << constRho_ << token::END_STATEMENT << nl;
382     os.writeKeyword("Cp") << constCp_ << token::END_STATEMENT << nl;
383     os.writeKeyword("K") << constK_ << token::END_STATEMENT << nl;
384     os.writeKeyword("Hf") << constHf_ << token::END_STATEMENT << nl;
385     os.writeKeyword("kappa") << constKappa_ << token::END_STATEMENT << nl;
386     os.writeKeyword("sigmaS") << constSigmaS_ << token::END_STATEMENT << nl;
387     os.writeKeyword("emissivity") << constEmissivity_ << token::END_STATEMENT
388         << nl;
389     return ok && os.good();
393 // * * * * * * * * * * * * * * IOStream operators  * * * * * * * * * * * * * //
395 Foam::Ostream& Foam::operator<<(Ostream& os, const constSolidThermo& s)
397     s.writeData(os);
398     return os;
402 // ************************************************************************* //