v0.9.0
Public Member Functions | Public Attributes | Protected Attributes | List of all members
MoFEM::CoordSystemsManager Struct Reference

#include <src/interfaces/CoordSystemsManager.hpp>

Inheritance diagram for MoFEM::CoordSystemsManager:
[legend]
Collaboration diagram for MoFEM::CoordSystemsManager:
[legend]

Public Member Functions

MoFEMErrorCode query_interface (const MOFEMuuid &uuid, UnknownInterface **iface) const
 
 CoordSystemsManager (const MoFEM::Core &core)
 
 ~CoordSystemsManager ()
 Destructor. More...
 
MoFEMErrorCode getTags (int verb=-1)
 get tags handlers used on meshsets conating information about coordinate systems More...
 
MoFEMErrorCode clearMap ()
 clear multi-index container More...
 
MoFEMErrorCode initialiseDatabaseFromMesh (int verb=0)
 
CoordSys_multiIndexgetCoordinateSystemsMultindex ()
 
MoFEMErrorCode addCoordinateSystem (const int cs_dim[], const std::string name, const enum MoFEMTypes bh=MF_EXCL)
 Add coordinate system. More...
 
MoFEMErrorCode setFieldCoordinateSystem (const std::string field_name, const std::string cs_name)
 Set coordinate system to field. More...
 
MoFEMErrorCode getCoordSysPtr (const EntityHandle id, boost::shared_ptr< CoordSys > &cs_ptr)
 Get the Coord Sys Ptr object. More...
 
MoFEMErrorCode getCoordSysPtr (const string name, boost::shared_ptr< CoordSys > &cs_ptr)
 Get the Coord Sys Ptr object. More...
 
boost::shared_ptr< CoordSysgetCoordSysPtr (const string name)
 Get the Coord Sys Ptr object. More...
 
Tag get_th_CoordSysName () const
 
- Public Member Functions inherited from MoFEM::UnknownInterface
template<class IFACE >
MoFEMErrorCode registerInterface (const MOFEMuuid &uuid, bool error_if_registration_failed=true)
 Register interface. More...
 
template<class IFACE , bool VERIFY = false>
MoFEMErrorCode getInterface (const MOFEMuuid &uuid, IFACE *&iface) const
 Get interface by uuid and return reference to pointer of interface. More...
 
template<class IFACE >
MoFEMErrorCode getInterface (IFACE *&iface) const
 Get interface refernce to pointer of interface. More...
 
template<class IFACE >
MoFEMErrorCode getInterface (IFACE **const iface) const
 Get interface pointer to pointer of interface. More...
 
template<class IFACE , typename boost::enable_if< boost::is_pointer< IFACE >, int >::type = 0>
IFACE getInterface () const
 Get interface pointer to pointer of interface. More...
 
template<class IFACE , typename boost::enable_if< boost::is_reference< IFACE >, int >::type = 0>
IFACE getInterface () const
 Get reference to interface. More...
 
template<class IFACE >
IFACE * getInterface () const
 Function returning pointer to interface. More...
 
virtual ~UnknownInterface ()=default
 
virtual MoFEMErrorCode getLibVersion (Version &version) const
 Get library version. More...
 
virtual const MoFEMErrorCode getFileVersion (moab::Interface &moab, Version &version) const
 Get database major version. More...
 
virtual MoFEMErrorCode getInterfaceVersion (Version &version) const
 Get database major version. More...
 
template<>
MoFEMErrorCode getInterface (const MOFEMuuid &uuid, UnknownInterface *&iface) const
 

Public Attributes

MoFEM::CorecOre
 

Protected Attributes

Tag th_CoordSysName
 Name of coordinate system. More...
 
Tag th_CoordSysDim
 
CoordSys_multiIndex coordinateSystems
 Coordinate systems multi-index. More...
 

Additional Inherited Members

- Protected Member Functions inherited from MoFEM::UnknownInterface
boost::typeindex::type_index getClassIdx (const MOFEMuuid &uid) const
 Get type name for interface Id. More...
 
MOFEMuuid getUId (const boost::typeindex::type_index &class_idx) const
 Get interface Id for class name. More...
 

Detailed Description

Definition at line 32 of file CoordSystemsManager.hpp.

