v0.8.4
Public Member Functions | Public Attributes | List of all members
MoFEM::ISManager Struct Reference

Section manager is used to create indexes and sections. More...

#include <src/interfaces/ISManager.hpp>

Inheritance diagram for MoFEM::ISManager:
[legend]
Collaboration diagram for MoFEM::ISManager:
[legend]

Public Member Functions

MoFEMErrorCode query_interface (const MOFEMuuid &uuid, UnknownInterface **iface) const
 
 ISManager (const MoFEM::Core &core)
 
 ~ISManager ()
 Destructor. More...
 
MoFEMErrorCode sectionCreate (const std::string &problem_name, PetscSection *s, const RowColData row_col=COL) const
 Create global selection. More...
 
MoFEMErrorCode isCreateProblemOrder (const std::string &problem, RowColData rc, int min_order, int max_order, IS *is) const
 create IS for given order range (collective) More...
 
MoFEMErrorCode isCreateProblemFieldAndRank (const std::string &problem, 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) More...
 
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 fieldNote that indices are ordered in ascending order of local indices in problem_y More...
 
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, IS *ix, IS *iy) const
 create IS for give two problems and fieldIndices are sorted by global PETSc index in problem_x. More...
 
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
 
MoFEMErrorCode isCreateFromProblemToOtherProblem (const std::string &x_problem, RowColData x_rc, const std::string &y_problem, RowColData y_rc, IS *ix, IS *iy) const
 
- Public Member Functions inherited from MoFEM::UnknownInterface
template<class IFACE >
MoFEMErrorCode registerInterface (const MOFEMuuid &uuid, bool error_if_registration_failed=true)
 Register interface. More...
 
template<class IFACE , bool VERIFY = false>
MoFEMErrorCode getInterface (const MOFEMuuid &uuid, IFACE *&iface) const
 Get interface by uuid and return reference to pointer of interface. More...
 
template<class IFACE >
MoFEMErrorCode getInterface (IFACE *&iface) const
 Get interface refernce to pointer of interface. More...
 
template<class IFACE >
MoFEMErrorCode getInterface (IFACE **const iface) const
 Get interface pointer to pointer of interface. More...
 
template<class IFACE , typename boost::enable_if< boost::is_pointer< IFACE >, int >::type = 0>
IFACE getInterface () const
 Get interface pointer to pointer of interface. More...
 
template<class IFACE , typename boost::enable_if< boost::is_reference< IFACE >, int >::type = 0>
IFACE getInterface () const
 Get reference to interface. More...
 
template<class IFACE >
IFACE * getInterface () const
 Function returning pointer to interface. More...
 
virtual ~UnknownInterface ()
 
virtual MoFEMErrorCode getLibVersion (Version &version) const
 Get library version. More...
 
virtual const MoFEMErrorCode getFileVersion (moab::Interface &moab, Version &version) const
 Get database major version. More...
 
virtual MoFEMErrorCode getInterfaceVersion (Version &version) const
 Get database major version. More...
 
template<>
MoFEMErrorCode getInterface (const MOFEMuuid &uuid, UnknownInterface *&iface) const
 

Public Attributes

const MoFEM::InterfacecOre
 
bool dEbug
 

Additional Inherited Members

- Protected Member Functions inherited from MoFEM::UnknownInterface
boost::typeindex::type_index getClassIdx (const MOFEMuuid &uid) const
 Get type name for interface Id. More...
 
MOFEMuuid getUId (const boost::typeindex::type_index &class_idx) const
 Get interface Id for class name. More...
 

Detailed Description

Section manager is used to create indexes and sections.

Examples:
cell_forces.cpp.

Definition at line 33 of file ISManager.hpp.

Constructor & Destructor Documentation

◆ ISManager()

MoFEM::ISManager::ISManager ( const MoFEM::Core core)

Definition at line 34 of file ISManager.cpp.

35  : cOre(const_cast<MoFEM::Core &>(core)), dEbug(false) {}
const MoFEM::Interface & cOre
Definition: ISManager.hpp:37

◆ ~ISManager()

MoFEM::ISManager::~ISManager ( )

Destructor.

Definition at line 36 of file ISManager.cpp.

36 {}

Member Function Documentation

◆ isCreateFromProblemToOtherProblem() [1/2]

MoFEMErrorCode MoFEM::ISManager::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

Definition at line 386 of file ISManager.cpp.

