Sierra Toolkit Version of the Day
ImplDetails.hpp
00001 /*------------------------------------------------------------------------*/
00002 /*                 Copyright 2010 Sandia Corporation.                     */
00003 /*  Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive   */
00004 /*  license for use of this work by or on behalf of the U.S. Government.  */
00005 /*  Export of this program may require a license from the                 */
00006 /*  United States Government.                                             */
00007 /*------------------------------------------------------------------------*/
00008 
00009 #ifndef stk_linsys_ImplDetails_hpp
00010 #define stk_linsys_ImplDetails_hpp
00011 
00012 #include <stk_linsys/FieldIdMap.hpp>
00013 
00014 #include <limits>
00015 #include <map>
00016 #include <stdexcept>
00017 #include <stk_mesh/base/Field.hpp>
00018 
00019 namespace stk {
00020 
00023 namespace linsys {
00024 
00027 namespace impl {
00028 
00033 int map_field_to_int(FieldIdMap& field_id_map,
00034                      const stk::mesh::FieldBase& field);
00035 
00040 int
00041 query_field_to_int_mapping(const FieldIdMap& field_id_map,
00042                            const stk::mesh::FieldBase& field);
00043 
00047 const stk::mesh::FieldBase* get_field(const FieldIdMap& field_id_map,
00048                                       int field_id);
00049 
00054 int entityid_to_int(stk::mesh::EntityId id);
00055 
00060 int entitytype_to_int(stk::mesh::EntityRank entity_rank);
00061 
00066 template<typename T>
00067 void verify_convertible_to_int(T id, const char* caller)
00068 {
00069   if (sizeof(T) <= sizeof(int)) return;
00070 
00071   T intmax = std::numeric_limits<int>::max();
00072   if (intmax < id) {
00073     std::ostringstream msg;
00074     msg << caller << " ERROR, id " << id << " is too large to convert to int.";
00075     std::string str = msg.str();
00076     throw std::runtime_error(str);
00077   }
00078 }
00079 
00080 }//namespace impl
00081 }//namespace linsys
00082 }//namespace stk
00083 
00084 #endif
00085 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends