Provided by: librheolef-dev_6.5-1build1_amd64 bug

NAME

       hack_array - container in distributed environment (rheolef-6.5)

SYNOPSYS

       STL-like vector container for a distributed memory machine model.  Contrarily to array<T>,
       here T can have a size only known at compile time.   This  class  is  used  when  T  is  a
       geo_element raw class, i.e. T=geo_element_e_raw.  The size of the geo_element depends upon
       the oder and is known only at run-time.  For efficiency purpose, the  hack_array  allocate
       all geo_elements of the same variant (e.g. edge) and order in a contiguous area, since the
       coreesponding element size is constant.

EXAMPLE

        A sample usage of the class is:

           std::pair<size_t,size_t> param (reference_element::t, 3); // triangle, order=3
           hack_array<geo_element_raw> x (distributor(100), param);

       The hack_array<T> interface is similar to those of the array<T> one.

OBJECT REQUIREMENT

        There are many pre-requises for the template objet type T:

           class T : public T::generic_type {
            typedef variant_type;
            typedef raw_type;
            typedef genetic_type;
            typedef automatic_type;
            static const variant_type _variant;
            static size_t _data_size(const parameter_type& param);
            static size_t _value_size(const parameter_type& param);
           };
           class T::automatic_type : public T::generic_type {
            automatic_type (const parameter_type& param);
           };
           class T::generic_type {
            typedef raw_type;
            typedef iterator;
            typedef const_iterator;
            iterator _data_begin();
            const_iterator _data_begin() const;
           };
           ostream& operator<< (ostream&, const T::generic_type&);

IMPLEMENTATION

       template <class T, class A>
       class hack_array<T,sequential,A> : public smart_pointer<hack_array_seq_rep<T,A> > {
       public:

       // typedefs:

           typedef hack_array_seq_rep<T,A>    rep;
           typedef smart_pointer<rep>            base;

           typedef sequential                    memory_type;
           typedef typename rep::size_type       size_type;
           typedef typename rep::value_type      value_type;
           typedef typename rep::reference       reference;
           typedef typename rep::dis_reference   dis_reference;
           typedef typename rep::iterator        iterator;
           typedef typename rep::const_reference const_reference;
           typedef typename rep::const_iterator  const_iterator;
           typedef typename rep::parameter_type  parameter_type;

       // allocators:

           hack_array (const A& alloc = A());
           hack_array (size_type loc_size,           const parameter_type& param, const A& alloc = A());
           void resize   (const distributor& ownership, const parameter_type& param);
           hack_array (const distributor& ownership, const parameter_type& param, const A& alloc = A());
           void resize   (size_type loc_size,           const parameter_type& param);

       // local accessors & modifiers:

           A get_allocator() const              { return base::data().get_allocator(); }
           size_type     size () const          { return base::data().size(); }
           size_type dis_size () const          { return base::data().dis_size(); }
           const distributor& ownership() const { return base::data().ownership(); }
           const communicator& comm() const     { return ownership().comm(); }

           reference       operator[] (size_type i)       { return base::data().operator[] (i); }
           const_reference operator[] (size_type i) const { return base::data().operator[] (i); }

           const_reference dis_at (size_type dis_i) const { return base::data().operator[] (dis_i); }

                 iterator begin()       { return base::data().begin(); }
           const_iterator begin() const { return base::data().begin(); }
                 iterator end()         { return base::data().end(); }
           const_iterator end() const   { return base::data().end(); }

       // global accessors (for compatibility with distributed interface):

           template<class Set> void append_dis_indexes (const Set& ext_idx_set) const {}
           void update_dis_entries() const {}

       // global modifiers (for compatibility with distributed interface):

           dis_reference dis_entry (size_type dis_i) { return operator[] (dis_i); }
           void dis_entry_assembly()                 {}
           template<class SetOp>
           void dis_entry_assembly(SetOp my_set_op)        {}
           template<class SetOp>
           void dis_entry_assembly_begin (SetOp my_set_op) {}
           template<class SetOp>
           void dis_entry_assembly_end (SetOp my_set_op)   {}

       // apply a partition:

       #ifdef TODO
           template<class RepSize>
           void repartition (                               // old_numbering for *this
               const RepSize&         partition,            // old_ownership
               hack_array<T,sequential,A>& new_array,       // new_ownership (created)
               RepSize&               old_numbering,        // new_ownership
               RepSize&               new_numbering) const  // old_ownership
               { return base::data().repartition (partition, new_array, old_numbering, new_numbering); }

           template<class RepSize>
           void permutation_apply (                       // old_numbering for *this
               const RepSize&          new_numbering,     // old_ownership
               hack_array<T,sequential,A>&  new_array) const   // new_ownership (already allocated)
               { return base::data().permutation_apply (new_numbering, new_array); }
       #endif // TODO

       // i/o:

           odiststream& put_values (odiststream& ops) const { return base::data().put_values(ops); }
           idiststream& get_values (idiststream& ips)       { return base::data().get_values(ips); }
           template <class GetFunction>
           idiststream& get_values (idiststream& ips, GetFunction get_element)       { return base::data().get_values(ips, get_element); }
           template <class PutFunction>
           odiststream& put_values (odiststream& ops, PutFunction put_element) const { return base::data().put_values(ops, put_element); }
       #ifdef TODO
           void dump (std::string name) const { return base::data().dump(name); }
       #endif // TODO
       };

