GRINS-0.7.0
antioch_evaluator.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------bl-
2 //--------------------------------------------------------------------------
3 //
4 // GRINS - General Reacting Incompressible Navier-Stokes
5 //
6 // Copyright (C) 2014-2016 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 #ifndef GRINS_ANTIOCH_EVALUATOR_H
27 #define GRINS_ANTIOCH_EVALUATOR_H
28 
29 #include "grins_config.h"
30 
31 #ifdef GRINS_HAVE_ANTIOCH
32 
33 // GRINS
34 #include "grins/antioch_mixture.h"
35 #include "grins/antioch_kinetics.h"
36 #include "grins/cached_values.h"
37 #include "grins/property_types.h"
38 
39 // Antioch
40 #include "antioch/temp_cache.h"
41 #include "antioch/cea_evaluator.h"
42 #include "antioch/stat_mech_thermo.h"
43 
44 namespace GRINS
45 {
47 
54  template<typename Thermo>
56  {
57  public:
58 
59  AntiochEvaluator( const AntiochMixture& mixture );
60 
61  virtual ~AntiochEvaluator(){};
62 
63  // Chemistry
64  libMesh::Real M( unsigned int species ) const;
65 
66  libMesh::Real M_mix( const std::vector<libMesh::Real>& mass_fractions ) const;
67 
68  libMesh::Real R( unsigned int species ) const;
69 
70  libMesh::Real R_mix( const std::vector<libMesh::Real>& mass_fractions ) const;
71 
72  libMesh::Real X( unsigned int species, libMesh::Real M, libMesh::Real mass_fraction ) const;
73 
74  void X( libMesh::Real M, const std::vector<libMesh::Real>& mass_fractions,
75  std::vector<libMesh::Real>& mole_fractions ) const;
76 
77  unsigned int species_index( const std::string& species_name ) const;
78 
79  std::string species_name( unsigned int species_index ) const;
80 
81  // Thermo
82  libMesh::Real cp( const libMesh::Real& T, const libMesh::Real P, const std::vector<libMesh::Real>& Y );
83 
84  libMesh::Real cv( const libMesh::Real& T, const libMesh::Real P, const std::vector<libMesh::Real>& Y );
85 
86  libMesh::Real h_s( const libMesh::Real& T, unsigned int species );
87 
88  // Kinetics
89  void omega_dot( const libMesh::Real& T, libMesh::Real rho,
90  const std::vector<libMesh::Real> mass_fractions,
91  std::vector<libMesh::Real>& omega_dot );
92 
93  protected:
94 
96 
97  // This is a template type
98  libMesh::UniquePtr<Thermo> _thermo;
99 
100  libMesh::UniquePtr<AntiochKinetics> _kinetics;
101 
102  libMesh::UniquePtr<Antioch::TempCache<libMesh::Real> > _temp_cache;
103 
105 
107  void check_and_reset_temp_cache( const libMesh::Real& T );
108 
109  /* Below we will specialize the specialized_build_* functions to the appropriate type.
110  This way, we can control how the cached transport objects get constructed
111  based on the template type. This is achieved by the dummy types forcing operator
112  overloading for each of the specialized types. */
113  void build_thermo( const AntiochMixture& mixture )
114  { specialized_build_thermo( mixture, _thermo, thermo_type<Thermo>() ); }
115 
116  private:
117 
119 
121  libMesh::UniquePtr<Antioch::StatMechThermodynamics<libMesh::Real> >& thermo,
122  thermo_type<Antioch::StatMechThermodynamics<libMesh::Real> > )
123  {
124  thermo.reset( new Antioch::StatMechThermodynamics<libMesh::Real>( mixture.chemical_mixture() ) );
125  return;
126  }
127 
129  libMesh::UniquePtr<Antioch::CEAEvaluator<libMesh::Real> >& thermo,
130  thermo_type<Antioch::CEAEvaluator<libMesh::Real> > )
131  {
132  thermo.reset( new Antioch::CEAEvaluator<libMesh::Real>( mixture.cea_mixture() ) );
133  return;
134  }
135 
136  };
137 
138  /* ------------------------- Inline Functions -------------------------*/
139  template<typename Thermo>
140  inline
141  libMesh::Real AntiochEvaluator<Thermo>::M( unsigned int species ) const
142  {
143  return _chem.M(species);
144  }
145 
146  template<typename Thermo>
147  inline
148  libMesh::Real AntiochEvaluator<Thermo>::M_mix( const std::vector<libMesh::Real>& mass_fractions ) const
149  {
150  return _chem.M_mix(mass_fractions);
151  }
152 
153  template<typename Thermo>
154  inline
155  libMesh::Real AntiochEvaluator<Thermo>::R( unsigned int species ) const
156  {
157  return _chem.R(species);
158  }
159 
160  template<typename Thermo>
161  inline
162  libMesh::Real AntiochEvaluator<Thermo>::R_mix( const std::vector<libMesh::Real>& mass_fractions ) const
163  {
164  return _chem.R_mix(mass_fractions);
165  }
166 
167  template<typename Thermo>
168  inline
169  libMesh::Real AntiochEvaluator<Thermo>::X( unsigned int species, libMesh::Real M, libMesh::Real mass_fraction ) const
170  {
171  return _chem.X(species,M,mass_fraction);
172  }
173 
174  template<typename Thermo>
175  inline
176  void AntiochEvaluator<Thermo>::X( libMesh::Real M, const std::vector<libMesh::Real>& mass_fractions,
177  std::vector<libMesh::Real>& mole_fractions ) const
178  {
179  _chem.X(M,mass_fractions,mole_fractions);
180  return;
181  }
182 
183  template<typename Thermo>
184  inline
185  unsigned int AntiochEvaluator<Thermo>::species_index( const std::string& species_name ) const
186  {
187  return _chem.species_index(species_name);
188  }
189 
190  template<typename Thermo>
191  inline
192  std::string AntiochEvaluator<Thermo>::species_name( unsigned int species_index ) const
193  {
194  return _chem.species_name(species_index);
195  }
196 
197  template<typename Thermo>
198  inline
200  {
201  // We can't compare T because it's a reference, so we may have already
202  // changed it upstream. So, we compare the next cheapest thing.
203  if( _temp_cache->T2 != T*T )
204  _temp_cache.reset( new Antioch::TempCache<libMesh::Real>(T) );
205  }
206 
207 } // end namespace GRINS
208 
209 #endif // GRINS_HAVE_ANTIOCH
210 
211 #endif // GRINS_ANTIOCH_EVALUATOR_H
void check_and_reset_temp_cache(const libMesh::Real &T)
Helper method for managing _temp_cache.
libMesh::Real cv(const libMesh::Real &T, const libMesh::Real P, const std::vector< libMesh::Real > &Y)
libMesh::Real cp(const libMesh::Real &T, const libMesh::Real P, const std::vector< libMesh::Real > &Y)
Wrapper class for evaluating chemistry and thermo properties using Antioch.
libMesh::UniquePtr< AntiochKinetics > _kinetics
const Antioch::ChemicalMixture< libMesh::Real > & chemical_mixture() const
Accessor to underlying Antioch object.
void specialized_build_thermo(const AntiochMixture &mixture, libMesh::UniquePtr< Antioch::CEAEvaluator< libMesh::Real > > &thermo, thermo_type< Antioch::CEAEvaluator< libMesh::Real > >)
void specialized_build_thermo(const AntiochMixture &mixture, libMesh::UniquePtr< Antioch::StatMechThermodynamics< libMesh::Real > > &thermo, thermo_type< Antioch::StatMechThermodynamics< libMesh::Real > >)
const Antioch::CEAThermoMixture< libMesh::Real > & cea_mixture() const
libMesh::Real h_s(const libMesh::Real &T, unsigned int species)
libMesh::UniquePtr< Antioch::TempCache< libMesh::Real > > _temp_cache
libMesh::Real R_mix(const std::vector< libMesh::Real > &mass_fractions) const
void omega_dot(const libMesh::Real &T, libMesh::Real rho, const std::vector< libMesh::Real > mass_fractions, std::vector< libMesh::Real > &omega_dot)
libMesh::Real M(unsigned int species) const
std::string species_name(unsigned int species_index) const
unsigned int species_index(const std::string &species_name) const
const AntiochMixture & _chem
GRINS namespace.
libMesh::UniquePtr< Thermo > _thermo
Wrapper class for storing state for Antioch thermo and kinetics.
libMesh::Real X(unsigned int species, libMesh::Real M, libMesh::Real mass_fraction) const
libMesh::Real M_mix(const std::vector< libMesh::Real > &mass_fractions) const
void build_thermo(const AntiochMixture &mixture)
libMesh::Real R(unsigned int species) const

Generated on Thu Jun 2 2016 21:52:28 for GRINS-0.7.0 by  doxygen 1.8.10