Rheolef  7.2
an efficient C++ finite element environment
 
Loading...
Searching...
No Matches
hack_array_seq.icc
Go to the documentation of this file.
1
21# include "rheolef/hack_array.h"
22namespace rheolef {
23
24// ===============================================================
25// allocators
26// ===============================================================
27template<class T, class A>
29 : base (alloc),
30 _ownership (),
31 _parameter (),
32 _value_size (),
33 _data_size ()
34{
35}
36template<class T, class A>
37hack_array_seq_rep<T,A>::hack_array_seq_rep (const distributor& ownership, const parameter_type& param, const A& alloc)
38 : base (alloc),
39 _ownership (ownership),
40 _parameter (param),
41 _value_size (T::_size_of (_parameter)),
42 _data_size (T::_data_size(_parameter))
43{
45}
46template<class T, class A>
48 : base (alloc),
49 _ownership (distributor::decide, communicator(), n),
50 _parameter (param),
51 _value_size (T::_size_of (_parameter)),
52 _data_size (T::_data_size(_parameter))
53{
55}
56template<class T, class A>
57void
59{
60 _ownership = ownership;
61 _parameter = param;
62 _value_size = T::_size_of (_parameter);
63 _data_size = T::_data_size(_parameter);
64 _init (_ownership, _parameter);
65}
66template<class T, class A>
67void
69{
70 _ownership = distributor (distributor::decide, communicator(), n);
71 _parameter = param;
72 _value_size = T::_size_of (_parameter);
73 _data_size = T::_data_size(_parameter);
74 _init (_ownership, _parameter);
75}
76template<class T, class A>
77void
79{
80 base::_ownership = distributor (ownership.dis_size()*_value_size, ownership.comm(), ownership.size()*_value_size),
81 base::resize (base::_ownership, std::numeric_limits<raw_type>::max());
82 size_type *p = base::begin().operator->();
83 for (size_type i = 0, n = ownership.size(); i < n; i++) {
84 new (p) T;
85 T* q = (T*)p;
86 q -> _set_parameter(param);
87 p += _value_size;
88 }
89}
90// ===============================================================
91// put & get
92// ===============================================================
93template <class T, class A>
94template <class PutFunction>
96hack_array_seq_rep<T,A>::put_values (odiststream& ops, PutFunction put_element) const
97{
98 std::ostream& os = ops.os();
99 for (size_type i = 0; i < size(); i++) {
100 put_element (os, operator[](i));
101 os << std::endl;
102 }
103 return ops;
104}
105template <class T, class A>
111template <class T, class A>
112template <class GetFunction>
114hack_array_seq_rep<T,A>::get_values (idiststream& ips, GetFunction get_element) {
115 check_macro (load_chunk (ips.is(), begin(), end(), get_element), "read failed on input stream.");
116 return ips;
117}
118template <class T, class A>
124
125} // namespace rheolef
see the distributor page for the full documentation
Definition distributor.h:69
size_type dis_size() const
global and local sizes
size_type size(size_type iproc) const
static const size_type decide
Definition distributor.h:83
const communicator_type & comm() const
odiststream & put_values(odiststream &ops) const
hack_array_seq_rep(const A &alloc=A())
base::size_type size_type
Definition hack_array.h:91
void resize(const distributor &ownership, const parameter_type &param)
T::parameter_type parameter_type
Definition hack_array.h:89
void _init(const distributor &ownership, const parameter_type &param)
idiststream & get_values(idiststream &ips)
idiststream: see the diststream page for the full documentation
Definition diststream.h:336
std::istream & is()
Definition diststream.h:400
odiststream: see the diststream page for the full documentation
Definition diststream.h:137
std::ostream & os()
Definition diststream.h:247
Expr1::float_type T
Definition field_expr.h:230
check_macro(expr1.have_homogeneous_space(Xh1), "dual(expr1,expr2); expr1 should have homogeneous space. HINT: use dual(interpolate(Xh, expr1),expr2)")
This file is part of Rheolef.
bool load_chunk(std::istream &s, RandomIterator iter, RandomIterator last)
Definition load_chunk.h:27
Definition sphere.icc:25
disarray element input helper
Definition disarray.h:205
disarray element output helper
Definition disarray.h:196