sutherlandTransport: Add support for reading thermo and transport from separate dictionaries

Based on patch provided by Daniel Jasinski
See http://www.openfoam.org/mantisbt/view.php?id=1888
This commit is contained in:
Henry Weller
2015-11-06 17:36:58 +00:00
parent fdc9432c4a
commit d46bbbf440
2 changed files with 41 additions and 8 deletions

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -26,6 +26,19 @@ License
#include "sutherlandTransport.H" #include "sutherlandTransport.H"
#include "IOstreams.H" #include "IOstreams.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
template<class Thermo>
Foam::scalar Foam::sutherlandTransport<Thermo>::readCoeff
(
const word& coeffName,
const dictionary& dict
)
{
return readScalar(dict.subDict("transport").lookup(coeffName));
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class Thermo> template<class Thermo>
@ -43,8 +56,21 @@ template<class Thermo>
Foam::sutherlandTransport<Thermo>::sutherlandTransport(const dictionary& dict) Foam::sutherlandTransport<Thermo>::sutherlandTransport(const dictionary& dict)
: :
Thermo(dict), Thermo(dict),
As_(readScalar(dict.subDict("transport").lookup("As"))), As_(readCoeff("As", dict)),
Ts_(readScalar(dict.subDict("transport").lookup("Ts"))) Ts_(readCoeff("Ts", dict))
{}
template<class Thermo>
Foam::sutherlandTransport<Thermo>::sutherlandTransport
(
const Thermo& t,
const dictionary& dict
)
:
Thermo(t),
As_(readCoeff("As", dict)),
Ts_(readCoeff("Ts", dict))
{} {}
@ -53,19 +79,20 @@ Foam::sutherlandTransport<Thermo>::sutherlandTransport(const dictionary& dict)
template<class Thermo> template<class Thermo>
void Foam::sutherlandTransport<Thermo>::write(Ostream& os) const void Foam::sutherlandTransport<Thermo>::write(Ostream& os) const
{ {
os << this->specie::name() << endl; os << this->specie::name() << endl
os << token::BEGIN_BLOCK << incrIndent << nl; << token::BEGIN_BLOCK << incrIndent << nl;
Thermo::write(os); Thermo::write(os);
dictionary dict("transport"); dictionary dict("transport");
dict.add("As", As_); dict.add("As", As_);
dict.add("Ts", Ts_); dict.add("Ts", Ts_);
os << indent << dict.dictName() << dict;
os << decrIndent << token::END_BLOCK << nl; os << indent << dict.dictName() << dict
<< decrIndent << token::END_BLOCK << nl;
} }
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
template<class Thermo> template<class Thermo>

View File

@ -2,7 +2,7 @@
========= | ========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
@ -114,6 +114,9 @@ class sutherlandTransport
const scalar mu2, const scalar T2 const scalar mu2, const scalar T2
); );
//- Read coefficient from dictionary
scalar readCoeff(const word& coeffName, const dictionary& dict);
public: public:
@ -144,6 +147,9 @@ public:
//- Construct from dictionary //- Construct from dictionary
sutherlandTransport(const dictionary& dict); sutherlandTransport(const dictionary& dict);
//- Construct from base thermo and dictionary
sutherlandTransport(const Thermo& t,const dictionary& dict);
//- Construct and return a clone //- Construct and return a clone
inline autoPtr<sutherlandTransport> clone() const; inline autoPtr<sutherlandTransport> clone() const;