v0.10.0
DofsMultiIndices.cpp
Go to the documentation of this file.
1 /** \file DofsMultiIndices.cpp
2  * \brief Multi-index containers for DOFs
3  *
4  * MoFEM is free software: you can redistribute it and/or modify it under
5  * the terms of the GNU Lesser General Public License as published by the
6  * Free Software Foundation, either version 3 of the License, or (at your
7  * option) any later version.
8  *
9  * MoFEM is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
12  * License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with MoFEM. If not, see <http://www.gnu.org/licenses/>
16  */
17 
18 namespace MoFEM {
19 
20 // moab dof
21 DofEntity::DofEntity(const boost::shared_ptr<FieldEntity> &entity_ptr,
22  const ApproximationOrder dof_order,
23  const FieldCoefficientsNumber dof_rank, const DofIdx dof)
24  : interface_FieldEntity<FieldEntity>(entity_ptr), dof(dof) {
25 
26  if (PetscUnlikely(!entity_ptr))
27  THROW_MESSAGE("FieldEntity pointer not initialized");
28  if (PetscUnlikely(!sPtr))
29  THROW_MESSAGE("FieldEntity pointer not initialized");
30  if (PetscUnlikely(!getFieldEntityPtr()))
31  THROW_MESSAGE("FieldEntity pointer not initialized");
32  // verify dof order
33  if (PetscUnlikely(dof_order != getDofOrderMap()[dof]))
35  "Inconsistent DOF order with order set before for entity " +
36  boost::lexical_cast<std::string>(*entity_ptr) + " dof_order->" +
37  boost::lexical_cast<std::string>(dof_order) +
38  " != " + boost::lexical_cast<std::string>(getDofOrderMap()[dof]) +
39  "<-getDofOrderMap()[dof]");
40  // verify dof rank
41  if (PetscUnlikely(dof_rank != dof % getNbOfCoeffs()))
42  THROW_MESSAGE("Inconsistent DOFs rank with index of DOF on entity");
43 }
44 
45 std::ostream &operator<<(std::ostream &os, const DofEntity &e) {
46  os << "dof_uid " << e.getLocalUniqueId() << " dof_order " << e.getDofOrder()
47  << " dof_rank " << e.getDofCoeffIdx() << " dof " << e.getEntDofIdx()
48  << " active " << (e.dof < 0 ? false : true) << " "
49  << *e.getFieldEntityPtr();
50  return os;
51 }
52 
54  : aCtive(active) {}
55 void DofEntity_active_change::operator()(boost::shared_ptr<DofEntity> &dof) {
56 
57  if (aCtive)
58  dof->dof = std::abs(dof->dof);
59  else
60  dof->dof = -std::abs(dof->dof);
61 
62  if (PetscUnlikely(aCtive && dof->getDofOrder() > dof->getMaxOrder())) {
63  MOFEM_LOG_CHANNEL("SELF");
64  MOFEM_LOG_TAG("SELF", "DofEntity_active_change");
65  MOFEM_LOG("SELF", Sev::error) << *dof;
66  THROW_MESSAGE("Set DoF active which has order larger than maximal order "
67  "set to entity");
68  }
69 }
70 
71 // numbered dof
73  const boost::shared_ptr<DofEntity> &dof_entity_ptr, const int dof_idx,
74  const int petsc_gloabl_dof_idx, const int petsc_local_dof_idx,
75  const int part
76 
77  )
78  : interface_DofEntity<DofEntity>(dof_entity_ptr), dofIdx(dof_idx),
79  petscGloablDofIdx(petsc_gloabl_dof_idx),
80  petscLocalDofIdx(petsc_local_dof_idx), pArt(part) {
81 }
82 
83 std::ostream &operator<<(std::ostream &os, const NumeredDofEntity &e) {
84  os << "idx " << e.dofIdx << " part " << e.pArt << " petsc idx "
85  << e.petscGloablDofIdx << " ( " << e.petscLocalDofIdx << " ) "
86  << *e.getFieldEntityPtr();
87  return os;
88 }
89 
90 std::ostream &operator<<(std::ostream &os, const FEDofEntity &e) {
91  os << "local dof FiniteElement idx "
92  << "side_number " << static_cast<int>(e.getSideNumberPtr()->side_number)
93  << " "
94  << "sense " << static_cast<int>(e.getSideNumberPtr()->sense) << " "
95  << *e.getFieldEntityPtr();
96  return os;
97 }
98 
99 std::ostream &operator<<(std::ostream &os, const FENumeredDofEntity &e) {
100  os << "local dof FiniteElement idx "
101  << "side_number " << (int)e.getSideNumberPtr()->side_number << " "
102  << "sense " << (int)e.getSideNumberPtr()->sense << " "
103  << *e.getFieldEntityPtr();
104  return os;
105 }
106 
107 } // namespace MoFEM
keeps information about indexed dofs for the finite element
DofIdx getEntDofIdx() const
FieldCoefficientsNumber getDofCoeffIdx() const
DofEntity(const boost::shared_ptr< FieldEntity > &entity_ptr, const ApproximationOrder dof_order, const FieldCoefficientsNumber dof_rank, const DofIdx dof)
keeps information about DOF on the entity
int ApproximationOrder
Approximation on the entity.
Definition: Types.hpp:37
#define MOFEM_LOG_TAG(channel, tag)
Tag channelTag channel tag is set until MOFEM_LOG_CHANNEL is called, then new tag can be set.
Definition: LogManager.hpp:334
Interface to FieldEntityinterface to FieldEntity.
#define MOFEM_LOG(channel, severity)
Log.
Definition: LogManager.hpp:303
#define THROW_MESSAGE(a)
Throw MoFEM exception.
Definition: definitions.h:628
Struct keeps handle to entity in the field.
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:21
keeps information about indexed dofs for the finite element
std::ostream & operator<<(std::ostream &os, const DataForcesAndSourcesCore::EntData &e)
boost::shared_ptr< FieldEntity > & getFieldEntityPtr() const
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
Definition: LogManager.hpp:279
boost::shared_ptr< FieldEntity > & getFieldEntityPtr() const
boost::shared_ptr< SideNumber > getSideNumberPtr() const
Get the Side number.
ApproximationOrder getDofOrder() const
void operator()(boost::shared_ptr< DofEntity > &dof)
keeps information about indexed dofs for the problemFIXME: Is too many iterator, this has to be manag...
int FieldCoefficientsNumber
Number of field coefficients.
Definition: Types.hpp:38
Interface to DofEntity.
int DofIdx
Index of DOF.
Definition: Types.hpp:29
UId getLocalUniqueId() const
std::array< int, MAX_DOFS_ON_ENTITY > & getDofOrderMap() const
get hash-map relating dof index on entity with its order
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)