Rheolef  7.1
an efficient C++ finite element environment
space_mpi.cc
Go to the documentation of this file.
1 
22 #include "rheolef/config.h"
23 
24 #ifdef _RHEOLEF_HAVE_MPI
25 
26 #include "rheolef/space.h"
27 #include "rheolef/space_mult.h"
28 
29 namespace rheolef {
30 
31 template <class T>
32 space_rep<T,distributed>::space_rep (
33  const space_constitution<T,distributed>& constit)
34  : space_base_rep<T,distributed>::space_base_rep (constit),
35  _idof2ios_dis_idof(),
36  _ios_idof2dis_idof(),
37  _ext_iu_set(),
38  _ext_ib_set()
39 {
40  base::get_constitution().set_ios_permutations (_idof2ios_dis_idof, _ios_idof2dis_idof);
41 }
42 template <class T>
43 space_rep<T,distributed>::space_rep (
44  const geo_basic<T,distributed>& omega_in,
45  std::string approx,
46  std::string valued)
47  : space_base_rep<T,distributed>::space_base_rep (omega_in, approx, valued),
48  _idof2ios_dis_idof(),
49  _ios_idof2dis_idof(),
50  _ext_iu_set(),
51  _ext_ib_set()
52 {
53  if (approx == "") return; // empty space cstor
54  base::get_constitution().set_ios_permutations (_idof2ios_dis_idof, _ios_idof2dis_idof);
55 }
56 template <class T>
57 space_rep<T,distributed>::space_rep (
58  const geo_basic<T,distributed>& omega_in,
59  const basis_basic<T>& b)
60  : space_base_rep<T,distributed>::space_base_rep (omega_in, b),
61  _idof2ios_dis_idof(),
62  _ios_idof2dis_idof(),
63  _ext_iu_set(),
64  _ext_ib_set()
65 {
66  if (! b.is_initialized()) return; // empty space cstor
67  base::get_constitution().set_ios_permutations (_idof2ios_dis_idof, _ios_idof2dis_idof);
68 }
69 template <class T>
70 space_rep<T,distributed>::space_rep (const space_mult_list<T,distributed>& expr)
71  : space_base_rep<T,distributed>::space_base_rep (expr),
72  _idof2ios_dis_idof(),
73  _ios_idof2dis_idof(),
74  _ext_iu_set(),
75  _ext_ib_set()
76 {
77  base::get_constitution().set_ios_permutations (_idof2ios_dis_idof, _ios_idof2dis_idof);
78 }
79 template <class T>
80 void
81 space_rep<T,distributed>::freeze_body () const
82 {
83  base::base_freeze_body();
84  // -----------------------------------------------------------------------
85  // 1) symbolic assembly:
86  // loop on elements & identify some dofs, that are referenced
87  // by locally-managed geo_elements, but these dofs are managed
88  // by another processor: e.g. dofs associated to vertices on
89  // a partition boundary.
90  // -----------------------------------------------------------------------
91  // set local numbering with global indexes
92  size_type first_dis_iu = base::_iu_ownership.first_index();
93  size_type first_dis_ib = base::_ib_ownership.first_index();
94  for (size_type idof = 0, ndof = base::_idof2blk_dis_iub.size(); idof < ndof; idof++) {
95  size_type first_dis_iub = base::_idof2blk_dis_iub [idof].is_blocked() ? first_dis_ib : first_dis_iu;
96  base::_idof2blk_dis_iub [idof].set_dis_iub (base::_idof2blk_dis_iub[idof].dis_iub() + first_dis_iub);
97  }
98  // -----------------------------------------------------------------------
99  // 2) get external dof numbering:
100  // -----------------------------------------------------------------------
101  std::set<size_type> ext_dof_set;
102  base::get_constitution().compute_external_dofs (ext_dof_set);
103  base::_idof2blk_dis_iub.set_dis_indexes (ext_dof_set);
104  // -----------------------------------------------------------------------
105  // 3) build also ext_iu_set and ext_ib_set, for field::dis_dof(dis_idof)
106  // -----------------------------------------------------------------------
107  for (typename std::set<size_type>::const_iterator iter = ext_dof_set.begin(), last = ext_dof_set.end();
108  iter != last; iter++) {
109  size_type dis_idof = *iter;
110  const space_pair_type& blk_dis_iub = base::_idof2blk_dis_iub.dis_at (dis_idof);
111  if (! blk_dis_iub.is_blocked()) {
112  _ext_iu_set.insert (blk_dis_iub.dis_iub());
113  } else {
114  _ext_ib_set.insert (blk_dis_iub.dis_iub());
115  }
116  }
117 }
118 // ----------------------------------------------------------------------------
119 // accessors for external dofs
120 // ----------------------------------------------------------------------------
121 template <class T>
123 space_rep<T,distributed>::dis_idof2dis_iub (size_type dis_idof) const
124 {
125  base::freeze_guard();
126  return base::_idof2blk_dis_iub.dis_at (dis_idof).dis_iub();
127 }
128 template <class T>
129 bool
130 space_rep<T,distributed>::dis_is_blocked (size_type dis_idof) const
131 {
132  base::freeze_guard();
133  return base::_idof2blk_dis_iub.dis_at (dis_idof).is_blocked();
134 }
135 // ----------------------------------------------------------------------------
136 // instanciation in library
137 // ----------------------------------------------------------------------------
138 template class space_rep<Float,distributed>;
139 
140 } // namespace rheolef
141 #endif // _RHEOLEF_HAVE_MPI
field::size_type size_type
Definition: branch.cc:425
Expr1::float_type T
Definition: field_expr.h:261
void dis_idof(const basis_basic< T > &b, const geo_size &gs, const geo_element &K, typename std::vector< size_type >::iterator dis_idof_tab)
size_type ndof(const basis_basic< T > &b, const geo_size &gs, size_type map_dim)
This file is part of Rheolef.