v0.14.0
DofsMultiIndices.cpp
Go to the documentation of this file.
1 /** \file DofsMultiIndices.cpp
2  * \brief Multi-index containers for DOFs
3  */
4 
5 
6 
7 namespace MoFEM {
8 
9 // moab dof
10 DofEntity::DofEntity(const boost::shared_ptr<FieldEntity> &entity_ptr,
11  const ApproximationOrder dof_order,
12  const FieldCoefficientsNumber dof_rank, const DofIdx dof)
13  : interface_FieldEntity<FieldEntity>(entity_ptr), dof(dof) {
14 
15 #ifndef NDEBUG
16  if (PetscUnlikely(!entity_ptr))
17  THROW_MESSAGE("FieldEntity pointer not initialized");
18  if (PetscUnlikely(!sPtr))
19  THROW_MESSAGE("FieldEntity pointer not initialized");
20  if (PetscUnlikely(!getFieldEntityPtr()))
21  THROW_MESSAGE("FieldEntity pointer not initialized");
22  // verify dof order
23  if (PetscUnlikely(dof_order != getDofOrderMap()[dof])) {
25  "Inconsistent DOF order with order set before for entity " +
26  boost::lexical_cast<std::string>(*entity_ptr) + "\n" + "dof->" +
27  boost::lexical_cast<std::string>(dof) + " dof_order->" +
28  boost::lexical_cast<std::string>(dof_order) +
29  " != " + boost::lexical_cast<std::string>(getDofOrderMap()[dof]) +
30  "<-getDofOrderMap()[dof]");
31  }
32 
33  // verify dof rank
34  if (PetscUnlikely(dof_rank != dof % getNbOfCoeffs()))
35  THROW_MESSAGE("Inconsistent DOFs rank with index of DOF on entity");
36 #endif
37 }
38 
39 std::ostream &operator<<(std::ostream &os, const DofEntity &e) {
40  os << "dof_uid " << e.getLocalUniqueId() << " dof_order " << e.getDofOrder()
41  << " dof_rank " << e.getDofCoeffIdx() << " dof " << e.getEntDofIdx()
42  << " active " << (e.dof < 0 ? false : true) << " "
43  << *e.getFieldEntityPtr();
44  return os;
45 }
46 
48  : aCtive(active) {}
49 void DofEntity_active_change::operator()(boost::shared_ptr<DofEntity> &dof) {
50 
51  if (aCtive)
52  dof->dof = std::abs(dof->dof);
53  else
54  dof->dof = -std::abs(dof->dof);
55 
56  if (PetscUnlikely(aCtive && dof->getDofOrder() > dof->getMaxOrder())) {
57  MOFEM_LOG_CHANNEL("SELF");
58  MOFEM_LOG_TAG("SELF", "DofEntity_active_change");
59  MOFEM_LOG("SELF", Sev::error) << *dof;
60  THROW_MESSAGE("Set DoF active which has order larger than maximal order "
61  "set to entity");
62  }
63 }
64 
65 // numbered dof
67  const boost::shared_ptr<DofEntity> &dof_entity_ptr, const int dof_idx,
68  const int petsc_gloabl_dof_idx, const int petsc_local_dof_idx,
69  const int part
70 
71  )
72  : interface_DofEntity<DofEntity>(dof_entity_ptr), dofIdx(dof_idx),
73  petscGloablDofIdx(petsc_gloabl_dof_idx),
74  petscLocalDofIdx(petsc_local_dof_idx), pArt(part) {
75 }
76 
77 std::ostream &operator<<(std::ostream &os, const NumeredDofEntity &e) {
78  os << "idx " << e.dofIdx << " part " << e.pArt << " petsc idx "
79  << e.petscGloablDofIdx << " ( " << e.petscLocalDofIdx << " ) "
80  << *e.getFieldEntityPtr();
81  return os;
82 }
83 
84 std::ostream &operator<<(std::ostream &os, const FEDofEntity &e) {
85  os << "local dof FiniteElement idx "
86  << "side_number " << static_cast<int>(e.getSideNumberPtr()->side_number)
87  << " "
88  << "sense " << static_cast<int>(e.getSideNumberPtr()->sense) << " "
89  << *e.getFieldEntityPtr();
90  return os;
91 }
92 
93 std::ostream &operator<<(std::ostream &os, const FENumeredDofEntity &e) {
94  os << "local dof FiniteElement idx "
95  << "side_number " << (int)e.getSideNumberPtr()->side_number << " "
96  << "sense " << (int)e.getSideNumberPtr()->sense << " "
97  << *e.getFieldEntityPtr();
98  return os;
99 }
100 
101 } // namespace MoFEM
MoFEM::DofEntity::DofEntity
DofEntity(const boost::shared_ptr< FieldEntity > &entity_ptr, const ApproximationOrder dof_order, const FieldCoefficientsNumber dof_rank, const DofIdx dof)
Definition: DofsMultiIndices.cpp:10
MoFEM::operator<<
std::ostream & operator<<(std::ostream &os, const EntitiesFieldData::EntData &e)
Definition: EntitiesFieldData.cpp:240
MoFEM::NumeredDofEntity::petscLocalDofIdx
DofIdx petscLocalDofIdx
Definition: DofsMultiIndices.hpp:237
MoFEM::DofEntity_active_change::aCtive
bool aCtive
Definition: DofsMultiIndices.hpp:528
MOFEM_LOG_CHANNEL
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
Definition: LogManager.hpp:284
MoFEM::NumeredDofEntity::pArt
unsigned int pArt
Definition: DofsMultiIndices.hpp:238
MoFEM::DofEntity
keeps information about DOF on the entity
Definition: DofsMultiIndices.hpp:16
MoFEM::FENumeredDofEntity
keeps information about indexed dofs for the finite element
Definition: DofsMultiIndices.hpp:283
MoFEM::DofEntity::getDofCoeffIdx
FieldCoefficientsNumber getDofCoeffIdx() const
Definition: DofsMultiIndices.hpp:131
MoFEM::NumeredDofEntity::dofIdx
DofIdx dofIdx
Definition: DofsMultiIndices.hpp:235
MoFEM::interface_RefEntity< FieldEntity >::sPtr
boost::shared_ptr< FieldEntity > sPtr
Definition: RefEntsMultiIndices.hpp:711
MoFEM::DofEntity::getEntDofIdx
DofIdx getEntDofIdx() const
Definition: DofsMultiIndices.hpp:36
MoFEM::interface_FieldEntity
Interface to FieldEntity.
Definition: FieldEntsMultiIndices.hpp:319
MoFEM::DofEntity_active_change::DofEntity_active_change
DofEntity_active_change(bool active)
Definition: DofsMultiIndices.cpp:47
THROW_MESSAGE
#define THROW_MESSAGE(msg)
Throw MoFEM exception.
Definition: definitions.h:574
MoFEM::interface_FieldEntity< FieldEntity >::getFieldEntityPtr
boost::shared_ptr< FieldEntity > & getFieldEntityPtr() const
Definition: FieldEntsMultiIndices.hpp:363
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::DofEntity::getDofOrder
ApproximationOrder getDofOrder() const
Definition: DofsMultiIndices.hpp:126
MoFEM::DofEntity::dof
DofIdx dof
Definition: DofsMultiIndices.hpp:141
MoFEM::DofEntity::getLocalUniqueId
UId getLocalUniqueId() const
Definition: DofsMultiIndices.hpp:65
MoFEM::Types::FieldCoefficientsNumber
int FieldCoefficientsNumber
Number of field coefficients.
Definition: Types.hpp:27
MoFEM::NumeredDofEntity::petscGloablDofIdx
DofIdx petscGloablDofIdx
Definition: DofsMultiIndices.hpp:236
MoFEM::FieldEntity
Struct keeps handle to entity in the field.
Definition: FieldEntsMultiIndices.hpp:24
MoFEM::DofEntity_active_change::operator()
void operator()(boost::shared_ptr< DofEntity > &dof)
Definition: DofsMultiIndices.cpp:49
MOFEM_LOG_TAG
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
Definition: LogManager.hpp:339
MoFEM::interface_Field< FieldEntity, FieldEntity >::getNbOfCoeffs
FieldCoefficientsNumber getNbOfCoeffs() const
Definition: FieldMultiIndices.hpp:381
MoFEM::NumeredDofEntity::NumeredDofEntity
NumeredDofEntity(const boost::shared_ptr< DofEntity > &dof_entity_ptr, const int dof_idx=-1, const int petsc_gloabl_dof_idx=-1, const int petsc_local_dof_idx=-1, const int part=-1)
Definition: DofsMultiIndices.cpp:66
MoFEM::interface_DofEntity::getFieldEntityPtr
boost::shared_ptr< FieldEntity > & getFieldEntityPtr() const
Definition: DofsMultiIndices.hpp:213
MoFEM::interface_RefEntity::getSideNumberPtr
boost::shared_ptr< SideNumber > getSideNumberPtr() const
Get the Side number.
Definition: RefEntsMultiIndices.hpp:589
MOFEM_LOG
#define MOFEM_LOG(channel, severity)
Log.
Definition: LogManager.hpp:308
MoFEM::Types::ApproximationOrder
int ApproximationOrder
Approximation on the entity.
Definition: Types.hpp:26
MoFEM::FEDofEntity
keeps information about indexed dofs for the finite element
Definition: DofsMultiIndices.hpp:267
MoFEM::interface_FieldEntity< FieldEntity >::getDofOrderMap
const std::array< int, MAX_DOFS_ON_ENTITY > & getDofOrderMap() const
get hash-map relating dof index on entity with its order
Definition: FieldEntsMultiIndices.hpp:375
convert.int
int
Definition: convert.py:64
MoFEM::interface_DofEntity
Interface to DofEntity.
Definition: DofsMultiIndices.hpp:155
MoFEM::Types::DofIdx
int DofIdx
Index of DOF.
Definition: Types.hpp:18