v0.9.0
BitLevelCoupler.cpp
Go to the documentation of this file.
1 /** \file BitLevelCoupler.cpp
2  * \brief BitLevelCoupler interface implementation
3 
4  *
5  * MoFEM is distributed in the hope that it will be useful, but WITHOUT
6  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
7  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
8  * License for more details.
9  *
10  * You should have received a copy of the GNU Lesser General Public
11  * License along with MoFEM. If not, see <http://www.gnu.org/licenses/>
12 */
13 
14 namespace MoFEM {
15 
18  UnknownInterface **iface) const {
20  *iface = NULL;
21  if (uuid == IDD_MOFEMBitLevelCoupler) {
22  *iface = const_cast<BitLevelCoupler *>(this);
24  }
25  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "unknown interface");
27 }
28 
30  int verb) {
32  Interface &m_field = cOre;
33  treePtr.reset(new AdaptiveKDTree(&m_field.get_moab()));
34  Range tets;
35  ierr = m_field.getInterface<BitRefManager>()->getEntitiesByTypeAndRefLevel(
36  parent_level, BitRefLevel().set(), MBTET, tets);
37  CHKERRG(ierr);
38  rval = treePtr->build_tree(tets);
40  if (verb > 2) {
41  rval = treePtr->print();
43  }
45 }
46 
48  int verb) {
50  treePtr->reset_tree();
51  treePtr.reset();
53 }
54 
56  EntityHandle &parent, bool tet_only,
57  const double iter_tol,
58  const double inside_tol, int verb) {
60  Interface &m_field = cOre;
61  EntityHandle leaf_out;
62  rval = treePtr->point_search(coords, leaf_out, iter_tol, inside_tol);
64  bool is_in;
65  Range tets;
66  ierr = m_field.get_moab().get_entities_by_type(leaf_out, MBTET, tets);
67  CHKERRG(ierr);
68  Range::iterator tit = tets.begin();
69  for (; tit != tets.end(); tit++) {
70  ierr = getLocCoordsOnTet(*tit, coords, verb);
71  CHKERRG(ierr);
72  is_in = true;
73  for (int nn = 0; nn < 4; nn++) {
74  if (N[nn] < -inside_tol || N[nn] > 1 + inside_tol) {
75  is_in = false;
76  break;
77  }
78  if (!is_in)
79  break;
80  }
81  parent = 0;
82  if (is_in) {
83  if (!tet_only) {
84  // vertices
85  if (fabs(N[0] - 1) < inside_tol && fabs(N[1]) < inside_tol &&
86  fabs(N[2]) < inside_tol && fabs(N[3]) < inside_tol) {
87  if (verb > 1)
88  std::cout << "node 0 found " << std::endl;
89  rval = m_field.get_moab().side_element(*tit, 0, 0, parent);
92  }
93  if (fabs(N[0]) < inside_tol && fabs(N[1] - 1) < inside_tol &&
94  fabs(N[2]) < inside_tol && fabs(N[3]) < inside_tol) {
95  if (verb > 1)
96  std::cout << "node 1 found " << std::endl;
97  rval = m_field.get_moab().side_element(*tit, 0, 1, parent);
100  }
101  if (fabs(N[0]) < inside_tol && fabs(N[1]) < inside_tol &&
102  fabs(N[2] - 2) < inside_tol && fabs(N[3]) < inside_tol) {
103  if (verb > 1)
104  std::cout << "node 2 found " << std::endl;
105  rval = m_field.get_moab().side_element(*tit, 0, 2, parent);
108  }
109  if (fabs(N[0]) < inside_tol && fabs(N[1]) < inside_tol &&
110  fabs(N[2]) < inside_tol && fabs(N[3] - 1) < inside_tol) {
111  if (verb > 1)
112  std::cout << "node 3 found " << std::endl;
113  rval = m_field.get_moab().side_element(*tit, 0, 3, parent);
116  }
117  // edges
118  if (fabs(N[0]) > inside_tol && fabs(N[1]) > inside_tol &&
119  fabs(N[2]) < inside_tol && fabs(N[3]) < inside_tol) {
120  if (verb > 1)
121  std::cout << "edge 0 found " << std::endl;
122  rval = m_field.get_moab().side_element(*tit, 1, 0, parent);
125  }
126  if (fabs(N[0]) < inside_tol && fabs(N[1]) > inside_tol &&
127  fabs(N[2]) > inside_tol && fabs(N[3]) < inside_tol) {
128  if (verb > 1)
129  std::cout << "edge 1 found " << std::endl;
130  rval = m_field.get_moab().side_element(*tit, 1, 1, parent);
133  }
134  if (fabs(N[0]) > inside_tol && fabs(N[1]) < inside_tol &&
135  fabs(N[2]) > inside_tol && fabs(N[3]) < inside_tol) {
136  if (verb > 1)
137  std::cout << "edge 2 found " << std::endl;
138  rval = m_field.get_moab().side_element(*tit, 1, 2, parent);
141  }
142  if (fabs(N[0]) > inside_tol && fabs(N[1]) < inside_tol &&
143  fabs(N[2]) < inside_tol && fabs(N[3]) > inside_tol) {
144  if (verb > 1)
145  std::cout << "edge 3 found " << std::endl;
146  rval = m_field.get_moab().side_element(*tit, 1, 3, parent);
149  }
150  if (fabs(N[0]) < inside_tol && fabs(N[1]) > inside_tol &&
151  fabs(N[2]) < inside_tol && fabs(N[3]) > inside_tol) {
152  if (verb > 1)
153  std::cout << "edge 4 found " << std::endl;
154  rval = m_field.get_moab().side_element(*tit, 1, 4, parent);
157  }
158  if (fabs(N[0]) < inside_tol && fabs(N[1]) < inside_tol &&
159  fabs(N[2]) > inside_tol && fabs(N[3]) > inside_tol) {
160  if (verb > 1)
161  std::cout << "edge 5 found " << std::endl;
162  rval = m_field.get_moab().side_element(*tit, 1, 5, parent);
165  }
166  // faces
167  if (fabs(N[0]) > inside_tol && fabs(N[1]) > inside_tol &&
168  fabs(N[2]) < inside_tol && fabs(N[3]) > inside_tol) {
169  if (verb > 1)
170  std::cout << "face 0 found " << std::endl;
171  rval = m_field.get_moab().side_element(*tit, 2, 0, parent);
174  }
175  if (fabs(N[0]) < inside_tol && fabs(N[1]) > inside_tol &&
176  fabs(N[2]) > inside_tol && fabs(N[3]) > inside_tol) {
177  if (verb > 1)
178  std::cout << "face 1 found " << std::endl;
179  rval = m_field.get_moab().side_element(*tit, 2, 1, parent);
182  }
183  if (fabs(N[0]) > inside_tol && fabs(N[1]) < inside_tol &&
184  fabs(N[2]) > inside_tol && fabs(N[3]) > inside_tol) {
185  if (verb > 1)
186  std::cout << "face 2 found " << std::endl;
187  rval = m_field.get_moab().side_element(*tit, 2, 2, parent);
190  }
191  if (fabs(N[0]) > inside_tol && fabs(N[1]) > inside_tol &&
192  fabs(N[2]) > inside_tol && fabs(N[3]) < inside_tol) {
193  if (verb > 1)
194  std::cout << "face 3 found " << std::endl;
195  rval = m_field.get_moab().side_element(*tit, 2, 2, parent);
198  }
199  // set parent
200  if (parent != 0) {
201  break;
202  }
203  }
204  if (verb > 1)
205  std::cout << "tet found " << std::endl;
206  parent = *tit;
207  break;
208  }
209  }
211 }
212 
214  const BitRefLevel &parent_level, Range &children, bool vertex_elements,
215  const double iter_tol, const double inside_tol, bool throw_error,
216  int verb) {
218  Interface &m_field = cOre;
219  // build Tree
220  bool init_tree = false;
221 
222  // find parents of all nodes, if node has no parent then tetrahedral
223  // containing that node is searched node on tetrahedra my by part of face or
224  // edge on that tetrahedral, this need to be verified
225  const RefEntity_multiIndex *refined_ptr;
226  ierr = m_field.get_ref_ents(&refined_ptr);
227  CHKERRG(ierr);
228  RefEntity_multiIndex::index<EntType_mi_tag>::type::iterator it, hi_it;
229  it = refined_ptr->get<EntType_mi_tag>().lower_bound(MBVERTEX);
230  hi_it = refined_ptr->get<EntType_mi_tag>().upper_bound(MBVERTEX);
231 
232  for (; it != hi_it; it++) {
233 
234  // entity on parent level, can be parent to yourself
235  if (((*it)->getBitRefLevel() & parent_level).any())
236  continue;
237 
238  if (verb > 1) {
239  std::cout << *it << " " << (*it)->getBitRefLevel() << std::endl;
240  }
241 
242  // that vertex is on parent bit level, no need to process
243  // check if vertex has a parent and parent is on parent bit level
244  EntityHandle parent_ent;
245  parent_ent = (*it)->getParentEnt();
246  const RefEntity ref_parent_ent(m_field.get_basic_entity_data_ptr(),
247  parent_ent);
248  if ((ref_parent_ent.getBitRefLevel() & parent_level).any()) {
249  continue;
250  }
251 
252  // check if vertex is on child entities set
253  EntityHandle node = (*it)->getRefEnt();
254  if (children.find(node) == children.end()) {
255  continue;
256  }
257 
258  // build a boundary volume Tree
259  // if(!treePtr) {
260  ierr = buildTree(parent_level, verb);
261  CHKERRG(ierr);
262  init_tree = true;
263  //}
264 
265  double coords[3];
266  rval = m_field.get_moab().get_coords(&node, 1, coords);
268  EntityHandle parent = 0;
269  ierr = getParent(coords, parent, false, iter_tol, inside_tol, verb);
270  CHKERRG(ierr);
271  ierr = chanegParent(refined_ptr->project<0>(it), parent);
272  CHKERRG(ierr);
273  if (throw_error && parent == 0) {
274  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
275  "tets or any other entity for node not found");
276  }
277  }
278 
279  if (init_tree) {
280  treePtr->reset_tree();
281  }
283 }
284 
286  const BitRefLevel &parent_level, Range &children, bool elements, int verb) {
288 
289  if (verb > 2)
290  std::cout << children << std::endl;
291 
292  Interface &m_field = cOre;
293 
294  // access to ref dofs multi-index
295  const RefEntity_multiIndex *refined_ptr;
296  ierr = m_field.get_ref_ents(&refined_ptr);
297  CHKERRG(ierr);
298 
299  std::vector<EntityHandle> conn_parents;
300 
301  Range::iterator eit, hi_eit;
302  eit = children.begin();
303  hi_eit = children.end();
304  for (; eit != hi_eit; eit++) {
305 
306  // check entity type
307  EntityType type;
308  type = m_field.get_moab().type_from_handle(*eit);
309  switch (type) {
310  case MBEDGE:
311  case MBTRI:
312  case MBTET:
313  break;
314  default:
315  continue;
316  }
317 
318  // get ref entity iterator
319  RefEntity_multiIndex::index<Ent_mi_tag>::type::iterator it;
320  it = refined_ptr->get<Ent_mi_tag>().find(*eit);
321  // that entity is on parent bit level, no need to process
322  if (((*it)->getBitRefLevel() & parent_level).any()) {
323  continue;
324  }
325 
326  if (verb > 1) {
327  std::cout << "before: " << **it << std::endl;
328  }
329 
330  // check if entity has a parent and parent is on parent bit level
331  EntityHandle parent_ent;
332  parent_ent = (*it)->getParentEnt();
333  const RefEntity ref_parent_ent(m_field.get_basic_entity_data_ptr(),
334  parent_ent);
335  if ((ref_parent_ent.getBitRefLevel() & parent_level).any()) {
336  if (!vErify)
337  continue;
338  }
339 
340  // connectivity
341  int max_dim = m_field.get_moab().dimension_from_handle(*eit);
342  const EntityHandle *conn;
343  int num_nodes;
344  ierr = m_field.get_moab().get_connectivity(*eit, conn, num_nodes);
345  CHKERRG(ierr);
346  conn_parents.resize(num_nodes);
347  for (int nn = 0; nn < num_nodes; nn++) {
348  const RefEntity ent(m_field.get_basic_entity_data_ptr(), conn[nn]);
349  conn_parents[nn] = ent.getParentEnt();
350  RefEntity_multiIndex::index<Ent_mi_tag>::type::iterator cit;
351  cit = refined_ptr->get<Ent_mi_tag>().find(conn_parents[nn]);
352  if (cit == refined_ptr->end()) {
353  conn_parents[nn] = conn[nn];
354  cit = refined_ptr->get<Ent_mi_tag>().find(conn_parents[nn]);
355  }
356  if (((*cit)->getBitRefLevel() & parent_level).none()) {
357  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
358  "parent of vertex is not on parent bit level");
359  }
360  int ent_dim = m_field.get_moab().dimension_from_handle(conn_parents[nn]);
361  max_dim = ent_dim > max_dim ? ent_dim : max_dim;
362  }
363 
364  if (verb > 1)
365  std::cout << "max_dim " << max_dim << std::endl;
366 
367  if (max_dim > 0) {
368 
369  for (; max_dim <= 3; max_dim++) {
370  Range parent_ents;
371  rval = m_field.get_moab().get_adjacencies(
372  &*conn_parents.begin(), num_nodes, max_dim, false, parent_ents);
374  parent_ents.erase((*it)->getRefEnt());
375  if (!parent_ents.empty()) {
376  ierr = chanegParent(refined_ptr->project<0>(it), *parent_ents.begin());
377  CHKERRG(ierr);
378  if (verb > 1) {
379  std::cout << "after: " << **it << std::endl << std::endl;
380  }
381  break;
382  }
383  }
384 
385  if (!vErify && max_dim > 3) {
386  ierr = chanegParent(refined_ptr->project<0>(it), 0);
387  CHKERRG(ierr);
388  if (verb > 1) {
389  std::cout << "parent not found\n";
390  }
391  }
392  }
393  }
394 
396 }
397 
398 MoFEMErrorCode BitLevelCoupler::chanegParent(RefEntity_multiIndex::iterator it,
399  EntityHandle parent) {
401 
402  Interface &m_field = cOre;
403  const RefEntity_multiIndex *refined_ptr;
404  ierr = m_field.get_ref_ents(&refined_ptr);
405  CHKERRG(ierr);
406 
407  if (vErify) {
408  ierr = verifyParent(it, parent);
409  CHKERRG(ierr);
410  }
411 
412  RefEntity_change_parent modifier(parent);
413  bool success =
414  const_cast<RefEntity_multiIndex *>(refined_ptr)->modify(it, modifier);
415  if (!success) {
416  SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
417  "unsuccessful operation");
418  }
419 
421 }
422 
423 MoFEMErrorCode BitLevelCoupler::resetParents(Range &children, bool elements,
424  int verb) {
426 
427  Interface &m_field = cOre;
428 
429  // access to ref dofs multi-index
430  const RefEntity_multiIndex *refined_ptr;
431  ierr = m_field.get_ref_ents(&refined_ptr);
432  CHKERRG(ierr);
433 
434  Range::iterator eit, hi_eit;
435  eit = children.begin();
436  hi_eit = children.end();
437  for (; eit != hi_eit; eit++) {
438 
439  // get ref entity iterator
440  RefEntity_multiIndex::index<Ent_mi_tag>::type::iterator it;
441  it = refined_ptr->get<Ent_mi_tag>().find(*eit);
442 
443  // resent entity parent
444  ierr = chanegParent(refined_ptr->project<0>(it), 0);
445  CHKERRG(ierr);
446  }
447 
449 }
450 
451 MoFEMErrorCode BitLevelCoupler::verifyParent(RefEntity_multiIndex::iterator it,
452  EntityHandle parent) {
454 
455  if (parent != (*it)->getParentEnt()) {
456  SETERRQ3(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
457  "data inconsistency %lu != %lu for ent %lu", parent,
458  (*it)->getParentEnt(), (*it)->getRefEnt());
459  }
460 
462 }
463 
465  const double *glob_coords,
466  int verb) {
467  Interface &m_field = cOre;
469 
470  int num_nodes;
471  rval = m_field.get_moab().get_connectivity(tet, cOnn, num_nodes, true);
473  rval = m_field.get_moab().get_coords(cOnn, num_nodes, cOords);
475  double shifted_glob_coors[3];
476  cblas_dcopy(3, glob_coords, 1, shifted_glob_coors, 1);
477  for (int nn = 1; nn < 4; nn++) {
478  cblas_daxpy(3, -1, cOords, 1, &cOords[nn * 3], 1);
479  }
480  cblas_daxpy(3, -1, cOords, 1, shifted_glob_coors, 1);
481  for (int dd = 0; dd < 3; dd++) {
482  cOords[dd] = 0;
483  }
485  CHKERRG(ierr);
486  locCoords[0] = locCoords[1] = locCoords[2] = 0;
487  ierr = ShapeMBTET(N, &locCoords[0], &locCoords[1], &locCoords[2], 1);
488  CHKERRG(ierr);
489  ierr = ShapeMBTET_inverse(N, diffN, cOords, shifted_glob_coors, locCoords);
490  CHKERRG(ierr);
491  ierr = ShapeMBTET(N, &locCoords[0], &locCoords[1], &locCoords[2], 1);
492  CHKERRG(ierr);
493 
494  if (verb > 1) {
495  std::cout << "N " << N[0] << " " << N[1] << " " << N[2] << " " << N[3]
496  << std::endl;
497  }
498 
500 }
501 
503  const std::vector<EntityHandle> &parents,
504  const std::vector<EntityHandle> &children, const bool verify) {
505  Interface &m_field = cOre;
506  moab::Interface &moab = m_field.get_moab();
508 
509  if (parents.size() != children.size()) {
510  SETERRQ2(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
511  "parents adn children vectors has to have the same size %d != %d",
512  parents.size(), children.size());
513  }
514 
515  const int nb_elems = parents.size();
516  std::vector<double *> data(nb_elems);
517  std::vector<int> data_size(nb_elems);
518 
519  const Field_multiIndex *fields_ptr;
520  CHKERR m_field.get_fields(&fields_ptr);
521  for (auto fit = fields_ptr->begin(); fit != fields_ptr->end(); fit++) {
522 
523  // Verify consistency with database
524  if (verify) {
525  // Get pointer to multi-index with field entities
526  const FieldEntity_multiIndex *field_ents;
527  CHKERR m_field.get_field_ents(&field_ents);
528 
529  auto get_ents_max_order = [&](const std::vector<EntityHandle> &ents) {
530  boost::shared_ptr<std::vector<const void *>> ents_max_order(
531  new std::vector<const void *>());
532  ents_max_order->resize(ents.size());
533  CHKERR moab.tag_get_by_ptr((*fit)->th_AppOrder, &*ents.begin(),
534  ents.size(), &*ents_max_order->begin());
535  return ents_max_order;
536  };
537 
538  auto max_order_parents = get_ents_max_order(parents);
539  auto max_order_children = get_ents_max_order(children);
540 
541  auto pit = parents.begin();
542  auto cit = children.begin();
543  auto vit_parent_max_order = max_order_parents->begin();
544  auto vit_child_max_order = max_order_children->begin();
545 
546  for (; pit != parents.end();
547  ++pit, ++cit, ++vit_parent_max_order, ++vit_child_max_order) {
548  // verify entity type
549  if (moab.type_from_handle(*pit) != moab.type_from_handle(*cit)) {
550  SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
551  "inconsistent type");
552  }
553  // ref ent pointers
554  auto ref_parent_ptr = boost::make_shared<RefEntity>(
555  m_field.get_basic_entity_data_ptr(), *pit);
556  auto ref_child_ptr = boost::make_shared<RefEntity>(
557  m_field.get_basic_entity_data_ptr(), *cit);
558  // create mofem entity objects
559  boost::shared_ptr<FieldEntity> mofem_ent_parent(new FieldEntity(
560  *fit, ref_parent_ptr,
561  FieldEntity::makeSharedFieldDataAdaptorPtr(*fit, ref_parent_ptr),
562  boost::shared_ptr<const int>(
563  max_order_parents,
564  static_cast<const int *>(*vit_parent_max_order))));
565  boost::shared_ptr<FieldEntity> mofem_ent_child(new FieldEntity(
566  *fit, ref_child_ptr,
567  FieldEntity::makeSharedFieldDataAdaptorPtr(*fit, ref_child_ptr),
568  boost::shared_ptr<const int>(
569  max_order_children,
570  static_cast<const int *>(*vit_child_max_order))));
571  // check approximation order
572  if (mofem_ent_parent->getMaxOrder() == mofem_ent_child->getMaxOrder()) {
573  // approximation order is equal, simply copy data
574  for (unsigned int dd = 0;
575  dd != mofem_ent_child->getEntFieldData().size(); dd++) {
576  mofem_ent_child->getEntFieldData()[dd] =
577  mofem_ent_parent->getEntFieldData()[dd];
578  }
579  } else {
580  // approximation orders is different
581  FieldEntity_multiIndex::iterator fcit =
582  field_ents->find(mofem_ent_child->getGlobalUniqueId());
583  if (fcit == field_ents->end()) {
584  // entity not in database, set order and copy data
585  (FieldEntity_change_order(mofem_ent_parent->getMaxOrder()))(
586  mofem_ent_child);
587  for (unsigned int dd = 0;
588  dd != mofem_ent_child->getEntFieldData().size(); dd++) {
589  mofem_ent_child->getEntFieldData()[dd] =
590  mofem_ent_parent->getEntFieldData()[dd];
591  }
592  } else {
593  int parent_nb_dofs = mofem_ent_parent->getEntFieldData().size();
594  int child_nb_dofs = mofem_ent_child->getEntFieldData().size();
595  for (int dd = 0; dd != child_nb_dofs; dd++) {
596  if (dd < parent_nb_dofs) {
597  mofem_ent_child->getEntFieldData()[dd] =
598  mofem_ent_parent->getEntFieldData()[dd];
599  } else {
600  mofem_ent_child->getEntFieldData()[dd] = 0;
601  }
602  }
603  }
604  }
605  }
606  } else {
607 
608  auto copy_tag_data = [this, &moab, &data, &data_size](auto th, auto &p,
609  auto &c) {
611  // Get pointer and size of field values tag
612  CHKERR moab.tag_get_by_ptr(th, p, (const void **)&data.front(),
613  &data_size.front());
614  // Set data
615  CHKERR moab.tag_set_by_ptr(th, c, (void *const *)&data.front(),
616  &data_size.front());
618  };
619 
620  Range p, c;
621  p.insert_list(parents.begin(), parents.end());
622  c.insert_list(children.begin(), children.end());
623 
624  Range parents_verts = p.subset_by_type(MBTET);
625  Range children_verts = c.subset_by_type(MBTET);
626  Range parents_without_verts = subtract(p, parents_verts);
627  Range children_without_verts = subtract(c, children_verts);
628 
629  CHKERR copy_tag_data(fit->get()->th_FieldDataVerts, parents_verts,
630  children_verts);
631  CHKERR copy_tag_data(fit->get()->th_FieldData, parents_verts,
632  children_verts);
633 
634  }
635  }
636 
638 }
639 
641  const BitRefLevel bit, const BitRefLevel mask, const bool verify) {
642  Interface &m_field = cOre;
643  // moab::Interface& moab = m_field.get_moab();
645  Range ents;
646  ierr = m_field.getInterface<BitRefManager>()->getEntitiesByRefLevel(bit, mask,
647  ents);
648  CHKERRG(ierr);
649  std::vector<EntityHandle> parents;
650  std::vector<EntityHandle> children;
651  for (Range::iterator eit = ents.begin(); eit != ents.end(); eit++) {
652  RefEntity ref_ent(m_field.get_basic_entity_data_ptr(), *eit);
653  if (ref_ent.getParentEntType() == ref_ent.getEntType()) {
654  children.push_back(*eit);
655  parents.push_back(ref_ent.getParentEnt());
656  }
657  }
658  ierr = copyFieldDataFromParentToChildren(parents, children, verify);
659  CHKERRG(ierr);
661 }
662 
663 } // namespace MoFEM
#define CHKERRQ_MOAB(a)
check error code of MoAB function
Definition: definitions.h:515
MoFEMErrorCode verifyParent(RefEntity_multiIndex::iterator it, EntityHandle parent)
bool vErify
by default is switched off, with it on to verify if existing parent is equal to parent set by interfa...
virtual MoFEMErrorCode get_ref_ents(const RefEntity_multiIndex **refined_ents_ptr) const =0
Get ref entities multi-index from database.
MoFEM interface unique ID.
change parentUse this function with care. Some other multi-indices can deponent on this.
virtual moab::Interface & get_moab()=0
PetscErrorCode ShapeMBTET(double *N, const double *G_X, const double *G_Y, const double *G_Z, int DIM)
calculate shape functions
Definition: fem_tools.c:318
virtual boost::shared_ptr< BasicEntityData > & get_basic_entity_data_ptr()=0
Get pointer to basic entity data.
boost::scoped_ptr< AdaptiveKDTree > treePtr
void cblas_daxpy(const int N, const double alpha, const double *X, const int incX, double *Y, const int incY)
Definition: cblas_daxpy.c:11
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:501
void cblas_dcopy(const int N, const double *X, const int incX, double *Y, const int incY)
Definition: cblas_dcopy.c:11
static boost::shared_ptr< FieldData *const > makeSharedFieldDataAdaptorPtr(const boost::shared_ptr< Field > &field_ptr, const boost::shared_ptr< RefEntity > &ref_ent_ptr)
Return shared pointer to entity field data vector adaptor.
base class for all interface classes
multi_index_container< boost::shared_ptr< FieldEntity >, indexed_by< ordered_unique< tag< Unique_mi_tag >, member< FieldEntity, UId, &FieldEntity::globalUId > >, ordered_non_unique< tag< FieldName_mi_tag >, const_mem_fun< FieldEntity::interface_type_Field, boost::string_ref, &FieldEntity::getNameRef > >, ordered_non_unique< tag< Ent_mi_tag >, const_mem_fun< FieldEntity, EntityHandle, &FieldEntity::getEnt > >, ordered_non_unique< tag< Composite_Name_And_Ent_mi_tag >, composite_key< FieldEntity, const_mem_fun< FieldEntity::interface_type_Field, boost::string_ref, &FieldEntity::getNameRef >, const_mem_fun< FieldEntity, EntityHandle, &FieldEntity::getEnt > > > > > FieldEntity_multiIndex
MultiIndex container keeps FieldEntity.
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
MoFEMErrorCode getLocCoordsOnTet(EntityHandle tet, const double *glob_coords, int verb=0)
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:544
multi_index_container< boost::shared_ptr< Field >, indexed_by< hashed_unique< tag< BitFieldId_mi_tag >, const_mem_fun< Field, const BitFieldId &, &Field::getId >, HashBit< BitFieldId >, EqBit< BitFieldId > >, ordered_unique< tag< Meshset_mi_tag >, member< Field, EntityHandle, &Field::meshSet > >, ordered_unique< tag< FieldName_mi_tag >, const_mem_fun< Field, boost::string_ref, &Field::getNameRef > >, ordered_non_unique< tag< BitFieldId_space_mi_tag >, const_mem_fun< Field, FieldSpace, &Field::getSpace > > > > Field_multiIndex
Field_multiIndex for Field.
MoFEMErrorCode buildAdjacenciesVerticesOnTets(const BitRefLevel &parent_level, Range &children, bool vertex_elements=false, const double iter_tol=1.0e-10, const double inside_tol=1.0e-6, bool throw_error=true, int verb=0)
finding parents for vertices
Struct keeps handle to entity in the field.
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508
Struct keeps handle to refined handle.
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:21
MoFEMErrorCode buildTree(const BitRefLevel &parent_level, int verb=0)
build adaptive kd-tree
PetscErrorCode ShapeMBTET_inverse(double *N, double *diffN, const double *elem_coords, const double *glob_coords, double *loc_coords)
calculate local coordinates for given global coordinates
Definition: fem_tools.c:347
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
Definition: Exceptions.hpp:84
MoFEMErrorCode buildAdjacenciesEdgesFacesVolumes(const BitRefLevel &parent_level, Range &children, bool elements=true, int verb=0)
finding parents for edegs, faces and tets
MoFEMErrorCode getInterface(const MOFEMuuid &uuid, IFACE *&iface) const
Get interface by uuid and return reference to pointer of interface.
PetscErrorCode ShapeDiffMBTET(double *diffN)
calculate derivatives of shape functions
Definition: fem_tools.c:331
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
MoFEMErrorCode getParent(const double *coords, EntityHandle &parent, bool tet_only=false, const double iter_tol=1.0e-10, const double inside_tol=1.0e-6, int verb=0)
get parent entity
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:66
MoFEMErrorCode resetParents(Range &children, bool elements=true, int verb=0)
reset parent entities
Managing BitRefLevels.
MoFEMErrorCode copyFieldDataFromParentToChildren(const std::vector< EntityHandle > &parents, const std::vector< EntityHandle > &children, const bool verify=true)
copy data from parents
#define CHKERR
Inline error check.
Definition: definitions.h:596
virtual MoFEMErrorCode get_field_ents(const FieldEntity_multiIndex **field_ents) const =0
Get field multi index.
structure to change FieldEntity order
const EntityHandle * cOnn
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition: Types.hpp:51
multi_index_container< boost::shared_ptr< RefEntity >, indexed_by< ordered_unique< tag< Ent_mi_tag >, member< RefEntity::BasicEntity, EntityHandle, &RefEntity::ent > >, ordered_non_unique< tag< Ent_Ent_mi_tag >, const_mem_fun< RefEntity, EntityHandle, &RefEntity::getParentEnt > >, ordered_non_unique< tag< EntType_mi_tag >, const_mem_fun< RefEntity::BasicEntity, EntityType, &RefEntity::getEntType > >, ordered_non_unique< tag< ParentEntType_mi_tag >, const_mem_fun< RefEntity, EntityType, &RefEntity::getParentEntType > >, ordered_non_unique< tag< Composite_EntType_and_ParentEntType_mi_tag >, composite_key< RefEntity, const_mem_fun< RefEntity::BasicEntity, EntityType, &RefEntity::getEntType >, const_mem_fun< RefEntity, EntityType, &RefEntity::getParentEntType > > >, ordered_non_unique< tag< Composite_ParentEnt_And_EntType_mi_tag >, composite_key< RefEntity, const_mem_fun< RefEntity::BasicEntity, EntityType, &RefEntity::getEntType >, const_mem_fun< RefEntity, EntityHandle, &RefEntity::getParentEnt > > > > > RefEntity_multiIndex
MoFEMErrorCode resetTree(const BitRefLevel &parent_level, int verb=0)
reset adaptive kd-tree
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407
MoFEMErrorCode query_interface(const MOFEMuuid &uuid, UnknownInterface **iface) const
virtual MPI_Comm & get_comm() const =0
virtual MoFEMErrorCode get_fields(const Field_multiIndex **fields_ptr) const =0
Get fields multi-index from database.
MoFEMErrorCode chanegParent(RefEntity_multiIndex::iterator it, EntityHandle parent)
static const MOFEMuuid IDD_MOFEMBitLevelCoupler