Stencils.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_mesh_Stencils_hpp
00010 #define stk_mesh_Stencils_hpp
00011 
00012 #include <stk_util/util/StaticAssert.hpp>
00013 #include <stk_mesh/base/Types.hpp>
00014 #include <stk_mesh/fem/EntityTypes.hpp>
00015 
00016 namespace stk {
00017 namespace mesh {
00018 namespace { // To prevent multiple copies for the linker
00019 
00020 enum { ElementStencils_OK =
00021        StaticAssert< stk::mesh::Node == 0 &&
00022        stk::mesh::Edge == 1 &&
00023        stk::mesh::Face == 2 &&
00024        stk::mesh::Element == 3 >::OK };
00025 
00026 //----------------------------------------------------------------------
00027 
00028 template< class TopologyTraits >
00029 int element_node_stencil( unsigned , unsigned , unsigned );
00030 
00031 template<>
00032 int element_node_stencil<void>( unsigned from_type ,
00033                                 unsigned to_type ,
00034                                 unsigned identifier )
00035 {
00036   int ordinal = -1 ;
00037 
00038   if ( Element == from_type && Node == to_type ) {
00039     ordinal = static_cast<int>(identifier);
00040   }
00041 
00042   return ordinal ;
00043 }
00044 
00045 template< class TopologyTraits >
00046 int element_node_stencil( unsigned from_type ,
00047                           unsigned to_type ,
00048                           unsigned   identifier )
00049 {
00050   enum { number_node = TopologyTraits::node_count };
00051 
00052   int ordinal = -1 ;
00053 
00054   if ( Element == from_type &&
00055        Node    == to_type &&
00056        identifier < number_node ) {
00057     ordinal = static_cast<int>(identifier);
00058   }
00059 
00060   return ordinal ;
00061 }
00062 
00063 template< class TopologyTraits >
00064 int element_node_lock_stencil( unsigned , unsigned , unsigned );
00065 
00066 template<>
00067 int element_node_lock_stencil<void>( unsigned from_type ,
00068                                      unsigned to_type ,
00069                                      unsigned identifier )
00070 {
00071   int ordinal = -1 ;
00072 
00073   if ( Element == from_type && Node == to_type ) {
00074     ordinal = (int) identifier ;
00075   }
00076 
00077   return ordinal ;
00078 }
00079 
00080 template< class TopologyTraits >
00081 int element_node_lock_stencil( unsigned from_type ,
00082                                unsigned to_type ,
00083                                unsigned identifier )
00084 {
00085   enum { number_node = TopologyTraits::node_count };
00086 
00087   int ordinal = -1 ;
00088 
00089   if ( Element == from_type &&
00090        Node    == to_type &&
00091        identifier < number_node ) {
00092     ordinal = (int) identifier ;
00093   }
00094 
00095   return ordinal ;
00096 }
00097 
00098 //----------------------------------------------------------------------
00099 
00100 } // namespace <empty>
00101 } // namespace mesh
00102 } // namespace stk
00103 
00104 #endif //  stk_mesh_Stencils_hpp

Generated on Tue Jul 13 09:27:32 2010 for Sierra Toolkit by  doxygen 1.4.7