OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
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
14template<typename T, typename Sfinae = void>
15struct has_state_vector: std::false_type {};
16template<typename T>
17struct has_state_vector<T, typename Void< typename T::is_state_vector>::type> : std::true_type
18{};
19
20
21namespace 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"
44struct 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;
51
52 __host__ __device__ size_t size() const
53 { return data.get<0>().size(); }
54
55};
63struct 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#endif
85
86namespace boost { namespace numeric { namespace odeint {
87
88 template<typename T>
89 struct is_resizeable< vector_dist_expression<0,openfpm::vector<aggregate<T>> > >
90 {
91 typedef boost::true_type type;
92 static const bool value = type::value;
93 };
94
95 } } }
96
106 }
107 typedef size_t size_type;
108 typedef size_t index_type;
109 typedef int is_state_vector;
111
112 size_t size() const
113 { return data.get<0>().size(); }
114
115 void resize(size_t n)
116 {
117 data.get<0>().resize(n);
118 }
119};
120
130 }
131 typedef size_t size_type;
132 typedef size_t index_type;
133 typedef int is_state_vector;
135
136 size_t size() const
137 { return data.get<0>().size(); }
138
139 void resize(size_t n)
140 {
141 data.get<0>().resize(n);
142 data.get<1>().resize(n);
143 }
144};
145
155 }
156 typedef size_t size_type;
157 typedef size_t index_type;
158 typedef int is_state_vector;
160
161 size_t size() const
162 { return data.get<0>().size(); }
163
164 void resize(size_t n)
165 {
166 data.get<0>().resize(n);
167 data.get<1>().resize(n);
168 data.get<2>().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 data.get<2>().resize(n);
195 data.get<3>().resize(n);
196 }
197};
198
208 }
209 typedef size_t size_type;
210 typedef size_t index_type;
211 typedef int is_state_vector;
213
214 size_t size() const
215 { return data.get<0>().size(); }
216
217 void resize(size_t n)
218 {
219 data.get<0>().resize(n);
220 data.get<1>().resize(n);
221 data.get<2>().resize(n);
222 data.get<3>().resize(n);
223 data.get<4>().resize(n);
224
225 }
226};
227
228template<int counter, typename state_type, typename ... list>
230{
231// typedef aggregate<list ..., texp_v<double>> one_more;
232 typedef typename state_type_ofpm_add_elements<counter-1,state_type, state_type,list ...>::type type;
233};
234
235template<typename state_type, typename ... list>
237{
238 typedef aggregate<list ...> type;
239};
240
241template<int n_state, typename state_type>
243{
245 typedef typename state_type::index_type index_type;
246 typedef int is_state_vector;
247
248 typedef typename state_type_ofpm_add_elements<n_state-1,state_type, state_type>::type type_data;
249
250 type_data data;
251
253 {
254 return data.template get<0>().size();
255 }
256
257
258 void resize(const FD::gdb_ext_plus_g_info<state_type::dims> & rsz_obj)
259 {
260 // to fill
261 }
262};
263
264
265namespace boost {
266 namespace numeric {
267 namespace odeint {
268
269 // FOR particles
270
271 template<>
272 struct is_resizeable<state_type_1d_ofp> {
273 typedef boost::true_type type;
274 static const bool value = type::value;
275 };
276#ifdef __NVCC__
277 template<>
278 struct is_resizeable<state_type_1d_ofp_gpu> {
279 typedef boost::true_type type;
280 static const bool value = type::value;
281 };
282#endif
283 template<>
284 struct is_resizeable<state_type_2d_ofp> {
285 typedef boost::true_type type;
286 static const bool value = type::value;
287 };
288
289 template<>
290 struct is_resizeable<state_type_3d_ofp> {
291 typedef boost::true_type type;
292 static const bool value = type::value;
293 };
294 template<>
295 struct is_resizeable<state_type_4d_ofp> {
296 typedef boost::true_type type;
297 static const bool value = type::value;
298 };
299 template<>
300 struct is_resizeable<state_type_5d_ofp> {
301 typedef boost::true_type type;
302 static const bool value = type::value;
303 };
304
305
306
307 template<>
308 struct vector_space_norm_inf<state_type_1d_ofp>
309 {
310 typedef double result_type;
311 };
312
313 template<>
314 struct vector_space_norm_inf<state_type_2d_ofp>
315 {
316 typedef double result_type;
317 };
318
319 template<>
320 struct vector_space_norm_inf<state_type_3d_ofp>
321 {
322 typedef double result_type;
323 };
324
325 template<>
326 struct vector_space_norm_inf<state_type_4d_ofp>
327 {
328 typedef double result_type;
329 };
330
331 template<>
332 struct vector_space_norm_inf<state_type_5d_ofp>
333 {
334 typedef double result_type;
335 };
336
337 // For GRIDs
338
339 template<typename state_type>
340 struct is_resizeable<state_type_ofpm_impl<1,state_type> > {
341 typedef boost::true_type type;
342 static const bool value = type::value;
343 };
344
345 template<typename state_type>
346 struct is_resizeable<state_type_ofpm_impl<2,state_type> > {
347 typedef boost::true_type type;
348 static const bool value = type::value;
349 };
350
351 template<typename state_type>
352 struct is_resizeable<state_type_ofpm_impl<3,state_type> > {
353 typedef boost::true_type type;
354 static const bool value = type::value;
355 };
356
357 template<typename state_type>
358 struct is_resizeable<state_type_ofpm_impl<4,state_type> > {
359 typedef boost::true_type type;
360 static const bool value = type::value;
361 };
362
363 template<typename state_type>
364 struct is_resizeable<state_type_ofpm_impl<5,state_type> > {
365 typedef boost::true_type type;
366 static const bool value = type::value;
367 };
368
369/* template<>
370 struct is_resizeable<state_type_2d_ofp> {
371 typedef boost::true_type type;
372 static const bool value = type::value;
373 };
374
375 template<>
376 struct is_resizeable<state_type_3d_ofp> {
377 typedef boost::true_type type;
378 static const bool value = type::value;
379 };
380 template<>
381 struct is_resizeable<state_type_4d_ofp> {
382 typedef boost::true_type type;
383 static const bool value = type::value;
384 };
385 template<>
386 struct is_resizeable<state_type_5d_ofp> {
387 typedef boost::true_type type;
388 static const bool value = type::value;
389 };*/
390
391
392
393/* // template<unsigned int nprp, typename state_type>
394 struct vector_space_norm_inf<state_type_ofpm_impl<nprp,state_type>>
395 {
396 typedef double result_type;
397 };*/
398
399 template<typename state_type>
400 struct vector_space_norm_inf<state_type_ofpm_impl<1,state_type>>
401 {
402 typedef double result_type;
403 };
404
405 template<typename state_type>
406 struct vector_space_norm_inf<state_type_ofpm_impl<2,state_type>>
407 {
408 typedef double result_type;
409 };
410
411 template<typename state_type>
412 struct vector_space_norm_inf<state_type_ofpm_impl<3,state_type>>
413 {
414 typedef double result_type;
415 };
416
417 template<typename state_type>
418 struct vector_space_norm_inf<state_type_ofpm_impl<4,state_type>>
419 {
420 typedef double result_type;
421 };
422
423 template<typename state_type>
424 struct vector_space_norm_inf<state_type_ofpm_impl<5,state_type>>
425 {
426 typedef double result_type;
427 };
428
429 }
430 }
431}
432
433
434
435#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
Void structure.
Definition common.hpp:74
aggregate of properties, from a list of object if create a struct that follow the OPENFPM native stru...
__device__ __host__ boost::mpl::at< type, boost::mpl::int_< i > >::type & get()
get the properties i
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.