IMPLEMENTATION

       template <class T, class A>
       class hack_array<T,distributed,A> : public smart_pointer<hack_array_mpi_rep<T,A> > {
       public:

       // typedefs:

           typedef hack_array_mpi_rep<T,A>    rep;
           typedef smart_pointer<rep>            base;

           typedef distributed                   memory_type;
           typedef typename rep::size_type       size_type;
           typedef typename rep::value_type      value_type;
           typedef typename rep::reference       reference;
           typedef typename rep::dis_reference   dis_reference;
           typedef typename rep::iterator        iterator;
           typedef typename rep::parameter_type  parameter_type;
           typedef typename rep::const_reference const_reference;
           typedef typename rep::const_iterator  const_iterator;
           typedef typename rep::scatter_map_type scatter_map_type;

       // allocators:

           hack_array (const A& alloc = A());
           hack_array (const distributor& ownership, const parameter_type& param, const A& alloc = A());
           void resize   (const distributor& ownership, const parameter_type& param);

       // local accessors & modifiers:

           A get_allocator() const              { return base::data().get_allocator(); }
           size_type     size () const          { return base::data().size(); }
           size_type dis_size () const          { return base::data().dis_size(); }
           const distributor& ownership() const { return base::data().ownership(); }
           const communicator& comm() const     { return base::data().comm(); }

           reference       operator[] (size_type i)       { return base::data().operator[] (i); }
           const_reference operator[] (size_type i) const { return base::data().operator[] (i); }

                 iterator begin()       { return base::data().begin(); }
           const_iterator begin() const { return base::data().begin(); }
                 iterator end()         { return base::data().end(); }
           const_iterator end() const   { return base::data().end(); }

       // global accessor:

           template<class Set, class Map>
           void append_dis_entry (const Set& ext_idx_set, Map& ext_idx_map) const { base::data().append_dis_entry (ext_idx_set, ext_idx_map); }

           template<class Set, class Map>
           void get_dis_entry    (const Set& ext_idx_set, Map& ext_idx_map) const { base::data().get_dis_entry (ext_idx_set, ext_idx_map); }

           template<class Set>
           void append_dis_indexes (const Set& ext_idx_set) const { base::data().append_dis_indexes (ext_idx_set); }

           template<class Set>
           void set_dis_indexes    (const Set& ext_idx_set)  { base::data().set_dis_indexes (ext_idx_set); }

           const_reference dis_at (size_type dis_i) const { return base::data().dis_at (dis_i); }

           // get all external pairs (dis_i, values):
           const scatter_map_type& get_dis_map_entries() const { return base::data().get_dis_map_entries(); }

           void update_dis_entries() const { base::data().update_dis_entries(); }

       // global modifiers (for compatibility with distributed interface):

           dis_reference dis_entry (size_type dis_i)       { return base::data().dis_entry(dis_i); }

           void dis_entry_assembly()                       { return base::data().dis_entry_assembly(); }

           template<class SetOp>
           void dis_entry_assembly       (SetOp my_set_op) { return base::data().dis_entry_assembly       (my_set_op); }
           template<class SetOp>
           void dis_entry_assembly_begin (SetOp my_set_op) { return base::data().dis_entry_assembly_begin (my_set_op); }
           template<class SetOp>
           void dis_entry_assembly_end   (SetOp my_set_op) { return base::data().dis_entry_assembly_end   (my_set_op); }

       // apply a partition:

           template<class RepSize>
           void repartition (                              // old_numbering for *this
               const RepSize&        partition,            // old_ownership
               hack_array<T,distributed>& new_array,            // new_ownership (created)
               RepSize&              old_numbering,        // new_ownership
               RepSize&              new_numbering) const  // old_ownership
               { return base::data().repartition (partition.data(), new_array.data(), old_numbering.data(), new_numbering.data()); }

       #ifdef TODO
           template<class RepSize>
           void permutation_apply (                       // old_numbering for *this
               const RepSize&          new_numbering,     // old_ownership
               hack_array<T,distributed,A>& new_array) const   // new_ownership (already allocated)
               { base::data().permutation_apply (new_numbering.data(), new_array.data()); }

           void reverse_permutation (                                 // old_ownership for *this=iold2dis_inew
               hack_array<size_type,distributed,A>& inew2dis_iold) const   // new_ownership
               { base::data().reverse_permutation (inew2dis_iold.data()); }
       #endif // TODO

       // i/o:

           odiststream& put_values (odiststream& ops) const { return base::data().put_values(ops); }
           idiststream& get_values (idiststream& ips)       { return base::data().get_values(ips); }
       #ifdef TODO
           void dump (std::string name) const      { return base::data().dump(name); }
       #endif // TODO

           template <class GetFunction>
           idiststream& get_values (idiststream& ips, GetFunction get_element)
                    { return base::data().get_values(ips, get_element); }
           template <class PutFunction>
           odiststream& put_values (odiststream& ops, PutFunction put_element) const
                    { return base::data().put_values(ops, put_element); }

           template <class PutFunction, class Permutation>
           odiststream& permuted_put_values (
               odiststream&                       ops,
               const Permutation&                 perm,
               PutFunction                        put_element) const
                    { return base::data().permuted_put_values (ops, perm.data(), put_element); }
       };