Planetary Orbital Evolution due to Tides
Orbital evolution of two objects experiencing tides
ThreadedInterpolation.h
Go to the documentation of this file.
1 
9 #include "../Core/SharedLibraryExportMacros.h"
11 #include "../Core/InterpolatingFunctionALGLIB.h"
12 
13 #ifndef TOOLCHAIN_MSVC
14  #include <pthread.h>
15 #endif
16 
17 #include <vector>
18 #include <list>
19 
20 namespace StellarEvolution {
21 
24  class LIB_LOCAL InterpolationQueue {
25  private:
27  std::list<const double *> __x;
28 
30  std::list<const double *> __y;
31 
33  std::list<size_t> __npoints;
34 
36  std::list<int> __nodes;
37 
39  std::list<double> __smoothing;
40 
42  std::list<int> __quantity_id;
43 
45  std::list<int> __grid_index;
46 
48  std::vector<Core::InterpolatingFunctionALGLIB*> __result;
49 
50 #ifndef TOOLCHAIN_MSVC
51  pthread_mutex_t __sync_mutex;
54 #endif
55 
56 #ifndef NDEBUG
57  std::list<int>::const_iterator __quantity_id_iter;
58 #endif
59 
62  void interpolate_thread();
63 
64  public:
67  {
68 #ifndef TOOLCHAIN_MSVC
69  pthread_mutex_init(&__sync_mutex, NULL);
70 #endif
71  }
72 
74  void push_back(const double *x,
75  const double *y,
76  size_t npoints,
77  int nodes,
78  double smoothing,
79  int quantity_id,
80  int grid_index);
81 
84  void calculate(unsigned num_threads);
85 
87  int quantity_id() const {return __quantity_id.front();}
88 
90  int grid_index() const {return __grid_index.front();}
91 
94  {return __result[__result.size() - __quantity_id.size()];}
95 
101  void pop_front();
102 
104  operator bool() const {return __quantity_id.size();}
105 
106  friend void *do_interpolation(void *);
107 
108  };//End InterpolationQueue class.
109 
110 } //End StellarEvolution namespace.
std::list< const double * > __y
The array of y values to use in the interpolation.
std::list< const double * > __x
The array of x values to use in the interpolation.
Defines constant to serve as identifier of the various quantities handled by the stellar evolution in...
InterpolationQueue()
Create an empty queue.
std::list< int > __grid_index
The index of the grid point being interpolated.
int grid_index() const
The grid index of the currently selected result.
Core::InterpolatingFunctionALGLIB * result() const
The currently selected interupolation result.
std::list< int > __quantity_id
The quantity ID of the quantity being interpolated.
A class that handles a queue of interpolation tasks. Also functions as an iterator over the results...
std::list< size_t > __npoints
The number of points to use in the interpolation.
std::list< int > __nodes
The number of nodes to use in the interpolation.
int quantity_id() const
The quantity ID of the currently selected result.
Function which interpolates, with possible smoothing, between points.
std::list< double > __smoothing
The smoothing to use in the interpolation.
std::vector< Core::InterpolatingFunctionALGLIB * > __result
The interpolation results.