Constructor & Destructor Documentation

◆ CoordSystemsManager()

MoFEM::CoordSystemsManager::CoordSystemsManager ( const MoFEM::Core core)

Definition at line 57 of file CoordSystemsManager.cpp.

58  : cOre(const_cast<Core &>(core)) {}

◆ ~CoordSystemsManager()

MoFEM::CoordSystemsManager::~CoordSystemsManager ( )

Destructor.

Definition at line 60 of file CoordSystemsManager.cpp.

60 {}

Member Function Documentation

◆ addCoordinateSystem()

MoFEMErrorCode MoFEM::CoordSystemsManager::addCoordinateSystem ( const int  cs_dim[],
const std::string  name,
const enum MoFEMTypes  bh = MF_EXCL 
)

Add coordinate system.

Parameters
cs_idsee CoordSystems for options
nameunique name of coordinate system

Definition at line 133 of file CoordSystemsManager.cpp.

134  {
135 
136  auto check_cs = [&](const std::string cs_name) {
137  auto undefined_cs_it =
138  coordinateSystems.get<CoordSysName_mi_tag>().find(cs_name);
139  if (undefined_cs_it == coordinateSystems.get<CoordSysName_mi_tag>().end())
140  return false;
141  else
142  return true;
143  };
144 
146 
147  if (!check_cs(cs_name)) {
148 
149  Interface &m_field = cOre;
150  moab::Interface &moab = m_field.get_moab();
151  EntityHandle meshset;
152  CHKERR moab.create_meshset(MESHSET_SET | MESHSET_TRACK_OWNER, meshset);
153  CHKERR moab.tag_set_data(th_CoordSysDim, &meshset, 1, cs_dim);
154  void const *cs_name_ptr[] = {cs_name.c_str()};
155  int cs_name_size[1];
156  cs_name_size[0] = cs_name.size();
157  CHKERR moab.tag_set_by_ptr(th_CoordSysName, &meshset, 1, cs_name_ptr,
158  cs_name_size);
159  auto p =
160  coordinateSystems.insert(boost::make_shared<CoordSys>(moab, meshset));
161  if (!p.second)
162  SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
163  "MeshSet to coord system <%s> not inserted", cs_name.c_str());
164 
165  } else if (bh == MF_EXCL)
166 
167  SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
168  "MeshSet to coord system <%s> exist", cs_name.c_str());
169 
170  else {
171 
172  auto cs_ptr = getCoordSysPtr(cs_name);
173  for (auto d : {0, 1, 2, 3})
174  if (cs_ptr->getDim(d) != cs_dim[d])
175  SETERRQ3(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
176  "Coord system <%s> has inconsistent dimension %d: %d != %d", d,
177  cs_ptr->getDim(d), cs_dim[d]);
178  }
179 
181 }
moab::Interface & get_moab()
Definition: Core.hpp:266
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
const Tensor1_Expr< const dTensor0< T, Dim, i >, typename promote< T, double >::V, Dim, i > d(const Tensor0< T * > &a, const Index< i, Dim > index, const Tensor1< int, Dim > &d_ijk, const Tensor1< double, Dim > &d_xyz)
Definition: dTensor0.hpp:27
MoFEMErrorCode getCoordSysPtr(const EntityHandle id, boost::shared_ptr< CoordSys > &cs_ptr)
Get the Coord Sys Ptr object.
CoordSys_multiIndex coordinateSystems
Coordinate systems multi-index.
#define CHKERR
Inline error check.
Definition: definitions.h:596
Tag th_CoordSysName
Name of coordinate system.
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407

◆ clearMap()

MoFEMErrorCode MoFEM::CoordSystemsManager::clearMap ( )

clear multi-index container

Returns
error code

Definition at line 78 of file CoordSystemsManager.cpp.

78  {
80  coordinateSystems.clear();
82 }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:501
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508
CoordSys_multiIndex coordinateSystems
Coordinate systems multi-index.

◆ get_th_CoordSysName()

Tag MoFEM::CoordSystemsManager::get_th_CoordSysName ( ) const

Definition at line 113 of file CoordSystemsManager.hpp.

113 { return th_CoordSysName; }
Tag th_CoordSysName
Name of coordinate system.

