1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
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
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 "directionalKSolidThermo.H"
27 #include "addToRunTimeSelectionTable.H"
28 #include "transform.H"
29 #include "transformField.H"
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 defineTypeNameAndDebug(directionalKSolidThermo, 0);
36 addToRunTimeSelectionTable
39 directionalKSolidThermo,
43 addToRunTimeSelectionTable
46 directionalKSolidThermo,
53 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
55 Foam::directionalKSolidThermo::directionalKSolidThermo
58 const dictionary& dict
61 interpolatedSolidThermo(mesh, typeName + "Coeffs", dict),
67 mesh_.time().timeName(),
73 dimEnergy/dimTime/(dimLength*dimTemperature)
80 mesh.time().timeName(),
93 Foam::directionalKSolidThermo::directionalKSolidThermo(const fvMesh& mesh)
95 interpolatedSolidThermo(mesh, typeName + "Coeffs"),
101 mesh_.time().timeName(),
107 dimEnergy/dimTime/(dimLength*dimTemperature)
114 mesh.time().timeName(),
127 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
129 Foam::directionalKSolidThermo::~directionalKSolidThermo()
133 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
135 void Foam::directionalKSolidThermo::init()
137 KValues_ = Field<vector>(subDict(typeName + "Coeffs").lookup("KValues"));
139 const fvMesh& mesh = directionalK_.mesh();
141 // Determine transforms for cell centres
142 forAll(mesh.C(), cellI)
144 vector dir = mesh.C()[cellI] - coordSys_.origin();
147 // Define local coordinate system with
148 // - e1 : axis from cc to centre
149 // - e3 : rotation axis
154 coordSys_.e3(), //z',e3
158 ccTransforms_[cellI] = cs.R();
161 forAll(mesh.C().boundaryField(), patchI)
163 const fvPatchVectorField& patchC = mesh.C().boundaryField()[patchI];
164 fvPatchTensorField& patchT = ccTransforms_.boundaryField()[patchI];
166 tensorField tc(patchT.size());
169 vector dir = patchC[i] - coordSys_.origin();
176 coordSys_.e3(), //z',e3
187 Info<< "directionalKSolidThermo : dumping converted Kxx, Kyy, Kzz"
195 mesh.time().timeName(),
198 IOobject::AUTO_WRITE,
204 Kxx.internalField() = transform
206 ccTransforms_.internalField(),
209 ccTransforms_.internalField().size(),
213 forAll(Kxx.boundaryField(), patchI)
215 Kxx.boundaryField()[patchI] = transform
217 ccTransforms_.boundaryField()[patchI],
220 ccTransforms_.boundaryField()[patchI].size(),
233 mesh.time().timeName(),
236 IOobject::AUTO_WRITE,
242 Kyy.internalField() = transform
244 ccTransforms_.internalField(),
247 ccTransforms_.internalField().size(),
251 forAll(Kyy.boundaryField(), patchI)
253 Kyy.boundaryField()[patchI] = transform
255 ccTransforms_.boundaryField()[patchI],
258 ccTransforms_.boundaryField()[patchI].size(),
271 mesh.time().timeName(),
274 IOobject::AUTO_WRITE,
280 Kzz.internalField() = transform
282 ccTransforms_.internalField(),
285 ccTransforms_.internalField().size(),
289 forAll(Kzz.boundaryField(), patchI)
291 Kzz.boundaryField()[patchI] = transform
293 ccTransforms_.boundaryField()[patchI],
296 ccTransforms_.boundaryField()[patchI].size(),
309 Foam::symmTensor Foam::directionalKSolidThermo::transformPrincipal
317 tt.xx()*st.x()*tt.xx()
318 + tt.xy()*st.y()*tt.xy()
319 + tt.xz()*st.z()*tt.xz(),
321 tt.xx()*st.x()*tt.yx()
322 + tt.xy()*st.y()*tt.yy()
323 + tt.xz()*st.z()*tt.yz(),
325 tt.xx()*st.x()*tt.zx()
326 + tt.xy()*st.y()*tt.zy()
327 + tt.xz()*st.z()*tt.zz(),
329 tt.yx()*st.x()*tt.yx()
330 + tt.yy()*st.y()*tt.yy()
331 + tt.yz()*st.z()*tt.yz(),
333 tt.yx()*st.x()*tt.zx()
334 + tt.yy()*st.y()*tt.zy()
335 + tt.yz()*st.z()*tt.zz(),
337 tt.zx()*st.x()*tt.zx()
338 + tt.zy()*st.y()*tt.zy()
339 + tt.zz()*st.z()*tt.zz()
344 void Foam::directionalKSolidThermo::transformField
346 symmTensorField& fld,
347 const tensorField& tt,
348 const vectorField& st
351 fld.setSize(tt.size());
354 fld[i] = transformPrincipal(tt[i], st[i]);
359 void Foam::directionalKSolidThermo::correct()
362 interpolatedSolidThermo::calculate();
366 const Foam::volSymmTensorField&
367 Foam::directionalKSolidThermo::directionalK() const
369 return directionalK_;
373 void Foam::directionalKSolidThermo::calculate()
375 // Correct directionalK
386 // Transform into global coordinate system
389 directionalK_.internalField(),
390 ccTransforms_.internalField(),
394 forAll(directionalK_.boundaryField(), patchI)
396 directionalK_.boundaryField()[patchI] == this->directionalK(patchI)();
401 const Foam::volScalarField& Foam::directionalKSolidThermo::K() const
405 const vector& v = KValues_[i];
413 FatalErrorIn("directionalKSolidThermo::K() const")
414 << "Supplied K values " << KValues_
415 << " are not isotropic." << exit(FatalError);
419 // Get temperature interpolated properties (principal directions)
430 tmp<volScalarField> tK
437 mesh_.time().timeName(),
443 dimEnergy/dimTime/(dimLength*dimTemperature)
446 volScalarField& K = tK();
448 K.internalField() = interpolateXY
452 KValues_.component(0)()
455 forAll(K.boundaryField(), patchI)
457 K.boundaryField()[patchI] == this->K(patchI)();
464 Foam::tmp<Foam::scalarField> Foam::directionalKSolidThermo::K
471 const vector& v = KValues_[i];
479 FatalErrorIn("directionalKSolidThermo::K() const")
480 << "Supplied K values " << KValues_
481 << " are not isotropic." << exit(FatalError);
485 return tmp<scalarField>
491 T_.boundaryField()[patchI],
493 KValues_.component(0)()
500 Foam::tmp<Foam::symmTensorField> Foam::directionalKSolidThermo::directionalK
505 const fvPatchScalarField& patchT = T_.boundaryField()[patchI];
507 Field<vector> localK(interpolateXY(patchT, TValues_, KValues_));
509 tmp<symmTensorField> tglobalK(new symmTensorField(localK.size()));
510 transformField(tglobalK(), ccTransforms_.boundaryField()[patchI], localK);
516 bool Foam::directionalKSolidThermo::read()
518 return read(subDict(typeName + "Coeffs"));
522 bool Foam::directionalKSolidThermo::read(const dictionary& dict)
524 coordSys_ = coordinateSystem(dict, mesh_);
525 KValues_ = Field<vector>(subDict(typeName + "Coeffs").lookup("KValues"));
530 bool Foam::directionalKSolidThermo::writeData(Ostream& os) const
532 bool ok = interpolatedSolidThermo::writeData(os);
533 os.writeKeyword("KValues") << KValues_ << token::END_STATEMENT << nl;
534 return ok && os.good();
538 // * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
540 Foam::Ostream& Foam::operator<<(Ostream& os, const directionalKSolidThermo& s)
547 // ************************************************************************* //