GRINS-0.6.0
antioch_evaluator.C
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // GRINS - General Reacting Incompressible Navier-Stokes
5 //
6 // Copyright (C) 2014-2015 Paul T. Bauman, Roy H. Stogner
7 // Copyright (C) 2010-2013 The PECOS Development Team
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the Version 2.1 GNU Lesser General
11 // Public License as published by the Free Software Foundation.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc. 51 Franklin Street, Fifth Floor,
21 // Boston, MA 02110-1301 USA
22 //
23 //-----------------------------------------------------------------------el-
24 
25 
26 #include "grins_config.h"
27 
28 #ifdef GRINS_HAVE_ANTIOCH
29 
30 // C++
31 #include <limits>
32 
33 // This class
35 
36 // GRINS
37 #include "grins/antioch_mixture.h"
38 #include "grins/cached_values.h"
39 
40 namespace GRINS
41 {
42  template<typename Thermo>
44  : _chem( mixture ),
45  _thermo( NULL ),
46  _kinetics( new AntiochKinetics(mixture) ),
47  _temp_cache( new Antioch::TempCache<libMesh::Real>(1.0) )
48  {
49  this->build_thermo( mixture );
50  return;
51  }
52 
53  template<typename Thermo>
55  {
56  return;
57  }
58 
59  template<typename Thermo>
60  void AntiochEvaluator<Thermo>::omega_dot( const CachedValues& cache, unsigned int qp,
61  std::vector<libMesh::Real>& omega_dot )
62  {
63  const libMesh::Real& T = cache.get_cached_values(Cache::TEMPERATURE)[qp];
64  const libMesh::Real rho = cache.get_cached_values(Cache::MIXTURE_DENSITY)[qp];
65  const std::vector<libMesh::Real>& Y = cache.get_cached_vector_values(Cache::MASS_FRACTIONS)[qp];
66 
67  this->omega_dot( T, rho, Y, omega_dot );
68 
69  return;
70  }
71 
72  template<typename Thermo>
73  void AntiochEvaluator<Thermo>::omega_dot( const libMesh::Real& T, libMesh::Real rho,
74  const std::vector<libMesh::Real> mass_fractions,
75  std::vector<libMesh::Real>& omega_dot )
76  {
77  this->check_and_reset_temp_cache(T);
78 
79  _kinetics->omega_dot( *(_temp_cache.get()), rho, mass_fractions, omega_dot );
80 
81  return;
82  }
83 
84  template<typename Thermo>
86  {
87  if( _temp_cache->T != T )
88  {
89  _temp_cache.reset( new Antioch::TempCache<libMesh::Real>(T) );
90  }
91 
92  return;
93  }
94 
95  template<>
97  unsigned int qp )
98  {
99  const libMesh::Real& T = cache.get_cached_values(Cache::TEMPERATURE)[qp];
100  const std::vector<libMesh::Real>& Y = cache.get_cached_vector_values(Cache::MASS_FRACTIONS)[qp];
101 
102  this->check_and_reset_temp_cache(T);
103 
104  return _thermo->cp( *(_temp_cache.get()), Y );
105  }
106 
107  template<>
109  unsigned int qp )
110  {
111  const libMesh::Real T = cache.get_cached_values(Cache::TEMPERATURE)[qp];
112  const std::vector<libMesh::Real>& Y = cache.get_cached_vector_values(Cache::MASS_FRACTIONS)[qp];
113 
114  return _thermo->cp( T, T, Y );
115  }
116 
117  template<>
118  libMesh::Real AntiochEvaluator<Antioch::CEAEvaluator<libMesh::Real> >::cp( const libMesh::Real& T,
119  const std::vector<libMesh::Real>& Y )
120  {
121  this->check_and_reset_temp_cache(T);
122 
123  return _thermo->cp( *(_temp_cache.get()), Y );
124  }
125 
126  template<>
127  libMesh::Real AntiochEvaluator<Antioch::StatMechThermodynamics<libMesh::Real> >::cp( const libMesh::Real& T,
128  const std::vector<libMesh::Real>& Y )
129  {
130  return _thermo->cp( T, T, Y );
131  }
132 
133  template<>
135  unsigned int qp )
136  {
137  const libMesh::Real& T = cache.get_cached_values(Cache::TEMPERATURE)[qp];
138  const std::vector<libMesh::Real>& Y = cache.get_cached_vector_values(Cache::MASS_FRACTIONS)[qp];
139 
140  this->check_and_reset_temp_cache(T);
141 
142  return _thermo->cv( *(_temp_cache.get()), Y );
143  }
144 
145  template<>
146  libMesh::Real AntiochEvaluator<Antioch::CEAEvaluator<libMesh::Real> >::h_s( const libMesh::Real& T, unsigned int species )
147  {
148  this->check_and_reset_temp_cache(T);
149 
150  return _thermo->h( *(_temp_cache.get()), species );;
151  }
152 
153  template<>
154  libMesh::Real AntiochEvaluator<Antioch::StatMechThermodynamics<libMesh::Real> >::h_s( const libMesh::Real& T, unsigned int species )
155  {
156  return _thermo->h_tot( species, T ) + _chem.h_stat_mech_ref_correction(species);
157  }
158 
159  template<>
161  unsigned int qp )
162  {
163  const libMesh::Real T = cache.get_cached_values(Cache::TEMPERATURE)[qp];
164  const std::vector<libMesh::Real>& Y = cache.get_cached_vector_values(Cache::MASS_FRACTIONS)[qp];
165 
166  return _thermo->cv( T, T, Y );
167  }
168 
169  template<>
171  unsigned int qp,
172  unsigned int species )
173  {
174  const libMesh::Real& T = cache.get_cached_values(Cache::TEMPERATURE)[qp];
175 
176  return this->h_s( T, species );
177  }
178 
179  template<>
181  unsigned int qp,
182  unsigned int species )
183  {
184  const libMesh::Real T = cache.get_cached_values(Cache::TEMPERATURE)[qp];
185 
186  return this->h_s(T, species);
187  }
188 
189  template<>
191  unsigned int qp,
192  std::vector<libMesh::Real>& h_s )
193  {
194  const libMesh::Real& T = cache.get_cached_values(Cache::TEMPERATURE)[qp];
195 
196  this->check_and_reset_temp_cache(T);
197 
198  _thermo->h( *(_temp_cache.get()), h_s );
199 
200  return;
201  }
202 
203  template<>
205  unsigned int qp,
206  std::vector<libMesh::Real>& h_s )
207  {
208  for( unsigned int s = 0; s < _chem.n_species(); s++ )
209  {
210  h_s[s] = this->h_s(cache,qp,s);
211  }
212 
213  return;
214  }
215 
216 } // end namespace GRINS
217 
218 #endif //GRINS_HAVE_ANTIOCH
void check_and_reset_temp_cache(const libMesh::Real &T)
Helper method for managing _temp_cache.
Wrapper class for evaluating chemistry and thermo properties using Antioch.
Wrapper class for evaluating chemical kinetics using Antioch.
libMesh::Real cp(const CachedValues &cache, unsigned int qp)
void omega_dot(const CachedValues &cache, unsigned int qp, std::vector< libMesh::Real > &omega_dot)
GRINS namespace.
const std::vector< std::vector< libMesh::Number > > & get_cached_vector_values(unsigned int quantity) const
Wrapper class for storing state for Antioch thermo and kinetics.
const std::vector< libMesh::Number > & get_cached_values(unsigned int quantity) const
Definition: cached_values.C:99
void build_thermo(const AntiochMixture &mixture)

Generated on Mon Jun 22 2015 21:32:20 for GRINS-0.6.0 by  doxygen 1.8.9.1