◆ getCoordinateSystemsMultindex()

CoordSys_multiIndex& MoFEM::CoordSystemsManager::getCoordinateSystemsMultindex ( )

Definition at line 64 of file CoordSystemsManager.hpp.

64  {
65  return coordinateSystems;
66  }
CoordSys_multiIndex coordinateSystems
Coordinate systems multi-index.

◆ getCoordSysPtr() [1/3]

MoFEMErrorCode MoFEM::CoordSystemsManager::getCoordSysPtr ( const EntityHandle  id,
boost::shared_ptr< CoordSys > &  cs_ptr 
)

Get the Coord Sys Ptr object.

Parameters
id
cs_ptr
Returns
MoFEMErrorCode

Definition at line 267 of file CoordSystemsManager.cpp.

268  {
270  auto cs_it = coordinateSystems.get<Meshset_mi_tag>().find(id);
271  if (cs_it == coordinateSystems.get<Meshset_mi_tag>().end())
272  SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
273  "Unknown Coordinate System ms_id %lu", id);
274  cs_ptr = *cs_it;
276 }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:501
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508
CoordSys_multiIndex coordinateSystems
Coordinate systems multi-index.

◆ getCoordSysPtr() [2/3]

MoFEMErrorCode MoFEM::CoordSystemsManager::getCoordSysPtr ( const string  name,
boost::shared_ptr< CoordSys > &  cs_ptr 
)

Get the Coord Sys Ptr object.

Parameters
name
cs_ptr
Returns
MoFEMErrorCode

Definition at line 279 of file CoordSystemsManager.cpp.

280  {
282  auto cs_it = coordinateSystems.get<CoordSysName_mi_tag>().find(name);
283  if (cs_it == coordinateSystems.get<CoordSysName_mi_tag>().end()) {
284  SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
285  "Unknown Coordinate System <%s>", name.c_str());
286  }
287  cs_ptr = *cs_it;
289 }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:501
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508
CoordSys_multiIndex coordinateSystems
Coordinate systems multi-index.

◆ getCoordSysPtr() [3/3]

boost::shared_ptr< CoordSys > MoFEM::CoordSystemsManager::getCoordSysPtr ( const string  name)

Get the Coord Sys Ptr object.

Parameters
name
Returns
boost::shared_ptr<CoordSys>

Definition at line 292 of file CoordSystemsManager.cpp.

292  {
294  auto cs_it = coordinateSystems.get<CoordSysName_mi_tag>().find(name);
295  if (cs_it == coordinateSystems.get<CoordSysName_mi_tag>().end())
296  return boost::shared_ptr<CoordSys>();
297  else
298  return *cs_it;
300 }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:501
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508
CoordSys_multiIndex coordinateSystems
Coordinate systems multi-index.

◆ getTags()

MoFEMErrorCode MoFEM::CoordSystemsManager::getTags ( int  verb = -1)

get tags handlers used on meshsets conating information about coordinate systems

Definition at line 62 of file CoordSystemsManager.cpp.

62  {
63 
64  Interface &m_field = cOre;
65  moab::Interface &moab = m_field.get_moab();
67  // Coordinate systems
68  const int def_coord_sys_dim[] = {0, 0, 0, 0};
69  CHKERR moab.tag_get_handle("_CoordSysDim", 4, MB_TYPE_INTEGER, th_CoordSysDim,
70  MB_TAG_CREAT | MB_TAG_SPARSE, &def_coord_sys_dim);
71  const int def_val_len = 0;
72  CHKERR moab.tag_get_handle(
73  "_CoordSysName", def_val_len, MB_TYPE_OPAQUE, th_CoordSysName,
74  MB_TAG_CREAT | MB_TAG_BYTES | MB_TAG_VARLEN | MB_TAG_SPARSE, NULL);
76 }
moab::Interface & get_moab()
Definition: Core.hpp:266
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
#define CHKERR
Inline error check.
Definition: definitions.h:596
Tag th_CoordSysName
Name of coordinate system.
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407

◆ initialiseDatabaseFromMesh()

MoFEMErrorCode MoFEM::CoordSystemsManager::initialiseDatabaseFromMesh ( int  verb = 0)

\brier initialize container form data on mesh

