v0.8.20
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)
 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 coordinate system by id More...
 
MoFEMErrorCode getCoordSysPtr (const string name, boost::shared_ptr< CoordSys > &cs_ptr)
 get coordinate system by name 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 ()
 
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
 Tag on cordsys meshset for dimension of coordinate system associated to fields. More...
 
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 30 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 
)

Add coordinate system.

Parameters
cs_idsee CoordSystems for options
nameunique name of coordinate system

Definition at line 183 of file CoordSystemsManager.cpp.

184  {
185 
186  Interface &m_field = cOre;
187  moab::Interface &moab = m_field.get_moab();
188  EntityHandle meshset;
190  rval = moab.create_meshset(MESHSET_SET | MESHSET_TRACK_OWNER, meshset);
192  rval = moab.tag_set_data(th_CoordSysDim, &meshset, 1, cs_dim);
194  void const *sys_name[] = {name.c_str()};
195  int sys_name_size[1];
196  sys_name_size[0] = name.size();
197  rval = moab.tag_set_by_ptr(th_CoordSysName, &meshset, 1, sys_name,
198  sys_name_size);
200  std::pair<CoordSys_multiIndex ::iterator, bool> p =
201  coordinateSystems.insert(boost::make_shared<CoordSys>(moab, meshset));
202  if (!p.second) {
203  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
204  "MeshSet to coord system not inserted");
205  }
207 }
#define CHKERRQ_MOAB(a)
check error code of MoAB function
Definition: definitions.h:513
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:499
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:506
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
Definition: Exceptions.hpp:84
CoordSys_multiIndex coordinateSystems
Coordinate systems multi-index.
Tag th_CoordSysDim
Tag on cordsys meshset for dimension of coordinate system associated to fields.
Tag th_CoordSysName
Name of coordinate system.

◆ clearMap()

MoFEMErrorCode MoFEM::CoordSystemsManager::clearMap ( )

clear multi-index container

Returns
error code

Definition at line 80 of file CoordSystemsManager.cpp.

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

◆ get_th_CoordSysName()

Tag MoFEM::CoordSystemsManager::get_th_CoordSysName ( ) const

Definition at line 94 of file CoordSystemsManager.hpp.

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

◆ getCoordinateSystemsMultindex()

CoordSys_multiIndex& MoFEM::CoordSystemsManager::getCoordinateSystemsMultindex ( )

Definition at line 60 of file CoordSystemsManager.hpp.

60  {
61  return coordinateSystems;
62  }
CoordSys_multiIndex coordinateSystems
Coordinate systems multi-index.

◆ getCoordSysPtr() [1/2]

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

get coordinate system by id

Parameters
idhandle of meshset containing data about CS
Returns
error code

Definition at line 280 of file CoordSystemsManager.cpp.

281  {
283  CoordSys_multiIndex::index<Meshset_mi_tag>::type::iterator cs_it;
284  cs_it = coordinateSystems.get<Meshset_mi_tag>().find(id);
285  if (cs_it == coordinateSystems.get<Meshset_mi_tag>().end()) {
286  SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
287  "Unknown Coordinate System ms_id %lu", id);
288  }
289  cs_ptr = *cs_it;
291 }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:499
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:506
CoordSys_multiIndex coordinateSystems
Coordinate systems multi-index.

◆ getCoordSysPtr() [2/2]

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

get coordinate system by name

Parameters
namename of coordinate system
Returns
error code

Definition at line 294 of file CoordSystemsManager.cpp.

295  {
297  CoordSys_multiIndex::index<CoordSysName_mi_tag>::type::iterator cs_it;
298  cs_it = coordinateSystems.get<CoordSysName_mi_tag>().find(name);
299  if (cs_it == coordinateSystems.get<CoordSysName_mi_tag>().end()) {
300  SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
301  "Unknown Coordinate System <%s>", name.c_str());
302  }
303  cs_ptr = *cs_it;
305 }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:499
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:506
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  const int def_val_len = 0;
68  // Coordinate systems
69  const int def_coord_sys_dim[] = {0, 0, 0, 0};
70  rval = moab.tag_get_handle("_CoordSysDim", 4, MB_TYPE_INTEGER, th_CoordSysDim,
71  MB_TAG_CREAT | MB_TAG_SPARSE, &def_coord_sys_dim);
73  rval = moab.tag_get_handle(
74  "_CoordSysName", def_val_len, MB_TYPE_OPAQUE, th_CoordSysName,
75  MB_TAG_CREAT | MB_TAG_BYTES | MB_TAG_VARLEN | MB_TAG_SPARSE, NULL);
78 }
#define CHKERRQ_MOAB(a)
check error code of MoAB function
Definition: definitions.h:513
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:499
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:506
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
Definition: Exceptions.hpp:84
Tag th_CoordSysDim
Tag on cordsys meshset for dimension of coordinate system associated to fields.
Tag th_CoordSysName
Name of coordinate system.