388  {
389  const MoFEM::Interface &m_field = cOre;
390  const Problem *px_ptr;
391  const Problem *py_ptr;
393  CHKERR m_field.get_problem(x_problem, &px_ptr);
394  CHKERR m_field.get_problem(y_problem, &py_ptr);
395  NumeredDofEntityByLocalIdx::iterator y_dit, hi_y_dit;
396  switch (y_rc) {
397  case ROW:
398  y_dit = py_ptr->numeredDofsRows->get<PetscLocalIdx_mi_tag>().lower_bound(0);
399  hi_y_dit = py_ptr->numeredDofsRows->get<PetscLocalIdx_mi_tag>().lower_bound(
400  py_ptr->getNbLocalDofsRow()); // should be lower
401  break;
402  case COL:
403  y_dit = py_ptr->numeredDofsCols->get<PetscLocalIdx_mi_tag>().lower_bound(0);
404  hi_y_dit = py_ptr->numeredDofsCols->get<PetscLocalIdx_mi_tag>().lower_bound(
405  py_ptr->getNbLocalDofsCol()); // should be lower
406  break;
407  default:
408  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "not implemented");
409  }
410  const NumeredDofEntityByUId *x_numered_dofs_by_uid;
411  switch (x_rc) {
412  case ROW:
413  x_numered_dofs_by_uid = &(px_ptr->numeredDofsRows->get<Unique_mi_tag>());
414  break;
415  case COL:
416  x_numered_dofs_by_uid = &(px_ptr->numeredDofsCols->get<Unique_mi_tag>());
417  break;
418  default:
419  SETERRQ(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED, "not implemented");
420  }
421  for (; y_dit != hi_y_dit; y_dit++) {
422  if ((*y_dit)->getPart() != (unsigned int)m_field.get_comm_rank()) {
423  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "data inconsistency");
424  }
425  NumeredDofEntityByUId::iterator x_dit;
426  x_dit = x_numered_dofs_by_uid->find((*y_dit)->getGlobalUniqueId());
427  if (x_dit == x_numered_dofs_by_uid->end())
428  continue;
429  idx.push_back((*x_dit)->getPetscGlobalDofIdx());
430  idy.push_back((*y_dit)->getPetscGlobalDofIdx());
431  }
433 }
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:498
virtual int get_comm_rank() const =0
virtual MoFEMErrorCode get_problem(const std::string &problem_name, const Problem **problem_ptr) const =0
Get problem database (data structure)
#define CHKERR
Inline error check.
Definition: definitions.h:617
const MoFEM::Interface & cOre
Definition: ISManager.hpp:37
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:443
NumeredDofEntity_multiIndex::index< Unique_mi_tag >::type NumeredDofEntityByUId
Numbered DoF multi-index by UId.

◆ isCreateFromProblemToOtherProblem() [2/2]

MoFEMErrorCode MoFEM::ISManager::isCreateFromProblemToOtherProblem ( const std::string &  x_problem,
RowColData  x_rc,
const std::string &  y_problem,
RowColData  y_rc,
IS *  ix,
IS *  iy 
) const

Definition at line 435 of file ISManager.cpp.

437  {
439  std::vector<int> idx(0), idy(0);
440  CHKERR isCreateFromProblemToOtherProblem(x_problem, x_rc, y_problem, y_rc,
441  idx, idy);
442  CHKERR ISCreateGeneral(PETSC_COMM_WORLD, idx.size(), &idx[0],
443  PETSC_COPY_VALUES, ix);
444  CHKERR ISCreateGeneral(PETSC_COMM_WORLD, idy.size(), &idy[0],
445  PETSC_COPY_VALUES, iy);
446  if (dEbug) {
447  ISView(*ix, PETSC_VIEWER_STDOUT_WORLD);
448  ISView(*iy, PETSC_VIEWER_STDOUT_WORLD);
449  }
451 }
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
Definition: ISManager.cpp:386
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:498
#define CHKERR
Inline error check.
Definition: definitions.h:617
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:443

◆ query_interface()

MoFEMErrorCode MoFEM::ISManager::query_interface ( const MOFEMuuid uuid,
UnknownInterface **  iface 
) const
virtual

Implements MoFEM::UnknownInterface.

Definition at line 22 of file ISManager.cpp.

23  {
25  *iface = NULL;
26  if (uuid == IDD_MOFEMISManager) {
27  *iface = const_cast<ISManager *>(this);
29  }
30  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "unknown interface");
32 }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:522
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:528
ISManager(const MoFEM::Core &core)
Definition: ISManager.cpp:34
static const MOFEMuuid IDD_MOFEMISManager
Definition: ISManager.hpp:26

◆ sectionCreate()

MoFEMErrorCode MoFEM::ISManager::sectionCreate ( const std::string &  problem_name,
PetscSection *  s,
const RowColData  row_col = COL 
) const

Create global selection.

Create section for given problem, such that points are sorted by UId, and number of dofs on point is equal to number of dofs on entity

It takes all fields

Parameters
problem_name
fields_list
s
row_colROE or COL, default is ROW
Returns
error code

Definition at line 38 of file ISManager.cpp.

40  {
41  const MoFEM::Interface &m_field = cOre;
42  const Problem *problem_ptr;
43  const Field_multiIndex *fields_ptr;
44  const FiniteElement_multiIndex *fe_ptr;
46  CHKERR m_field.get_problem(problem_name, &problem_ptr);
47  CHKERR m_field.get_fields(&fields_ptr);
48  CHKERR m_field.get_finite_elements(&fe_ptr);
49  boost::shared_ptr<NumeredDofEntity_multiIndex> dofs;
50  BitFieldId fields_ids;
51  switch (row_col) {
52  case ROW:
53  dofs = problem_ptr->numeredDofsRows;
54  for (FiniteElement_multiIndex::iterator fit = fe_ptr->begin();
55  fit != fe_ptr->end(); fit++) {
56  if ((fit->get()->getId() & problem_ptr->getBitFEId()).any()) {
57  fields_ids |= fit->get()->getBitFieldIdRow();
58  }
59  }
60  break;
61  case COL:
62  dofs = problem_ptr->numeredDofsCols;
63  for (FiniteElement_multiIndex::iterator fit = fe_ptr->begin();
64  fit != fe_ptr->end(); fit++) {
65  if ((fit->get()->getId() & problem_ptr->getBitFEId()).any()) {
66  fields_ids |= fit->get()->getBitFieldIdCol();
67  }
68  }
69  break;
70  default:
71  SETERRQ(PETSC_COMM_WORLD, MOFEM_DATA_INCONSISTENCY,
72  "Has to be ROW or COLUMN");
73  }
74  // get fields names on the problem
75  map<std::string, std::pair<int, int> > fields_map;
76  {
77  int field = 0;
78  for (Field_multiIndex::iterator fit = fields_ptr->begin();
79  fit != fields_ptr->end(); fit++) {
80  if ((fit->get()->getId() & fields_ids).any()) {
81  fields_map[fit->get()->getName()].first = field++;
82  fields_map[fit->get()->getName()].second = fit->get()->getNbOfCoeffs();
83  }
84  }
85  }
86  const int proc = m_field.get_comm_rank();
87  CHKERR PetscSectionCreate(PETSC_COMM_WORLD, s);
88  CHKERR PetscSectionSetNumFields(*s, fields_map.size());
89  for (map<std::string, std::pair<int, int> >::iterator mit =
90  fields_map.begin();
91  mit != fields_map.end(); mit++) {
92  CHKERR PetscSectionSetFieldName(*s, mit->second.first, mit->first.c_str());
93  CHKERR PetscSectionSetFieldComponents(*s, mit->second.first,
94  mit->second.second);
95  }
96  // determine number of points
97  int nb_charts = 0;
98  {
99  NumeredDofEntity_multiIndex::iterator dit, hi_dit;
100  dit = dofs->begin();
101  hi_dit = dofs->end();
102  for (; dit != hi_dit;) {
103  EntityHandle ent = dit->get()->getEnt();
104  if (static_cast<int>(dit->get()->getPart()) == proc && dit->get()->getEntDofIdx() == 0) {
105  while (dit != hi_dit && ent == dit->get()->getEnt()) {
106  const int nb_of_dofs_on_ent = dit->get()->getNbDofsOnEnt();
107  for (int dd = 0; dd != nb_of_dofs_on_ent; dd++, dit++) {
108  }
109  }
110  ++nb_charts;
111  } else {
112  ++dit;
113  }
114  }
115  }
116  // get layout, i.e. chart
117  PetscLayout layout;
118  CHKERR PetscLayoutCreate(PETSC_COMM_WORLD, &layout);
119  CHKERR PetscLayoutSetBlockSize(layout, 1);
120  CHKERR PetscLayoutSetLocalSize(layout, nb_charts);
121  CHKERR PetscLayoutSetUp(layout);
122  int rstart, rend;
123  CHKERR PetscLayoutGetRange(layout, &rstart, &rend);
124  CHKERR PetscLayoutDestroy(&layout);
125  CHKERR PetscSectionSetChart(*s, rstart, rend);
126  // cerr << rstart << " " << rend << " " << proc << endl;
127  // loop of all dofs
128  {
129  NumeredDofEntity_multiIndex::iterator dit, hi_dit;
130  dit = dofs->begin();
131  hi_dit = dofs->end();
132  int point = rstart;
133  for (; dit != hi_dit;) {
134  EntityHandle ent = dit->get()->getEnt();
135  if (static_cast<int>(dit->get()->getPart()) == proc && dit->get()->getEntDofIdx() == 0) {
136  // exploit that does are continuously stored on entity
137  // that includes fields
138  while (dit != hi_dit && ent == dit->get()->getEnt()) {
139  const int nb_of_dofs_on_ent = dit->get()->getNbDofsOnEnt();
140  std::string field_name = dit->get()->getName();
141  if (fields_map.find(field_name) == fields_map.end()) {
142  PetscPrintf(PETSC_COMM_WORLD, "Warning: Field %s not found\n",
143  dit->get()->getName().c_str());
144  } else {
145  if (dit->get()->getEntDofIdx() != 0) {
146  cerr << **dit << endl;
147  SETERRQ(PETSC_COMM_WORLD, MOFEM_DATA_INCONSISTENCY,
148  "data inconsistency");
149  }
150  CHKERR PetscSectionAddDof(*s, point, nb_of_dofs_on_ent);
151  int field = fields_map.at(field_name).first;
152  CHKERR PetscSectionSetFieldDof(*s, point, field, nb_of_dofs_on_ent);
153  }
154  for (int dd = 0; dd != nb_of_dofs_on_ent; dd++, dit++) {
155  if (field_name != dit->get()->getName()) {
156  SETERRQ2(PETSC_COMM_WORLD, MOFEM_DATA_INCONSISTENCY,
157  "field name inconsistency %s!=%s", field_name.c_str(),
158  dit->get()->getName().c_str());
159  }
160  }
161  // cerr << point << endl;
162  }
163  ++point;
164  } else {
165  ++dit;
166  }
167  }
168  }
169  // cerr << "done " << proc << endl;
170  CHKERR PetscSectionSetUp(*s);
171  // cerr << "end " << proc << endl;
173 }
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
multi_index_container< boost::shared_ptr< FiniteElement >, indexed_by< hashed_unique< tag< FiniteElement_Meshset_mi_tag >, member< FiniteElement, EntityHandle, &FiniteElement::meshset > >, hashed_unique< tag< BitFEId_mi_tag >, const_mem_fun< FiniteElement, BitFEId, &FiniteElement::getId >, HashBit< BitFEId >, EqBit< BitFEId > >, ordered_unique< tag< FiniteElement_name_mi_tag >, const_mem_fun< FiniteElement, boost::string_ref, &FiniteElement::getNameRef > > > > FiniteElement_multiIndex
MultiIndex for entities for FiniteElement.
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.
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:498
std::bitset< BITFIELDID_SIZE > BitFieldId
Definition: Common.hpp:149
virtual MoFEMErrorCode get_finite_elements(const FiniteElement_multiIndex **fe_ptr) const =0
Get finite elements multi-index.
virtual int get_comm_rank() const =0
virtual MoFEMErrorCode get_problem(const std::string &problem_name, const Problem **problem_ptr) const =0
Get problem database (data structure)
#define CHKERR
Inline error check.
Definition: definitions.h:617
const MoFEM::Interface & cOre
Definition: ISManager.hpp:37
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:443
virtual MoFEMErrorCode get_fields(const Field_multiIndex **fields_ptr) const =0
Get fields multi-index from database.

Member Data Documentation

◆ cOre

const MoFEM::Interface& MoFEM::ISManager::cOre

Definition at line 37 of file ISManager.hpp.

◆ dEbug

bool MoFEM::ISManager::dEbug

Definition at line 38 of file ISManager.hpp.


The documentation for this struct was generated from the following files: