v0.14.0
Loading...
Searching...
No Matches
DofsMultiIndices.cpp
Go to the documentation of this file.
1/** \file DofsMultiIndices.cpp
2 * \brief Multi-index containers for DOFs
3 */
4
5
6
7namespace MoFEM {
8
9// moab dof
10DofEntity::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
39std::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) {}
49void 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
77std::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
84std::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
93std::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
#define THROW_MESSAGE(msg)
Throw MoFEM exception.
Definition: definitions.h:561
#define MOFEM_LOG(channel, severity)
Log.
Definition: LogManager.hpp:308
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
Definition: LogManager.hpp:339
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
Definition: LogManager.hpp:284
int DofIdx
Index of DOF.
Definition: Types.hpp:18
int ApproximationOrder
Approximation on the entity.
Definition: Types.hpp:26
int FieldCoefficientsNumber
Number of field coefficients.
Definition: Types.hpp:27
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
std::ostream & operator<<(std::ostream &os, const EntitiesFieldData::EntData &e)
void operator()(boost::shared_ptr< DofEntity > &dof)
keeps information about DOF on the entity
UId getLocalUniqueId() const
DofIdx getEntDofIdx() const
ApproximationOrder getDofOrder() const
DofEntity(const boost::shared_ptr< FieldEntity > &entity_ptr, const ApproximationOrder dof_order, const FieldCoefficientsNumber dof_rank, const DofIdx dof)
FieldCoefficientsNumber getDofCoeffIdx() const
keeps information about indexed dofs for the finite element
keeps information about indexed dofs for the finite element
Struct keeps handle to entity in the field.
keeps information about indexed dofs for the problem
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)
Interface to DofEntity.
boost::shared_ptr< FieldEntity > & getFieldEntityPtr() const
const std::array< int, MAX_DOFS_ON_ENTITY > & getDofOrderMap() const
get hash-map relating dof index on entity with its order
boost::shared_ptr< FieldEntity > & getFieldEntityPtr() const
FieldCoefficientsNumber getNbOfCoeffs() const
boost::shared_ptr< SideNumber > getSideNumberPtr() const