v0.9.1
Classes | Public Member Functions | Protected Member Functions | Private Types | Private Attributes | List of all members
MoFEM::UnknownInterface Struct Referenceabstract

base class for all interface classes More...

#include <src/interfaces/UnknownInterface.hpp>

Inheritance diagram for MoFEM::UnknownInterface:
[legend]

Classes

struct  HashMOFEMuuid
 
struct  NotKnownClass
 
struct  UIdTypeMap
 

Public Member Functions

virtual MoFEMErrorCode query_interface (const MOFEMuuid &uuid, UnknownInterface **iface) const =0
 
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
 

Protected Member Functions

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...
 

Private Types

typedef multi_index_container< UIdTypeMap, indexed_by< hashed_unique< member< UIdTypeMap, MOFEMuuid, &UIdTypeMap::uID >, HashMOFEMuuid >, hashed_unique< member< UIdTypeMap, boost::typeindex::type_index, &UIdTypeMap::classIdx > > > > iFaceTypeMap_multiIndex
 Data structure for interfaces Id and class names. More...
 

Private Attributes

iFaceTypeMap_multiIndex iFaceTypeMap
 Maps MOFEMuuid to interface type name. More...
 

Detailed Description

base class for all interface classes

Examples
EshelbianPlasticity.cpp.

Definition at line 75 of file UnknownInterface.hpp.

Member Typedef Documentation

◆ iFaceTypeMap_multiIndex

typedef multi_index_container< UIdTypeMap, indexed_by< hashed_unique<member<UIdTypeMap, MOFEMuuid, &UIdTypeMap::uID>, HashMOFEMuuid>, hashed_unique<member<UIdTypeMap, boost::typeindex::type_index, &UIdTypeMap::classIdx> > > > MoFEM::UnknownInterface::iFaceTypeMap_multiIndex
private

Data structure for interfaces Id and class names.

Definition at line 420 of file UnknownInterface.hpp.

Constructor & Destructor Documentation

◆ ~UnknownInterface()

virtual MoFEM::UnknownInterface::~UnknownInterface ( )
virtualdefault

Member Function Documentation

◆ getClassIdx()

boost::typeindex::type_index MoFEM::UnknownInterface::getClassIdx ( const MOFEMuuid uid) const
protected

Get type name for interface Id.

Parameters
uidinterface Id
Returns
class name

Definition at line 371 of file UnknownInterface.hpp.

371  {
372  iFaceTypeMap_multiIndex::nth_index<0>::type::iterator it;
373  it = iFaceTypeMap.get<0>().find(uid);
374  if (it != iFaceTypeMap.get<0>().end()) {
375  return it->classIdx;
376  }
377  return boost::typeindex::type_id<NotKnownClass>();
378  }
iFaceTypeMap_multiIndex iFaceTypeMap
Maps MOFEMuuid to interface type name.

◆ getFileVersion()

virtual const MoFEMErrorCode MoFEM::UnknownInterface::getFileVersion ( moab::Interface &  moab,
Version version 
) const
virtual

Get database major version.

This is database version. MoFEM can read DataBase from file created by older version. Then library version and database version could be different.

Returns
error code

Definition at line 323 of file UnknownInterface.hpp.

324  {
326  const EntityHandle root_meshset = 0;
327  const int def_version[] = {-1, -1, -1};
328  Tag th;
329  rval = moab.tag_get_handle("MOFEM_VERSION", 3, MB_TYPE_INTEGER, th,
330  MB_TAG_CREAT | MB_TAG_MESH, &def_version);
331  int *version_ptr;
332  if (rval == MB_ALREADY_ALLOCATED) {
333  const void *tag_data[1];
334  CHKERR moab.tag_get_by_ptr(th, &root_meshset, 1, tag_data);
335  version_ptr = (int *)tag_data[0];
336  } else {
337  const void *tag_data[1];
338  CHKERR moab.tag_get_by_ptr(th, &root_meshset, 1, tag_data);
339  version_ptr = (int *)tag_data[0];
340  version_ptr[0] = MoFEM_VERSION_MAJOR;
341  version_ptr[1] = MoFEM_VERSION_MINOR;
342  version_ptr[2] = MoFEM_VERSION_BUILD;
343  }
344  version = Version(version_ptr);
346  }
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:483
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
Definition: Exceptions.hpp:85
#define CHKERR
Inline error check.
Definition: definitions.h:602
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:413

