v0.9.0
DofsMultiIndices.cpp
Go to the documentation of this file.
1 /** \file CoreDataStructures.cpp
2  * \brief Multi-index container, data structures and other low-level functions
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  const bool is_active)
25  : interface_FieldEntity<FieldEntity>(entity_ptr), active(is_active) {
26 
27  globalUId = getGlobalUniqueIdCalculate(dof, entity_ptr);
28 
29  if (PetscUnlikely(!entity_ptr))
30  THROW_MESSAGE("FieldEntity pointer not initialized");
31  if (PetscUnlikely(!sPtr))
32  THROW_MESSAGE("FieldEntity pointer not initialized");
33  if (PetscUnlikely(!getFieldEntityPtr()))
34  THROW_MESSAGE("FieldEntity pointer not initialized");
35  // verify dof order
36  if (PetscUnlikely(dof_order != getDofOrderMap()[dof]))
38  "Inconsistent DOF order with order set before for entity " +
39  boost::lexical_cast<std::string>(*entity_ptr) + " dof_order->" +
40  boost::lexical_cast<std::string>(dof_order) +
41  " != " + boost::lexical_cast<std::string>(getDofOrderMap()[dof]) +
42  "<-getDofOrderMap()[dof]");
43  // verify dof rank
44  if (PetscUnlikely(dof_rank != dof % getNbOfCoeffs()))
45  THROW_MESSAGE("Inconsistent DOFs rank with index of DOF on entity");
46 
47 }
48 
49 std::ostream &operator<<(std::ostream &os, const DofEntity &e) {
50  os << "dof_uid " << e.getGlobalUniqueId() << " dof_order " << e.getDofOrder()
51  << " dof_rank " << e.getDofCoeffIdx() << " dof " << e.getEntDofIdx()
52  << " active " << e.active << " " << *(e.sFieldPtr);
53  return os;
54 }
55 
57  : aCtive(active) {}
58 void DofEntity_active_change::operator()(boost::shared_ptr<DofEntity> &dof) {
59  dof->active = aCtive;
60  if (aCtive && dof->getDofOrder() > dof->getMaxOrder()) {
61  cerr << *dof << endl;
62  THROW_MESSAGE("Set DoF active which has order larger than maximal order "
63  "set to entity");
64  }
65 }
66 
67 // numbered dof
69  const boost::shared_ptr<DofEntity> &dof_entity_ptr, const int dof_idx,
70  const int petsc_gloabl_dof_idx, const int petsc_local_dof_idx,
71  const int part
72 
73  )
74  : interface_DofEntity<DofEntity>(dof_entity_ptr), dofIdx(dof_idx),
75  petscGloablDofIdx(petsc_gloabl_dof_idx),
76  petscLocalDofIdx(petsc_local_dof_idx), pArt(part) {}
77 
78 std::ostream &operator<<(std::ostream &os, const NumeredDofEntity &e) {
79  os << "idx " << e.dofIdx << " part " << e.pArt << " petsc idx "
80  << e.petscGloablDofIdx << " ( " << e.petscLocalDofIdx << " ) "
81  << *e.sFieldPtr;
82  return os;
83 }
84 
86  const boost::tuple<const boost::shared_ptr<SideNumber> &,
87  const boost::shared_ptr<DofEntity> &> &t)
88  : BaseFEEntity(t.get<0>()), interface_DofEntity<DofEntity>(t.get<1>()) {}
89 
90 FEDofEntity::FEDofEntity(const boost::shared_ptr<SideNumber> &side_number_ptr,
91  const boost::shared_ptr<DofEntity> &dof_ptr)
92  : BaseFEEntity(side_number_ptr), interface_DofEntity<DofEntity>(
93  dof_ptr) {}
94 
95 std::ostream &operator<<(std::ostream &os, const FEDofEntity &e) {
96  os << "local dof FiniteElement idx "
97  << "side_number " << (int)e.sideNumberPtr->side_number << " "
98  << "sense " << (int)e.sideNumberPtr->sense << " " << *e.sFieldPtr;
99  return os;
100 }
101 
103  const boost::shared_ptr<SideNumber> &side_number_ptr,
104  const boost::shared_ptr<NumeredDofEntity> &dof_ptr)
105  : BaseFEEntity(side_number_ptr),
107 
109  const boost::tuple<const boost::shared_ptr<SideNumber> &,
110  const boost::shared_ptr<NumeredDofEntity> &> &t)
112  t.get<1>()) {}
113 
114 std::ostream &operator<<(std::ostream &os, const FENumeredDofEntity &e) {
115  os << "local dof FiniteElement idx "
116  << "side_number " << (int)e.sideNumberPtr->side_number << " "
117  << "sense " << (int)e.sideNumberPtr->sense << " " << *e.sFieldPtr;
118  return os;
119 }
120 
121 } // namespace MoFEM
Keeps basic information about entity on the finite element.
boost::shared_ptr< FieldEntity > sPtr
keeps information about indexed dofs for the finite element
DofIdx getEntDofIdx() const
FENumeredDofEntity(const boost::shared_ptr< SideNumber > &side_number_ptr, const boost::shared_ptr< NumeredDofEntity > &dof_ptr)
DofEntity(const boost::shared_ptr< FieldEntity > &entity_ptr, const ApproximationOrder dof_order, const FieldCoefficientsNumber dof_rank, const DofIdx dof, const bool is_active=false)
FieldCoefficientsNumber getDofCoeffIdx() const
keeps information about DOF on the entity
boost::shared_ptr< SideNumber > sideNumberPtr
Interface to FieldEntityinterface to FieldEntity.
const UId & getGlobalUniqueId() const
FieldCoefficientsNumber getNbOfCoeffs() const
#define THROW_MESSAGE(a)
Throw MoFEM exception.
Definition: definitions.h:620
Struct keeps handle to entity in the field.
interface to NumeredDofEntity
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)
static UId getGlobalUniqueIdCalculate(const DofIdx dof, const UId &ent_uid)
boost::shared_ptr< FieldEntity > & getFieldEntityPtr() const
bool active
true if dof is active
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...
Interface to DofEntity.
FEDofEntity(const boost::shared_ptr< SideNumber > &side_number_ptr, const boost::shared_ptr< DofEntity > &dof_ptr)
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)
UId globalUId
global unique id for this dof
boost::shared_ptr< T > sFieldPtr