OpenFPM  5.2.0
Project that contain the implementation of distributed structures
OdeIntegrators.hpp
1 //
2 // Created by Abhinav Singh on 01.12.20.
3 // in Development
4 
5 #ifndef OPENFPM_NUMERICS_ODEINTEGRATORS_HPP
6 #define OPENFPM_NUMERICS_ODEINTEGRATORS_HPP
7 
8 
9 //namespace std{
10 // double abs(pair_ref<double,double> tmp);
11 // double abs(const_pair_ref<double,double> tmp);
12 //}
13 
14 template<typename T, typename Sfinae = void>
15 struct has_state_vector: std::false_type {};
16 template<typename T>
17 struct has_state_vector<T, typename Void< typename T::is_state_vector>::type> : std::true_type
18 {};
19 
20 
21 namespace boost{
22  template<class T,class Enabler=typename std::enable_if<has_state_vector<T>::value>::type>
23  inline auto
24  size(const T& rng) -> decltype(rng.size())
25  {
26  return rng.size();
27  }
28 }
29 
30 #include <boost/numeric/odeint.hpp>
31 #include "Operators/Vector/vector_dist_operators.hpp"
32 #include "FiniteDifference/FD_expressions.hpp"
33 #include "OdeIntegrators/vector_algebra_ofp.hpp"
34 
35 #ifdef __NVCC__
36 #include "OdeIntegrators/vector_algebra_ofp_gpu.hpp"
44 struct state_type_1d_ofp_ker{
45  state_type_1d_ofp_ker(){
46  }
47  typedef decltype(std::declval<texp_v_gpu<double>>().getVector().toKernel()) state_kernel;
48  typedef size_t size_type;
49  typedef int is_state_vector;
50  aggregate<state_kernel> data;
51 
52  __host__ __device__ size_t size() const
53  { return data.get<0>().size(); }
54 
55 };
63 struct state_type_1d_ofp_gpu{
64  state_type_1d_ofp_gpu(){
65  }
66  typedef size_t size_type;
67  typedef int is_state_vector;
69 
70  size_t size() const
71  { return data.get<0>().size(); }
72 
73  void resize(size_t n)
74  {
75  data.get<0>().resize(n);
76  }
77  state_type_1d_ofp_ker toKernel() const
78  {
79  state_type_1d_ofp_ker s1_ker;
80  s1_ker.data.get<0>()=data.get<0>().getVector().toKernel();
81  return s1_ker;
82  }
83 };
84 
92 struct state_type_2d_ofp_ker{
93  state_type_2d_ofp_ker(){
94  }
95  typedef decltype(std::declval<texp_v_gpu<double>>().getVector().toKernel()) state_kernel;
96  typedef size_t size_type;
97  typedef int is_state_vector;
98  aggregate<state_kernel,state_kernel> data;
99 
100  __host__ __device__ size_t size() const
101  { return data.get<0>().size(); }
102 
103 };
111 struct state_type_2d_ofp_gpu{
112  state_type_2d_ofp_gpu(){
113  }
114  typedef size_t size_type;
115  typedef int is_state_vector;
117 
118  size_t size() const
119  { return data.get<0>().size(); }
120 
121  void resize(size_t n)
122  {
123  data.get<0>().resize(n);
124  data.get<1>().resize(n);
125  }
126  state_type_2d_ofp_ker toKernel() const
127  {
128  state_type_2d_ofp_ker s2_ker;
129  s2_ker.data.get<0>()=data.get<0>().getVector().toKernel();
130  s2_ker.data.get<1>()=data.get<1>().getVector().toKernel();
131  return s2_ker;
132  }
133 };
134 
135 #endif
136 
137 namespace boost { namespace numeric { namespace odeint {
138 
139  template<typename T>
140  struct is_resizeable< vector_dist_expression<0,openfpm::vector<aggregate<T>> > >
141  {
142  typedef boost::true_type type;
143  static const bool value = type::value;
144  };
145 
146  } } }
147 
157  }
158  typedef size_t size_type;
159  typedef size_t index_type;
160  typedef int is_state_vector;
162 
163  size_t size() const
164  { return data.get<0>().size(); }
165 
166  void resize(size_t n)
167  {
168  data.get<0>().resize(n);
169  }
170 };
171 
181  }
182  typedef size_t size_type;
183  typedef size_t index_type;
184  typedef int is_state_vector;
186 
187  size_t size() const
188  { return data.get<0>().size(); }
189 
190  void resize(size_t n)
191  {
192  data.get<0>().resize(n);
193  data.get<1>().resize(n);
194  }
195 };
196 
206  }
207  typedef size_t size_type;
208  typedef size_t index_type;
209  typedef int is_state_vector;
211 
212  size_t size() const
213  { return data.get<0>().size(); }
214 
215  void resize(size_t n)
216  {
217  data.get<0>().resize(n);
218  data.get<1>().resize(n);
219  data.get<2>().resize(n);
220  }
221 };
222 
232  }
233  typedef size_t size_type;
234  typedef size_t index_type;
235  typedef int is_state_vector;
237 
238  size_t size() const
239  { return data.get<0>().size(); }
240 
241  void resize(size_t n)
242  {
243  data.get<0>().resize(n);
244  data.get<1>().resize(n);
245  data.get<2>().resize(n);
246  data.get<3>().resize(n);
247  }
248 };
249 
259  }
260  typedef size_t size_type;
261  typedef size_t index_type;
262  typedef int is_state_vector;
264 
265  size_t size() const
266  { return data.get<0>().size(); }
267 
268  void resize(size_t n)
269  {
270  data.get<0>().resize(n);
271  data.get<1>().resize(n);
272  data.get<2>().resize(n);
273  data.get<3>().resize(n);
274  data.get<4>().resize(n);
275 
276  }
277 };
278 
279 // On 17.09.24 - foggia
289  }
290  typedef size_t size_type;
291  typedef size_t index_type;
292  typedef int is_state_vector;
294 
295  size_t size() const
296  { return data.get<0>().size(); }
297 
298  void resize(size_t n)
299  {
300  data.get<0>().resize(n);
301  data.get<1>().resize(n);
302  data.get<2>().resize(n);
303  data.get<3>().resize(n);
304  data.get<4>().resize(n);
305  data.get<5>().resize(n);
306  }
307 };
308 
309 // On 17.09.24 - foggia
319  }
320  typedef size_t size_type;
321  typedef size_t index_type;
322  typedef int is_state_vector;
324 
325  size_t size() const
326  { return data.get<0>().size(); }
327 
328  void resize(size_t n)
329  {
330  data.get<0>().resize(n);
331  data.get<1>().resize(n);
332  data.get<2>().resize(n);
333  data.get<3>().resize(n);
334  data.get<4>().resize(n);
335  data.get<5>().resize(n);
336  data.get<6>().resize(n);
337  }
338 };
339 
340 
341 template<int counter, typename state_type, typename ... list>
343 {
344 // typedef aggregate<list ..., texp_v<double>> one_more;
345  typedef typename state_type_ofpm_add_elements<counter-1,state_type, state_type,list ...>::type type;
346 };
347 
348 template<typename state_type, typename ... list>
350 {
351  typedef aggregate<list ...> type;
352 };
353 
354 template<int n_state, typename state_type>
356 {
358  typedef typename state_type::index_type index_type;
359  typedef int is_state_vector;
360 
361  typedef typename state_type_ofpm_add_elements<n_state-1,state_type, state_type>::type type_data;
362 
363  type_data data;
364 
366  {
367  return data.template get<0>().size();
368  }
369 
370 
371  void resize(const FD::gdb_ext_plus_g_info<state_type::dims> & rsz_obj)
372  {
373  // to fill
374  }
375 };
376 
377 
378 namespace boost {
379  namespace numeric {
380  namespace odeint {
381 
382  // FOR particles
383 
384  template<>
385  struct is_resizeable<state_type_1d_ofp> {
386  typedef boost::true_type type;
387  static const bool value = type::value;
388  };
389 #ifdef __NVCC__
390  template<>
391  struct is_resizeable<state_type_1d_ofp_gpu> {
392  typedef boost::true_type type;
393  static const bool value = type::value;
394  };
395 #endif
396  template<>
397  struct is_resizeable<state_type_2d_ofp> {
398  typedef boost::true_type type;
399  static const bool value = type::value;
400  };
401 
402  template<>
403  struct is_resizeable<state_type_3d_ofp> {
404  typedef boost::true_type type;
405  static const bool value = type::value;
406  };
407  template<>
408  struct is_resizeable<state_type_4d_ofp> {
409  typedef boost::true_type type;
410  static const bool value = type::value;
411  };
412  template<>
413  struct is_resizeable<state_type_5d_ofp> {
414  typedef boost::true_type type;
415  static const bool value = type::value;
416  };
417 
418  // On 17.09.24 - foggia
419  template<>
420  struct is_resizeable<state_type_6d_ofp> {
421  typedef boost::true_type type;
422  static const bool value = type::value;
423  };
424 
425  // On 17.09.24 - foggia
426  template<>
427  struct is_resizeable<state_type_7d_ofp> {
428  typedef boost::true_type type;
429  static const bool value = type::value;
430  };
431 
432 
433  template<>
434  struct vector_space_norm_inf<state_type_1d_ofp>
435  {
436  typedef double result_type;
437  };
438 
439  template<>
440  struct vector_space_norm_inf<state_type_2d_ofp>
441  {
442  typedef double result_type;
443  };
444 
445  template<>
446  struct vector_space_norm_inf<state_type_3d_ofp>
447  {
448  typedef double result_type;
449  };
450 
451  template<>
452  struct vector_space_norm_inf<state_type_4d_ofp>
453  {
454  typedef double result_type;
455  };
456 
457  template<>
458  struct vector_space_norm_inf<state_type_5d_ofp>
459  {
460  typedef double result_type;
461  };
462 
463  // On 17.09.24 - foggia
464  template<>
465  struct vector_space_norm_inf<state_type_6d_ofp>
466  {
467  typedef double result_type;
468  };
469 
470  // On 17.09.24 - foggia
471  template<>
472  struct vector_space_norm_inf<state_type_7d_ofp>
473  {
474  typedef double result_type;
475  };
476 
477  // For GRIDs
478 
479  template<typename state_type>
480  struct is_resizeable<state_type_ofpm_impl<1,state_type> > {
481  typedef boost::true_type type;
482  static const bool value = type::value;
483  };
484 
485  template<typename state_type>
486  struct is_resizeable<state_type_ofpm_impl<2,state_type> > {
487  typedef boost::true_type type;
488  static const bool value = type::value;
489  };
490 
491  template<typename state_type>
492  struct is_resizeable<state_type_ofpm_impl<3,state_type> > {
493  typedef boost::true_type type;
494  static const bool value = type::value;
495  };
496 
497  template<typename state_type>
498  struct is_resizeable<state_type_ofpm_impl<4,state_type> > {
499  typedef boost::true_type type;
500  static const bool value = type::value;
501  };
502 
503  template<typename state_type>
504  struct is_resizeable<state_type_ofpm_impl<5,state_type> > {
505  typedef boost::true_type type;
506  static const bool value = type::value;
507  };
508 
509  // On 17.09.24 - foggia
510  template<typename state_type>
511  struct is_resizeable<state_type_ofpm_impl<6,state_type> > {
512  typedef boost::true_type type;
513  static const bool value = type::value;
514  };
515 
516  // On 17.09.24 - foggia
517  template<typename state_type>
518  struct is_resizeable<state_type_ofpm_impl<7,state_type> > {
519  typedef boost::true_type type;
520  static const bool value = type::value;
521  };
522 
523 
524 /* template<>
525  struct is_resizeable<state_type_2d_ofp> {
526  typedef boost::true_type type;
527  static const bool value = type::value;
528  };
529 
530  template<>
531  struct is_resizeable<state_type_3d_ofp> {
532  typedef boost::true_type type;
533  static const bool value = type::value;
534  };
535  template<>
536  struct is_resizeable<state_type_4d_ofp> {
537  typedef boost::true_type type;
538  static const bool value = type::value;
539  };
540  template<>
541  struct is_resizeable<state_type_5d_ofp> {
542  typedef boost::true_type type;
543  static const bool value = type::value;
544  };*/
545 
546 
547 
548 /* // template<unsigned int nprp, typename state_type>
549  struct vector_space_norm_inf<state_type_ofpm_impl<nprp,state_type>>
550  {
551  typedef double result_type;
552  };*/
553 
554  template<typename state_type>
555  struct vector_space_norm_inf<state_type_ofpm_impl<1,state_type>>
556  {
557  typedef double result_type;
558  };
559 
560  template<typename state_type>
561  struct vector_space_norm_inf<state_type_ofpm_impl<2,state_type>>
562  {
563  typedef double result_type;
564  };
565 
566  template<typename state_type>
567  struct vector_space_norm_inf<state_type_ofpm_impl<3,state_type>>
568  {
569  typedef double result_type;
570  };
571 
572  template<typename state_type>
573  struct vector_space_norm_inf<state_type_ofpm_impl<4,state_type>>
574  {
575  typedef double result_type;
576  };
577 
578  template<typename state_type>
579  struct vector_space_norm_inf<state_type_ofpm_impl<5,state_type>>
580  {
581  typedef double result_type;
582  };
583 
584  // On 17.09.24 - foggia
585  template<typename state_type>
586  struct vector_space_norm_inf<state_type_ofpm_impl<6,state_type>>
587  {
588  typedef double result_type;
589  };
590 
591  // On 17.09.24 - foggia
592  template<typename state_type>
593  struct vector_space_norm_inf<state_type_ofpm_impl<7,state_type>>
594  {
595  typedef double result_type;
596  };
597 
598 
599  }
600  }
601 }
602 
603 
604 
605 #endif //OPENFPM_NUMERICS_ODEINTEGRATORS_HPP
Main class that encapsulate a vector properties operand to be used for expressions construction.
convert a type into constant type
Definition: aggregate.hpp:302
Void structure.
Definition: common.hpp:74
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...
Definition: aggregate.hpp:221
__device__ __host__ boost::mpl::at< type, boost::mpl::int_< i > >::type & get()
get the properties i
Definition: aggregate.hpp:249
A 1d Odeint and Openfpm compatible structure.
A 2d Odeint and Openfpm compatible structure.
A 3d Odeint and Openfpm compatible structure.
A 4d Odeint and Openfpm compatible structure.
A 5d Odeint and Openfpm compatible structure.
A 6d Odeint and Openfpm compatible structure.
A 7d Odeint and Openfpm compatible structure.