v0.8.15
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 88 of file CoordSystemsManager.cpp.

88  :
89  cOre(const_cast<Core&>(core)) {
90  }

◆ ~CoordSystemsManager()

MoFEM::CoordSystemsManager::~CoordSystemsManager ( )

Destructor.

Definition at line 92 of file CoordSystemsManager.cpp.

92 {}

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

210  {
211 
212  Interface &m_field = cOre;
213  moab::Interface &moab = m_field.get_moab();
214  EntityHandle meshset;
216  rval = moab.create_meshset(MESHSET_SET|MESHSET_TRACK_OWNER,meshset); CHKERRQ_MOAB(rval);
217  rval = moab.tag_set_data(th_CoordSysDim,&meshset,1,cs_dim); CHKERRQ_MOAB(rval);
218  void const* sys_name[] = { name.c_str() };
219  int sys_name_size[1];
220  sys_name_size[0] = name.size();
221  rval = moab.tag_set_by_ptr(
222  th_CoordSysName,&meshset,1,sys_name,sys_name_size
223  ); CHKERRQ_MOAB(rval);
224  std::pair<CoordSys_multiIndex ::iterator,bool> p = coordinateSystems.insert(
225  boost::make_shared<CoordSys>(moab,meshset)
226  );
227  if(!p.second) {
228  SETERRQ(PETSC_COMM_SELF,MOFEM_DATA_INCONSISTENCY,"MeshSet to coord system not inserted");
229  }
231  }
#define CHKERRQ_MOAB(a)
check error code of MoAB function
Definition: definitions.h:497
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:483
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:490
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
Definition: Common.hpp:78
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 116 of file CoordSystemsManager.cpp.

116  {
118  coordinateSystems.clear();
120  }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:483
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:490
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 306 of file CoordSystemsManager.cpp.

306  {
308  CoordSys_multiIndex::index<Meshset_mi_tag>::type::iterator cs_it;
309  cs_it = coordinateSystems.get<Meshset_mi_tag>().find(id);
310  if(cs_it==coordinateSystems.get<Meshset_mi_tag>().end()) {
311  SETERRQ1(
312  PETSC_COMM_SELF,
314  "Unknown Coordinate System ms_id %lu",
315  id
316  );
317  }
318  cs_ptr = *cs_it;
320  }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:483
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:490
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

◆ getTags()

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

get tags handlers used on meshsets conating information about coordinate systems

Definition at line 94 of file CoordSystemsManager.cpp.

94  {
95 
96  Interface &m_field = cOre;
97  moab::Interface &moab = m_field.get_moab();
99  const int def_val_len = 0;
100  //Coordinate systems
101  const int def_coord_sys_dim[] = { 0,0,0,0 };
102  rval = moab.tag_get_handle(
103  "_CoordSysDim",4,MB_TYPE_INTEGER,th_CoordSysDim,MB_TAG_CREAT|MB_TAG_SPARSE,&def_coord_sys_dim
104  ); CHKERRQ_MOAB(rval);
105  rval = moab.tag_get_handle(
106  "_CoordSysName",
107  def_val_len,
108  MB_TYPE_OPAQUE,
110  MB_TAG_CREAT|MB_TAG_BYTES|MB_TAG_VARLEN|MB_TAG_SPARSE,
111  NULL
112  ); CHKERRQ_MOAB(rval);
114  }
#define CHKERRQ_MOAB(a)
check error code of MoAB function
Definition: definitions.h:497
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:483
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:490
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
Definition: Common.hpp:78
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 123 of file CoordSystemsManager.cpp.

