From fde66d51bb67620e8cd677ee878de5a2566204c2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Jasi=C5=84ski?= <daniel.jasinski@gmail.com>
Date: Sun, 1 Nov 2015 14:31:52 +0100
Subject: [PATCH] ChemkinReader - support for transport properties of
 individual species

---
 .../chemistryReaders/chemkinReader/chemkinLexer.L  |  5 +--
 .../chemistryReaders/chemkinReader/chemkinReader.C | 41 +++++++++++++++++++---
 .../chemistryReaders/chemkinReader/chemkinReader.H |  9 ++++-
 .../transport/sutherland/sutherlandTransport.C     | 31 ++++++++++++++--
 .../transport/sutherland/sutherlandTransport.H     | 21 ++++++-----
 5 files changed, 89 insertions(+), 18 deletions(-)

diff --git a/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinLexer.L b/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinLexer.L
index 98a7bbd..ae98050 100644
--- a/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinLexer.L
+++ b/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinLexer.L
@@ -645,8 +645,9 @@ bool finishReaction = false;
                     highCpCoeffs,
                     lowCpCoeffs
                 ),
-                1.67212e-6,
-                170.672
+                transportDict_.isDict(currentSpecieName)?
+                transportDict_.subDict(currentSpecieName):
+                defTransportDict_
             )
         );
 
diff --git a/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinReader.C b/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinReader.C
index 2334241..db49297 100644
--- a/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinReader.C
+++ b/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinReader.C
@@ -774,9 +774,26 @@ void Foam::chemkinReader::addReaction
 void Foam::chemkinReader::read
 (
     const fileName& CHEMKINFileName,
-    const fileName& thermoFileName
+    const fileName& thermoFileName,
+    const fileName& transportFileName
 )
 {
+    // Initialize default transport dictionary
+    dictionary transport;
+    transport.add("As", 1.67212e-6);
+    transport.add("Ts", 170.672);
+    defTransportDict_.add("transport",transport);
+
+    if (transportFileName != fileName::null)
+    {
+        transportDict_.read(IFstream(transportFileName)());
+
+        if (transportDict_.isDict("default"))
+        {
+            defTransportDict_ = transportDict_.subDict("default");
+        }
+    }
+
     if (thermoFileName != fileName::null)
     {
         std::ifstream thermoStream(thermoFileName.c_str());
@@ -843,7 +860,7 @@ Foam::chemkinReader::chemkinReader
     newFormat_(newFormat),
     imbalanceTol_(ROOTSMALL)
 {
-    read(CHEMKINFileName, thermoFileName);
+    read(CHEMKINFileName, thermoFileName, fileName::null);
 }
 
 
@@ -869,11 +886,22 @@ Foam::chemkinReader::chemkinReader
 
     fileName thermoFile = fileName::null;
 
+    fileName transportFile = fileName::null;
+
     if (thermoDict.found("CHEMKINThermoFile"))
     {
         thermoFile = fileName(thermoDict.lookup("CHEMKINThermoFile")).expand();
     }
 
+    if (thermoDict.found("CHEMKINTransportFile"))
+    {
+        transportFile =
+            fileName
+            (
+                thermoDict.lookup("CHEMKINTransportFile")
+            ).expand();
+    }
+
     // allow relative file names
     fileName relPath = thermoDict.name().path();
     if (relPath.size())
@@ -883,13 +911,18 @@ Foam::chemkinReader::chemkinReader
             chemkinFile = relPath/chemkinFile;
         }
 
-        if (!thermoFile.isAbsolute())
+        if (thermoFile != fileName::null && !thermoFile.isAbsolute())
         {
             thermoFile = relPath/thermoFile;
         }
+
+        if (transportFile != fileName::null && !transportFile.isAbsolute())
+        {
+            transportFile = relPath/transportFile;
+        }
     }
 
-    read(chemkinFile, thermoFile);
+    read(chemkinFile, thermoFile, transportFile);
 }
 
 