◆ initialiseDatabaseFromMesh()

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

initialize container form data on mesh

Returns
error code

Definition at line 86 of file CoordSystemsManager.cpp.

86  {
87 
88  Interface &m_field = cOre;
89  moab::Interface &moab = m_field.get_moab();
91 
92  Range meshsets;
93  rval = moab.get_entities_by_type(0, MBENTITYSET, meshsets, false);
95  Range::iterator mit;
96  // loop all meshsehset to find coordinate system
97  mit = meshsets.begin();
98  for (; mit != meshsets.end(); mit++) {
99  try {
100  const char *cs_name;
101  int cs_name_size;
102  rval = moab.tag_get_by_ptr(th_CoordSysName, &*mit, 1,
103  (const void **)&cs_name, &cs_name_size);
104  if (rval == MB_SUCCESS && cs_name_size) {
105  int dim[4];
106  rval = moab.tag_get_data(th_CoordSysDim, &*mit, 1, dim);
108  if ((dim[0] + dim[1] + dim[2] + dim[3]) != 0) {
109  std::pair<CoordSys_multiIndex::iterator, bool> p =
110  coordinateSystems.insert(
111  boost::make_shared<CoordSys>(moab, *mit));
112  if (!p.second) {
113  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
114  "meshset to coord system not inserted");
115  }
116  }
117  }
118  } catch (MoFEMException const &e) {
119  SETERRQ(PETSC_COMM_SELF, e.errorCode, e.errorMessage);
120  }
121  }
122  { // Create cartesian coordinate system if not exist
123  CoordSys_multiIndex::index<CoordSysName_mi_tag>::type::iterator csit;
124  csit = coordinateSystems.get<CoordSysName_mi_tag>().find("CARTESIAN3D");
125  if (csit == coordinateSystems.get<CoordSysName_mi_tag>().end()) {
126  EntityHandle meshset;
127  rval = moab.create_meshset(MESHSET_SET | MESHSET_TRACK_OWNER, meshset);
129  int dim[] = {3, 0, 0, 0};
130  rval = moab.tag_set_data(th_CoordSysDim, &meshset, 1, dim);
132  std::string sys_name_str = "CARTESIAN3D";
133  void const *sys_name[] = {sys_name_str.c_str()};
134  int sys_name_size[1];
135  sys_name_size[0] = sys_name_str.size();
136  rval = moab.tag_set_by_ptr(th_CoordSysName, &meshset, 1, sys_name,
137  sys_name_size);
139  std::pair<CoordSys_multiIndex ::iterator, bool> p =
140  coordinateSystems.insert(boost::make_shared<CoordSys>(moab, meshset));
141  if (!p.second) {
142  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
143  "MeshSet to coord system not inserted");
144  }
145  }
146  csit = coordinateSystems.get<CoordSysName_mi_tag>().find("UNDEFINED");
147  if (csit == coordinateSystems.get<CoordSysName_mi_tag>().end()) {
148  EntityHandle meshset;
149  rval = moab.create_meshset(MESHSET_SET | MESHSET_TRACK_OWNER, meshset);
151  int dim[] = {-1, 0, 0, 0};
152  rval = moab.tag_set_data(th_CoordSysDim, &meshset, 1, dim);
154  std::string sys_name_str = "UNDEFINED";
155  void const *sys_name[] = {sys_name_str.c_str()};
156  int sys_name_size[1];
157  sys_name_size[0] = sys_name_str.size();
158  rval = moab.tag_set_by_ptr(th_CoordSysName, &meshset, 1, sys_name,
159  sys_name_size);
161  std::pair<CoordSys_multiIndex ::iterator, bool> p =
162  coordinateSystems.insert(boost::make_shared<CoordSys>(moab, meshset));
163  if (!p.second) {
164  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
165  "MeshSet to coord system not inserted");
166  }
167  }
168  }
169  // PetscSynchronizedFlush(comm,PETSC_STDOUT);
170  CoordSys_multiIndex::index<CoordSysName_mi_tag>::type::iterator
171  undefined_cs_it;
172  undefined_cs_it =
173  coordinateSystems.get<CoordSysName_mi_tag>().find("UNDEFINED");
174  if (undefined_cs_it == coordinateSystems.get<CoordSysName_mi_tag>().end()) {
175  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
176  "Undefined system not found");
177  }
178 
180 }
#define CHKERRQ_MOAB(a)
check error code of MoAB function
Definition: definitions.h:513
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:499
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:506
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
Definition: Exceptions.hpp:84
CoordSys_multiIndex coordinateSystems
Coordinate systems multi-index.
Tag th_CoordSysDim
Tag on cordsys meshset for dimension of coordinate system associated to fields.
Tag th_CoordSysName
Name of coordinate system.