◆ getInterface() [1/7]

template<class IFACE , bool VERIFY = false>
MoFEMErrorCode MoFEM::UnknownInterface::getInterface ( const MOFEMuuid uuid,
IFACE *&  iface 
) const

Get interface by uuid and return reference to pointer of interface.

Note
uuid of interface and interface are verified, if second template parameter is true. Function throw error if both do not match.
Do not use this function directly, it is called by other overload getInterface methods.
Parameters
uuid
ifacereference to a interface pointer
Returns
MoFEMErrorCode
Examples
add_blockset.cpp, add_cubit_meshsets.cpp, analytical_nonlinear_poisson.cpp, analytical_poisson.cpp, analytical_poisson_field_split.cpp, bernstein_bezier_generate_base.cpp, bone_adaptation.cpp, boundary_marker.cpp, build_problems.cpp, continuity_check_on_skeleton_3d.cpp, continuity_check_on_skeleton_with_simple_2d.cpp, cubit_bc_test.cpp, dm_build_partitioned_mesh.cpp, dm_create_subdm.cpp, dm_partitioned_no_field.cpp, elasticity.cpp, elasticity_mixed_formulation.cpp, ep.cpp, field_axpy_atom_test.cpp, field_blas_set_vertex_dofs.cpp, field_evaluator.cpp, field_to_vertices.cpp, forces_and_sources_testing_edge_element.cpp, forces_and_sources_testing_flat_prism_element.cpp, forces_and_sources_testing_users_base.cpp, hcurl_check_approx_in_2d.cpp, hcurl_curl_operator.cpp, hcurl_divergence_operator_2d.cpp, hdiv_divergence_operator.cpp, hello_world.cpp, lesson1_moment_of_inertia.cpp, lesson2_approximaton.cpp, lesson3_poisson.cpp, lesson4_elastic.cpp, lesson5_helmholtz.cpp, lesson6_radiation.cpp, lesson7_plastic.cpp, lesson8_contact.cpp, loop_entities.cpp, lorentz_force.cpp, MagneticElement.hpp, mesh_cut.cpp, mesh_insert_interface_atom.cpp, mesh_smoothing.cpp, meshset_to_vtk.cpp, minimal_surface_area.cpp, prism_elements_from_surface.cpp, prism_polynomial_approximation.cpp, quad_polynomial_approximation.cpp, reaction_diffusion_equation.cpp, remove_entities_from_problem.cpp, scalar_check_approximation_2d.cpp, simple_contact.cpp, simple_elasticity.cpp, simple_interface.cpp, split_sideset.cpp, test_jacobian_of_simple_contact_element.cpp, testing_jacobian_of_hook_element.cpp, testing_jacobian_of_hook_scaled_with_density_element.cpp, unsaturated_transport.cpp, and UnsaturatedFlow.hpp.

Definition at line 121 of file UnknownInterface.hpp.

122  {
124  iface = NULL;
125  if (VERIFY) {
126  if (boost::typeindex::type_id<IFACE>() != getClassIdx(uuid)) {
127  SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA,
128  "Inconsistency between interface Id and type");
129  }
130  }
131  UnknownInterface *ptr;
132  ierr = getInterface<UnknownInterface, false>(uuid, ptr);
133  CHKERRG(ierr);
134  iface = static_cast<IFACE *>(ptr);
136  }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:507
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:550
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:514
boost::typeindex::type_index getClassIdx(const MOFEMuuid &uid) const
Get type name for interface Id.

◆ getInterface() [2/7]

template<class IFACE >
MoFEMErrorCode MoFEM::UnknownInterface::getInterface ( IFACE *&  iface) const

Get interface refernce to pointer of interface.