Returns
error code

Definition at line 84 of file CoordSystemsManager.cpp.

84  {
85  Interface &m_field = cOre;
86  moab::Interface &moab = m_field.get_moab();
88 
89  Range meshsets;
90  CHKERR moab.get_entities_by_type(0, MBENTITYSET, meshsets, false);
91 
92  // Iterate all mesh sets to find coordinate system
93  for (auto meshset : meshsets) {
94  const void *cs_name_ptr = nullptr;
95  int cs_name_size = 0;
96  rval = moab.tag_get_by_ptr(th_CoordSysName, &meshset, 1,
97  (const void **)&cs_name_ptr, &cs_name_size);
98  if (rval == MB_SUCCESS && cs_name_size) {
99  std::string cs_name(static_cast<const char *>(cs_name_ptr), cs_name_size);
100 
101  std::array<int, 4> dim;
102  rval = moab.tag_get_data(th_CoordSysDim, &meshset, 1, dim.data());
103  if (rval == MB_SUCCESS && (dim[0] + dim[1] + dim[2] + dim[3]) != 0) {
104 
105  std::pair<CoordSys_multiIndex::iterator, bool> p =
106  coordinateSystems.insert(
107  boost::make_shared<CoordSys>(moab, meshset));
108 
109  if (!p.second) {
110  // Coordinate system is in database. Could be created by another
111  // processor Check consistency of both coordinate systems with the
112  // same name.
113  if (((*p.first)->getDim(0) != dim[0]) ||
114  ((*p.first)->getDim(1) != dim[1]) ||
115  ((*p.first)->getDim(2) != dim[2]) ||
116  ((*p.first)->getDim(3) != dim[3])) {
117  SETERRQ2(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
118  "meshset to coord system not inserted "
119  "cs_name %s dim = %d",
120  cs_name.c_str(), dim[0] + dim[1] + dim[2] + dim[3]);
121  } else {
122  // Remove duplicate mesheset
123  CHKERR moab.delete_entities(&meshset, 1);
124  }
125  }
126  }
127  }
128  }
129 
131 }
moab::Interface & get_moab()
Definition: Core.hpp:266
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
Definition: Exceptions.hpp:84
CoordSys_multiIndex coordinateSystems
Coordinate systems multi-index.
#define CHKERR
Inline error check.
Definition: definitions.h:596
Tag th_CoordSysName
Name of coordinate system.
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407

◆ query_interface()

MoFEMErrorCode MoFEM::CoordSystemsManager::query_interface ( const MOFEMuuid uuid,
UnknownInterface **  iface 
) const
virtual

Implements MoFEM::UnknownInterface.

Definition at line 44 of file CoordSystemsManager.cpp.

45  {
46 
48  *iface = NULL;
49  if (uuid == IDD_MOFEMMeshsetsManager) {
50  *iface = const_cast<CoordSystemsManager *>(this);
52  }
53  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "unknown interface");
55 }
static const MOFEMuuid IDD_MOFEMMeshsetsManager
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:501
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:508

◆ setFieldCoordinateSystem()

MoFEMErrorCode MoFEM::CoordSystemsManager::setFieldCoordinateSystem ( const std::string  field_name,
const std::string  cs_name 
)

Set coordinate system to field.

Parameters
nameof field
nameunique name of coordinate system

Definition at line 184 of file CoordSystemsManager.cpp.

