Rheolef  7.1
an efficient C++ finite element environment
disarray.h
Go to the documentation of this file.
1 #ifndef _RHEO_DISARRAY_H
2 #define _RHEO_DISARRAY_H
3 //
4 // This file is part of Rheolef.
5 //
6 // Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
7 //
8 // Rheolef is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // Rheolef is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with Rheolef; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 //
22 // =========================================================================
23 
24 namespace rheolef {
166 } // namespace rheolef
167 
168 
169 /*
170 Misc notes:
171  "scatter" via "get_dis_entry".
172 
173  "gather" via "dis_entry(dis_i) = value"
174  or "dis_entry(dis_i) += value". Note that += applies when T=idx_set where
175  idx_set is a wrapper class of std::set<size_t> ; the += operator represents the
176  union of a set. The operator= is used when T=double or others simple T types
177  without algebra. If there is a conflict, i.e. several processes set the dis_i
178  index, then the result of operator+= depends upon the order of the process at
179  each run and is not deterministic. Such ambiguous behavior is not detected
180  yet at run time.
181 
182 */
183 
184 #include "rheolef/distributed.h"
185 #include "rheolef/distributor.h"
186 #include "rheolef/diststream.h"
187 #include "rheolef/heap_allocator.h"
188 #include "rheolef/msg_util.h"
189 #include "rheolef/container_traits.h"
190 #ifdef _RHEOLEF_HAVE_MPI
191 #include "rheolef/mpi_pair_datatype.h"
192 #endif // _RHEOLEF_HAVE_MPI
193 
194 namespace rheolef {
196 template <class T>
198  std::ostream& operator() (std::ostream& os, const T& x) const { return os << x; }
199 };
200 template <class T>
202  std::ostream& operator() (std::ostream& os, const T& x) const { return os << x << ";"; }
203 };
205 template <class T>
207  std::istream& operator() (std::istream& is, T& x) const { return is >> x; }
208 };
209 } // namespace rheolef
210 // -------------------------------------------------------------
211 // the sequential representation
212 // -------------------------------------------------------------
213 namespace rheolef {
214 
215 template <class T, class M, class A> class disarray_rep {};
216 
217 template <class T, class A>
218 class disarray_rep<T,sequential,A> : public std::vector<T> { // TODO: vector<T,A> for heap_alloc
219 public:
220  typedef T value_type;
221  typedef A allocator_type;
222  typedef typename A::difference_type difference_type;
223  typedef std::vector<T> base; // TODO: vector<T,A> for heap_alloc
224  typedef typename base::size_type size_type;
225  typedef typename base::iterator iterator;
226  typedef typename base::const_iterator const_iterator;
227  typedef typename base::const_reference const_reference;
228  typedef typename base::reference reference;
232 
233  explicit disarray_rep (const A& alloc = A());
234  disarray_rep (const distributor& ownership, const T& init_val = T(), const A& alloc = A());
235  void resize (const distributor& ownership, const T& init_val = T());
236  disarray_rep (size_type loc_size = 0, const T& init_val = T(), const A& alloc = A());
237  void resize (size_type loc_size = 0, const T& init_val = T());
239 
240  A get_allocator() const { return base::get_allocator(); }
241  size_type size() const { return base::size(); }
242  iterator begin() { return base::begin(); }
243  const_iterator begin() const { return base::begin(); }
244  iterator end() { return base::end(); }
245  const_iterator end() const { return base::end(); }
246  const distributor& ownership() const { return _ownership; }
247 
248  reference operator[] (size_type i) { return base::operator[] (i); }
249  const_reference operator[] (size_type i) const { return base::operator[] (i); }
250  const_reference dis_at (size_type dis_i) const { return operator[] (dis_i); }
251 
252  size_type dis_size () const { return base::size(); }
253  size_type first_index () const { return 0; }
254  size_type last_index () const { return base::size(); }
255  reference dis_entry (size_type dis_i) { return operator[](dis_i); }
256  void get_dis_indexes (std::set<size_type>& ext_idx_set) const;
257  void reset_dis_indexes() const {}
258  template<class SetOp = typename default_set_op<T>::type>
259  void dis_entry_assembly_begin (SetOp = SetOp()) {}
260  template<class SetOp = typename default_set_op<T>::type>
261  void dis_entry_assembly_end (SetOp = SetOp()) {}
262  void repartition ( // old_numbering for *this
263  const disarray_rep<size_type,sequential,A>& partition, // old_ownership
264  disarray_rep<T,sequential,A>& new_disarray, // new_ownership (created)
265  disarray_rep<size_type,sequential,A>& old_numbering, // new_ownership
266  disarray_rep<size_type,sequential,A>& new_numbering) const // old_ownership
267  {
268  error_macro ("not yet");
269  }
270  template<class A2>
271  void reverse_permutation ( // old_ownership for *this=iold2dis_inew
272  disarray_rep<size_type,sequential,A2>& inew2dis_iold) const; // new_ownership
273 
274  idiststream& get_values (idiststream& s);
275  odiststream& put_values (odiststream& s) const;
276  odiststream& put_matlab (odiststream& s) const;
277  template <class GetFunction> idiststream& get_values (idiststream& ips, GetFunction get_element);
278  template <class PutFunction> odiststream& put_values (odiststream& ops, PutFunction put_element) const;
279  void dump (std::string name) const;
280 protected:
281 // data:
283 };
284 // -------------------------------------------------------------
285 // the distributed representation
286 // -------------------------------------------------------------
287 #ifdef _RHEOLEF_HAVE_MPI
288 template <class T, class A>
289 class disarray_rep<T,distributed,A> : public disarray_rep<T,sequential,A> {
290 public:
291 
292 // typedefs:
293 
294  typedef disarray_rep<T,sequential,A> base;
295  typedef typename base::value_type value_type;
296  typedef typename base::size_type size_type;
297  typedef typename base::difference_type difference_type;
298  typedef typename base::reference reference;
299  typedef typename base::const_reference const_reference;
300  typedef typename base::iterator iterator;
301  typedef typename base::const_iterator const_iterator;
302  typedef distributor::communicator_type communicator_type;
303  typedef distributed memory_type;
304  typedef std::map <size_type, T> scatter_map_type; // TODO: map<T,A> for heap_alloc
305 
306  struct dis_reference {
307  dis_reference (disarray_rep<T,distributed,A>& x, size_type dis_i)
308  : _x(x), _dis_i(dis_i) {}
309 
310  dis_reference& operator= (const T& value) {
311  _x.set_dis_entry (_dis_i, value);
312  return *this;
313  }
314  template<class U>
315  dis_reference& operator+= (const U& value) {
316  _x.set_add_dis_entry (_dis_i, value);
317  return *this;
318  }
319  // data:
320  protected:
322  size_type _dis_i;
323  };
324 
325 // allocators:
326 
327  disarray_rep (const distributor& ownership, const T& init_val = T(), const A& alloc = A());
328  void resize (const distributor& ownership, const T& init_val = T());
329  disarray_rep (const disarray_rep<T,distributed,A>& x);
330 
331  A get_allocator() const { return base::get_allocator(); }
332  size_type size() const { return base::size(); }
333  const_iterator begin() const { return base::begin(); }
334  const_iterator end() const { return base::end(); }
335  iterator begin() { return base::begin(); }
336  iterator end() { return base::end(); }
337 
338  const distributor& ownership() const { return base::_ownership; }
339  const mpi::communicator& comm() const { return ownership().comm(); }
340  size_type first_index () const { return ownership().first_index(); }
341  size_type last_index () const { return ownership().last_index(); }
342  size_type dis_size () const { return ownership().dis_size(); }
343 
344  dis_reference dis_entry (size_type dis_i) { return dis_reference (*this, dis_i); }
345 
346  template<class SetOp = typename default_set_op<T>::type>
347  void dis_entry_assembly_begin (SetOp my_set_op = SetOp());
348  template<class SetOp = typename default_set_op<T>::type>
349  void dis_entry_assembly_end (SetOp my_set_op = SetOp());
350  template<class SetOp = typename default_set_op<T>::type>
351  void dis_entry_assembly (SetOp my_set_op = SetOp())
352  { dis_entry_assembly_begin (my_set_op); dis_entry_assembly_end (my_set_op); }
353 
354  template<class Set, class Map>
355  void append_dis_entry (const Set& ext_idx_set, Map& ext_idx_map) const;
356 
357  template<class Set, class Map>
358  void get_dis_entry (const Set& ext_idx_set, Map& ext_idx_map) const {
359  ext_idx_map.clear();
360  append_dis_entry (ext_idx_set, ext_idx_map);
361  }
362 
363  template<class Set>
364  void append_dis_indexes (const Set& ext_idx_set) const { append_dis_entry (ext_idx_set, _ext_x); }
365 
366  template<class Set>
367  void set_dis_indexes (const Set& ext_idx_set) const { get_dis_entry (ext_idx_set, _ext_x); }
368  void get_dis_indexes (std::set<size_type>& ext_idx_set) const;
369  void reset_dis_indexes() const;
370 
371  const_reference dis_at (size_type dis_i) const;
372 
373  // get all external pairs (dis_i, values):
374  const scatter_map_type& get_dis_map_entries() const { return _ext_x; }
375 
376  template<class A2>
377  void repartition ( // old_numbering for *this
378  const disarray_rep<size_type,distributed,A2>& partition, // old_ownership
379  disarray_rep<T,distributed,A>& new_disarray, // new_ownership (created)
380  disarray_rep<size_type,distributed,A2>& old_numbering, // new_ownership
381  disarray_rep<size_type,distributed,A2>& new_numbering) const; // old_ownership
382 
383  template<class A2>
384  void permutation_apply ( // old_numbering for *this
385  const disarray_rep<size_type,distributed,A2>& new_numbering, // old_ownership
386  disarray_rep<T,distributed,A>& new_disarray) const; // new_ownership (already allocated)
387 
388  template<class A2>
389  void reverse_permutation ( // old_ownership for *this=iold2dis_inew
390  disarray_rep<size_type,distributed,A2>& inew2dis_iold) const; // new_ownership
391 
392  idiststream& get_values (idiststream& s);
393  odiststream& put_values (odiststream& s) const;
394  odiststream& put_matlab (odiststream& s) const;
395  template <class GetFunction> idiststream& get_values (idiststream& ips, GetFunction get_element);
396  template <class PutFunction> odiststream& put_values (odiststream& ops, PutFunction put_element) const;
397  template <class PutFunction, class A2> odiststream& permuted_put_values (odiststream& ops, const disarray_rep<size_type,distributed,A2>& perm,
398  PutFunction put_element) const;
399  void dump (std::string name) const;
400 protected:
401  void set_dis_entry (size_type dis_i, const T& val);
402  template<class U>
403  void set_add_dis_entry (size_type dis_i, const U& val);
404 // typedefs:
408  template<class Pair>
409  struct remove_const_in_pair {
410  typedef Pair type;
411  };
412  template<class T1, class T2>
413  struct remove_const_in_pair<std::pair<T1,T2> > {
414  typedef std::pair<typename std::decay<T1>::type,
415  typename std::decay<T2>::type> type;
416  };
417  template<class U, class IsContainer> struct stash_traits {};
418  template<class U>
419  struct stash_traits<U,std::false_type> {
420  typedef U mapped_type;
421  typedef std::map <size_type, U> map_type; // TODO: map<T,A> for heap_alloc
422  };
423  template<class U>
424  struct stash_traits<U,std::true_type> {
425  typedef typename remove_const_in_pair<typename U::value_type>::type mapped_type;
426  typedef std::multimap <size_type, mapped_type> map_type; // TODO: map<T,A> for heap_alloc
427  };
428  typedef typename is_container_of_mpi_datatype<T>::type is_container;
429  typedef typename stash_traits<T,is_container>::mapped_type stash_value;
430  typedef typename stash_traits<T,is_container>::map_type stash_map_type;
431 
434  struct message_type {
435  std::list<std::pair<size_type,mpi::request> > waits; // TODO: list<T,A> for heap_alloc
436  std::vector<std::pair<size_type,stash_value> > data; // TODO: vector<T,A> for heap_alloc
437  message_type() : waits(), data() {}
438  };
441  template<class Set, class Map>
442  void append_dis_entry (const Set& ext_idx_set, Map& ext_idx_map, std::true_type) const;
443  template<class Set, class Map>
444  void append_dis_entry (const Set& ext_idx_set, Map& ext_idx_map, std::false_type) const;
445 
446 // data:
447  stash_map_type _stash; // for assembly msgs:
448  message_type _send;
449  message_type _receive;
450  size_type _receive_max_size;
451  mutable scatter_map_type _ext_x; // for ext values (scatter)
452 };
453 #endif // _RHEOLEF_HAVE_MPI
454 // -------------------------------------------------------------
455 // the basic class with a smart pointer to representation
456 // the user-level class with memory-model parameter
457 // -------------------------------------------------------------
458 template <class T, class M = rheo_default_memory_model, class A = std::allocator<T> >
459 class disarray {
460 public:
461  typedef M memory_type;
463  typedef typename rep::base::size_type size_type;
464  typedef typename rep::base::iterator iterator;
466 };
467 template <class T, class A>
468 class disarray<T,sequential,A> : public smart_pointer<disarray_rep<T,sequential,A> > {
469 public:
470 
471 // typedefs:
472 
475 
477  typedef typename rep::size_type size_type;
479  typedef typename rep::value_type value_type;
480  typedef typename rep::reference reference;
482  typedef typename rep::iterator iterator;
485 
486 // allocators:
487 
488 
489  disarray (size_type loc_size = 0, const T& init_val = T(), const A& alloc = A());
490  void resize (size_type loc_size = 0, const T& init_val = T());
491  disarray (const distributor& ownership, const T& init_val = T(), const A& alloc = A());
492  void resize (const distributor& ownership, const T& init_val = T());
493 
494 // local accessors & modifiers:
495 
496  A get_allocator() const { return base::data().get_allocator(); }
497  size_type size () const { return base::data().size(); }
498  size_type dis_size () const { return base::data().dis_size(); }
499  const distributor& ownership() const { return base::data().ownership(); }
500  const communicator& comm() const { return ownership().comm(); }
501 
502  reference operator[] (size_type i) { return base::data().operator[] (i); }
503  const_reference operator[] (size_type i) const { return base::data().operator[] (i); }
504  reference operator() (size_type i) { return base::data().operator[] (i); }
505  const_reference operator() (size_type i) const { return base::data().operator[] (i); }
506  const_reference dis_at (size_type dis_i) const { return operator[] (dis_i); }
507 
508  iterator begin() { return base::data().begin(); }
509  const_iterator begin() const { return base::data().begin(); }
510  iterator end() { return base::data().end(); }
511  const_iterator end() const { return base::data().end(); }
512 
513 // global modifiers (for compatibility with distributed interface):
514 
515  dis_reference dis_entry (size_type dis_i) { return base::data().dis_entry(dis_i); }
516  template<class SetOp = typename default_set_op<T>::type>
517  void dis_entry_assembly (SetOp my_set_op = SetOp()) {}
518  template<class SetOp = typename default_set_op<T>::type>
519  void dis_entry_assembly_begin (SetOp my_set_op = SetOp()) {}
520  template<class SetOp = typename default_set_op<T>::type>
521  void dis_entry_assembly_end (SetOp my_set_op = SetOp()) {}
522 
526 
527  void get_dis_indexes (std::set<size_type>& ext_idx_set) const { base::data().get_dis_indexes (ext_idx_set); }
528  void reset_dis_indexes() const {}
529  template<class Set> void set_dis_indexes (const Set& ext_idx_set) const {}
530  template<class Set> void append_dis_indexes (const Set& ext_idx_set) const {}
531  template<class Set, class Map> void append_dis_entry (const Set& ext_idx_set, Map& ext_idx_map) const {}
532  template<class Set, class Map> void get_dis_entry (const Set& ext_idx_set, Map& ext_idx_map) const {}
533 
534 // apply a partition:
535 
536  template<class RepSize>
537  void repartition ( // old_numbering for *this
538  const RepSize& partition, // old_ownership
539  disarray<T,sequential,A>& new_disarray, // new_ownership (created)
540  RepSize& old_numbering, // new_ownership
541  RepSize& new_numbering) const // old_ownership
542  { return base::data().repartition (partition, new_disarray, old_numbering, new_numbering); }
543 
544  template<class RepSize>
545  void permutation_apply ( // old_numbering for *this
546  const RepSize& new_numbering, // old_ownership
547  disarray<T,sequential,A>& new_disarray) const // new_ownership (already allocated)
548  { return base::data().permutation_apply (new_numbering, new_disarray); }
549 
550  void reverse_permutation ( // old_ownership for *this=iold2dis_inew
551  disarray<size_type,sequential,A>& inew2dis_iold) const // new_ownership
552  { base::data().reverse_permutation (inew2dis_iold.data()); }
553 
554 // i/o:
555 
556  odiststream& put_values (odiststream& ops) const { return base::data().put_values(ops); }
557  idiststream& get_values (idiststream& ips) { return base::data().get_values(ips); }
558  template <class GetFunction>
559  idiststream& get_values (idiststream& ips, GetFunction get_element) { return base::data().get_values(ips, get_element); }
560  template <class PutFunction>
561  odiststream& put_values (odiststream& ops, PutFunction put_element) const { return base::data().put_values(ops, put_element); }
562  void dump (std::string name) const { return base::data().dump(name); }
563 };
564 template <class T, class A>
565 inline
567  size_type loc_size,
568  const T& init_val,
569  const A& alloc)
570  : base(new_macro(rep(loc_size,init_val,alloc)))
571 {
572 }
573 template <class T, class A>
574 inline
576  const distributor& ownership,
577  const T& init_val,
578  const A& alloc)
579  : base(new_macro(rep(ownership,init_val,alloc)))
580 {
581 }
582 template <class T, class A>
583 inline
584 void
586  size_type loc_size,
587  const T& init_val)
588 {
589  base::data().resize (loc_size,init_val);
590 }
591 template <class T, class A>
592 inline
593 void
595  const distributor& ownership,
596  const T& init_val)
597 {
598  base::data().resize (ownership,init_val);
599 }
600 #ifdef _RHEOLEF_HAVE_MPI
601 // [verbatim_disarray]
602 template <class T, class A>
603 class disarray<T,distributed,A> : public smart_pointer<disarray_rep<T,distributed,A> > {
604 public:
605 
606 // typedefs:
607 
609  typedef smart_pointer<rep> base;
610 
611  typedef distributed memory_type;
612  typedef typename rep::size_type size_type;
613  typedef typename rep::difference_type difference_type;
614  typedef typename rep::value_type value_type;
615  typedef typename rep::reference reference;
616  typedef typename rep::dis_reference dis_reference;
617  typedef typename rep::iterator iterator;
618  typedef typename rep::const_reference const_reference;
619  typedef typename rep::const_iterator const_iterator;
620  typedef typename rep::scatter_map_type scatter_map_type;
621 
622 // allocators:
623 
624  disarray (const distributor& ownership = distributor(), const T& init_val = T(), const A& alloc = A());
625  void resize (const distributor& ownership = distributor(), const T& init_val = T());
626 
627 // local accessors & modifiers:
628 
629  A get_allocator() const { return base::data().get_allocator(); }
630  size_type size () const { return base::data().size(); }
631  size_type dis_size () const { return base::data().dis_size(); }
632  const distributor& ownership() const { return base::data().ownership(); }
633  const communicator& comm() const { return base::data().comm(); }
634 
635  reference operator[] (size_type i) { return base::data().operator[] (i); }
636  const_reference operator[] (size_type i) const { return base::data().operator[] (i); }
637  reference operator() (size_type i) { return base::data().operator[] (i); }
638  const_reference operator() (size_type i) const { return base::data().operator[] (i); }
639 
640  iterator begin() { return base::data().begin(); }
641  const_iterator begin() const { return base::data().begin(); }
642  iterator end() { return base::data().end(); }
643  const_iterator end() const { return base::data().end(); }
644 
645 // global accessor:
646 
647  template<class Set, class Map>
648  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); }
649 
650  template<class Set, class Map>
651  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); }
652 
653  template<class Set>
654  void append_dis_indexes (const Set& ext_idx_set) const { base::data().append_dis_indexes (ext_idx_set); }
655  void reset_dis_indexes() const { base::data().reset_dis_indexes(); }
656  void get_dis_indexes (std::set<size_type>& ext_idx_set) const { base::data().get_dis_indexes (ext_idx_set); }
657 
658  template<class Set>
659  void set_dis_indexes (const Set& ext_idx_set) const { base::data().set_dis_indexes (ext_idx_set); }
660 
661  const T& dis_at (size_type dis_i) const { return base::data().dis_at (dis_i); }
662 
663  // get all external pairs (dis_i, values):
664  const scatter_map_type& get_dis_map_entries() const { return base::data().get_dis_map_entries(); }
665 
666 // global modifiers (for compatibility with distributed interface):
667 
668  dis_reference dis_entry (size_type dis_i) { return base::data().dis_entry(dis_i); }
669 
670  template<class SetOp = typename default_set_op<T>::type>
671  void dis_entry_assembly_begin (SetOp my_set_op = SetOp()) { base::data().dis_entry_assembly_begin (my_set_op); }
672  template<class SetOp = typename default_set_op<T>::type>
673  void dis_entry_assembly_end (SetOp my_set_op = SetOp()) { base::data().dis_entry_assembly_end (my_set_op); }
674  template<class SetOp = typename default_set_op<T>::type>
675  void dis_entry_assembly (SetOp my_set_op = SetOp()) { base::data().dis_entry_assembly (my_set_op); }
676 
677  void dis_entry_assembly_begin() { base::data().template dis_entry_assembly_begin<typename default_set_op<T>::type>(); }
678  void dis_entry_assembly_end() { base::data().template dis_entry_assembly_end<typename default_set_op<T>::type>(); }
679  void dis_entry_assembly() { dis_entry_assembly_begin(); dis_entry_assembly_end(); }
680 
681 // apply a partition:
682 
683  template<class RepSize>
684  void repartition ( // old_numbering for *this
685  const RepSize& partition, // old_ownership
686  disarray<T,distributed>& new_disarray, // new_ownership (created)
687  RepSize& old_numbering, // new_ownership
688  RepSize& new_numbering) const // old_ownership
689  { return base::data().repartition (partition.data(), new_disarray.data(), old_numbering.data(), new_numbering.data()); }
690 
691  template<class RepSize>
692  void permutation_apply ( // old_numbering for *this
693  const RepSize& new_numbering, // old_ownership
694  disarray<T,distributed,A>& new_disarray) const // new_ownership (already allocated)
695  { base::data().permutation_apply (new_numbering.data(), new_disarray.data()); }
696 
697  void reverse_permutation ( // old_ownership for *this=iold2dis_inew
698  disarray<size_type,distributed,A>& inew2dis_iold) const // new_ownership
699  { base::data().reverse_permutation (inew2dis_iold.data()); }
700 
701 // i/o:
702 
703  odiststream& put_values (odiststream& ops) const { return base::data().put_values(ops); }
704  idiststream& get_values (idiststream& ips) { return base::data().get_values(ips); }
705  void dump (std::string name) const { return base::data().dump(name); }
706 
707  template <class GetFunction>
708  idiststream& get_values (idiststream& ips, GetFunction get_element) { return base::data().get_values(ips, get_element); }
709  template <class PutFunction>
710  odiststream& put_values (odiststream& ops, PutFunction put_element) const { return base::data().put_values(ops, put_element); }
711  template <class PutFunction, class A2> odiststream& permuted_put_values (
712  odiststream& ops, const disarray<size_type,distributed,A2>& perm, PutFunction put_element) const
713  { return base::data().permuted_put_values (ops, perm.data(), put_element); }
714 };
715 // [verbatim_disarray]
716 template <class T, class A>
717 inline
718 disarray<T,distributed,A>::disarray (
719  const distributor& ownership,
720  const T& init_val,
721  const A& alloc)
722  : base(new_macro(rep(ownership,init_val,alloc)))
723 {
724 }
725 template <class T, class A>
726 inline
727 void
728 disarray<T,distributed,A>::resize (
729  const distributor& ownership,
730  const T & init_val)
731 {
732  base::data().resize (ownership,init_val);
733 }
734 #endif // _RHEOLEF_HAVE_MPI
735 
736 // -------------------------------------------------------------
737 // i/o with operator<< & >>
738 // -------------------------------------------------------------
739 template <class T, class A>
740 inline
741 idiststream&
743 {
744  return x.get_values(ips);
745 }
746 template <class T, class A>
747 inline
750 {
751  return x.put_values(ops);
752 }
753 #ifdef _RHEOLEF_HAVE_MPI
754 template <class T, class A>
755 inline
756 idiststream&
757 operator >> (idiststream& ips, disarray<T,distributed,A>& x)
758 {
759  return x.get_values(ips);
760 }
761 template <class T, class A>
762 inline
763 odiststream&
764 operator << (odiststream& ops, const disarray<T,distributed,A>& x)
765 {
766  return x.put_values(ops);
767 }
768 #endif // _RHEOLEF_HAVE_MPI
769 } // namespace rheolef
770 // -------------------------------------------------------------
771 // not inlined : longer code
772 // -------------------------------------------------------------
773 #include "rheolef/disarray_seq.icc"
774 #include "rheolef/disarray_mpi.icc"
775 #endif // _RHEO_DISARRAY_H
field::size_type size_type
Definition: branch.cc:425
void reverse_permutation(disarray< size_type, sequential, A > &inew2dis_iold) const
Definition: disarray.h:550
idiststream & get_values(idiststream &ips, GetFunction get_element)
Definition: disarray.h:559
rep::const_iterator const_iterator
Definition: disarray.h:484
void get_dis_entry(const Set &ext_idx_set, Map &ext_idx_map) const
Definition: disarray.h:532
const_reference dis_at(size_type dis_i) const
Definition: disarray.h:506
void set_dis_indexes(const Set &ext_idx_set) const
Definition: disarray.h:529
rep::dis_reference dis_reference
Definition: disarray.h:481
disarray_rep< T, sequential, A > rep
Definition: disarray.h:473
const_iterator begin() const
Definition: disarray.h:509
dis_reference dis_entry(size_type dis_i)
Definition: disarray.h:515
rep::difference_type difference_type
Definition: disarray.h:478
void append_dis_indexes(const Set &ext_idx_set) const
Definition: disarray.h:530
void repartition(const RepSize &partition, disarray< T, sequential, A > &new_disarray, RepSize &old_numbering, RepSize &new_numbering) const
Definition: disarray.h:537
odiststream & put_values(odiststream &ops) const
Definition: disarray.h:556
void dis_entry_assembly_begin(SetOp my_set_op=SetOp())
Definition: disarray.h:519
const distributor & ownership() const
Definition: disarray.h:499
void permutation_apply(const RepSize &new_numbering, disarray< T, sequential, A > &new_disarray) const
Definition: disarray.h:545
odiststream & put_values(odiststream &ops, PutFunction put_element) const
Definition: disarray.h:561
rep::const_reference const_reference
Definition: disarray.h:483
idiststream & get_values(idiststream &ips)
Definition: disarray.h:557
void dis_entry_assembly_end(SetOp my_set_op=SetOp())
Definition: disarray.h:521
void get_dis_indexes(std::set< size_type > &ext_idx_set) const
Definition: disarray.h:527
void dis_entry_assembly(SetOp my_set_op=SetOp())
Definition: disarray.h:517
void dump(std::string name) const
Definition: disarray.h:562
const_iterator end() const
Definition: disarray.h:511
const communicator & comm() const
Definition: disarray.h:500
void append_dis_entry(const Set &ext_idx_set, Map &ext_idx_map) const
Definition: disarray.h:531
const_reference dis_at(size_type dis_i) const
Definition: disarray.h:250
distributor::communicator_type communicator_type
Definition: disarray.h:230
void dis_entry_assembly_begin(SetOp=SetOp())
Definition: disarray.h:259
base::const_reference const_reference
Definition: disarray.h:227
const distributor & ownership() const
Definition: disarray.h:246
void dis_entry_assembly_end(SetOp=SetOp())
Definition: disarray.h:261
void repartition(const disarray_rep< size_type, sequential, A > &partition, disarray_rep< T, sequential, A > &new_disarray, disarray_rep< size_type, sequential, A > &old_numbering, disarray_rep< size_type, sequential, A > &new_numbering) const
Definition: disarray.h:262
reference dis_entry(size_type dis_i)
Definition: disarray.h:255
see the disarray page for the full documentation
Definition: disarray.h:459
disarray_rep< T, sequential, A > rep
Definition: disarray.h:462
rep::base::const_iterator const_iterator
Definition: disarray.h:465
rep::base::iterator iterator
Definition: disarray.h:464
rep::base::size_type size_type
Definition: disarray.h:463
see the distributor page for the full documentation
Definition: distributor.h:62
const communicator_type & comm() const
Definition: distributor.h:145
odiststream: see the diststream page for the full documentation
Definition: diststream.h:126
see the smart_pointer page for the full documentation
typename Expr1::memory_type memory_type
rheolef::std type
size_t size_type
Definition: basis_get.cc:76
rheolef::std value
result_type value_type
Expr1::float_type T
Definition: field_expr.h:261
verbose clean transpose logscale grid shrink ball stereo iso volume skipvtk deformation fastfieldload lattice reader_on_stdin color format format format format format format format format format format format format format format format format format format dump
This file is part of Rheolef.
std::istream & operator>>(std::istream &is, const catchmark &m)
Definition: catchmark.h:88
std::ostream & operator<<(std::ostream &os, const catchmark &m)
Definition: catchmark.h:99
std::enable_if< details::is_rheolef_arithmetic< U >::value,ad3_basic< T > & >::type operator+=(ad3_basic< T > &a, const U &b)
Definition: ad3.h:286
disarray element input helper
Definition: disarray.h:206
std::istream & operator()(std::istream &is, T &x) const
Definition: disarray.h:207
disarray element output helper
Definition: disarray.h:197
std::ostream & operator()(std::ostream &os, const T &x) const
Definition: disarray.h:198
std::ostream & operator()(std::ostream &os, const T &x) const
Definition: disarray.h:202
Expr1::memory_type M
Definition: vec_expr_v2.h:416