// Create moab database
moab::Core mb_instance;
// Access moab database by interface
moab::Interface &moab = mb_instance;
// Create MoFEM database
MoFEM::Core core(moab);
// Acces MoFEM database by Interface
MoFEM::Interface &m_field = core;
// Get interface
// Get simple interface is simplified version enabling quick and
// easy construction of problem.
Simple *simple_interface;
// Query interface and get pointer to Simple interface
CHKERR m_field.getInterface(simple_interface);
Parameters
ifacereference to a interface pointer
Returns
MoFEMErrorCode

Definition at line 165 of file UnknownInterface.hpp.

165  {
166  return getInterface<IFACE, false>(
167  getUId(boost::typeindex::type_id<IFACE>()), iface);
168  }
MOFEMuuid getUId(const boost::typeindex::type_index &class_idx) const
Get interface Id for class name.

◆ getInterface() [3/7]

template<class IFACE >
MoFEMErrorCode MoFEM::UnknownInterface::getInterface ( IFACE **const  iface) const

Get interface pointer to pointer of interface.

// Create moab database
moab::Core mb_instance;
// Access moab database by interface
moab::Interface &moab = mb_instance;
// Create MoFEM database
MoFEM::Core core(moab);
// Acces MoFEM database by Interface
MoFEM::Interface &m_field = core;
// Get interface
// Get simple interface is simplified version enabling quick and
// easy construction of problem.
Simple *simple_interface;
// Query interface and get pointer to Simple interface
CHKERR m_field.getInterface(&simple_interface);
Parameters
ifaceconst pointer to a interface pointer
Returns
MoFEMErrorCode

Definition at line 198 of file UnknownInterface.hpp.

198  {
199  return getInterface<IFACE, false>(boost::typeindex::type_id<IFACE>(),
200  *iface);
201  }

◆ getInterface() [4/7]

template<class IFACE , typename boost::enable_if< boost::is_pointer< IFACE >, int >::type = 0>
IFACE MoFEM::UnknownInterface::getInterface ( ) const

Get interface pointer to pointer of interface.

// Create moab database
moab::Core mb_instance;
// Access moab database by interface
moab::Interface &moab = mb_instance;
// Create MoFEM database
MoFEM::Core core(moab);
// Acces MoFEM database by Interface
MoFEM::Interface &m_field = core;
// Get interface
// Get simple interface is simplified version enabling quick and
// easy construction of problem.
Simple *simple_interface = m_field.getInterface<Simple*,0>();
Returns
IFACE*

Definition at line 228 of file UnknownInterface.hpp.

228  {
229  typedef typename boost::remove_pointer<IFACE>::type IFaceType;
230  IFaceType *iface = NULL;
231  ierr = getInterface<IFaceType, false>(
232  getUId(boost::typeindex::type_id<IFaceType>()), iface);
233  CHKERRABORT(PETSC_COMM_SELF, ierr);
234  return iface;
235  }
MOFEMuuid getUId(const boost::typeindex::type_index &class_idx) const
Get interface Id for class name.

◆ getInterface() [5/7]

template<class IFACE , typename boost::enable_if< boost::is_reference< IFACE >, int >::type = 0>
IFACE MoFEM::UnknownInterface::getInterface ( ) const

Get reference to interface.

// Create moab database
moab::Core mb_instance;
// Access moab database by interface
moab::Interface &moab = mb_instance;
// Create MoFEM database
MoFEM::Core core(moab);
// Acces MoFEM database by Interface
MoFEM::Interface &m_field = core;
// Get interface
// Get simple interface is simplified version enabling quick and
// easy construction of problem.
Simple &simple_interface = m_field.getInterface<Simple&,0>();
Returns
IFACE&

Definition at line 262 of file UnknownInterface.hpp.

262  {
263  typedef typename boost::remove_reference<IFACE>::type IFaceType;
264  IFaceType *iface = NULL;
265  ierr = getInterface<IFaceType, false>(
266  getUId(boost::typeindex::type_id<IFaceType>()), iface);
267  CHKERRABORT(PETSC_COMM_SELF, ierr);
268  return *iface;
269  }
MOFEMuuid getUId(const boost::typeindex::type_index &class_idx) const
Get interface Id for class name.

◆ getInterface() [6/7]