◆ 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:499
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:506
CoordSystemsManager(const MoFEM::Core &core)

◆ 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 210 of file CoordSystemsManager.cpp.

211  {
212 
213  Interface &m_field = cOre;
214  const Field_multiIndex *fields_ptr;
216  ierr = m_field.get_fields(&fields_ptr);
217  CHKERRG(ierr);
218  Field_multiIndex::index<FieldName_mi_tag>::type::iterator field_it;
219  field_it = fields_ptr->get<FieldName_mi_tag>().find(field_name);
220  if (field_it == fields_ptr->get<FieldName_mi_tag>().end()) {
221  SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
222  "Field < %s > not found", field_name.c_str());
223  }
224  CoordSys_multiIndex::index<CoordSysName_mi_tag>::type::iterator cs_it;
225  cs_it = coordinateSystems.get<CoordSysName_mi_tag>().find(cs_name);
226  if (cs_it == coordinateSystems.get<CoordSysName_mi_tag>().end()) {
227  SETERRQ1(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
228  "Coord system < %s > not found", cs_name.c_str());
229  }
230  int dim = 1;
231  for (int alpha = 0; alpha < 4; alpha++) {
232  if ((*cs_it)->getDim(alpha) > 0) {
233  dim *= (*cs_it)->getDim(alpha);
234  }
235  }
236  switch ((*field_it)->getSpace()) {
237  case NOSPACE:
238  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "No space given");
239  case H1:
240  if ((*field_it)->getNbOfCoeffs() != dim) {
241  SETERRQ2(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
242  "dimension mismatch of field and coordinate system"
243  "cs dim %d field rank %d",
244  dim, (*field_it)->getNbOfCoeffs());
245  }
246  break;
247  case HDIV:
248  case HCURL:
249  if (3 * (*field_it)->getNbOfCoeffs() != dim) {
250  SETERRQ2(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
251  "dimension mismatch of field and coordinate system"
252  "cs dim %d field rank %d",
253  dim, (*field_it)->getNbOfCoeffs());
254  }
255  break;
256  case L2:
257  if ((*field_it)->getNbOfCoeffs() != dim) {
258  SETERRQ2(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
259  "dimension mismatch of field and coordinate system"
260  "cs dim %d field rank %d",
261  dim, (*field_it)->getNbOfCoeffs());
262  }
263  case NOFIELD:
264  case LASTSPACE:
265  break;
266  default:
267  SETERRQ1(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
268  "Not implemented for this space", (*field_it)->getSpace());
269  }
270  bool success = const_cast<Field_multiIndex *>(fields_ptr)
271  ->modify(fields_ptr->project<0>(field_it),
272  FieldChangeCoordinateSystem(*cs_it));
273  if (!success)
274  SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
275  "modification unsuccessful");
277 }
field with continuous normal traction
Definition: definitions.h:171
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:499
scalar or vector of scalars describe (no true field)
Definition: definitions.h:168
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:542
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.
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:506
FieldSpace in [ 0, LASTSPACE )
Definition: definitions.h:173
CoordSys_multiIndex coordinateSystems
Coordinate systems multi-index.
field with continuous tangents
Definition: definitions.h:170
continuous field
Definition: definitions.h:169
field with C-1 continuity
Definition: definitions.h:172

Member Data Documentation

◆ coordinateSystems

CoordSys_multiIndex MoFEM::CoordSystemsManager::coordinateSystems
protected

Coordinate systems multi-index.

Definition at line 102 of file CoordSystemsManager.hpp.

◆ cOre

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

Definition at line 34 of file CoordSystemsManager.hpp.

◆ th_CoordSysDim

Tag MoFEM::CoordSystemsManager::th_CoordSysDim
protected

Tag on cordsys meshset for dimension of coordinate system associated to fields.

Definition at line 99 of file CoordSystemsManager.hpp.

◆ th_CoordSysName

Tag MoFEM::CoordSystemsManager::th_CoordSysName
protected

Name of coordinate system.

Definition at line 98 of file CoordSystemsManager.hpp.


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