Sierra Toolkit  Version of the Day
ImplDetails.hpp
1 /*------------------------------------------------------------------------*/
2 /* Copyright 2010 Sandia Corporation. */
3 /* Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive */
4 /* license for use of this work by or on behalf of the U.S. Government. */
5 /* Export of this program may require a license from the */
6 /* United States Government. */
7 /*------------------------------------------------------------------------*/
8 
9 #ifndef stk_linsys_ImplDetails_hpp
10 #define stk_linsys_ImplDetails_hpp
11 
12 #include <stk_linsys/FieldIdMap.hpp>
13 
14 #include <limits>
15 #include <map>
16 #include <stdexcept>
17 #include <stk_mesh/base/Field.hpp>
18 
19 namespace stk_classic {
20 
23 namespace linsys {
24 
27 namespace impl {
28 
33 int map_field_to_int(FieldIdMap& field_id_map,
34  const stk_classic::mesh::FieldBase& field);
35 
40 int
41 query_field_to_int_mapping(const FieldIdMap& field_id_map,
42  const stk_classic::mesh::FieldBase& field);
43 
47 const stk_classic::mesh::FieldBase* get_field(const FieldIdMap& field_id_map,
48  int field_id);
49 
54 int entityid_to_int(stk_classic::mesh::EntityId id);
55 
60 int entitytype_to_int(stk_classic::mesh::EntityRank entity_rank);
61 
66 template<typename T>
67 void verify_convertible_to_int(T id, const char* caller)
68 {
69  if (sizeof(T) <= sizeof(int)) return;
70 
71  T intmax = std::numeric_limits<int>::max();
72  if (intmax < id) {
73  std::ostringstream msg;
74  msg << caller << " ERROR, id " << id << " is too large to convert to int.";
75  std::string str = msg.str();
76  throw std::runtime_error(str);
77  }
78 }
79 
80 }//namespace impl
81 }//namespace linsys
82 }//namespace stk_classic
83 
84 #endif
85 
int entitytype_to_int(stk_classic::mesh::EntityRank entity_rank)
Definition: ImplDetails.cpp:70
const stk_classic::mesh::FieldBase * get_field(const FieldIdMap &field_id_map, int field_id)
Definition: ImplDetails.cpp:51
Field base class with an anonymous data type and anonymous multi-dimension.
Definition: FieldBase.hpp:53
std::map< const stk_classic::mesh::FieldBase *, int > FieldIdMap
Definition: FieldIdMap.hpp:20
int entityid_to_int(stk_classic::mesh::EntityId id)
Definition: ImplDetails.cpp:79
Sierra Toolkit.
int map_field_to_int(FieldIdMap &field_id_map, const stk_classic::mesh::FieldBase &field)
Definition: ImplDetails.cpp:21
int query_field_to_int_mapping(const FieldIdMap &field_id_map, const stk_classic::mesh::FieldBase &field)
Definition: ImplDetails.cpp:34
EntityRank entity_rank(const EntityKey &key)
Given an entity key, return an entity type (rank).
void verify_convertible_to_int(T id, const char *caller)
Definition: ImplDetails.hpp:67