123  {
124 
125  Interface &m_field = cOre;
126  moab::Interface &moab = m_field.get_moab();
128 
129  Range meshsets;
130  rval = moab.get_entities_by_type(0,MBENTITYSET,meshsets,false); CHKERRQ_MOAB(rval);
131  Range::iterator mit;
132  //loop all meshsehset to find coordinate system
133  mit = meshsets.begin();
134  for(;mit!=meshsets.end();mit++) {
135  try {
136  const char *cs_name;
137  int cs_name_size;
138  rval = moab.tag_get_by_ptr(
139  th_CoordSysName,&*mit,1,(const void **)&cs_name,&cs_name_size
140  ) ;
141  if(rval == MB_SUCCESS && cs_name_size) {
142  int dim[4];
143  rval = moab.tag_get_data(th_CoordSysDim,&*mit,1,dim); CHKERRQ_MOAB(rval);
144  if((dim[0]+dim[1]+dim[2]+dim[3])!=0) {
145  std::pair<CoordSys_multiIndex::iterator,bool> p = coordinateSystems.insert(
146  boost::make_shared<CoordSys>(moab,*mit)
147  );
148  if(!p.second) {
149  SETERRQ(PETSC_COMM_SELF,MOFEM_DATA_INCONSISTENCY,"meshset to coord system not inserted");
150  }
151  }
152  }
153  } catch (MoFEMException const &e) {
154  SETERRQ(PETSC_COMM_SELF,e.errorCode,e.errorMessage);
155  }
156  }
157  { // Create cartesian coordinate system if not exist
158  CoordSys_multiIndex::index<CoordSysName_mi_tag >::type::iterator csit;
159  csit = coordinateSystems.get<CoordSysName_mi_tag >().find("CARTESIAN3D");
160  if(csit==coordinateSystems.get<CoordSysName_mi_tag >().end()) {
161  EntityHandle meshset;
162  rval = moab.create_meshset(MESHSET_SET|MESHSET_TRACK_OWNER,meshset); CHKERRQ_MOAB(rval);
163  int dim[] = { 3,0,0,0 };
164  rval = moab.tag_set_data(th_CoordSysDim,&meshset,1,dim); CHKERRQ_MOAB(rval);
165  std::string sys_name_str = "CARTESIAN3D";
166  void const* sys_name[] = { sys_name_str.c_str() };
167  int sys_name_size[1];
168  sys_name_size[0] = sys_name_str.size();
169  rval = moab.tag_set_by_ptr(
170  th_CoordSysName,&meshset,1,sys_name,sys_name_size
171  ); CHKERRQ_MOAB(rval);
172  std::pair<CoordSys_multiIndex ::iterator,bool> p = coordinateSystems.insert(
173  boost::make_shared<CoordSys>(moab,meshset)
174  );
175  if(!p.second) {
176  SETERRQ(PETSC_COMM_SELF,MOFEM_DATA_INCONSISTENCY,"MeshSet to coord system not inserted");
177  }
178  }
179  csit = coordinateSystems.get<CoordSysName_mi_tag>().find("UNDEFINED");
180  if(csit==coordinateSystems.get<CoordSysName_mi_tag>().end()) {
181  EntityHandle meshset;
182  rval = moab.create_meshset(MESHSET_SET|MESHSET_TRACK_OWNER,meshset); CHKERRQ_MOAB(rval);
183  int dim[] = { -1,0,0,0 };
184  rval = moab.tag_set_data(th_CoordSysDim,&meshset,1,dim); CHKERRQ_MOAB(rval);
185  std::string sys_name_str = "UNDEFINED";
186  void const* sys_name[] = { sys_name_str.c_str() };
187  int sys_name_size[1];
188  sys_name_size[0] = sys_name_str.size();
189  rval = moab.tag_set_by_ptr(
190  th_CoordSysName,&meshset,1,sys_name,sys_name_size
191  ); CHKERRQ_MOAB(rval);
192  std::pair<CoordSys_multiIndex ::iterator,bool> p = coordinateSystems.insert(
193  boost::make_shared<CoordSys>(moab,meshset)
194  );
195  if(!p.second) {
196  SETERRQ(PETSC_COMM_SELF,MOFEM_DATA_INCONSISTENCY,"MeshSet to coord system not inserted");
197  }
198  }
199  }
200  //PetscSynchronizedFlush(comm,PETSC_STDOUT);
201  CoordSys_multiIndex::index<CoordSysName_mi_tag>::type::iterator undefined_cs_it;
202  undefined_cs_it = coordinateSystems.get<CoordSysName_mi_tag>().find("UNDEFINED");
203  if(undefined_cs_it==coordinateSystems.get<CoordSysName_mi_tag>().end()) {
204  SETERRQ(PETSC_COMM_SELF,MOFEM_DATA_INCONSISTENCY,"Undefined system not found");
205  }
206 
208  }
#define CHKERRQ_MOAB(a)
check error code of MoAB function
Definition: definitions.h:497
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:483
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:490
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
Definition: Common.hpp:78
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 76 of file CoordSystemsManager.cpp.

