1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // Antioch - A Gas Dynamics Thermochemistry Library
5 //
6 // Copyright (C) 2014-2016 Paul T. Bauman, Benjamin S. Kirk,
7 //                         Sylvain Plessis, Roy H. Stonger
8 //
9 // Copyright (C) 2013 The PECOS Development Team
10 //
11 // This library is free software; you can redistribute it and/or
12 // modify it under the terms of the Version 2.1 GNU Lesser General
13 // Public License as published by the Free Software Foundation.
14 //
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
23 // Boston, MA  02110-1301  USA
24 //
25 //-----------------------------------------------------------------------el-
26 
27 #include "antioch/sutherland_parsing.h"
28 
29 // Antioch
30 #include "antioch/sutherland_viscosity.h"
31 #include "antioch/mixture_viscosity.h"
32 #include "antioch/input_utils.h"
33 #include "antioch/sutherland_parsing_instantiate_macro.h"
34 
35 // C++
36 #include <fstream>
37 #include <iostream>
38 
39 namespace Antioch
40 {
41   template<class NumericType>
read_sutherland_data_ascii(MixtureViscosity<SutherlandViscosity<NumericType>,NumericType> & mu,const std::string & filename)42   void read_sutherland_data_ascii( MixtureViscosity<SutherlandViscosity<NumericType>,NumericType >& mu,
43 				   const std::string &filename)
44   {
45     std::ifstream in(filename.c_str());
46     if(!in.is_open())
47       {
48         std::cerr << "ERROR: unable to load file " << filename << std::endl;
49         antioch_error();
50       }
51 
52     // skip the header
53     skip_comment_lines(in, '#');
54 
55     std::string name;
56     NumericType a, b;
57 
58     while (in.good())
59       {
60         in >> name; // Species Name
61         in >> a;    //
62         in >> b;    //
63 
64         // If we are still good, we have a valid set of transport
65         // data for this species. Otherwise, we read past end-of-file
66         // in the section above
67         if (in.good())
68           {
69 	    const ChemicalMixture<NumericType>& chem_mixture = mu.chemical_mixture();
70 
71 	    // Check if this is a species we want.
72 	    if( chem_mixture.species_name_map().find(name) !=
73 		chem_mixture.species_name_map().end() )
74 	      {
75 		// Pack up coefficients
76 		std::vector<NumericType> coeffs(2);
77 		coeffs[0] = a;
78 		coeffs[1] = b;
79 		mu.add(name, coeffs);
80 	      }
81 	  }
82       }
83     in.close();
84   }
85 
86   template<class NumericType>
read_sutherland_data_ascii_default(MixtureViscosity<SutherlandViscosity<NumericType>,NumericType> & mu)87   void read_sutherland_data_ascii_default( MixtureViscosity<SutherlandViscosity<NumericType>,NumericType >& mu )
88   {
89     read_sutherland_data_ascii(mu, DefaultFilename::sutherland_data());
90   }
91 
92   // Instantiate
93   ANTIOCH_SUTHERLAND_PARSING_INSTANTIATE();
94 
95 } // end namespace Antioch
96