diff --git a/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinReader.H b/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinReader.H
index ee1986f..82be8b7 100644
--- a/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinReader.H
+++ b/src/thermophysicalModels/reactionThermo/chemistryReaders/chemkinReader/chemkinReader.H
@@ -208,6 +208,12 @@ private:
         //- List of the reactions
         ReactionList<gasHThermoPhysics> reactions_;
 
+        //- Transport properties dictionary
+        dictionary transportDict_;
+
+        //- Default transport properties dictionary
+        dictionary defTransportDict_;
+
         //- Flag to indicate that file is in new format
         Switch newFormat_;
 
@@ -302,7 +308,8 @@ private:
         void read
         (
             const fileName& CHEMKINFileName,
-            const fileName& thermoFileName
+            const fileName& thermoFileName,
+            const fileName& transportFileName
         );
 
 
diff --git a/src/thermophysicalModels/specie/transport/sutherland/sutherlandTransport.C b/src/thermophysicalModels/specie/transport/sutherland/sutherlandTransport.C
index d23f604..756f6b7 100644
--- a/src/thermophysicalModels/specie/transport/sutherland/sutherlandTransport.C
+++ b/src/thermophysicalModels/specie/transport/sutherland/sutherlandTransport.C
@@ -26,6 +26,15 @@ License
 #include "sutherlandTransport.H"
 #include "IOstreams.H"
 
+// * * * * * * * * * * * * * Private Member Functions  * * * * * * * * * * * //
+
+template<class Thermo>
+void Foam::sutherlandTransport<Thermo>::readFrom(const dictionary& dict)
+{
+    As_ = readScalar(dict.subDict("transport").lookup("As"));
+    Ts_ = readScalar(dict.subDict("transport").lookup("Ts"));
+}
+
 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
 
 template<class Thermo>
@@ -43,11 +52,27 @@ template<class Thermo>
 Foam::sutherlandTransport<Thermo>::sutherlandTransport(const dictionary& dict)
 :
     Thermo(dict),
-    As_(readScalar(dict.subDict("transport").lookup("As"))),
-    Ts_(readScalar(dict.subDict("transport").lookup("Ts")))
-{}
+    As_(0.0),
+    Ts_(0.0)
+{
+    readFrom(dict);
+}
 
 
+template<class Thermo>
+Foam::sutherlandTransport<Thermo>::sutherlandTransport
+(
+    const Thermo& t,
+    const dictionary& dict
+)
+:
+    Thermo(t),
+    As_(0.0),
+    Ts_(0.0)
+{
+    readFrom(dict);
+}
+
 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
 
 template<class Thermo>
diff --git a/src/thermophysicalModels/specie/transport/sutherland/sutherlandTransport.H b/src/thermophysicalModels/specie/transport/sutherland/sutherlandTransport.H
index 25973ac..2c3e270 100644
--- a/src/thermophysicalModels/specie/transport/sutherland/sutherlandTransport.H
+++ b/src/thermophysicalModels/specie/transport/sutherland/sutherlandTransport.H
@@ -106,6 +106,14 @@ class sutherlandTransport
 
     // Private Member Functions
 
+        //- Construct from components
+        inline sutherlandTransport
+        (
+            const Thermo& t,
+            const scalar As,
+            const scalar Ts
+        );
+
         //- Calculate the Sutherland coefficients
         //  given two viscosities and temperatures
         inline void calcCoeffs
@@ -114,19 +122,13 @@ class sutherlandTransport
             const scalar mu2, const scalar T2
         );
 
+        //- Read coefficients from dictionary
+        void readFrom(const dictionary& dict);
 
 public:
 
     // Constructors
 
-        //- Construct from components
-        inline sutherlandTransport
-        (
-            const Thermo& t,
-            const scalar As,
-            const scalar Ts
-        );
-
         //- Construct from two viscosities
         inline sutherlandTransport
         (
@@ -144,6 +146,9 @@ public:
         //- Construct from dictionary
         sutherlandTransport(const dictionary& dict);
 
+        //- Construct from base thermo and dictionary
+        sutherlandTransport(const Thermo& t,const dictionary& dict);
+
         //- Construct and return a clone
         inline autoPtr<sutherlandTransport> clone() const;
 
-- 
1.9.1

