v0.14.0
ISManager.cpp
Go to the documentation of this file.
1 /** \file ISManager.cpp
2  * \brief IS creating
3  * \ingroup mofem_is_managers
4  */
5 
6 
7 namespace MoFEM {
8 
10 ISManager::query_interface(boost::typeindex::type_index type_index,
11  UnknownInterface **iface) const {
13  *iface = const_cast<ISManager *>(this);
15 }
16 
18  : cOre(const_cast<MoFEM::Core &>(core)), dEbug(false) {}
19 
20 MoFEMErrorCode ISManager::sectionCreate(const std::string problem_name,
21  PetscSection *s,
22  const RowColData row_col) const {
23  const MoFEM::Interface &m_field = cOre;
24  const Problem *problem_ptr = m_field.get_problem(problem_name);
25  auto fields_ptr = m_field.get_fields();
26  auto fe_ptr = m_field.get_finite_elements();
28  boost::shared_ptr<NumeredDofEntity_multiIndex> dofs;
29  BitFieldId fields_ids(0);
30  switch (row_col) {
31  case ROW:
32  dofs = problem_ptr->numeredRowDofsPtr;
33  for (auto fit = fe_ptr->begin(); fit != fe_ptr->end(); fit++) {
34  if ((fit->get()->getId() & problem_ptr->getBitFEId()).any()) {
35  fields_ids |= fit->get()->getBitFieldIdRow();
36  }
37  }
38  break;
39  case COL:
40  dofs = problem_ptr->numeredColDofsPtr;
41  for (auto fit = fe_ptr->begin(); fit != fe_ptr->end(); fit++) {
42  if ((fit->get()->getId() & problem_ptr->getBitFEId()).any()) {
43  fields_ids |= fit->get()->getBitFieldIdCol();
44  }
45  }
46  break;
47  default:
48  SETERRQ(PETSC_COMM_WORLD, MOFEM_DATA_INCONSISTENCY,
49  "Has to be ROW or COLUMN");
50  }
51  // get fields names on the problem
52  map<std::string, std::pair<int, int>> fields_map;
53  {
54  int field = 0;
55  for (auto fit = fields_ptr->begin(); fit != fields_ptr->end(); fit++) {
56  if ((fit->get()->getId() & fields_ids).any()) {
57  fields_map[fit->get()->getName()].first = field++;
58  fields_map[fit->get()->getName()].second = fit->get()->getNbOfCoeffs();
59  }
60  }
61  }
62  const int proc = m_field.get_comm_rank();
63  CHKERR PetscSectionCreate(PETSC_COMM_WORLD, s);
64  CHKERR PetscSectionSetNumFields(*s, fields_map.size());
65  for (auto mit = fields_map.begin(); mit != fields_map.end(); mit++) {
66  CHKERR PetscSectionSetFieldName(*s, mit->second.first, mit->first.c_str());
67  CHKERR PetscSectionSetFieldComponents(*s, mit->second.first,
68  mit->second.second);
69  }
70  // determine number of points
71  int nb_charts = 0;
72  {
73  auto dit = dofs->begin();
74  auto hi_dit = dofs->end();
75  for (; dit != hi_dit;) {
76  if (static_cast<int>(dit->get()->getPart()) == proc) {
77  const auto &ent_uid = dit->get()->getEntLocalUniqueId();
78  while (dit != hi_dit && dit->get()->getEntLocalUniqueId() == ent_uid) {
79  ++dit;
80  }
81  ++nb_charts;
82  } else {
83  ++dit;
84  }
85  }
86  }
87  // get layout, i.e. chart
88  PetscLayout layout;
89  CHKERR PetscLayoutCreate(PETSC_COMM_WORLD, &layout);
90  CHKERR PetscLayoutSetBlockSize(layout, 1);
91  CHKERR PetscLayoutSetLocalSize(layout, nb_charts);
92  CHKERR PetscLayoutSetUp(layout);
93  int rstart, rend;
94  CHKERR PetscLayoutGetRange(layout, &rstart, &rend);
95  CHKERR PetscLayoutDestroy(&layout);
96  CHKERR PetscSectionSetChart(*s, rstart, rend);
97 
98  // loop of all dofs
99  {
100  auto dit = dofs->begin();
101  auto hi_dit = dofs->end();
102  int point = rstart;
103  for (; dit != hi_dit;) {
104  if (static_cast<int>(dit->get()->getPart()) == proc) {
105 
106  const auto &field_name = dit->get()->getName();
107 
108  int dd = 0;
109  const auto &ent_uid = dit->get()->getEntLocalUniqueId();
110  while (dit != hi_dit && dit->get()->getEntLocalUniqueId() == ent_uid) {
111  const DofIdx loc_idx = dit->get()->getPetscLocalDofIdx();
112  if (loc_idx >= 0)
113  ++dd;
114  ++dit;
115  }
116 
117  if (fields_map.find(field_name) == fields_map.end()) {
118  MOFEM_LOG_C("SELF", Sev::warning, "Warning: Field %s not found",
119  dit->get()->getName().c_str());
120  } else {
121  CHKERR PetscSectionAddDof(*s, point, dd);
122  int field = fields_map.at(field_name).first;
123  CHKERR PetscSectionSetFieldDof(*s, point, field, dd);
124  }
125 
126  ++point;
127 
128  } else {
129  ++dit;
130  }
131  }
132  }
133  // cerr << "done " << proc << endl;
134  CHKERR PetscSectionSetUp(*s);
135  // cerr << "end " << proc << endl;
137 }
138 
140 ISManager::sectionCreate(const std::string problem_name,
141  const RowColData row_col) const {
142 
143  PetscSection s;
144  CHK_THROW_MESSAGE(sectionCreate(problem_name, &s, row_col),
145  "Section not created");
146  return SmartPetscObj<PetscSection>(s, false);
147 }
148 
149 MoFEMErrorCode ISManager::isCreateProblem(const std::string problem_name,
150  RowColData rc, IS *is) const {
151  const MoFEM::Interface &m_field = cOre;
152  const Problem *problem_ptr;
154  CHKERR m_field.get_problem(problem_name, &problem_ptr);
155 
156  const int rank = m_field.get_comm_rank();
157 
158  decltype(problem_ptr->numeredRowDofsPtr) dofs_ptr;
159 
160  switch (rc) {
161  case ROW:
162  dofs_ptr = problem_ptr->numeredRowDofsPtr;
163  break;
164  case COL:
165  dofs_ptr = problem_ptr->numeredColDofsPtr;
166  break;
167  default:
168  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "not implemented");
169  }
170 
171  auto lo = dofs_ptr->get<Part_mi_tag>().lower_bound(rank);
172  auto hi = dofs_ptr->get<Part_mi_tag>().upper_bound(rank);
173  const int size = std::distance(lo, hi);
174 
175  int *id;
176  CHKERR PetscMalloc(size * sizeof(int), &id);
177  int *id_it = id;
178  for (; lo != hi; ++lo, ++id_it)
179  *id_it = (*lo)->getPetscGlobalDofIdx();
180  sort(id, &id[size]);
181 
182  CHKERR ISCreateGeneral(PETSC_COMM_WORLD, size, id, PETSC_OWN_POINTER, is);
183 
185 }
186 
187 MoFEMErrorCode ISManager::isCreateProblem(const std::string problem_name,
188  RowColData rc,
189  SmartPetscObj<IS> &is) const {
191  IS raw_is;
192  CHKERR isCreateProblem(problem_name, rc, &raw_is);
193  is = SmartPetscObj<IS>(raw_is);
195 }
196 
197 SmartPetscObj<IS> ISManager::isCreateProblem(const std::string problem_name,
198  RowColData rc) const {
200  CHK_THROW_MESSAGE(isCreateProblem(problem_name, rc, is), "IS not created");
201  return is;
202 }
203 
204 MoFEMErrorCode ISManager::isCreateProblemOrder(const std::string problem_name,
205  RowColData rc, int min_order,
206  int max_order, IS *is) const {
207  const MoFEM::Interface &m_field = cOre;
208  const Problem *problem_ptr;
210  CHKERR m_field.get_problem(problem_name, &problem_ptr);
211 
212  typedef multi_index_container<
213  boost::shared_ptr<NumeredDofEntity>,
214 
215  indexed_by<
216 
217  sequenced<>,
218 
219  ordered_non_unique<
220  tag<Order_mi_tag>,
223 
224  >>
225  NumeredDofEntity_order_view_multiIndex;
226 
227  const int rank = m_field.get_comm_rank();
228 
229  NumeredDofEntity_order_view_multiIndex dofs_by_order;
230  auto insert_part_range = [&dofs_by_order, rank](auto &dofs) {
231  dofs_by_order.insert(dofs_by_order.end(), dofs.lower_bound(rank),
232  dofs.upper_bound(rank));
233  };
234 
235  switch (rc) {
236  case ROW:
237  insert_part_range(problem_ptr->numeredRowDofsPtr->get<Part_mi_tag>());
238  break;
239  case COL:
240  insert_part_range(problem_ptr->numeredColDofsPtr->get<Part_mi_tag>());
241  break;
242  default:
243  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "not implemented");
244  }
245 
246  auto lo = dofs_by_order.get<Order_mi_tag>().lower_bound(min_order);
247  auto hi = dofs_by_order.get<Order_mi_tag>().upper_bound(max_order);
248  const int size = std::distance(lo, hi);
249  int *id;
250  CHKERR PetscMalloc(size * sizeof(int), &id);
251  int *id_it = id;
252  for (; lo != hi; ++lo, ++id_it)
253  *id_it = (*lo)->getPetscGlobalDofIdx();
254  sort(id, &id[size]);
255 
256  CHKERR ISCreateGeneral(PETSC_COMM_WORLD, size, id, PETSC_OWN_POINTER, is);
257 
259 }
260 
261 MoFEMErrorCode ISManager::isCreateProblemOrder(const std::string problem_name,
262  RowColData rc, int min_order,
263  int max_order,
264  SmartPetscObj<IS> &is) const {
266  IS raw_is;
267  CHKERR isCreateProblemOrder(problem_name, rc, min_order, max_order, &raw_is);
268  is = SmartPetscObj<IS>(raw_is);
270 }
271 
273  const std::string problem_name, RowColData rc, const std::string field,
274  int min_coeff_idx, int max_coeff_idx, IS *is, Range *ents_ptr) const {
275  const MoFEM::Interface &m_field = cOre;
276  const Problem *problem_ptr;
278  CHKERR m_field.get_problem(problem_name, &problem_ptr);
279  const auto bit_number = m_field.get_field_bit_number(field);
280 
282  DofsByUId::iterator it, hi_it;
283  int nb_loc_dofs;
284  switch (rc) {
285  case ROW:
286  nb_loc_dofs = problem_ptr->getNbLocalDofsRow();
287  it = problem_ptr->numeredRowDofsPtr->get<Unique_mi_tag>().lower_bound(
288  FieldEntity::getLoBitNumberUId(bit_number));
289  hi_it = problem_ptr->numeredRowDofsPtr->get<Unique_mi_tag>().upper_bound(
290  FieldEntity::getHiBitNumberUId(bit_number));
291  break;
292  case COL:
293  nb_loc_dofs = problem_ptr->getNbLocalDofsCol();
294  it = problem_ptr->numeredColDofsPtr->get<Unique_mi_tag>().lower_bound(
295  FieldEntity::getLoBitNumberUId(bit_number));
296  hi_it = problem_ptr->numeredColDofsPtr->get<Unique_mi_tag>().upper_bound(
297  FieldEntity::getHiBitNumberUId(bit_number));
298  break;
299  default:
300  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "not implemented");
301  }
302 
303  std::vector<int> idx_vec;
304  idx_vec.reserve(std::distance(it, hi_it));
305  for (; it != hi_it; ++it) {
306 
307  auto true_if_dof_on_entity = [&]() {
308  if (ents_ptr) {
309  return ents_ptr->find((*it)->getEnt()) != ents_ptr->end();
310  } else {
311  return true;
312  }
313  };
314 
315  auto check = [&]() {
316  const auto coeff_idx = (*it)->getDofCoeffIdx();
317  if (
318 
319  (*it)->getPetscLocalDofIdx() >= nb_loc_dofs ||
320 
321  coeff_idx < min_coeff_idx || coeff_idx > max_coeff_idx
322 
323  )
324  return false;
325  else
326  return true;
327  };
328 
329  if (check()) {
330  if (true_if_dof_on_entity()) {
331  idx_vec.emplace_back((*it)->getPetscGlobalDofIdx());
332  }
333  }
334  }
335 
336  int *id;
337  CHKERR PetscMalloc(idx_vec.size() * sizeof(int), &id);
338  std::copy(idx_vec.begin(), idx_vec.end(), id);
339  CHKERR ISCreateGeneral(m_field.get_comm(), idx_vec.size(), id,
340  PETSC_OWN_POINTER, is);
341 
343 }
344 
346  const std::string problem_name, RowColData rc, const std::string field,
347  int min_coeff_idx, int max_coeff_idx, SmartPetscObj<IS> &smart_is,
348  Range *ents_ptr) const {
350  IS is;
351  CHKERR isCreateProblemFieldAndRank(problem_name, rc, field, min_coeff_idx,
352  max_coeff_idx, &is, ents_ptr);
353  smart_is = SmartPetscObj<IS>(is);
355 }
356 
358  const std::string problem_name, RowColData rc, const std::string field,
359  int min_coeff_idx, int max_coeff_idx, IS *is, Range *ents_ptr) const {
360  const MoFEM::Interface &m_field = cOre;
361  const Problem *problem_ptr;
363  CHKERR m_field.get_problem(problem_name, &problem_ptr);
364  const auto bit_number = m_field.get_field_bit_number(field);
365 
366  auto get_low_hi_uid = [&]() {
367  return std::make_pair(FieldEntity::getLoBitNumberUId(bit_number),
368  FieldEntity::getHiBitNumberUId(bit_number));
369  };
370 
371  auto get_low_hi_uid_by_entities = [&](auto f, auto s) {
372  return std::make_pair(DofEntity::getLoFieldEntityUId(bit_number, f),
373  DofEntity::getHiFieldEntityUId(bit_number, s));
374  };
375 
376  auto get_low_hi = [&](auto lo_uid, auto hi_uid) {
378  DofsByUId::iterator it, hi_it;
379  switch (rc) {
380  case ROW:
381  it = problem_ptr->numeredRowDofsPtr->get<Unique_mi_tag>().lower_bound(
382  lo_uid);
383  hi_it = problem_ptr->numeredRowDofsPtr->get<Unique_mi_tag>().upper_bound(
384  hi_uid);
385  break;
386  case COL:
387  it = problem_ptr->numeredColDofsPtr->get<Unique_mi_tag>().lower_bound(
388  lo_uid);
389  hi_it = problem_ptr->numeredColDofsPtr->get<Unique_mi_tag>().upper_bound(
390  hi_uid);
391  break;
392  default:
393  THROW_MESSAGE("not implemented");
394  }
395  return std::make_pair(it, hi_it);
396  };
397 
398  auto check = [&](auto it) {
399  const auto coeff_idx = (*it)->getDofCoeffIdx();
400  if (
401 
402  coeff_idx < min_coeff_idx || coeff_idx > max_coeff_idx
403 
404  )
405  return false;
406  else
407  return true;
408  };
409 
410  auto emplace_indices = [&](auto it, auto hi_it, auto &idx_vec) {
411  for (; it != hi_it; ++it) {
412  if (check(it))
413  idx_vec.emplace_back((*it)->getPetscLocalDofIdx());
414  }
415  };
416 
417  auto [lo_uid, hi_uid] = get_low_hi_uid();
418  auto [lo, hi] = get_low_hi(lo_uid, hi_uid);
419  std::vector<int> idx_vec;
420  idx_vec.reserve(std::distance(lo, hi));
421 
422  if (ents_ptr) {
423  for (auto pit = ents_ptr->const_pair_begin();
424  pit != ents_ptr->const_pair_end(); ++pit) {
425  auto [lo_uid, hi_uid] =
426  get_low_hi_uid_by_entities(pit->first, pit->second);
427  auto [lo, hi] = get_low_hi(lo_uid, hi_uid);
428  emplace_indices(lo, hi, idx_vec);
429  }
430  } else {
431  emplace_indices(lo, hi, idx_vec);
432  }
433 
434  int *id;
435  CHKERR PetscMalloc(idx_vec.size() * sizeof(int), &id);
436  std::copy(idx_vec.begin(), idx_vec.end(), id);
437  CHKERR ISCreateGeneral(PETSC_COMM_SELF, idx_vec.size(), id, PETSC_OWN_POINTER,
438  is);
439 
441 }
442 
444  const std::string problem_name, RowColData rc, const std::string field,
445  int min_coeff_idx, int max_coeff_idx, SmartPetscObj<IS> &smart_is,
446  Range *ents_ptr) const {
448  IS is;
449  CHKERR isCreateProblemFieldAndRankLocal(problem_name, rc, field,
450  min_coeff_idx, max_coeff_idx, &is,
451  ents_ptr);
452  smart_is = SmartPetscObj<IS>(is);
454 }
455 
457  const std::string problem_name, RowColData rc, const std::string field,
458  EntityType low_type, EntityType hi_type, int min_coeff_idx,
459  int max_coeff_idx, IS *is, Range *ents_ptr) const {
460  const MoFEM::Interface &m_field = cOre;
462  EntityHandle field_meshset = m_field.get_field_meshset(field);
463  Range ents;
464  for (; low_type <= hi_type; ++low_type)
465  CHKERR m_field.get_moab().get_entities_by_type(field_meshset, low_type,
466  ents, true);
467  if (ents_ptr)
468  ents = intersect(ents, *ents_ptr);
469  CHKERR isCreateProblemFieldAndRank(problem_name, rc, field, min_coeff_idx,
470  max_coeff_idx, is, &ents);
472 }
473 
475  const std::string x_problem, const std::string x_field_name,
476  RowColData x_rc, const std::string y_problem,
477  const std::string y_field_name, RowColData y_rc, std::vector<int> &idx,
478  std::vector<int> &idy) const {
479  const MoFEM::Interface &m_field = cOre;
480  const Problem *px_ptr;
481  const Problem *py_ptr;
483 
484  CHKERR m_field.get_problem(x_problem, &px_ptr);
485  CHKERR m_field.get_problem(y_problem, &py_ptr);
486 
487  typedef multi_index_container<
488  boost::shared_ptr<NumeredDofEntity>,
489 
490  indexed_by<
491 
492  sequenced<>,
493 
494  ordered_non_unique<
495  tag<Composite_Ent_And_EntDofIdx_mi_tag>,
496  composite_key<
502 
503  >>
504  NumeredDofEntity_view_multiIndex;
505 
506  NumeredDofEntity_view_multiIndex dofs_view;
507 
508  auto x_bit_number = m_field.get_field_bit_number(x_field_name);
509 
510  switch (x_rc) {
511  case ROW:
512  dofs_view.insert(
513  dofs_view.end(),
514  px_ptr->numeredRowDofsPtr->get<Unique_mi_tag>().lower_bound(
515  FieldEntity::getLoBitNumberUId(x_bit_number)),
516  px_ptr->numeredRowDofsPtr->get<Unique_mi_tag>().upper_bound(
517  FieldEntity::getHiBitNumberUId(x_bit_number)));
518  break;
519  case COL:
520  dofs_view.insert(
521  dofs_view.end(),
522  px_ptr->numeredColDofsPtr->get<Unique_mi_tag>().lower_bound(
523  FieldEntity::getLoBitNumberUId(x_bit_number)),
524  px_ptr->numeredColDofsPtr->get<Unique_mi_tag>().upper_bound(
525  FieldEntity::getHiBitNumberUId(x_bit_number)));
526  break;
527  default:
528  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
529  "only makes sense for ROWS and COLS");
530  }
531 
532  decltype(py_ptr->numeredRowDofsPtr) dofs_ptr;
533  switch (y_rc) {
534  case ROW:
535  dofs_ptr = py_ptr->numeredRowDofsPtr;
536  break;
537  case COL:
538  dofs_ptr = py_ptr->numeredColDofsPtr;
539  break;
540  default:
541  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
542  "only makes sense for ROWS and COLS");
543  }
544 
545  std::map<int, int> global_dofs_map;
546  const auto y_bit_number = m_field.get_field_bit_number(y_field_name);
547  auto dit = dofs_ptr->get<Unique_mi_tag>().lower_bound(
548  FieldEntity::getLoBitNumberUId(y_bit_number));
549  auto hi_dit = dofs_ptr->get<Unique_mi_tag>().upper_bound(
550  FieldEntity::getHiBitNumberUId(y_bit_number));
551  const auto rank = m_field.get_comm_rank();
552  for (; dit != hi_dit; ++dit) {
553  if ((*dit)->getPart() == rank) {
554  auto x_dit = dofs_view.get<Composite_Ent_And_EntDofIdx_mi_tag>().find(
555  boost::make_tuple((*dit)->getEnt(), (*dit)->getEntDofIdx()));
556  if (x_dit != dofs_view.get<Composite_Ent_And_EntDofIdx_mi_tag>().end()) {
557  global_dofs_map[(*x_dit)->getPetscGlobalDofIdx()] =
558  (*dit)->getPetscGlobalDofIdx();
559  }
560  }
561  }
562 
563  idx.resize(global_dofs_map.size());
564  idy.resize(global_dofs_map.size());
565  {
566  auto ix = idx.begin();
567  auto iy = idy.begin();
568  for (auto mit = global_dofs_map.begin(); mit != global_dofs_map.end();
569  mit++, ix++, iy++) {
570  *ix = mit->first;
571  *iy = mit->second;
572  }
573  }
575 }
576 
578  const std::string x_problem, const std::string x_field_name,
579  RowColData x_rc, const std::string y_problem,
580  const std::string y_field_name, RowColData y_rc, IS *ix, IS *iy) const {
582  const MoFEM::Interface &m_field = cOre;
583  std::vector<int> idx(0), idy(0);
585  x_problem, x_field_name, x_rc, y_problem, y_field_name, y_rc, idx, idy);
586  if (ix != PETSC_NULL) {
587  CHKERR ISCreateGeneral(m_field.get_comm(), idx.size(), &idx[0],
588  PETSC_COPY_VALUES, ix);
589  }
590  CHKERR ISCreateGeneral(m_field.get_comm(), idy.size(), &idy[0],
591  PETSC_COPY_VALUES, iy);
592  if (dEbug) {
593  ISView(*ix, PETSC_VIEWER_STDOUT_WORLD);
594  ISView(*iy, PETSC_VIEWER_STDOUT_WORLD);
595  }
597 }
598 
600  const std::string x_problem, RowColData x_rc, const std::string y_problem,
601  RowColData y_rc, std::vector<int> &idx, std::vector<int> &idy) const {
602  const MoFEM::Interface &m_field = cOre;
603  const Problem *px_ptr;
604  const Problem *py_ptr;
606  CHKERR m_field.get_problem(x_problem, &px_ptr);
607  CHKERR m_field.get_problem(y_problem, &py_ptr);
608  NumeredDofEntityByLocalIdx::iterator y_dit, hi_y_dit;
609  switch (y_rc) {
610  case ROW:
611  y_dit =
612  py_ptr->numeredRowDofsPtr->get<PetscLocalIdx_mi_tag>().lower_bound(0);
613  hi_y_dit =
614  py_ptr->numeredRowDofsPtr->get<PetscLocalIdx_mi_tag>().lower_bound(
615  py_ptr->getNbLocalDofsRow()); // should be lower
616  break;
617  case COL:
618  y_dit =
619  py_ptr->numeredColDofsPtr->get<PetscLocalIdx_mi_tag>().lower_bound(0);
620  hi_y_dit =
621  py_ptr->numeredColDofsPtr->get<PetscLocalIdx_mi_tag>().lower_bound(
622  py_ptr->getNbLocalDofsCol()); // should be lower
623  break;
624  default:
625  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "not implemented");
626  }
627  const NumeredDofEntityByUId *x_numered_dofs_by_uid;
628  switch (x_rc) {
629  case ROW:
630  x_numered_dofs_by_uid = &(px_ptr->numeredRowDofsPtr->get<Unique_mi_tag>());
631  break;
632  case COL:
633  x_numered_dofs_by_uid = &(px_ptr->numeredColDofsPtr->get<Unique_mi_tag>());
634  break;
635  default:
636  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "not implemented");
637  }
638  for (; y_dit != hi_y_dit; y_dit++) {
639  if ((*y_dit)->getPart() != (unsigned int)m_field.get_comm_rank()) {
640  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "data inconsistency");
641  }
642  NumeredDofEntityByUId::iterator x_dit;
643  x_dit = x_numered_dofs_by_uid->find((*y_dit)->getLocalUniqueId());
644  if (x_dit == x_numered_dofs_by_uid->end())
645  continue;
646  idx.push_back((*x_dit)->getPetscGlobalDofIdx());
647  idy.push_back((*y_dit)->getPetscGlobalDofIdx());
648  }
650 }
651 
653  const std::string x_problem, RowColData x_rc, const std::string y_problem,
654  RowColData y_rc, IS *ix, IS *iy) const {
655  const MoFEM::Interface &m_field = cOre;
657  std::vector<int> idx(0), idy(0);
658  CHKERR isCreateFromProblemToOtherProblem(x_problem, x_rc, y_problem, y_rc,
659  idx, idy);
660  CHKERR ISCreateGeneral(m_field.get_comm(), idx.size(), &idx[0],
661  PETSC_COPY_VALUES, ix);
662  CHKERR ISCreateGeneral(m_field.get_comm(), idy.size(), &idy[0],
663  PETSC_COPY_VALUES, iy);
664  if (dEbug) {
665  ISView(*ix, PETSC_VIEWER_STDOUT_WORLD);
666  ISView(*iy, PETSC_VIEWER_STDOUT_WORLD);
667  }
669 }
670 } // namespace MoFEM
MoFEMFunctionReturnHot
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:460
MoFEM::ISManager::isCreateProblemFieldAndRank
MoFEMErrorCode isCreateProblemFieldAndRank(const std::string problem_name, RowColData rc, const std::string field, int min_coeff_idx, int max_coeff_idx, IS *is, Range *ents=nullptr) const
create IS for given problem, field and rank range (collective)
Definition: ISManager.cpp:272
MoFEM::CoreTmp< 0 >
Core (interface) class.
Definition: Core.hpp:82
MoFEM::ISManager::query_interface
MoFEMErrorCode query_interface(boost::typeindex::type_index type_index, UnknownInterface **iface) const
Definition: ISManager.cpp:10
EntityHandle
MoFEM::CoreInterface::get_comm
virtual MPI_Comm & get_comm() const =0
CHK_THROW_MESSAGE
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
Definition: definitions.h:609
MoFEM::ISManager::isCreateFromProblemFieldToOtherProblemField
MoFEMErrorCode isCreateFromProblemFieldToOtherProblemField(const std::string x_problem, const std::string x_field_name, RowColData x_rc, const std::string y_problem, const std::string y_field_name, RowColData y_rc, std::vector< int > &idx, std::vector< int > &idy) const
create IS for give two problems and field
Definition: ISManager.cpp:474
MoFEM::Exceptions::MoFEMErrorCode
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
MoFEM::CoreInterface::get_field_bit_number
virtual FieldBitNumber get_field_bit_number(const std::string name) const =0
get field bit number
MoFEM::PetscLocalIdx_mi_tag
Definition: TagMultiIndices.hpp:45
MoFEM::NumeredDofEntity::interface_type_DofEntity
interface_DofEntity< DofEntity > interface_type_DofEntity
Definition: DofsMultiIndices.hpp:232
MoFEM::CoreInterface::get_comm_rank
virtual int get_comm_rank() const =0
MoFEM::Types::BitFieldId
std::bitset< BITFIELDID_SIZE > BitFieldId
Field Id.
Definition: Types.hpp:42
MoFEM::CoreInterface::get_problem
virtual const Problem * get_problem(const std::string problem_name) const =0
Get the problem object.
MoFEM::Problem::getBitFEId
BitFEId getBitFEId() const
Get the BitFEIDs in problem
Definition: ProblemsMultiIndices.cpp:45
MoFEM::CoreInterface::get_finite_elements
virtual const FiniteElement_multiIndex * get_finite_elements() const =0
Get the finite elements object.
MoFEM::CoreInterface::get_field_meshset
virtual EntityHandle get_field_meshset(const std::string name) const =0
get field meshset
MoFEM::Order_mi_tag
MultiIndex Tag for field order.
Definition: TagMultiIndices.hpp:64
THROW_MESSAGE
#define THROW_MESSAGE(msg)
Throw MoFEM exception.
Definition: definitions.h:574
MoFEM::DeprecatedCoreInterface
Deprecated interface functions.
Definition: DeprecatedCoreInterface.hpp:16
MoFEM::ISManager::isCreateProblem
MoFEMErrorCode isCreateProblem(const std::string problem_name, RowColData rc, IS *is) const
Create IS for problem.
Definition: ISManager.cpp:149
ROW
@ ROW
Definition: definitions.h:136
MoFEM::NumeredDofEntityByUId
NumeredDofEntity_multiIndex::index< Unique_mi_tag >::type NumeredDofEntityByUId
Numbered DoF multi-index by UId.
Definition: DofsMultiIndices.hpp:476
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:548
MoFEM::CoreInterface::get_moab
virtual moab::Interface & get_moab()=0
MoFEM::NumeredDofEntity
keeps information about indexed dofs for the problem
Definition: DofsMultiIndices.hpp:226
MoFEM
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
MoFEM::Part_mi_tag
Definition: TagMultiIndices.hpp:53
MoFEM::ISManager
Section manager is used to create indexes and sections.
Definition: ISManager.hpp:23
MoFEM::ISManager::cOre
const MoFEM::Interface & cOre
Definition: ISManager.hpp:28
MoFEM::Problem::numeredColDofsPtr
boost::shared_ptr< NumeredDofEntity_multiIndex > numeredColDofsPtr
store DOFs on columns for this problem
Definition: ProblemsMultiIndices.hpp:75
MOFEM_LOG_C
#define MOFEM_LOG_C(channel, severity, format,...)
Definition: LogManager.hpp:311
RowColData
RowColData
RowColData.
Definition: definitions.h:136
convert.type
type
Definition: convert.py:64
MoFEM::FieldEntity::getLoBitNumberUId
static UId getLoBitNumberUId(const FieldBitNumber bit_number)
Definition: FieldEntsMultiIndices.hpp:222
COL
@ COL
Definition: definitions.h:136
MoFEM::interface_DofEntity< DofEntity >::getEnt
EntityHandle getEnt() const
Definition: DofsMultiIndices.hpp:192
MoFEM::Problem::getNbLocalDofsRow
DofIdx getNbLocalDofsRow() const
Definition: ProblemsMultiIndices.hpp:378
MoFEM::ISManager::dEbug
bool dEbug
Definition: ISManager.hpp:29
MoFEM::ISManager::isCreateProblemFieldAndRankLocal
MoFEMErrorCode isCreateProblemFieldAndRankLocal(const std::string problem_name, RowColData rc, const std::string field, int min_coeff_idx, int max_coeff_idx, IS *is, Range *ents=nullptr) const
create IS for given problem, field and rank range (collective)
Definition: ISManager.cpp:357
MoFEM::DofEntity::getLoFieldEntityUId
static UId getLoFieldEntityUId(const FieldBitNumber bit, const EntityHandle ent)
Definition: DofsMultiIndices.hpp:69
field_name
constexpr auto field_name
Definition: poisson_2d_homogeneous.cpp:13
MoFEM::CoreInterface::get_fields
virtual const Field_multiIndex * get_fields() const =0
Get the fields object.
MoFEM::Problem::numeredRowDofsPtr
boost::shared_ptr< NumeredDofEntity_multiIndex > numeredRowDofsPtr
store DOFs on rows for this problem
Definition: ProblemsMultiIndices.hpp:73
MoFEM::UnknownInterface
base class for all interface classes
Definition: UnknownInterface.hpp:34
MoFEM::ISManager::ISManager
ISManager(const MoFEM::Core &core)
Definition: ISManager.cpp:17
Range
FTensor::dd
const Tensor2_symmetric_Expr< const ddTensor0< T, Dim, i, j >, typename promote< T, double >::V, Dim, i, j > dd(const Tensor0< T * > &a, const Index< i, Dim > index1, const Index< j, Dim > index2, const Tensor1< int, Dim > &d_ijk, const Tensor1< double, Dim > &d_xyz)
Definition: ddTensor0.hpp:33
MoFEM::Types::ApproximationOrder
int ApproximationOrder
Approximation on the entity.
Definition: Types.hpp:26
MoFEM::interface_DofEntity< DofEntity >::getDofOrder
ApproximationOrder getDofOrder() const
Definition: DofsMultiIndices.hpp:195
MoFEM::Composite_Ent_And_EntDofIdx_mi_tag
Definition: TagMultiIndices.hpp:81
MoFEM::DofEntity::getHiFieldEntityUId
static UId getHiFieldEntityUId(const FieldBitNumber bit, const EntityHandle ent)
Definition: DofsMultiIndices.hpp:75
HenckyOps::f
auto f
Definition: HenckyOps.hpp:15
MOFEM_DATA_INCONSISTENCY
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
MoFEM::FieldEntity::getHiBitNumberUId
static UId getHiBitNumberUId(const FieldBitNumber bit_number)
Definition: FieldEntsMultiIndices.hpp:228
MoFEM::Problem::getNbLocalDofsCol
DofIdx getNbLocalDofsCol() const
Definition: ProblemsMultiIndices.hpp:379
MoFEMFunctionBeginHot
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:453
MoFEM::ISManager::isCreateFromProblemToOtherProblem
MoFEMErrorCode isCreateFromProblemToOtherProblem(const std::string x_problem, RowColData x_rc, const std::string y_problem, RowColData y_rc, std::vector< int > &idx, std::vector< int > &idy) const
Create is from one problem to other problem.
Definition: ISManager.cpp:599
MoFEM::Unique_mi_tag
Definition: TagMultiIndices.hpp:18
MoFEM::ISManager::sectionCreate
MoFEMErrorCode sectionCreate(const std::string problem_name, PetscSection *s, const RowColData row_col=COL) const
Create global selection.
Definition: ISManager.cpp:20
MoFEM::ISManager::isCreateProblemFieldAndEntityType
MoFEMErrorCode isCreateProblemFieldAndEntityType(const std::string problem_name, RowColData rc, const std::string field, EntityType low_type, EntityType hi_type, int min_coeff_idx, int max_coeff_idx, IS *is, Range *ents=nullptr) const
create IS for given problem, field and type range (collective)
Definition: ISManager.cpp:456
MoFEM::Problem
keeps basic data about problem
Definition: ProblemsMultiIndices.hpp:54
MoFEM::SmartPetscObj
intrusive_ptr for managing petsc objects
Definition: PetscSmartObj.hpp:82
MoFEM::ISManager::isCreateProblemOrder
MoFEMErrorCode isCreateProblemOrder(const std::string problem_name, RowColData rc, int min_order, int max_order, IS *is) const
create IS for given order range (collective)
Definition: ISManager.cpp:204
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:429
MOFEM_NOT_IMPLEMENTED
@ MOFEM_NOT_IMPLEMENTED
Definition: definitions.h:32
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:359
MoFEM::interface_DofEntity< DofEntity >::getEntDofIdx
DofIdx getEntDofIdx() const
Definition: DofsMultiIndices.hpp:186
MoFEM::Types::DofIdx
int DofIdx
Index of DOF.
Definition: Types.hpp:18