76  {
77 
79  *iface = NULL;
80  if(uuid == IDD_MOFEMMeshsetsManager) {
81  *iface = const_cast<CoordSystemsManager*>(this);
83  }
84  SETERRQ(PETSC_COMM_SELF,MOFEM_DATA_INCONSISTENCY,"unknown interface");
86  }
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:483
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return() ...
Definition: definitions.h:490
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 233 of file CoordSystemsManager.cpp.

233  {
234 
235  Interface &m_field = cOre;
236  const Field_multiIndex *fields_ptr;
238  ierr = m_field.get_fields(&fields_ptr); CHKERRG(ierr);
239  Field_multiIndex::index<FieldName_mi_tag>::type::iterator field_it;
240  field_it = fields_ptr->get<FieldName_mi_tag>().find(field_name);
241  if(field_it==fields_ptr->get<FieldName_mi_tag>().end()) {
242  SETERRQ1(
243  PETSC_COMM_SELF,MOFEM_DATA_INCONSISTENCY,"Field < %s > not found",field_name.c_str()
244  );
245  }
246  CoordSys_multiIndex::index<CoordSysName_mi_tag>::type::iterator cs_it;
247  cs_it = coordinateSystems.get<CoordSysName_mi_tag>().find(cs_name);
248  if(cs_it==coordinateSystems.get<CoordSysName_mi_tag>().end()) {
249  SETERRQ1(
250  PETSC_COMM_SELF,MOFEM_DATA_INCONSISTENCY,"Coord system < %s > not found",cs_name.c_str()
251  );
252  }
253  int dim = 1;
254  for(int alpha = 0;alpha<4;alpha++) {
255  if((*cs_it)->getDim(alpha)>0) {
256  dim *= (*cs_it)->getDim(alpha);
257  }
258  }
259  switch((*field_it)->getSpace()) {
260  case NOSPACE:
261  SETERRQ(PETSC_COMM_SELF,MOFEM_DATA_INCONSISTENCY,"No space given");
262  case H1:
263  if((*field_it)->getNbOfCoeffs()!=dim) {
264  SETERRQ2(
265  PETSC_COMM_SELF,MOFEM_DATA_INCONSISTENCY,
266  "dimension mismatch of field and coordinate system"
267  "cs dim %d field rank %d",
268  dim,(*field_it)->getNbOfCoeffs()
269  );
270  }
271  break;
272  case HDIV:
273  case HCURL:
274  if(3*(*field_it)->getNbOfCoeffs()!=dim) {
275  SETERRQ2(
276  PETSC_COMM_SELF,MOFEM_DATA_INCONSISTENCY,
277  "dimension mismatch of field and coordinate system"
278  "cs dim %d field rank %d",
279  dim,(*field_it)->getNbOfCoeffs()
280  );
281  }
282  break;
283  case L2:
284  if((*field_it)->getNbOfCoeffs()!=dim) {
285  SETERRQ2(
286  PETSC_COMM_SELF,MOFEM_DATA_INCONSISTENCY,
287  "dimension mismatch of field and coordinate system"
288  "cs dim %d field rank %d",
289  dim,(*field_it)->getNbOfCoeffs()
290  );
291  }
292  case NOFIELD:
293  case LASTSPACE:
294  break;
295  default:
296  SETERRQ1(PETSC_COMM_SELF, MOFEM_NOT_IMPLEMENTED,
297  "Not implemented for this space", (*field_it)->getSpace());
298  }
299  bool success = const_cast<Field_multiIndex*>(fields_ptr)->modify(
300  fields_ptr->project<0>(field_it),FieldChangeCoordinateSystem(*cs_it)
301  );
302  if(!success) SETERRQ(PETSC_COMM_SELF,MOFEM_OPERATION_UNSUCCESSFUL,"modification unsuccessful");
304  }
field with continuous normal traction
Definition: definitions.h:170
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:483
scalar or vector of scalars describe (no true field)
Definition: definitions.h:167
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:526
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:490
FieldSpace in [ 0, LASTSPACE )
Definition: definitions.h:172
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Common.hpp:80
CoordSys_multiIndex coordinateSystems
Coordinate systems multi-index.
field with continuous tangents
Definition: definitions.h:169
continuous field
Definition: definitions.h:168
field with C-1 continuity
Definition: definitions.h:171

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: