v0.10.0
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 84 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 429 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 380 of file UnknownInterface.hpp.

380  {
381  iFaceTypeMap_multiIndex::nth_index<0>::type::iterator it;
382  it = iFaceTypeMap.get<0>().find(uid);
383  if (it != iFaceTypeMap.get<0>().end()) {
384  return it->classIdx;
385  }
386  return boost::typeindex::type_id<NotKnownClass>();
387  }
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 332 of file UnknownInterface.hpp.

333  {
335  const EntityHandle root_meshset = 0;
336  const int def_version[] = {-1, -1, -1};
337  Tag th;
338  rval = moab.tag_get_handle("MOFEM_VERSION", 3, MB_TYPE_INTEGER, th,
339  MB_TAG_CREAT | MB_TAG_MESH, &def_version);
340  int *version_ptr;
341  if (rval == MB_ALREADY_ALLOCATED) {
342  const void *tag_data[1];
343  CHKERR moab.tag_get_by_ptr(th, &root_meshset, 1, tag_data);
344  version_ptr = (int *)tag_data[0];
345  } else {
346  const void *tag_data[1];
347  CHKERR moab.tag_get_by_ptr(th, &root_meshset, 1, tag_data);
348  version_ptr = (int *)tag_data[0];
349  version_ptr[0] = MoFEM_VERSION_MAJOR;
350  version_ptr[1] = MoFEM_VERSION_MINOR;
351  version_ptr[2] = MoFEM_VERSION_BUILD;
352  }
353  version = Version(version_ptr);
355  }
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:485
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
Definition: Exceptions.hpp:85
#define CHKERR
Inline error check.
Definition: definitions.h:604
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:415

◆ 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_large_problem.cpp, build_problems.cpp, contact.cpp, continuity_check_on_contact_prism_side_ele.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, dynamic_elastic.cpp, eigen_elastic.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, heat_equation.cpp, hello_world.cpp, helmholtz.cpp, lesson3_poisson.cpp, lesson6_radiation.cpp, lesson7_plastic.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.cpp, remove_entities_from_problem.cpp, scalar_check_approximation_2d.cpp, simple_contact.cpp, simple_elasticity.cpp, simple_interface.cpp, split_sideset.cpp, test_cache_on_entities.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, UnsaturatedFlow.hpp, and wave_equation.cpp.

Definition at line 130 of file UnknownInterface.hpp.

131  {
133  iface = NULL;
134  if (VERIFY) {
135  if (boost::typeindex::type_id<IFACE>() != getClassIdx(uuid)) {
136  SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA,
137  "Inconsistency between interface Id and type");
138  }
139  }
140  UnknownInterface *ptr;
141  ierr = getInterface<UnknownInterface, false>(uuid, ptr);
142  CHKERRG(ierr);
143  iface = static_cast<IFACE *>(ptr);
145  }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:509
#define CHKERRG(n)
Check error code of MoFEM/MOAB/PETSc function.
Definition: definitions.h:552
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:516
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:87
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 174 of file UnknownInterface.hpp.

174  {
175  return getInterface<IFACE, false>(
176  getUId(boost::typeindex::type_id<IFACE>()), iface);
177  }
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 207 of file UnknownInterface.hpp.

207  {
208  return getInterface<IFACE, false>(boost::typeindex::type_id<IFACE>(),
209  *iface);
210  }

◆ 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 237 of file UnknownInterface.hpp.

237  {
238  typedef typename boost::remove_pointer<IFACE>::type IFaceType;
239  IFaceType *iface = NULL;
240  ierr = getInterface<IFaceType, false>(
241  getUId(boost::typeindex::type_id<IFaceType>()), iface);
242  CHKERRABORT(PETSC_COMM_SELF, ierr);
243  return iface;
244  }
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:87
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 271 of file UnknownInterface.hpp.

271  {
272  typedef typename boost::remove_reference<IFACE>::type IFaceType;
273  IFaceType *iface = NULL;
274  ierr = getInterface<IFaceType, false>(
275  getUId(boost::typeindex::type_id<IFaceType>()), iface);
276  CHKERRABORT(PETSC_COMM_SELF, ierr);
277  return *iface;
278  }
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:87
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 303 of file UnknownInterface.hpp.

303  {
304  return getInterface<IFACE *, 0>();
305  }

◆ getInterface() [7/7]

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

Definition at line 436 of file UnknownInterface.hpp.

437  {
438  return query_interface(uuid, &iface);
439 }
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 365 of file UnknownInterface.hpp.

365  {
367  version =
368  Version(MoFEM_VERSION_MAJOR, MoFEM_VERSION_MINOR, MoFEM_VERSION_BUILD);
370  }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:509
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:516

◆ getLibVersion()

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

Get library version.

This is library version.

Returns
error code

Definition at line 316 of file UnknownInterface.hpp.

316  {
318  version =
319  Version(MoFEM_VERSION_MAJOR, MoFEM_VERSION_MINOR, MoFEM_VERSION_BUILD);
321  }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:509
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:516

◆ 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 394 of file UnknownInterface.hpp.

394  {
395  iFaceTypeMap_multiIndex::nth_index<1>::type::iterator it;
396  it = iFaceTypeMap.get<1>().find(class_idx);
397  if (it != iFaceTypeMap.get<1>().end()) {
398  return it->uID;
399  }
400  return IDD_MOFEMUnknown;
401  }
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 103 of file UnknownInterface.hpp.

104  {
106  auto p = iFaceTypeMap.insert(
107  UIdTypeMap(uuid, boost::typeindex::type_id<IFACE>()));
108  if (error_if_registration_failed && (!p.second)) {
109  SETERRQ1(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
110  "Registration of interface typeid(IFACE).name() = %s failed",
111  typeid(IFACE).name());
112  }
114  }
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:509
static Index< 'p', 3 > p
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:516
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 432 of file UnknownInterface.hpp.


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