ReFRACtor
temperature_imp_base.h
Go to the documentation of this file.
1 #ifndef TEMPERATURE_IMP_BASE_H
2 #define TEMPERATURE_IMP_BASE_H
3 #include "temperature.h"
5 #include <boost/function.hpp>
6 
7 namespace FullPhysics {
8 /****************************************************************/
17 class TemperatureImpBase: public SubStateVectorArray<Temperature> {
18 public:
19  virtual ~TemperatureImpBase() {}
22  { fill_cache();
24  units::K);
25  }
26  virtual boost::shared_ptr<Temperature> clone() const = 0;
28  clone(const boost::shared_ptr<Pressure>& Press) const = 0;
29 
30  virtual void update_sub_state_hook()
31  { cache_stale = true; }
32 
33 //-----------------------------------------------------------------------
38 //-----------------------------------------------------------------------
39  virtual void print(std::ostream& Os) const { Os << desc(); }
40 
41 //-----------------------------------------------------------------------
44 //-----------------------------------------------------------------------
45  virtual std::string desc() const { return "TemperatureImpBase"; }
46 protected:
47 //-----------------------------------------------------------------------
50 //-----------------------------------------------------------------------
51  mutable bool cache_stale;
52 
53 //-----------------------------------------------------------------------
57 //-----------------------------------------------------------------------
58  mutable boost::function<AutoDerivative<double>(AutoDerivative<double>)> tgrid;
59 
60 //-----------------------------------------------------------------------
63 //-----------------------------------------------------------------------
64  virtual void calc_temperature_grid() const = 0;
65 
66 //-----------------------------------------------------------------------
68 //-----------------------------------------------------------------------
69 
70  void init(const blitz::Array<double, 1>& Coeff,
71  const blitz::Array<bool, 1>& Used_flag,
72  const boost::shared_ptr<Pressure>& Press,
73  bool Mark_according_to_press = true,
74  int Pdep_start = 0)
75  { SubStateVectorArray<Temperature>::init(Coeff, Used_flag, Press,
76  Mark_according_to_press,
77  Pdep_start);
78  }
79 
80 //-----------------------------------------------------------------------
83 //-----------------------------------------------------------------------
84 
85  TemperatureImpBase() : cache_stale(true) { }
86 
87 //-----------------------------------------------------------------------
91 //-----------------------------------------------------------------------
92  TemperatureImpBase(const blitz::Array<double, 1>& Coeff,
93  const blitz::Array<bool, 1>& Used_flag,
94  const boost::shared_ptr<Pressure>& Press,
95  bool Mark_according_to_press = true,
96  int Pdep_start = 0)
97  : SubStateVectorArray<Temperature>(Coeff, Used_flag, Press,
98  Mark_according_to_press, Pdep_start),
99  cache_stale(true) { }
100 private:
101  void fill_cache() const
102  {
103  if(cache_stale)
105  cache_stale = false;
106  }
107 
108 };
109 }
110 #endif
virtual AutoDerivativeWithUnit< double > temperature(const AutoDerivativeWithUnit< double > &Press) const
Return the temperature at the given pressure (in Pascals)
virtual void print(std::ostream &Os) const
Print to stream.
This is a AutoDerivative that also has units associated with it.
void init(const blitz::Array< double, 1 > &Coeff, const blitz::Array< bool, 1 > &Used_flag, const boost::shared_ptr< Pressure > &Press, bool Mark_according_to_press=true, int Pdep_start=0)
Initialize object.
TemperatureImpBase()
Default constructor, derived class should call init if they use this constructor. ...
AutoDerivativeWithUnit< T > convert(const Unit &R) const
Convert to the given units.
virtual void update_sub_state_hook()
Hook for anything a derived class needs to do after coefficient is updated and before notify_update...
const Unit Pa("Pa", N/(m *m))
virtual boost::shared_ptr< Temperature > clone() const =0
Clone a Temperature object.
const Unit K("K", 1.0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0)
virtual std::string desc() const
Description of object, to be printed to stream.
As a design principle, we have each base class with the absolutely minimum interface needed for use f...
It is common to have a class that is an Observable with a set of coefficients, a subset of which are ...
Contains classes to abstract away details in various Spurr Radiative Transfer software.
Definition: doxygen_python.h:1
virtual void calc_temperature_grid() const =0
Derived classes should provide a function to fill in tgrid when this is called.
void init(const blitz::Array< double, 1 > &Coeff, const blitz::Array< bool, 1 > &Used_flag, const boost::shared_ptr< Pressure > &Press=boost::shared_ptr< Pressure >(), bool Mark_according_to_press=true, int Pdep_start=0)
boost::function< AutoDerivative< double >AutoDerivative< double >)> tgrid
The cached temperature grid.
This class maintains the temperature portion of the state.
Definition: temperature.h:22
TemperatureImpBase(const blitz::Array< double, 1 > &Coeff, const blitz::Array< bool, 1 > &Used_flag, const boost::shared_ptr< Pressure > &Press, bool Mark_according_to_press=true, int Pdep_start=0)
Constructor that sets the coefficient() and used_flag() values.
bool cache_stale
If this is true, the recalculate the temperature_grid the next time we need it.

Copyright © 2017, California Institute of Technology.
ALL RIGHTS RESERVED.
U.S. Government Sponsorship acknowledged.
Generated Fri Aug 24 2018 15:44:10