template<class IFACE >
IFACE* MoFEM::UnknownInterface::getInterface ( ) const

Function returning pointer to interface.

// Create moab database
moab::Core mb_instance;
// Access moab database by interface
moab::Interface &moab = mb_instance;
// Create MoFEM database
MoFEM::Core core(moab);
// Acces MoFEM database by Interface
MoFEM::Interface &m_field = core;
// Get interface
// Get simple interface is simplified version enabling quick and
// easy construction of problem.
Simple *simple_interface = m_field.getInterface<Simple,0>();
Returns
IFACE*

Definition at line 294 of file UnknownInterface.hpp.

294  {
295  return getInterface<IFACE *, 0>();
296  }

◆ getInterface() [7/7]

template<>
MoFEMErrorCode MoFEM::UnknownInterface::getInterface ( const MOFEMuuid uuid,
UnknownInterface *&  iface 
) const

Definition at line 427 of file UnknownInterface.hpp.

428  {
429  return query_interface(uuid, &iface);
430 }
virtual MoFEMErrorCode query_interface(const MOFEMuuid &uuid, UnknownInterface **iface) const =0

◆ getInterfaceVersion()

virtual MoFEMErrorCode MoFEM::UnknownInterface::getInterfaceVersion ( Version version) const
virtual

Get database major version.

Implementation of particular interface could be different than main lib. For example user could use older interface, to keep back compatibility.

Returns
error code

Definition at line 356 of file UnknownInterface.hpp.

356  {
358  version =
359  Version(MoFEM_VERSION_MAJOR, MoFEM_VERSION_MINOR, MoFEM_VERSION_BUILD);
361  }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:507
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:514

◆ getLibVersion()

virtual MoFEMErrorCode MoFEM::UnknownInterface::getLibVersion ( Version version) const
virtual

Get library version.

This is library version.

Returns
error code

Definition at line 307 of file UnknownInterface.hpp.

307  {
309  version =
310  Version(MoFEM_VERSION_MAJOR, MoFEM_VERSION_MINOR, MoFEM_VERSION_BUILD);
312  }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:507
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:514

◆ getUId()

MOFEMuuid MoFEM::UnknownInterface::getUId ( const boost::typeindex::type_index &  class_idx) const
protected

Get interface Id for class name.

Parameters
class_name
Returns
Id

Definition at line 385 of file UnknownInterface.hpp.

385  {
386  iFaceTypeMap_multiIndex::nth_index<1>::type::iterator it;
387  it = iFaceTypeMap.get<1>().find(class_idx);
388  if (it != iFaceTypeMap.get<1>().end()) {
389  return it->uID;
390  }
391  return IDD_MOFEMUnknown;
392  }
static const MOFEMuuid IDD_MOFEMUnknown
iFaceTypeMap_multiIndex iFaceTypeMap
Maps MOFEMuuid to interface type name.

◆ query_interface()

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

◆ registerInterface()

template<class IFACE >
MoFEMErrorCode MoFEM::UnknownInterface::registerInterface ( const MOFEMuuid uuid,
bool  error_if_registration_failed = true 
)

Register interface.

Example:

ierr = regSubInterface<Simple>(IDD_MOFEMSimple);
CHKERRABORT(PETSC_COMM_SELF, ierr);
Parameters
uuid
true
Returns
MoFEMErrorCode

Definition at line 94 of file UnknownInterface.hpp.

95  {
97  auto p = iFaceTypeMap.insert(
98  UIdTypeMap(uuid, boost::typeindex::type_id<IFACE>()));
99  if (error_if_registration_failed && (!p.second)) {
100  SETERRQ1(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
101  "Registration of interface typeid(IFACE).name() = %s failed",
102  typeid(IFACE).name());
103  }
105  }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:507
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:514
iFaceTypeMap_multiIndex iFaceTypeMap
Maps MOFEMuuid to interface type name.

Member Data Documentation

◆ iFaceTypeMap

iFaceTypeMap_multiIndex MoFEM::UnknownInterface::iFaceTypeMap
mutableprivate

Maps MOFEMuuid to interface type name.

Definition at line 423 of file UnknownInterface.hpp.


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