Sierra Toolkit Version of the Day
HexFixture.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_FIXTURES_HEX_MESH_FIXTURE_HPP
00010 #define STK_MESH_FIXTURES_HEX_MESH_FIXTURE_HPP
00011 
00012 #include <Shards_BasicTopologies.hpp>
00013 
00014 #include <stk_util/parallel/Parallel.hpp>
00015 
00016 #include <stk_mesh/base/Types.hpp>
00017 #include <stk_mesh/base/MetaData.hpp>
00018 #include <stk_mesh/base/BulkData.hpp>
00019 #include <stk_mesh/base/Field.hpp>
00020 #include <stk_mesh/base/DataTraits.hpp>
00021 
00022 #include <stk_mesh/fem/FEMMetaData.hpp>
00023 #include <stk_mesh/fem/CoordinateSystems.hpp>
00024 #include <stk_mesh/fem/TopologyDimensions.hpp>
00025 
00026 namespace stk {
00027 namespace mesh {
00028 namespace fixtures {
00029 
00036 class HexFixture
00037 {
00038  public:
00039   typedef double                     Scalar ;
00040   typedef Field<Scalar, Cartesian>   CoordFieldType;
00041   typedef Field<Scalar*,ElementNode> CoordGatherFieldType;
00042 
00047   HexFixture(stk::ParallelMachine pm, unsigned nx, unsigned ny, unsigned nz);
00048 
00049   const int                     m_spatial_dimension;
00050   const unsigned                m_nx;
00051   const unsigned                m_ny;
00052   const unsigned                m_nz;
00053   fem::FEMMetaData              m_fem_meta;
00054   BulkData                      m_bulk_data;
00055   Part &                        m_hex_part;
00056   Part &                        m_node_part;
00057   CoordFieldType &              m_coord_field ;
00058   CoordGatherFieldType &        m_coord_gather_field ;
00059 
00064   EntityId node_id( unsigned x , unsigned y , unsigned z ) const  {
00065     return 1 + x + ( m_nx + 1 ) * ( y + ( m_ny + 1 ) * z );
00066   }
00067 
00072   EntityId elem_id( unsigned x , unsigned y , unsigned z ) const  {
00073     return 1 + x + m_nx * ( y + m_ny * z );
00074   }
00075 
00080   Entity * node( unsigned x , unsigned y , unsigned z ) const {
00081     return m_bulk_data.get_entity( fem::FEMMetaData::NODE_RANK , node_id(x, y, z) );
00082   }
00083 
00089   Entity * elem( unsigned x , unsigned y , unsigned z ) const {
00090     return m_bulk_data.get_entity( m_fem_meta.element_rank(), elem_id(x, y, z) );
00091   }
00092 
00097   void node_x_y_z( EntityId entity_id, unsigned &x , unsigned &y , unsigned &z ) const;
00098 
00103   void elem_x_y_z( EntityId entity_id, unsigned &x , unsigned &y , unsigned &z ) const;
00104 
00108   void generate_mesh();
00109 
00110   void generate_mesh( std::vector<EntityId> & element_ids_on_this_processor );
00111 
00112  private:
00113 
00114   HexFixture();
00115   HexFixture( const HexFixture &);
00116   HexFixture & operator = (const HexFixture &);
00117 };
00118 
00119 
00120 } // fixtures
00121 } // mesh
00122 } // stk
00123 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines