18 : cOre(const_cast<
MoFEM::
Core &>(core)), dEbug(false) {}
28 boost::shared_ptr<NumeredDofEntity_multiIndex> dofs;
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();
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();
49 "Has to be ROW or COLUMN");
52 map<std::string, std::pair<int, int>> fields_map;
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();
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,
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) {
89 CHKERR PetscLayoutCreate(PETSC_COMM_WORLD, &layout);
90 CHKERR PetscLayoutSetBlockSize(layout, 1);
91 CHKERR PetscLayoutSetLocalSize(layout, nb_charts);
92 CHKERR PetscLayoutSetUp(layout);
94 CHKERR PetscLayoutGetRange(layout, &rstart, &rend);
95 CHKERR PetscLayoutDestroy(&layout);
96 CHKERR PetscSectionSetChart(*s, rstart, rend);
100 auto dit = dofs->begin();
101 auto hi_dit = dofs->end();
103 for (; dit != hi_dit;) {
104 if (
static_cast<int>(dit->get()->getPart()) == proc) {
106 const auto &
field_name = dit->get()->getName();
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();
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());
121 CHKERR PetscSectionAddDof(*s, point, dd);
123 CHKERR PetscSectionSetFieldDof(*s, point, field, dd);
134 CHKERR PetscSectionSetUp(*s);
145 "Section not created");
151 int max_order, IS *is)
const {
157 typedef multi_index_container<
158 boost::shared_ptr<NumeredDofEntity>,
170 NumeredDofEntity_order_view_multiIndex;
174 NumeredDofEntity_order_view_multiIndex dofs_by_order;
175 auto insert_part_range = [&dofs_by_order, rank](
auto &dofs) {
176 dofs_by_order.insert(dofs_by_order.end(), dofs.lower_bound(rank),
177 dofs.upper_bound(rank));
191 auto lo = dofs_by_order.get<
Order_mi_tag>().lower_bound(min_order);
192 auto hi = dofs_by_order.get<
Order_mi_tag>().upper_bound(max_order);
193 const int size = std::distance(lo, hi);
195 CHKERR PetscMalloc(size *
sizeof(
int), &
id);
197 for (; lo != hi; ++lo, ++id_it)
198 *id_it = (*lo)->getPetscGlobalDofIdx();
201 CHKERR ISCreateGeneral(PETSC_COMM_WORLD, size,
id, PETSC_OWN_POINTER, is);
218 const std::string problem_name,
RowColData rc,
const std::string field,
219 int min_coeff_idx,
int max_coeff_idx, IS *is,
Range *ents_ptr)
const {
226 typedef NumeredDofEntity_multiIndex::index<Unique_mi_tag>::type DofsByUId;
227 DofsByUId::iterator it, hi_it;
248 std::vector<int> idx_vec;
249 idx_vec.reserve(std::distance(it, hi_it));
250 for (; it != hi_it; ++it) {
252 auto true_if_dof_on_entity = [&]() {
254 return ents_ptr->find((*it)->getEnt()) != ents_ptr->end();
261 const auto ceff_idx = (*it)->getDofCoeffIdx();
264 (*it)->getPetscLocalDofIdx() >= nb_loc_dofs ||
266 ceff_idx < min_coeff_idx || ceff_idx > max_coeff_idx
275 if (true_if_dof_on_entity()) {
276 idx_vec.emplace_back((*it)->getPetscGlobalDofIdx());
282 CHKERR PetscMalloc(idx_vec.size() *
sizeof(
int), &
id);
283 std::copy(idx_vec.begin(), idx_vec.end(),
id);
284 CHKERR ISCreateGeneral(PETSC_COMM_WORLD, idx_vec.size(),
id,
285 PETSC_OWN_POINTER, is);
291 const std::string problem_name,
RowColData rc,
const std::string field,
293 Range *ents_ptr)
const {
297 max_coeff_idx, &is, ents_ptr);
303 const std::string problem_name,
RowColData rc,
const std::string field,
305 int max_coeff_idx, IS *is,
Range *ents_ptr)
const {
310 for (; low_type <= hi_type; ++low_type)
311 CHKERR m_field.
get_moab().get_entities_by_type(field_meshset, low_type,
314 ents = intersect(ents, *ents_ptr);
316 max_coeff_idx, is, &ents);
321 const std::string x_problem,
const std::string x_field_name,
323 const std::string y_field_name,
RowColData y_rc, std::vector<int> &idx,
324 std::vector<int> &idy)
const {
333 typedef multi_index_container<
334 boost::shared_ptr<NumeredDofEntity>,
341 tag<Composite_Ent_And_EntDofIdx_mi_tag>,
350 NumeredDofEntity_view_multiIndex;
352 NumeredDofEntity_view_multiIndex dofs_view;
375 "only makes sense for ROWS and COLS");
388 "only makes sense for ROWS and COLS");
391 std::map<int, int> global_dofs_map;
398 for (; dit != hi_dit; ++dit) {
399 if ((*dit)->getPart() == rank) {
401 boost::make_tuple((*dit)->getEnt(), (*dit)->getEntDofIdx()));
403 global_dofs_map[(*x_dit)->getPetscGlobalDofIdx()] =
404 (*dit)->getPetscGlobalDofIdx();
409 idx.resize(global_dofs_map.size());
410 idy.resize(global_dofs_map.size());
412 auto ix = idx.begin();
413 auto iy = idy.begin();
414 for (
auto mit = global_dofs_map.begin(); mit != global_dofs_map.end();
424 const std::string x_problem,
const std::string x_field_name,
426 const std::string y_field_name,
RowColData y_rc, IS *ix, IS *iy)
const {
428 std::vector<int> idx(0), idy(0);
430 x_problem, x_field_name, x_rc, y_problem, y_field_name, y_rc, idx, idy);
431 if (ix != PETSC_NULL) {
432 CHKERR ISCreateGeneral(PETSC_COMM_WORLD, idx.size(), &idx[0],
433 PETSC_COPY_VALUES, ix);
435 CHKERR ISCreateGeneral(PETSC_COMM_WORLD, idy.size(), &idy[0],
436 PETSC_COPY_VALUES, iy);
438 ISView(*ix, PETSC_VIEWER_STDOUT_WORLD);
439 ISView(*iy, PETSC_VIEWER_STDOUT_WORLD);
445 const std::string x_problem,
RowColData x_rc,
const std::string y_problem,
446 RowColData y_rc, std::vector<int> &idx, std::vector<int> &idy)
const {
453 NumeredDofEntityByLocalIdx::iterator y_dit, hi_y_dit;
483 for (; y_dit != hi_y_dit; y_dit++) {
484 if ((*y_dit)->getPart() != (
unsigned int)m_field.
get_comm_rank()) {
487 NumeredDofEntityByUId::iterator x_dit;
488 x_dit = x_numered_dofs_by_uid->find((*y_dit)->getLocalUniqueId());
489 if (x_dit == x_numered_dofs_by_uid->end())
491 idx.push_back((*x_dit)->getPetscGlobalDofIdx());
492 idy.push_back((*y_dit)->getPetscGlobalDofIdx());
498 const std::string x_problem,
RowColData x_rc,
const std::string y_problem,
501 std::vector<int> idx(0), idy(0);
504 CHKERR ISCreateGeneral(PETSC_COMM_WORLD, idx.size(), &idx[0],
505 PETSC_COPY_VALUES, ix);
506 CHKERR ISCreateGeneral(PETSC_COMM_WORLD, idy.size(), &idy[0],
507 PETSC_COPY_VALUES, iy);
509 ISView(*ix, PETSC_VIEWER_STDOUT_WORLD);
510 ISView(*iy, PETSC_VIEWER_STDOUT_WORLD);
#define MOFEM_LOG_C(channel, severity, format,...)
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_DATA_INCONSISTENCY
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
NumeredDofEntity_multiIndex::index< Unique_mi_tag >::type NumeredDofEntityByUId
Numbered DoF multi-index by UId.
virtual const Problem * get_problem(const std::string problem_name) const =0
Get the problem object.
virtual const FiniteElement_multiIndex * get_finite_elements() const =0
Get the finite elements object.
virtual const Field_multiIndex * get_fields() const =0
Get the fields object.
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
MoFEMErrorCode sectionCreate(const std::string problem_name, PetscSection *s, const RowColData row_col=COL) const
Create global selection.
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)
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.
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)
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)
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
int ApproximationOrder
Approximation on the entity.
std::bitset< BITFIELDID_SIZE > BitFieldId
Field Id.
implementation of Data Operators for Forces and Sources
constexpr auto field_name
virtual FieldBitNumber get_field_bit_number(const std::string name) const =0
get field bit number
virtual moab::Interface & get_moab()=0
virtual EntityHandle get_field_meshset(const std::string name) const =0
get field meshset
virtual int get_comm_rank() const =0
Deprecated interface functions.
static UId getHiBitNumberUId(const FieldBitNumber bit_number)
static UId getLoBitNumberUId(const FieldBitNumber bit_number)
Section manager is used to create indexes and sections.
MoFEMErrorCode query_interface(boost::typeindex::type_index type_index, UnknownInterface **iface) const
const MoFEM::Interface & cOre
ISManager(const MoFEM::Core &core)
keeps information about indexed dofs for the problem
interface_DofEntity< DofEntity > interface_type_DofEntity
MultiIndex Tag for field order.
keeps basic data about problem
DofIdx getNbLocalDofsRow() const
boost::shared_ptr< NumeredDofEntity_multiIndex > numeredRowDofsPtr
store DOFs on rows for this problem
BitFEId getBitFEId() const
DofIdx getNbLocalDofsCol() const
boost::shared_ptr< NumeredDofEntity_multiIndex > numeredColDofsPtr
store DOFs on columns for this problem
intrusive_ptr for managing petsc objects
base class for all interface classes
DofIdx getEntDofIdx() const
ApproximationOrder getDofOrder() const
EntityHandle getEnt() const