Program Listing for File Interpolator.h¶
↰ Return to documentation for file (/home/kpenev/projects/git/poet/poet_src/StellarEvolution/Interpolator.h)
#ifndef __INTERPOLATOR_H
#define __INTERPOLATOR_H
#include "../Core/SharedLibraryExportMacros.h"
#include "EvolvingStellarQuantity.h"
#include "InterpolationQuantities.h"
#include "ThreadedInterpolation.h"
#include "../Core/StellarZone.h"
#include "../Core/Error.h"
#include <valarray>
#include <list>
#include <string>
#include <iostream>
#include <fstream>
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/list.hpp>
#include <boost/serialization/valarray.hpp>
#include <boost/serialization/vector.hpp>
namespace StellarEvolution {
class LIB_PUBLIC Interpolator {
private:
friend class boost::serialization::access;
template<class Archive> void serialize(
Archive & ar,
const unsigned int
);
std::valarray<double>
__track_masses,
__track_feh;
std::vector< std::vector<const OneArgumentDiffFunction*> >
__interpolated_quantities;
std::vector<bool> __vs_log_age;
std::vector<bool> __log_quantity;
double __core_formation;
int find_first_core_index(
const std::valarray<double> &core_mass
) const;
void perform_queued_interpolations(
InterpolationQueue &interpolation_queue,
unsigned num_threads = 1
);
public:
Interpolator() :
__track_masses(),
__track_feh(),
__interpolated_quantities(NUM_QUANTITIES),
__core_formation(Core::NaN)
{}
Interpolator(
const std::valarray<double> &tabulated_masses,
const std::valarray<double> &tabulated_feh,
const std::list< std::valarray<double> > &tabulated_ages,
const std::vector< std::list< std::valarray<double> > >
&tabulated_quantities,
const std::vector<double> &smoothing,
const std::vector<int> &nodes,
const std::vector<bool> &vs_log_age,
const std::vector<bool> &log_quantity,
unsigned num_threads
)
{
create_from(tabulated_masses,
tabulated_feh,
tabulated_ages,
tabulated_quantities,
smoothing,
nodes,
vs_log_age,
log_quantity,
num_threads);
}
void create_from(
const std::valarray<double> &tabulated_masses,
const std::valarray<double> &tabulated_feh,
const std::list< std::valarray<double> > &tabulated_ages,
const std::vector< std::list< std::valarray<double> > >
&tabulated_quantities,
const std::vector<double> &smoothing,
const std::vector<int> &nodes,
const std::vector<bool> &vs_log_age,
const std::vector<bool> &log_quantity,
unsigned num_threads
);
virtual EvolvingStellarQuantity *operator()(
QuantityID quantity,
double mass,
double feh
) const;
virtual double core_formation_age() const {return __core_formation;}
#ifndef NO_SERIALIZE
virtual void save_state(
const std::string &filename="../interp_state_data"
) const;
virtual void load_state(
const std::string &filename="../interp_state_data"
);
#endif
void delete_tracks();
virtual ~Interpolator() {}
}; //End of Interpolator class declaration.
#ifndef NO_SERIALIZE
template<class Archive> void Interpolator::serialize(
Archive & ar,
const unsigned int
)
{
if(!std::isfinite(__core_formation)) __core_formation = -1;
ar & __track_masses;
ar & __track_feh;
ar & __interpolated_quantities;
ar & __vs_log_age;
ar & __log_quantity;
ar & __core_formation;
#ifndef NDEBUG
std::cerr << "Track masses: " << __track_masses << std::endl;
std::cerr << "Track [Fe/H]: " << __track_masses << std::endl;
std::cerr << "Quantities with sizes: ";
for(unsigned i = 0; i < __interpolated_quantities.size(); ++i)
std::cerr << (i ? ", " : "") << __interpolated_quantities[i].size();
std::cerr << std::endl;
std::cerr << "vs log(age): ";
for(unsigned i = 0; i < __vs_log_age.size(); ++i)
std::cerr << (i ? ", " : "") << __vs_log_age[i];
std::cerr << std::endl;
std::cerr << "log(quantity): ";
for(unsigned i = 0; i < __log_quantity.size(); ++i)
std::cerr << (i ? ", " : "") << __log_quantity[i];
std::cerr << std::endl;
#endif
if(__core_formation < 0) __core_formation = Core::Inf;
}
#endif
}//End of StellarEvolution namespace
#endif