185  {
186 
187  Interface &m_field = cOre;
188  const Field_multiIndex *fields_ptr;
190  CHKERR m_field.get_fields(&fields_ptr);
191 
192  // Find field
193  auto field_it = fields_ptr->get<FieldName_mi_tag>().find(field_name);
194  if (field_it == fields_ptr->get<FieldName_mi_tag>().end())
195  SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
196  "Field < %s > not found", field_name.c_str());
197 
198  // Remove field from other coordinate system
199  EntityHandle field_meshest = (*field_it)->getMeshset();
200  for (auto &cs : coordinateSystems)
201  CHKERR m_field.get_moab().remove_entities(cs->getMeshset(), &field_meshest,
202  1);
203 
204  // Find coordinate system
205  auto cs_it = coordinateSystems.get<CoordSysName_mi_tag>().find(cs_name);
206  if (cs_it == coordinateSystems.get<CoordSysName_mi_tag>().end())
207  SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
208  "Coord system < %s > not found", cs_name.c_str());
209 
210  // Add field to coordinate system
211  CHKERR m_field.get_moab().add_entities((*cs_it)->getMeshset(), &field_meshest,
212  1);
213 
214  int dim = 1;
215  for (int alpha = 0; alpha < 4; alpha++) {
216  if ((*cs_it)->getDim(alpha) > 0) {
217  dim *= (*cs_it)->getDim(alpha);
218  }
219  }
220 
221  // Check consistency of field and coordinate system
222  switch ((*field_it)->getSpace()) {
223  case NOSPACE:
224  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "No space given");
225  case H1:
226  if ((*field_it)->getNbOfCoeffs() != dim) {
227  SETERRQ2(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
228  "dimension mismatch of field and coordinate system"
229  "cs dim %d field rank %d",
230  dim, (*field_it)->getNbOfCoeffs());
231  }
232  break;
233  case HDIV:
234  case HCURL:
235  if (3 * (*field_it)->getNbOfCoeffs() != dim) {
236  SETERRQ2(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
237  "dimension mismatch of field and coordinate system"
238  "cs dim %d field rank %d",
239  dim, (*field_it)->getNbOfCoeffs());
240  }
241  break;
242  case L2:
243  if ((*field_it)->getNbOfCoeffs() != dim) {
244  SETERRQ2(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
245  "dimension mismatch of field and coordinate system"
246  "cs dim %d field rank %d",
247  dim, (*field_it)->getNbOfCoeffs());
248  }
249  case NOFIELD:
250  case LASTSPACE:
251  break;
252  default:
253  SETERRQ1(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
254  "Not implemented for this space", (*field_it)->getSpace());
255  }
256  bool success = const_cast<Field_multiIndex *>(fields_ptr)
257  ->modify(fields_ptr->project<0>(field_it),
258  FieldChangeCoordinateSystem(*cs_it));
259  if (!success)
260  SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
261  "modification unsuccessful");
262 
264 }
field with continuous normal traction
Definition: definitions.h:173
scalar or vector of scalars describe (no true field)
Definition: definitions.h:170
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:477
multi_index_container< boost::shared_ptr< Field >, indexed_by< hashed_unique< tag< BitFieldId_mi_tag >, const_mem_fun< Field, const BitFieldId &, &Field::getId >, HashBit< BitFieldId >, EqBit< BitFieldId > >, ordered_unique< tag< Meshset_mi_tag >, member< Field, EntityHandle, &Field::meshSet > >, ordered_unique< tag< FieldName_mi_tag >, const_mem_fun< Field, boost::string_ref, &Field::getNameRef > >, ordered_non_unique< tag< BitFieldId_space_mi_tag >, const_mem_fun< Field, FieldSpace, &Field::getSpace > > > > Field_multiIndex
Field_multiIndex for Field.
FieldSpace in [ 0, LASTSPACE )
Definition: definitions.h:175
CoordSys_multiIndex coordinateSystems
Coordinate systems multi-index.
field with continuous tangents
Definition: definitions.h:172
#define CHKERR
Inline error check.
Definition: definitions.h:596
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:407
continuous field
Definition: definitions.h:171
field with C-1 continuity
Definition: definitions.h:174

Member Data Documentation

◆ coordinateSystems

CoordSys_multiIndex MoFEM::CoordSystemsManager::coordinateSystems
protected

Coordinate systems multi-index.

Definition at line 121 of file CoordSystemsManager.hpp.

◆ cOre

MoFEM::Core& MoFEM::CoordSystemsManager::cOre

Definition at line 37 of file CoordSystemsManager.hpp.

◆ th_CoordSysDim

Tag MoFEM::CoordSystemsManager::th_CoordSysDim
protected

Tag on cordinate sys meshset for dimension of coordinate system associated to fields

Definition at line 117 of file CoordSystemsManager.hpp.

◆ th_CoordSysName

Tag MoFEM::CoordSystemsManager::th_CoordSysName
protected

Name of coordinate system.

Definition at line 116 of file CoordSystemsManager.hpp.


The documentation for this struct was generated from the following files: