antioch-0.4.0
mixture_viscosity_vec_unit.C
Go to the documentation of this file.
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 // $Id$
28 //
29 //--------------------------------------------------------------------------
30 //--------------------------------------------------------------------------
31 
32 #include "antioch_config.h"
33 
34 #include <valarray>
35 
36 #ifdef ANTIOCH_HAVE_EIGEN
37 #include "Eigen/Dense"
38 #endif
39 
40 #ifdef ANTIOCH_HAVE_METAPHYSICL
41 #include "metaphysicl/numberarray.h"
42 #endif
43 
44 #ifdef ANTIOCH_HAVE_VEXCL
45 #include "vexcl/vexcl.hpp"
46 #endif
47 
48 // Antioch
49 
50 // Declare metaprogramming overloads before they're used
55 
62 
63 #include "antioch/eigen_utils.h"
65 #include "antioch/valarray_utils.h"
66 #include "antioch/vexcl_utils.h"
67 
69 
70 #ifdef ANTIOCH_HAVE_GRVY
71 #include "grvy.h"
72 
73 GRVY::GRVY_Timer_Class gt;
74 #endif
75 
76 // C++
77 #include <cmath>
78 #include <iostream>
79 
80 template <typename PairScalars>
81 int vectester(const PairScalars& example, const std::string& testname)
82 {
83  typedef typename Antioch::value_type<PairScalars>::type Scalar;
84 
85  std::vector<std::string> species_str_list;
86  const unsigned int n_species = 2;
87  species_str_list.reserve(n_species);
88  species_str_list.push_back( "N2" );
89  species_str_list.push_back( "Air" ); // Yes, I know this doesn't make sense, it's just a test.
90 
91  Antioch::ChemicalMixture<Scalar> chem_mixture( species_str_list );
92 
93  typedef Antioch::StatMechThermodynamics<Scalar> MicroThermo;
94  MicroThermo thermo_stat( chem_mixture );
95 
96  Antioch::TransportMixture<Scalar> tran_mixture( chem_mixture );
97 
99  s_mu_mixture(tran_mixture);
100 
102  b_mu_mixture(tran_mixture);
103 
104  Antioch::read_sutherland_data_ascii<Scalar>( s_mu_mixture, Antioch::DefaultFilename::sutherland_data() );
105  Antioch::read_blottner_data_ascii<Scalar>( b_mu_mixture, Antioch::DefaultFilename::blottner_data() );
106 
107  std::cout << s_mu_mixture << std::endl;
108  std::cout << b_mu_mixture << std::endl;
109 
110  PairScalars T = example;
111  for (unsigned int tuple=0; tuple != ANTIOCH_N_TUPLES; ++tuple)
112  {
113  T[2*tuple ] = 1500.1;
114  T[2*tuple+1] = 1600.1;
115  }
116 
117  PairScalars mu = example;
118 
119  std::cout << "Blottner:" << std::endl;
120  for( unsigned int s = 0; s < n_species; s++ )
121  {
122 #ifdef ANTIOCH_HAVE_GRVY
123  const std::string testblottner = testname + "-blottner";
124  gt.BeginTimer(testblottner);
125 #endif
126 
127  mu = b_mu_mixture(s,T);
128 
129 #ifdef ANTIOCH_HAVE_GRVY
130  gt.EndTimer(testblottner);
131 #endif
132 
133  std::cout << "mu(" << species_str_list[s] << ") = " << mu << std::endl;
134  }
135 
136  std::cout << "Sutherland:" << std::endl;
137  for( unsigned int s = 0; s < n_species; s++ )
138  {
139 #ifdef ANTIOCH_HAVE_GRVY
140  const std::string testsutherland = testname + "-sutherland";
141  gt.BeginTimer(testsutherland);
142 #endif
143 
144  mu = s_mu_mixture(s,T);
145 
146 #ifdef ANTIOCH_HAVE_GRVY
147  gt.EndTimer(testsutherland);
148 #endif
149 
150  std::cout << "mu(" << species_str_list[s] << ") = " << mu << std::endl;
151  }
152 
153  int return_flag = 0;
154 
155  return return_flag;
156 }
157 
158 int main()
159 {
160  int returnval = 0;
161 
162  returnval = returnval ||
163  vectester (std::valarray<float>(2*ANTIOCH_N_TUPLES), "valarray<float>");
164  returnval = returnval ||
165  vectester (std::valarray<double>(2*ANTIOCH_N_TUPLES), "valarray<double>");
166  returnval = returnval ||
167  vectester (std::valarray<long double>(2*ANTIOCH_N_TUPLES), "valarray<ld>");
168 #ifdef ANTIOCH_HAVE_EIGEN
169  returnval = returnval ||
170  vectester (Eigen::Array<float, 2*ANTIOCH_N_TUPLES, 1>(), "Eigen::ArrayXf");
171  returnval = returnval ||
172  vectester (Eigen::Array<double, 2*ANTIOCH_N_TUPLES, 1>(), "Eigen::ArrayXd");
173  returnval = returnval ||
174  vectester (Eigen::Array<long double, 2*ANTIOCH_N_TUPLES, 1>(), "Eigen::ArrayXld");
175 #endif
176 #ifdef ANTIOCH_HAVE_METAPHYSICL
177  returnval = returnval ||
178  vectester (MetaPhysicL::NumberArray<2*ANTIOCH_N_TUPLES, float> (0), "NumberArray<float>");
179  returnval = returnval ||
180  vectester (MetaPhysicL::NumberArray<2*ANTIOCH_N_TUPLES, double> (0), "NumberArray<double>");
181  returnval = returnval ||
182  vectester (MetaPhysicL::NumberArray<2*ANTIOCH_N_TUPLES, long double> (0), "NumberArray<ld>");
183 #endif
184 #ifdef ANTIOCH_HAVE_VEXCL
185  vex::Context ctx_f (vex::Filter::All);
186  if (!ctx_f.empty())
187  returnval = returnval ||
188  vectester (vex::vector<float> (ctx_f, 2*ANTIOCH_N_TUPLES), "vex::vector<float>");
189 
190  vex::Context ctx_d (vex::Filter::DoublePrecision);
191  if (!ctx_d.empty())
192  returnval = returnval ||
193  vectester (vex::vector<double> (ctx_d, 2*ANTIOCH_N_TUPLES), "vex::vector<double>");
194 #endif
195 
196 #ifdef ANTIOCH_HAVE_GRVY
197  gt.Finalize();
198  gt.Summarize();
199 #endif
200 
201  return returnval;
202 }
int vectester(const PairScalars &example, const std::string &testname)
Container class for species viscosities.
Class storing chemical mixture properties.
Definition: ascii_parser.h:55
static const std::string & sutherland_data()
static const std::string & blottner_data()
Class storing chemical mixture properties.

Generated on Thu Jul 7 2016 11:09:46 for antioch-0.4.0 by  doxygen 1.8.8