hack_array_seq.icc
Go to the documentation of this file.
# include "rheolef/hack_array.h"
namespace rheolef {
// ===============================================================
// allocators
// ===============================================================
template<class T, class A>
hack_array_seq_rep<T,A>::hack_array_seq_rep (const A& alloc)
: base (alloc),
_ownership (),
_parameter (),
_value_size (),
_data_size ()
{
}
template<class T, class A>
hack_array_seq_rep<T,A>::hack_array_seq_rep (const distributor& ownership, const parameter_type& param, const A& alloc)
: base (alloc),
_ownership (ownership),
_parameter (param),
_value_size (T::_size_of (_parameter)),
_data_size (T::_data_size(_parameter))
{
_init (_ownership, _parameter);
}
template<class T, class A>
hack_array_seq_rep<T,A>::hack_array_seq_rep (size_type n, const parameter_type& param, const A& alloc)
: base (alloc),
_ownership (distributor::decide, communicator(), n),
_parameter (param),
_value_size (T::_size_of (_parameter)),
_data_size (T::_data_size(_parameter))
{
_init (_ownership, _parameter);
}
template<class T, class A>
void
hack_array_seq_rep<T,A>::resize (const distributor& ownership, const parameter_type& param)
{
_ownership = ownership;
_parameter = param;
_value_size = T::_size_of (_parameter);
_data_size = T::_data_size(_parameter);
_init (_ownership, _parameter);
}
template<class T, class A>
void
hack_array_seq_rep<T,A>::resize (size_type n, const parameter_type& param)
{
_ownership = distributor (distributor::decide, communicator(), n);
_parameter = param;
_value_size = T::_size_of (_parameter);
_data_size = T::_data_size(_parameter);
_init (_ownership, _parameter);
}
template<class T, class A>
void
hack_array_seq_rep<T,A>::_init (const distributor& ownership, const parameter_type& param)
{
base::_ownership = distributor (ownership.dis_size()*_value_size, ownership.comm(), ownership.size()*_value_size),
base::resize (base::_ownership, std::numeric_limits<raw_type>::max());
size_type *p = base::begin().operator->();
for (size_type i = 0, n = ownership.size(); i < n; i++) {
new (p) T;
T* q = (T*)p;
q -> _set_parameter(param);
p += _value_size;
}
}
// ===============================================================
// put & get
// ===============================================================
template <class T, class A>
template <class PutFunction>
odiststream&
hack_array_seq_rep<T,A>::put_values (odiststream& ops, PutFunction put_element) const
{
std::ostream& os = ops.os();
for (size_type i = 0; i < size(); i++) {
put_element (os, operator[](i));
os << std::endl;
}
return ops;
}
template <class T, class A>
odiststream&
hack_array_seq_rep<T,A>::put_values (odiststream& ops) const
{
return put_values (ops, _disarray_put_element_type<generic_value_type>());
}
template <class T, class A>
template <class GetFunction>
idiststream&
hack_array_seq_rep<T,A>::get_values (idiststream& ips, GetFunction get_element) {
check_macro (load_chunk (ips.is(), begin(), end(), get_element), "read failed on input stream.");
return ips;
}
template <class T, class A>
idiststream&
hack_array_seq_rep<T,A>::get_values (idiststream& ips)
{
return get_values (ips, _disarray_get_element_type<generic_value_type>());
}
} // namespace rheolef
rheolef::disarray_rep
Definition: disarray.h:215
rheolef::distributor
see the distributor page for the full documentation
Definition: distributor.h:62
rheolef::distributor::dis_size
size_type dis_size() const
global and local sizes
Definition: distributor.h:207
rheolef::distributor::size
size_type size(size_type iproc) const
Definition: distributor.h:163
rheolef::distributor::decide
static const size_type decide
Definition: distributor.h:76
rheolef::distributor::comm
const communicator_type & comm() const
Definition: distributor.h:145
rheolef::hack_array_seq_rep::put_values
odiststream & put_values(odiststream &ops) const
Definition: hack_array_seq.icc:107
rheolef::hack_array_seq_rep::hack_array_seq_rep
hack_array_seq_rep(const A &alloc=A())
Definition: hack_array_seq.icc:28
rheolef::hack_array_seq_rep::_ownership
distributor _ownership
Definition: hack_array.h:147
rheolef::hack_array_seq_rep::size_type
base::size_type size_type
Definition: hack_array.h:91
rheolef::hack_array_seq_rep::_parameter
parameter_type _parameter
Definition: hack_array.h:148
rheolef::hack_array_seq_rep::resize
void resize(const distributor &ownership, const parameter_type &param)
Definition: hack_array_seq.icc:58
rheolef::hack_array_seq_rep::parameter_type
T::parameter_type parameter_type
Definition: hack_array.h:89
rheolef::hack_array_seq_rep::_init
void _init(const distributor &ownership, const parameter_type &param)
Definition: hack_array_seq.icc:78
rheolef::hack_array_seq_rep::get_values
idiststream & get_values(idiststream &ips)
Definition: hack_array_seq.icc:120
rheolef::odiststream
odiststream: see the diststream page for the full documentation
Definition: diststream.h:126
rheolef::odiststream::os
std::ostream & os()
Definition: diststream.h:236
T
Expr1::float_type T
Definition: field_expr.h:261
check_macro
check_macro(expr1.have_homogeneous_space(Xh1), "dual(expr1,expr2); expr1 should have homogeneous space. HINT: use dual(interpolate(Xh, expr1),expr2)")
mkgeo_ball.n
int n
Definition: mkgeo_ball.sh:150
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37
rheolef::load_chunk
bool load_chunk(std::istream &s, RandomIterator iter, RandomIterator last)
Definition: load_chunk.h:27
p
Definition: sphere.icc:25
rheolef::_disarray_get_element_type
disarray element input helper
Definition: disarray.h:206
rheolef::_disarray_put_element_type
disarray element output helper
Definition: disarray.h:197