oomph::MeshChecker Namespace Reference

Functions

template<class GEOM_ELEMENT_BASE , class ELEMENT >
void assert_geometric_element (const unsigned &dim, const unsigned &nnode_1d=0)
 

Detailed Description

//////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// Namespace with helper function to check element type in mesh constructors (say).

Function Documentation

◆ assert_geometric_element()

template<class GEOM_ELEMENT_BASE , class ELEMENT >
void oomph::MeshChecker::assert_geometric_element ( const unsigned dim,
const unsigned nnode_1d = 0 
)

Helper function to assert that finite element of type ELEMENT can be cast to base class of type GEOM_ELEMENT_BASE – useful to avoid confusion if a mesh that was written for a specific element type (e.g. a QElement) is used with another one (e.g. a TElement. First argument specifies the required spatial dimension of the element (i.e. the number of local coordinates). The optional second argument specifies the required nnode_1d (i.e. the number of nodes along a 1D element edge). Can be omitted if the mesh can handle any number in which case this test is skipped.

2823  {
2824  // Only do tests in paranoia mode
2825 #ifndef PARANOID
2826  return;
2827 #endif
2828 
2829  // Instantiate element
2830  ELEMENT* el_pt = new ELEMENT;
2831 
2832  // Can we cast to required geometric element base type
2833  if (dynamic_cast<GEOM_ELEMENT_BASE*>(el_pt) == 0)
2834  {
2835  std::stringstream error_message;
2836  error_message << "You have specified an illegal element type! Element "
2837  "is of type \n\n"
2838  << typeid(el_pt).name()
2839  << "\n\nand cannot be cast to type \n\n "
2840  << typeid(GEOM_ELEMENT_BASE).name() << "\n\n";
2841  throw OomphLibError(error_message.str(),
2844  }
2845 
2846  // Does the dimension match?
2847  if (dim != el_pt->dim())
2848  {
2849  std::stringstream error_message;
2850  error_message << "You have specified an illegal element type! Element "
2851  "is of type \n\n"
2852  << typeid(el_pt).name()
2853  << "\n\nand has dimension = " << el_pt->dim()
2854  << " but we need dim = " << dim << std::endl;
2855  throw OomphLibError(error_message.str(),
2858  }
2859 
2860  // Does nnode_1d match?
2861  if (nnode_1d != 0)
2862  {
2863  if (nnode_1d != el_pt->nnode_1d())
2864  {
2865  std::stringstream error_message;
2866  error_message << "You have specified an illegal element type! "
2867  "Element is of type \n\n"
2868  << typeid(el_pt).name()
2869  << "\n\nand has nnode_1d = " << el_pt->nnode_1d()
2870  << " but we need nnode_1d = " << nnode_1d << std::endl;
2871  throw OomphLibError(error_message.str(),
2874  }
2875  }
2876 
2877  // Clean up
2878  delete el_pt;
2879  }
string name
Definition: plotDoE.py:33
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86

References plotDoE::name, OOMPH_CURRENT_FUNCTION, and OOMPH_EXCEPTION_LOCATION.