antioch-0.4.0
mixture_viscosity.h
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 #ifndef ANTIOCH_MIXTURE_VISCOSITY_H
33 #define ANTIOCH_MIXTURE_VISCOSITY_H
34 
35 // Antioch
39 // C++
40 #include <string>
41 #include <vector>
42 
43 namespace Antioch
44 {
46 
51  template<typename Viscosity, class CoeffType=double>
52  class MixtureViscosity : public MixtureTransportBase<CoeffType>
53  {
54  public:
55 
56  MixtureViscosity( const TransportMixture<CoeffType>& transport_mixture );
58 
60 
61  template <typename StateType>
62  StateType operator()( const unsigned int s, const StateType& T ) const;
63 
65  void add( const std::string& species_name,
66  const std::vector<CoeffType>& coeffs );
67 
69  void reset_coeffs( const unsigned int s,
70  const std::vector<CoeffType> coeffs );
71 
73 
78  template <typename StateType>
79  void extrapolate_max_temp(const StateType& Tmax);
80 
81  const std::vector<Viscosity*> & species_viscosities() const;
82 
84  void print(std::ostream& os = std::cout) const;
85 
87  friend std::ostream& operator<<(std::ostream& os, const MixtureViscosity& mu)
88  {
89  mu.print(os);
90  return os;
91  }
92 
93  typedef Viscosity species_viscosity_type;
94 
95  protected:
96 
97  std::vector<SpeciesViscosityBase<Viscosity,CoeffType>*> _species_viscosities;
98 
99  private:
100 
102 
103  };
104 
105  template<typename Viscosity, class CoeffType>
107  : MixtureTransportBase<CoeffType>(transport_mixture),
108  _species_viscosities( transport_mixture.n_species(), NULL )
109  {}
110 
111  template<typename Viscosity, class CoeffType>
113  {
114  // Need to delete all the species viscosities we allocated
115  for( typename std::vector<SpeciesViscosityBase<Viscosity,CoeffType>*>::iterator it = _species_viscosities.begin();
116  it != _species_viscosities.end(); ++it )
117  {
118  delete (*it);
119  }
120  }
121 
122  template<typename Viscosity, class CoeffType>
123  void MixtureViscosity<Viscosity,CoeffType>::add( const std::string& species_name,
124  const std::vector<CoeffType>& coeffs )
125  {
126  antioch_assert( this->_transport_mixture.species_name_map().find(species_name) !=
127  this->_transport_mixture.species_name_map().end() );
128 
129  unsigned int s = this->_transport_mixture.species_name_map().find(species_name)->second;
130 
131  antioch_assert_less_equal( s, _species_viscosities.size() );
132  antioch_assert( !_species_viscosities[s] );
133 
134  _species_viscosities[s] = new Viscosity(coeffs);
135  return;
136  }
137 
138  template<typename Viscosity, class CoeffType>
140  const std::vector<CoeffType> coeffs )
141  {
142  _species_viscosities[s]->reset_coeffs(coeffs);
143  }
144 
145  template<typename Viscosity, class CoeffType>
146  template<typename StateType>
147  inline
148  StateType MixtureViscosity<Viscosity,CoeffType>::operator()( const unsigned int s,
149  const StateType& T ) const
150  {
151  antioch_assert_less_equal( s, _species_viscosities.size() );
152  antioch_assert( _species_viscosities[s] );
153 
154  return (*_species_viscosities[s])(T);
155  }
156 
157  template<typename Viscosity, class CoeffType>
158  template <typename StateType>
159  inline
161  {
162  for( typename std::vector<SpeciesViscosityBase<Viscosity,CoeffType>*>::iterator it = _species_viscosities.begin();
163  it != _species_viscosities.end(); ++it )
164  {
165  (*it)->extrapolate_max_temp(Tmax);
166  }
167  }
168 
169  template<typename Viscosity, class CoeffType>
170  inline
171  const std::vector<Viscosity*>& MixtureViscosity<Viscosity,CoeffType>::species_viscosities() const
172  {
173  return _species_viscosities;
174  }
175 
176  template<typename Viscosity, class CoeffType>
177  void MixtureViscosity<Viscosity,CoeffType>::print(std::ostream& os) const
178  {
179  antioch_assert_equal_to( _species_viscosities.size(), this->_transport_mixture.n_species() );
180 
181  for( unsigned int s = 0; s < this->_transport_mixture.n_species(); s++ )
182  {
183  const Species& species = this->_transport_mixture.species_list()[s];
184  const std::string& name = this->_transport_mixture.species_inverse_name_map().find( species )->second;
185 
186  os << "mu(" << name << ") = " << (*_species_viscosities[s]) << std::endl;
187  }
188 
189  return;
190  }
191 
192 } // end namespace Antioch
193 
194 #endif // ANTIOCH_MIXTURE_VISCOSITY_H
#define antioch_assert(asserted)
unsigned int Species
Base class for species viscosity models.
friend std::ostream & operator<<(std::ostream &os, const MixtureViscosity &mu)
Formatted print.
const std::vector< Viscosity * > & species_viscosities() const
Container class for species viscosities.
#define antioch_assert_equal_to(expr1, expr2)
std::vector< SpeciesViscosityBase< Viscosity, CoeffType > * > _species_viscosities
void add(const std::string &species_name, const std::vector< CoeffType > &coeffs)
Add species viscosity.
#define antioch_assert_less_equal(expr1, expr2)
void extrapolate_max_temp(const StateType &Tmax)
Extrapolate to input maximum temperature, given in [K].
Base class for MixtureViscosity, MixtureConductivity, etc.
Class storing chemical mixture properties.
Definition: ascii_parser.h:55
void print(std::ostream &os=std::cout) const
Formatted print, by default to std::cout.
StateType operator()(const unsigned int s, const StateType &T) const
Evaluate viscosity for species s.
The parameters are reduced parameters.
void reset_coeffs(const unsigned int s, const std::vector< CoeffType > coeffs)
Reset model coefficients for viscosity model of species s.
const TransportMixture< CoeffType > & transport_mixture() const

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